=encoding utf-8


=head1 Name


njs_about - About njs


=head1



njs is a subset of the JavaScript language that allows
implementing location and variable handlers in
L<http|ngx_http_js_module> and
L<stream|ngx_stream_js_module>.
njs is created in compliance with
L<ECMAScript 5.1|http://www.ecma-international.org/ecma-262/5.1/>
with some
L<ECMAScript 6|http://www.ecma-international.org/ecma-262/6.0/>
extensions.
The compliance is still evolving.




=head1 What is currently supported




=over




=item *

Boolean values, numbers, strings, objects, arrays,
functions, and regular expressions



=item *

ES5.1 operators, ES7 exponentiation operators



=item *

ES5.1 statements: C<var>, C<if>,
C<else>, C<switch>, C<for>,
C<for in>, C<while>,
C<do while>, C<break>,
C<continue>, C<return>, C<try>,
C<catch>, C<throw>, C<finally>



=item *

ES6 C<Number> and
C<Math> properties and methods



=item *

C<String> methods:

=over




=item *

ES5.1:
C<fromCharCode>, C<concat>,
C<slice>, C<substring>,
C<substr>, C<charAt>,
C<charCodeAt>, C<indexOf>,
C<lastIndexOf>, C<toLowerCase>,
C<toUpperCase>, C<trim>,
C<search>, C<match>, C<split>,
C<replace>



=item *

ES6:
C<fromCodePoint>, C<codePointAt>,
C<includes>, C<startsWith>,
C<endsWith>, C<repeat>



=item *

non-standard:
C<fromUTF8>, C<toUTF8>,
C<fromBytes>, C<toBytes>


=back






=item *

C<Object> methods:

=over



=item *

ES5.1:
C<create> (support without properties list),
C<keys>,
C<defineProperty>,
C<defineProperties>,
C<getOwnPropertyDescriptor>,
C<getPrototypeOf>,
C<hasOwnProperty>,
C<isPrototypeOf>,
C<preventExtensions>,
C<isExtensible>,
C<freeze>,
C<isFrozen>,
C<seal>,
C<isSealed>


=back






=item *

C<Array> methods:

=over



=item *

ES5.1:
C<isArray>, C<slice>, C<splice>,
C<push>, C<pop>, C<unshift>,
C<shift>, C<reverse>, C<sort>,
C<join>, C<concat>, C<indexOf>,
C<lastIndexOf>, C<forEach>,
C<some>, C<every>, C<filter>,
C<map>, C<reduce>,
C<reduceRight>



=item *

ES6:
C<of>, C<fill>, C<find>,
C<findIndex>



=item *

ES7: C<includes>


=back






=item *

ES5.1 C<Function> methods:
C<call>, C<apply>, C<bind>



=item *

ES5.1 C<RegExp> methods:
C<test>, C<exec>



=item *

ES5.1 C<Date> methods



=item *

ES5.1 C<JSON> object



=item *

ES5.1 global functions:
C<isFinite>, C<isNaN>,
C<parseFloat>, C<parseInt>,
C<decodeURI>, C<decodeURIComponent>,
C<encodeURI>, C<encodeURIComponent>



=item *

C<Error> objects:
C<Error>, C<EvalError>,
C<InternalError>, C<RangeError>,
C<ReferenceError>, C<SyntaxError>,
C<TypeError>, C<URIError>



=item *

C<setTimeout()> and C<clearTimeout()> functions
(0.2.0)



=item *

L<Node.js style|https://nodejs.org/api/fs.html#fs_file_system>
C<File system> methods:
C<fs.readFile>, C<fs.readFileSync>,
C<fs.appendFile>, C<fs.appendFileSync>,
C<fs.writeFile>, C<fs.writeFileSync>



=item *

L<Node.js style|https://nodejs.org/api/crypto.html#crypto_class_hash>
C<Crypto> methods (0.2.0):
C<crypto.createHash>,
C<crypto.createHmac>




=back






=head1 What is not supported yet




=over




=item *

ES6 C<let> and C<const> declarations



=item *

labels



=item *

C<arguments> array



=item *

C<eval> function



=item *

C<new Function()> constructor



=item *

C<setInterval>,
C<setImmediate> functions



=item *

non-integer fractions (C<.235>),
binary literals (C<0b0101>)



=back






=head1 Change Log



The complete list of njs changes is available
L<here|njs_changes>.



=head1 Download and install



njs is available in two modules:

=over




=item *

L<ngx_http_js_module|ngx_http_js_module>



=item *

L<ngx_stream_js_module|ngx_stream_js_module>



=back


Both modules are not built by default,
they should be either compiled from the sources
or installed as a Linux package.





=head2 Installing as a Linux package



For Linux, njs modules
L<packages|linux_packages> can be used:

=over




=item *

C<nginx-module-njs> — njs
L<dynamic|ngx_core_module> modules



=item *

C<nginx-module-njs-dbg> — debug symbols for the
C<nginx-module-njs> package



=back






=head2 Building from the sources



The L<repository|http://hg.nginx.org/njs>
with njs sources can be cloned with the following command:
(requires L<Mercurial|https://www.mercurial-scm.org> client):

    
    hg clone http://hg.nginx.org/njs


Then the modules should be compiled using the
C<--add-module> configuration parameter:

    
    ./configure --add-module=<value>path-to-njs</value>/nginx


The modules can also be built as
L<dynamic|ngx_core_module>:

    
    ./configure --add-dynamic-module=<value>path-to-njs</value>/nginx






