About nginScript
| What is currently supported What is not supported yet Download and install Installing as a Linux package Building from the sources Known Issues |
nginScript is a subset of the JavaScript language that allows implementing location and variable handlers in http and stream. nginScript is created in compliance with ECMAScript 5.1 with some ECMAScript 6 extensions. The compliance is still evolving.
What is currently supported
- Boolean values, numbers, strings, objects, arrays, functions, and regular expressions
- ES5.1 operators, ES7 exponentiation operators
-
ES5.1 statements:
var,if,else,switch,for,for in,while,do while,break,continue,return,try,catch,throw,finally -
ES6
NumberandMathproperties and methods -
Stringmethods:-
ES5.1:
fromCharCode,concat,slice,substring,substr,charAt,charCodeAt,indexOf,lastIndexOf,toLowerCase,toUpperCase,trim,search,match,split,replace -
ES6:
fromCodePoint,codePointAt,includes,startsWith,endsWith,repeat -
non-standard:
fromUTF8,toUTF8,fromBytes,toBytes
-
ES5.1:
-
Object: rudimentaryObject.create()support without properties list -
Arraymethods:-
ES5.1:
isArray,slice,splice,push,pop,unshift,shift,reverse,sort,join,concat,indexOf,lastIndexOf,forEach,some,every,filter,map,reduce,reduceRight -
ES7:
includes
-
ES5.1:
-
ES5.1
Functionmethods:call,apply,bind -
ES5.1
RegExpmethods:test,exec -
ES5.1
Datemethods -
ES5.1 global functions:
isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent
What is not supported yet
- Scopes
-
ES6
letandconstdeclarations -
cycle
forwithvarin declaration (for (var...) - nested functions
- closures
- labels
-
argumentsarray -
evalfunction -
JSONobject -
Errorobject -
setTimeout,setInterval,setImmediatefunctions - functions hoisting
-
non-integer fractions (
.235), exponential (3.35e10), binary (0b0101), octal (0o77), hexadecimal (0x1123) literals
Download and install
nginScript is available in two modules:
Both modules are not built by default, they should be either compiled from the sources or installed as a Linux package.
Installing as a Linux package
For Linux, nginScript modules packages can be used:
-
nginx-module-njs— nginScript dynamic modules -
nginx-module-njs-dbg— debug symbols for thenginx-module-njspackage
Building from the sources
The repository with nginScript sources can be cloned with the following command: (requires Mercurial client):
hg clone http://hg.nginx.org/njs
Then the modules should be compiled using the
--add_module configuration parameter:
./configure --add-module=path-to-njs/nginx
The modules can also be built as dynamic:
./configure --add-dynamic_module=path-to-njs/nginx
Known Issues
Both modules are experimental, caveat emptor applies.
