No description, website, or topics provided.
JavaScript Batchfile
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist
doc
ext_src
src
test
.gitignore
Gruntfile.js
README.md
bower.json
package.json

README.md

JScriptExtender

Use Array#filter, map, reduce, String#trim, JSON.parse/stringify
...and more lovely functions on legacy JScript!

Overview

JScriptExtender is an extension library for Microsoft JScript.
This library provides following functions to lagacy JScript(e.g. v5.8 on Windows7).

Usage

Include dist/JScriptExtender.js in your .wsh script.

<job>
<!-- include at here -->
<script language="JavaScript" src="dist/JScriptExtender.js"></script>
<script language="JavaScript">

function test() {
  // Get arguments from command line
  // e.g. if you call script with args "arg0 arg1 /arg2:123"
  var args = Arguments.Get(); // => {'0': 'arg0', '1': 'arg1', 'arg2': '123'}

  // Array's cool methods
  var num = [1, 2, 3, 4, 5].filter(function(v){
    return (v % 2 === 0);
  }).map(function(v) {
    return v * v;
  }).reduce(function(prev, current, i , ar) {
    return prev + current;
  });
  WScript.Echo(num); // => 20

  // Generate JSON string
  var str = JSON.stringify({'Hello': 123});
  WScript.Echo(str); // => '{"Hello":123}'

  // Load ini file into object(hash)
  var iniReader = new Ini('hoge.ini');
  var iniObj = iniReader.Load();
}
WScript.Quit(test());

</script>
</job>

API Document

See the url below.
(Only for additional functions, except es5-shim and JSON3)
http://poppycocker.github.io/JScriptExtender/doc/index.html