Mercurial > hg > nginx-site
comparison xml/en/docs/njs_about.xml @ 1846:bfac366fa1e4
Added article about nginScript.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Thu, 01 Dec 2016 20:09:24 +0300 |
parents | |
children | 7eb5e1cff842 |
comparison
equal
deleted
inserted
replaced
1845:c0f9510ea9c6 | 1846:bfac366fa1e4 |
---|---|
1 <?xml version="1.0"?> | |
2 | |
3 <!-- | |
4 Copyright (C) Nginx, Inc. | |
5 --> | |
6 | |
7 <!DOCTYPE article SYSTEM "../../../dtd/article.dtd"> | |
8 | |
9 <article name="About nginScript" | |
10 link="/en/docs/njs_about.html" | |
11 lang="en" | |
12 rev="1"> | |
13 | |
14 <section id="summary"> | |
15 | |
16 <para> | |
17 nginScript is a subset of the JavaScript language that allows | |
18 implementing location and variable handlers in | |
19 <link doc="http/ngx_http_js_module.xml">http</link> and | |
20 <link doc="stream/ngx_stream_js_module.xml">stream</link>. | |
21 nignScript is created in compliance with | |
22 <link url="http://www.ecma-international.org/ecma-262/5.1/">ECMAScript 5.1</link> | |
23 with some | |
24 <link url="http://www.ecma-international.org/ecma-262/6.0/">ECMAScript 6</link> | |
25 extensions. | |
26 The compliance is still evolving. | |
27 </para> | |
28 | |
29 </section> | |
30 | |
31 | |
32 <section id="supported" name="What is currently supported"> | |
33 | |
34 <para> | |
35 <list type="bullet"> | |
36 | |
37 <listitem> | |
38 boolean values, numbers, strings, objects, arrays, | |
39 functions, and regular expressions | |
40 </listitem> | |
41 | |
42 <listitem> | |
43 ES5.1 operators | |
44 </listitem> | |
45 | |
46 <listitem> | |
47 ES5.1 statements: <literal>var</literal>, <literal>if</literal>, | |
48 <literal>else</literal>, <literal>switch</literal>, <literal>for</literal>, | |
49 <literal>for in</literal>, <literal>while</literal>, | |
50 <literal>do while</literal>, <literal>break</literal>, | |
51 <literal>continue</literal>, <literal>return</literal>, <literal>try</literal>, | |
52 <literal>catch</literal>, <literal>throw</literal>, <literal>finally</literal> | |
53 </listitem> | |
54 | |
55 <listitem> | |
56 ES6 <literal>Number</literal> and | |
57 <literal>Math</literal> properties and methods | |
58 </listitem> | |
59 | |
60 <listitem> | |
61 <literal>String</literal> methods: | |
62 <list type="bullet"> | |
63 | |
64 <listitem> | |
65 ES5.1: | |
66 <literal>fromCharCode</literal>, <literal>concat</literal>, | |
67 <literal>slice</literal>, <literal>substring</literal>, | |
68 <literal>substr</literal>, <literal>charAt</literal>, | |
69 <literal>charCodeAt</literal>, <literal>indexOf</literal>, | |
70 <literal>lastIndexOf</literal>, <literal>toLowerCase</literal>, | |
71 <literal>toUpperCase</literal>, <literal>trim</literal>, | |
72 <literal>search</literal>, <literal>match</literal>, <literal>split</literal>, | |
73 <literal>replace</literal> | |
74 </listitem> | |
75 | |
76 <listitem> | |
77 ES6: | |
78 <literal>fromCodePoint</literal>, <literal>codePointAt</literal>, | |
79 <literal>includes</literal>, <literal>startsWith</literal>, | |
80 <literal>endsWith</literal>, <literal>repeat</literal> | |
81 </listitem> | |
82 | |
83 <listitem> | |
84 non-standard: | |
85 <literal>fromUTF8</literal>, <literal>toUTF8</literal>, | |
86 <literal>fromBytes</literal>, <literal>toBytes</literal> | |
87 </listitem> | |
88 </list> | |
89 | |
90 </listitem> | |
91 | |
92 <listitem> | |
93 <literal>Object</literal>: | |
94 rudimentary <literal>Object.create()</literal> support without properties list | |
95 </listitem> | |
96 | |
97 <listitem> | |
98 <literal>Array</literal> methods: | |
99 <list type="bullet"> | |
100 <listitem> | |
101 ES5.1: | |
102 <literal>isArray</literal>, <literal>slice</literal>, <literal>splice</literal>, | |
103 <literal>push</literal>, <literal>pop</literal>,<literal>unshift,</literal> | |
104 <literal>shift</literal>, <literal>reverse</literal>, <literal>sort</literal>, | |
105 <literal>join</literal>, <literal>concat</literal>, <literal>indexOf</literal>, | |
106 <literal>lastIndexOf</literal>, <literal>forEach</literal>, | |
107 <literal>some</literal>, <literal>every</literal>, <literal>filter</literal>, | |
108 <literal>map</literal>, <literal>reducde</literal>, | |
109 <literal>reduceRight</literal> | |
110 </listitem> | |
111 | |
112 <listitem> | |
113 ES6: <literal>includes</literal> | |
114 </listitem> | |
115 </list> | |
116 | |
117 </listitem> | |
118 | |
119 <listitem> | |
120 ES5.1 <literal>Function</literal> methods: | |
121 <literal>call</literal>, <literal>apply</literal>, <literal>bind</literal> | |
122 </listitem> | |
123 | |
124 <listitem> | |
125 ES5.1 <literal>RegExp</literal> methods: | |
126 <literal>test</literal>, <literal>exec</literal> | |
127 </listitem> | |
128 | |
129 <listitem> | |
130 ES5.1 <literal>Date</literal> methods | |
131 </listitem> | |
132 | |
133 <listitem> | |
134 ES5.1 global functions: | |
135 <literal>isFinite</literal>, <literal>isNaN</literal>, | |
136 <literal>parseFloat</literal>, <literal>parseInt</literal>, | |
137 <literal>decodeURI</literal>, <literal>decodeURIComponent</literal>, | |
138 <literal>encodeURI</literal>, <literal>encodeURIComponent</literal> | |
139 </listitem> | |
140 | |
141 </list> | |
142 </para> | |
143 | |
144 </section> | |
145 | |
146 | |
147 <section id="not_supported" name="What still is not supported"> | |
148 | |
149 <para> | |
150 <list type="bullet"> | |
151 | |
152 <listitem> | |
153 broken scopes support | |
154 </listitem> | |
155 | |
156 <listitem> | |
157 ES6 <literal>let</literal> and <literal>const</literal> declarations | |
158 </listitem> | |
159 | |
160 <listitem> | |
161 cycle <literal>for</literal> with <literal>var</literal> in declaration | |
162 (<literal>for (var...</literal>) | |
163 </listitem> | |
164 | |
165 <listitem> | |
166 nested functions | |
167 </listitem> | |
168 | |
169 <listitem> | |
170 closures | |
171 </listitem> | |
172 | |
173 <listitem> | |
174 labels | |
175 </listitem> | |
176 | |
177 <listitem> | |
178 <literal>arguments</literal> array | |
179 </listitem> | |
180 | |
181 <listitem> | |
182 <literal>eval</literal> function | |
183 </listitem> | |
184 | |
185 <listitem> | |
186 <literal>JSON</literal> object | |
187 </listitem> | |
188 | |
189 <listitem> | |
190 <literal>Error</literal> object | |
191 </listitem> | |
192 | |
193 <listitem> | |
194 <literal>setTimeout</literal>, <literal>setInterval</literal>, | |
195 <literal>setImmediate</literal> functions | |
196 </listitem> | |
197 | |
198 <listitem> | |
199 functions hoisting | |
200 </listitem> | |
201 | |
202 <listitem> | |
203 non-integer fractions (<literal>.235</literal>), | |
204 exponential (<literal>3.35e10</literal>), | |
205 binary (<literal>0b0101</literal>), | |
206 octal (<literal>0o77</literal>), | |
207 hexadecimal (<literal>0x1123</literal>) literals | |
208 </listitem> | |
209 | |
210 </list> | |
211 </para> | |
212 | |
213 </section> | |
214 | |
215 | |
216 <section id="install" name="Download and install"> | |
217 | |
218 <para> | |
219 nginScript is available in two modules: | |
220 <list type="bullet"> | |
221 | |
222 <listitem> | |
223 <link doc="http/ngx_http_js_module.xml">ngx_http_js_module</link> | |
224 </listitem> | |
225 | |
226 <listitem> | |
227 <link doc="stream/ngx_stream_js_module.xml">ngx_stream_js_module</link> | |
228 </listitem> | |
229 | |
230 </list> | |
231 Both modules are not built by default, | |
232 they should be either compiled from the sources | |
233 or installed as a Linux package. | |
234 </para> | |
235 | |
236 | |
237 <section id="install_package" name="Installing as a Linux package"> | |
238 <para> | |
239 For Linux, nginScript modules | |
240 <link doc="../linux_packages.xml" id="dynmodules">packages</link> can be used: | |
241 <list type="bullet"> | |
242 | |
243 <listitem> | |
244 <literal>nginx-module-njs</literal> — nginScript | |
245 <link doc="ngx_core_module.xml" id="load_module">dynamic</link> modules | |
246 </listitem> | |
247 | |
248 <listitem> | |
249 <literal>nginx-module-njs-dbg</literal> — debug symbols for the | |
250 <literal>nginx-module-njs</literal> package | |
251 </listitem> | |
252 | |
253 </list> | |
254 </para> | |
255 | |
256 </section> | |
257 | |
258 | |
259 <section id="install_sources" name="Building from the sources"> | |
260 | |
261 <para> | |
262 The <link url="http://hg.nginx.org/njs">repository</link> | |
263 with nginScript sources can be cloned with the following command: | |
264 (requires <link url="https://www.mercurial-scm.org">Mercurial</link> client): | |
265 <example> | |
266 hg clone http://hg.nginx.org/njs | |
267 </example> | |
268 Then the modules should be compiled using the | |
269 <literal>--add_module</literal> configuration parameter: | |
270 <example> | |
271 ./configure --add-module=<value>path-to-njs</value>/nginx | |
272 </example> | |
273 The modules can also be built as | |
274 <link doc="ngx_core_module.xml" id="load_module">dynamic</link>: | |
275 <example> | |
276 ./configure --add-dynamic_module=<value>path-to-njs</value>/nginx | |
277 </example> | |
278 </para> | |
279 | |
280 </section> | |
281 | |
282 </section> | |
283 | |
284 | |
285 <section id="issues" name="Known Issues"> | |
286 | |
287 <para> | |
288 Both modules are experimental, caveat emptor applies. | |
289 </para> | |
290 | |
291 </section> | |
292 | |
293 </article> |