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.
var
, if
, else
, switch
, for
, for in
, while
, do while
, break
, continue
, return
, try
, catch
, throw
, finally
Number
and Math
properties and methods String
methods: fromCharCode
, concat
, slice
, substring
, substr
, charAt
, charCodeAt
, indexOf
, lastIndexOf
, toLowerCase
, toUpperCase
, trim
, search
, match
, split
, replace
fromCodePoint
, codePointAt
, includes
, startsWith
, endsWith
, repeat
fromUTF8
, toUTF8
, fromBytes
, toBytes
Object
methods: create
(support without properties list), keys
, defineProperty
, defineProperties
, getOwnPropertyDescriptor
, getPrototypeOf
, hasOwnProperty
, isPrototypeOf
, preventExtensions
, isExtensible
, freeze
, isFrozen
, seal
, isSealed
Array
methods: isArray
, slice
, splice
, push
, pop
, unshift
, shift
, reverse
, sort
, join
, concat
, indexOf
, lastIndexOf
, forEach
, some
, every
, filter
, map
, reduce
, reduceRight
of
, fill
, find
, findIndex
includes
Function
methods: call
, apply
, bind
RegExp
methods: test
, exec
Date
methods JSON
object isFinite
, isNaN
, parseFloat
, parseInt
, decodeURI
, decodeURIComponent
, encodeURI
, encodeURIComponent
Error
objects: Error
, EvalError
, InternalError
, RangeError
, ReferenceError
, SyntaxError
, TypeError
, URIError
File system
methods (Node.js style): fs.readFile
, fs.readFileSync
, fs.appendFile
, fs.appendFileSync
, fs.writeFile
, fs.writeFileSync
let
and const
declarations arguments
array eval
function setTimeout
, setInterval
, setImmediate
functions .235
), binary literals (0b0101
) 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.
For Linux, nginScript modules packages can be used:
nginx-module-njs
— nginScript dynamic modules nginx-module-njs-dbg
— debug symbols for the nginx-module-njs
package 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
© 2002-2017 Igor Sysoev
© 2011-2017 Nginx, Inc.
Licensed under the BSD License.
https://nginx.org/en/docs/njs_about.html