Mercurial > hg > nginx-site
comparison xml/en/docs/njs/reference.xml @ 2315:ae56e4613280
Corrected language in njs.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Tue, 25 Dec 2018 17:27:37 +0300 |
parents | 35b02ed44e4a |
children | 5eba0f7b24a9 |
comparison
equal
deleted
inserted
replaced
2314:bff6da10f841 | 2315:ae56e4613280 |
---|---|
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="18"> | 12 rev="19"> |
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 |
487 | 487 |
488 | 488 |
489 <section id="string" name="String"> | 489 <section id="string" name="String"> |
490 | 490 |
491 <para> | 491 <para> |
492 There are two types of strings: | 492 There are two types of strings in njs: a Unicode string (default) and |
493 a <literal>Unicode string</literal> (default) and | 493 a byte string. |
494 a <literal>byte string</literal>. | 494 </para> |
495 </para> | 495 |
496 | 496 <para> |
497 <para> | 497 A Unicode string corresponds to an ECMAScript string |
498 A <literal>Unicode string</literal> corresponds to an ECMAScript string | |
499 which contains Unicode characters. | 498 which contains Unicode characters. |
500 </para> | 499 </para> |
501 | 500 |
502 <para> | 501 <para> |
503 <literal>Byte strings</literal> contain a sequence of bytes. | 502 Byte strings contain a sequence of bytes |
504 They are used to serialize Unicode strings | 503 and are used to serialize Unicode strings |
505 to external data and deserialize from external sources. | 504 to external data and deserialize from external sources. |
506 For example, the <link id="string_toutf8">toUTF8()</link> method serializes | 505 For example, the <link id="string_toutf8">toUTF8()</link> method serializes |
507 a Unicode string to a byte string using UTF8 encoding: | 506 a Unicode string to a byte string using UTF8 encoding: |
508 <example> | 507 <example> |
509 >> '£'.toUTF8().toString('hex') | 508 >> '£'.toUTF8().toString('hex') |
535 | 534 |
536 <tag-name id="string_bytesfrom"><literal>String.bytesFrom(<value>array</value> | 535 <tag-name id="string_bytesfrom"><literal>String.bytesFrom(<value>array</value> |
537 | <value>string</value>, <value>encoding</value>)</literal></tag-name> | 536 | <value>string</value>, <value>encoding</value>)</literal></tag-name> |
538 <tag-desc> | 537 <tag-desc> |
539 (njs specific) Creates a byte string either from an array that contains octets, | 538 (njs specific) Creates a byte string either from an array that contains octets, |
540 or from an encoded string (0.2.3). | 539 or from an encoded string |
540 (<link doc="../njs/changes.xml" id="njs0.2.3">0.2.3</link>). | |
541 The encoding can be | 541 The encoding can be |
542 <literal>hex</literal>, | 542 <literal>hex</literal>, |
543 <literal>base64</literal>, and | 543 <literal>base64</literal>, and |
544 <literal>base64url</literal>. | 544 <literal>base64url</literal>. |
545 <example> | 545 <example> |
574 <tag-name id="string_charat"><literal>String.prototype.charAt(<value>index</value>)</literal></tag-name> | 574 <tag-name id="string_charat"><literal>String.prototype.charAt(<value>index</value>)</literal></tag-name> |
575 <tag-desc> | 575 <tag-desc> |
576 Returns a string representing one Unicode code unit | 576 Returns a string representing one Unicode code unit |
577 at the specified <literal>index</literal>; | 577 at the specified <literal>index</literal>; |
578 empty string if index is out of range. | 578 empty string if index is out of range. |
579 The <literal>index</literal> can be integer | 579 The index can be an integer |
580 between 0 and 1-less-than the length of the string. | 580 between 0 and 1-less-than the length of the string. |
581 If no index is provided, the default is <literal>0</literal>, | 581 If no index is provided, the default is <literal>0</literal>, |
582 so the first character in the string is returned. | 582 so the first character in the string is returned. |
583 </tag-desc> | 583 </tag-desc> |
584 | 584 |
585 <tag-name id="string_codepointat"><literal>String.prototype.CodePointAt(<value>position</value>)</literal></tag-name> | 585 <tag-name id="string_codepointat"><literal>String.prototype.CodePointAt(<value>position</value>)</literal></tag-name> |
586 <tag-desc> | 586 <tag-desc> |
587 Returns a number representing the code point value of the character | 587 Returns a number representing the code point value of the character |
588 at the given index; | 588 at the given <literal>position</literal>; |
589 <literal>undefined</literal> if there is no element at position. | 589 <literal>undefined</literal> if there is no element at position. |
590 <example> | 590 <example> |
591 >> 'ABCD'.codePointAt(3); | 591 >> 'ABCD'.codePointAt(3); |
592 68 | 592 68 |
593 </example> | 593 </example> |
650 | 650 |
651 <tag-name id="string_indexof"><literal>String.prototype.indexOf(<value>searchString</value>[, | 651 <tag-name id="string_indexof"><literal>String.prototype.indexOf(<value>searchString</value>[, |
652 <value>fromIndex</value>])</literal></tag-name> | 652 <value>fromIndex</value>])</literal></tag-name> |
653 <tag-desc> | 653 <tag-desc> |
654 Returns the position of the first occurrence | 654 Returns the position of the first occurrence |
655 of the <literal>searchString</literal> | 655 of the <literal>searchString</literal>. |
656 The search is started at <literal>fromIndex</literal>. | 656 The search is started at <literal>fromIndex</literal>. |
657 Returns <value>-1</value> if the value is not found. | 657 Returns <value>-1</value> if the value is not found. |
658 The <literal>fromIndex</literal> is an integer, | 658 The <literal>fromIndex</literal> is an integer, |
659 default value is 0. | 659 default value is 0. |
660 If <literal>fromIndex</literal> is lower than 0 | 660 If <literal>fromIndex</literal> is lower than 0 |
703 | 703 |
704 <tag-name id="string_padend"><literal>String.prototype.padEnd(<value>length</value> | 704 <tag-name id="string_padend"><literal>String.prototype.padEnd(<value>length</value> |
705 [, <value>string</value>])</literal></tag-name> | 705 [, <value>string</value>])</literal></tag-name> |
706 <tag-desc> | 706 <tag-desc> |
707 Returns a string of a specified <literal>length</literal> | 707 Returns a string of a specified <literal>length</literal> |
708 with the pad <literal>string</literal> applied | 708 with the pad <literal>string</literal> applied to the end of the specified |
709 to the end of the specified string (0.2.3). | 709 string (<link doc="../njs/changes.xml" id="njs0.2.3">0.2.3</link>). |
710 <example> | 710 <example> |
711 >> '1234'.padEnd(8, 'abcd') | 711 >> '1234'.padEnd(8, 'abcd') |
712 '1234abcd' | 712 '1234abcd' |
713 </example> | 713 </example> |
714 </tag-desc> | 714 </tag-desc> |
715 | 715 |
716 <tag-name id="string_padstart"><literal>String.prototype.padStart(<value>length</value> | 716 <tag-name id="string_padstart"><literal>String.prototype.padStart(<value>length</value> |
717 [, <value>string</value>])</literal></tag-name> | 717 [, <value>string</value>])</literal></tag-name> |
718 <tag-desc> | 718 <tag-desc> |
719 Returns a string of a specified <literal>length</literal> | 719 Returns a string of a specified <literal>length</literal> |
720 with the pad <literal>string</literal> applied | 720 with the pad <literal>string</literal> applied to the start of the specified |
721 to the start of the specified string (0.2.3). | 721 string (<link doc="../njs/changes.xml" id="njs0.2.3">0.2.3</link>). |
722 <example> | 722 <example> |
723 >> '1234'.padStart(8, 'abcd') | 723 >> '1234'.padStart(8, 'abcd') |
724 'abcd1234' | 724 'abcd1234' |
725 </example> | 725 </example> |
726 </tag-desc> | 726 </tag-desc> |
727 | 727 |
728 <tag-name id="string_repeat"><literal>String.prototype.repeat(<value>number</value>)</literal></tag-name> | 728 <tag-name id="string_repeat"><literal>String.prototype.repeat(<value>number</value>)</literal></tag-name> |
729 <tag-desc> | 729 <tag-desc> |
730 Returns a string | 730 Returns a string |
731 with the specified <literal>number</literal> of copies of the string. | 731 with the specified <literal>number</literal> of copies of the string. |
732 <example> | 732 <example> |
733 >> 'abc'.repeat(3) | 733 >> 'abc'.repeat(3) |
734 'abcabcabc' | 734 'abcabcabc' |
735 </example> | 735 </example> |
895 </example> | 895 </example> |
896 </tag-desc> | 896 </tag-desc> |
897 | 897 |
898 <tag-name id="encodeuri"><literal>encodeURI(<value>URI</value>)</literal></tag-name> | 898 <tag-name id="encodeuri"><literal>encodeURI(<value>URI</value>)</literal></tag-name> |
899 <tag-desc> | 899 <tag-desc> |
900 encodes a URI by replacing each instance of certain characters by | 900 Encodes a URI by replacing each instance of certain characters |
901 one, two, three, or four escape sequences | 901 by one, two, three, or four escape sequences |
902 representing the UTF-8 encoding of the character | 902 representing the UTF-8 encoding of the character |
903 <example> | 903 <example> |
904 >> encodeURI('012αβγδ') | 904 >> encodeURI('012αβγδ') |
905 '012%CE%B1%CE%B2%CE%B3%CE%B4' | 905 '012%CE%B1%CE%B2%CE%B3%CE%B4' |
906 </example> | 906 </example> |