Use Array#filter, map, reduce, String#trim, JSON.parse/stringify
...and more lovely functions on legacy JScript!
JScriptExtender is an extension library for Microsoft JScript.
This library provides following functions to lagacy JScript(e.g. v5.8 on Windows7).
- ES5 methods (from es5-shim https://github.com/es-shims/es5-shim)
- JSON support (from JSON3 https://github.com/bestiejs/json3)
- and some additional functions
- Class pattern framework (using Leaflet.js's L.Class as a reference)
- Parser for command line arguments
- Helpers for reading/writing file stream
- Ini file reader
Include dist/JScriptExtender.js in your .wsh script.
<job>
<!-- include at here -->
<scriptlanguage="JavaScript"src="dist/JScriptExtender.js"></script><scriptlanguage="JavaScript">
function test() {// Get arguments from command line// e.g. if you call script with args "arg0 arg1 /arg2:123"varargs=Arguments.Get();// => {'0': 'arg0', '1': 'arg1', 'arg2': '123'}// Array's cool methodsvarnum=[1,2,3,4,5].filter(function(v){return(v%2===0);}).map(function(v){returnv*v;}).reduce(function(prev,current,i,ar){returnprev+current;});WScript.Echo(num);// => 20// Generate JSON stringvarstr=JSON.stringify({'Hello': 123});WScript.Echo(str);// => '{"Hello":123}'// Load ini file into object(hash)variniReader=newIni('hoge.ini');variniObj=iniReader.Load();}
WScript.Quit(test());
</script></job>See the url below.
(Only for additional functions, except es5-shim and JSON3)
http://poppycocker.github.io/JScriptExtender/doc/index.html