comparison xml/en/docs/njs/reference.xml @ 2579:63cef7604e0d

Minor review of njs Reference for typos and style.
author Yaroslav Zhuravlev <yar@nginx.com>
date Thu, 06 Aug 2020 17:38:31 +0100
parents fafb7767c128
children e162a71453b0
comparison
equal deleted inserted replaced
2578:fafb7767c128 2579:63cef7604e0d
7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> 7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd">
8 8
9 <article name="Reference" 9 <article name="Reference"
10 link="/en/docs/njs/reference.html" 10 link="/en/docs/njs/reference.html"
11 lang="en" 11 lang="en"
12 rev="49"> 12 rev="50">
13 13
14 <section id="summary"> 14 <section id="summary">
15 15
16 <para> 16 <para>
17 <link doc="index.xml">njs</link> provides objects, methods and properties 17 <link doc="index.xml">njs</link> provides objects, methods and properties
314 boolean flag (<link doc="changes.xml" id="njs0.3.9">0.3.9</link>), 314 boolean flag (<link doc="changes.xml" id="njs0.3.9">0.3.9</link>),
315 if <literal>true</literal>, the created subrequest is a detached subrequest. 315 if <literal>true</literal>, the created subrequest is a detached subrequest.
316 Responses to detached subrequests are ignored. 316 Responses to detached subrequests are ignored.
317 Unlike ordinary subrequests, a detached subrequest 317 Unlike ordinary subrequests, a detached subrequest
318 can be created inside a variable handler. 318 can be created inside a variable handler.
319 The detached flag and callback argument are mutually exclusive. 319 The <literal>detached</literal> flag and callback argument
320 are mutually exclusive.
320 </tag-desc> 321 </tag-desc>
321 322
322 </list> 323 </list>
323 </para> 324 </para>
324 325
344 read-only 345 read-only
345 </tag-desc> 346 </tag-desc>
346 347
347 <tag-name id="r_variables"><literal>r.variables{}</literal></tag-name> 348 <tag-name id="r_variables"><literal>r.variables{}</literal></tag-name>
348 <tag-desc> 349 <tag-desc>
349 nginx variables object, 350 nginx variables object, writable
350 writable (since <link doc="changes.xml" id="njs0.2.8">0.2.8</link>) 351 (since <link doc="changes.xml" id="njs0.2.8">0.2.8</link>)
351 </tag-desc> 352 </tag-desc>
352 353
353 <tag-name id="r_warn"><literal>r.warn(<value>string</value>)</literal></tag-name> 354 <tag-name id="r_warn"><literal>r.warn(<value>string</value>)</literal></tag-name>
354 <tag-desc> 355 <tag-desc>
355 writes a <literal>string</literal> to the error log 356 writes a <literal>string</literal> to the error log
418 </tag-desc> 419 </tag-desc>
419 420
420 <tag-name id="s_on"><literal>s.on(<value>event</value>, 421 <tag-name id="s_on"><literal>s.on(<value>event</value>,
421 <value>callback</value>)</literal></tag-name> 422 <value>callback</value>)</literal></tag-name>
422 <tag-desc> 423 <tag-desc>
423 registers a <literal>callback</literal> for the specified <literal>event</literal> 424 registers a <literal>callback</literal>
425 for the specified <literal>event</literal>
424 (<link doc="changes.xml" id="njs0.2.4">0.2.4</link>). 426 (<link doc="changes.xml" id="njs0.2.4">0.2.4</link>).
425 427
426 <para> 428 <para>
427 An <literal>event</literal> may be one of the following strings: 429 An <literal>event</literal> may be one of the following strings:
428 <list type="tag"> 430 <list type="tag">
465 <tag-desc> 467 <tag-desc>
466 sends the data to the client 468 sends the data to the client
467 (<link doc="changes.xml" id="njs0.2.4">0.2.4</link>). 469 (<link doc="changes.xml" id="njs0.2.4">0.2.4</link>).
468 The <literal>options</literal> is an object used 470 The <literal>options</literal> is an object used
469 to override nginx buffer flags derived from an incoming data chunk buffer. 471 to override nginx buffer flags derived from an incoming data chunk buffer.
470 The flags can be overriden with the following flags: 472 The flags can be overridden with the following flags:
471 <para> 473 <para>
472 <list type="tag"> 474 <list type="tag">
473 475
474 <tag-name><literal>last</literal></tag-name> 476 <tag-name><literal>last</literal></tag-name>
475 <tag-desc> 477 <tag-desc>
476 boolean, true if the buffer is the last buffer 478 boolean,
479 true if the buffer is the last buffer
477 </tag-desc> 480 </tag-desc>
478 481
479 <tag-name><literal>flush</literal></tag-name> 482 <tag-name><literal>flush</literal></tag-name>
480 <tag-desc> 483 <tag-desc>
481 boolean, true if the buffer should have the <literal>flush</literal> flag 484 boolean,
485 true if the buffer should have the <literal>flush</literal> flag
482 </tag-desc> 486 </tag-desc>
483 </list> 487 </list>
484 </para> 488 </para>
485 The method can be called multiple times per callback invocation. 489 The method can be called multiple times per callback invocation.
486 </tag-desc> 490 </tag-desc>
516 <para> 520 <para>
517 The <literal>process</literal> object is a global object 521 The <literal>process</literal> object is a global object
518 that provides information about the current process 522 that provides information about the current process
519 (<link doc="changes.xml" id="njs0.3.3">0.3.3</link>). 523 (<link doc="changes.xml" id="njs0.3.3">0.3.3</link>).
520 </para> 524 </para>
521
522 525
523 <para> 526 <para>
524 <list type="tag"> 527 <list type="tag">
525 528
526 <tag-name id="process_argv"><literal>process.argv</literal></tag-name> 529 <tag-name id="process_argv"><literal>process.argv</literal></tag-name>
636 Converts a byte string containing a valid UTF8 string 639 Converts a byte string containing a valid UTF8 string
637 into a Unicode string, 640 into a Unicode string,
638 otherwise <literal>null</literal> is returned. 641 otherwise <literal>null</literal> is returned.
639 </tag-desc> 642 </tag-desc>
640 643
641 <tag-name id="string_tobytes"><literal>String.prototype.toBytes(start[, 644 <tag-name id="string_tobytes"><literal>String.prototype.toBytes(<value>start</value>[,
642 end])</literal></tag-name> 645 <value>end</value>])</literal></tag-name>
643 <tag-desc> 646 <tag-desc>
644 Serializes a Unicode string to a byte string. 647 Serializes a Unicode string to a byte string.
645 Returns <literal>null</literal> if a character larger than 255 is 648 Returns <literal>null</literal> if a character larger than 255 is
646 found in the string. 649 found in the string.
647 </tag-desc> 650 </tag-desc>
686 689
687 690
688 <section id="njs_api_timers" name="Timers"> 691 <section id="njs_api_timers" name="Timers">
689 692
690 <para> 693 <para>
691
692 <list type="tag"> 694 <list type="tag">
693 695
694 <tag-name id="cleartimeout"><literal>clearTimeout(<value>timeout</value>)</literal></tag-name> 696 <tag-name id="cleartimeout"><literal>clearTimeout(<value>timeout</value>)</literal></tag-name>
695 <tag-desc> 697 <tag-desc>
696 Cancels a <literal>timeout</literal> object 698 Cancels a <literal>timeout</literal> object
697 created by <link id="settimeout">setTimeout()</link>. 699 created by <link id="settimeout"><literal>setTimeout()</literal></link>.
698 </tag-desc> 700 </tag-desc>
699 701
700 <tag-name id="settimeout"><literal>setTimeout(<value>function</value>, 702 <tag-name id="settimeout"><literal>setTimeout(<value>function</value>,
701 <value>ms</value>[, <value>arg1</value>, <value>argN</value>])</literal></tag-name> 703 <value>milliseconds</value>[,
704 <value>argument1</value>,
705 <value>argumentN</value>])</literal></tag-name>
702 <tag-desc> 706 <tag-desc>
703 Calls a <literal>function</literal> 707 Calls a <literal>function</literal>
704 after a specified number of <literal>milliseconds</literal>. 708 after a specified number of <literal>milliseconds</literal>.
705 One or more optional <literal>arguments</literal> 709 One or more optional <literal>arguments</literal>
706 can be passed to the specified function. 710 can be passed to the specified function.
752 </tag-desc> 756 </tag-desc>
753 757
754 <tag-name id="crypto_createhmac"><literal>crypto.createHmac(<value>algorithm</value>, 758 <tag-name id="crypto_createhmac"><literal>crypto.createHmac(<value>algorithm</value>,
755 <value>secret key</value>)</literal></tag-name> 759 <value>secret key</value>)</literal></tag-name>
756 <tag-desc> 760 <tag-desc>
757 Creates and returns an <link id="crypto_hmac">HMAC</link> object 761 Creates and returns an <link id="crypto_hmac">HMAC</link> object that uses
758 that uses the given <value>algorithm</value> and <value>secret key</value>. 762 the given <value>algorithm</value> and <value>secret key</value>.
759 The algorithm can be 763 The algorithm can be
760 <literal>md5</literal>, 764 <literal>md5</literal>,
761 <literal>sha1</literal>, and 765 <literal>sha1</literal>, and
762 <literal>sha256</literal>. 766 <literal>sha256</literal>.
763 </tag-desc> 767 </tag-desc>
1201 <literal>a+</literal>&mdash;open a file for reading and appending. 1205 <literal>a+</literal>&mdash;open a file for reading and appending.
1202 If the file does not exist, it will be created 1206 If the file does not exist, it will be created
1203 </listitem> 1207 </listitem>
1204 1208
1205 <listitem> 1209 <listitem>
1206 <literal>ax+</literal>&mdash;the same as <literal>a+</literal> 1210 <literal>ax+</literal>&mdash;the same as <literal>a+</literal>
1207 but fails if the file already exists 1211 but fails if the file already exists
1208 </listitem> 1212 </listitem>
1209 1213
1210 <listitem> 1214 <listitem>
1211 <literal>as</literal>&mdash;open a file for appending in synchronous mode. 1215 <literal>as</literal>&mdash;open a file for appending
1216 in synchronous mode.
1212 If the file does not exist, it will be created 1217 If the file does not exist, it will be created
1213 </listitem> 1218 </listitem>
1214 1219
1215 <listitem> 1220 <listitem>
1216 <literal>as+</literal>&mdash;open a file for reading and appending 1221 <literal>as+</literal>&mdash;open a file for reading and appending