# HG changeset patch # User Yaroslav Zhuravlev # Date 1533046056 -10800 # Node ID e029f4bc7ede558ad6f34e88227d5c9054f2630e # Parent 8218075490059fe2f6e3f63b319bc0c0e0bc2200 Added quotes to njs examples. diff -r 821807549005 -r e029f4bc7ede xml/en/docs/njs/njs_api.xml --- a/xml/en/docs/njs/njs_api.xml Tue Jul 31 16:43:03 2018 +0300 +++ b/xml/en/docs/njs/njs_api.xml Tue Jul 31 17:07:36 2018 +0300 @@ -9,7 +9,7 @@
+ rev="6">
@@ -45,14 +45,14 @@ a Unicode string to a byte string using UTF8 encoding: >> '£'.toUTF8().toString('hex') -c2a3 /* C2 A3 is the UTF8 representation of 00A3 ('£') code point */ +'c2a3' /* C2 A3 is the UTF8 representation of 00A3 ('£') code point */ The toBytes() method serializes a Unicode string with code points up to 255 into a byte string, otherwise, null is returned: >> '£'.toBytes().toString('hex') -a3 /* a3 is a byte equal to 00A3 ('£') code point */ +'a3' /* a3 is a byte equal to 00A3 ('£') code point */ Only byte strings can be converted to different encodings. For example, a string cannot be encoded to hex directly: @@ -66,7 +66,7 @@ first, it should be converted to a byte string and then to hex: >> 'αβγδ'.toUTF8().toString('base64') -zrHOss6zzrQ= +'zrHOss6zzrQ=' @@ -95,7 +95,7 @@ Returns a string from one or more Unicode code points. >> String.fromCodePoint(97, 98, 99, 100) -abcd +'abcd' @@ -106,7 +106,7 @@ strings. >> "a".concat("b", "c") -abc +'abc' @@ -203,7 +203,7 @@ Matches a string against a regexp. >> 'nginx'.match( /ng/i ) -ng +'ng' @@ -237,7 +237,7 @@ with the specified number of copies of the string. >> 'abc'.repeat(3) -abcabcabc +'abcabcabc' @@ -249,7 +249,7 @@ replaced by a string or a function. >> 'abcdefgh'.replace('d', 1) -abc1efgh +'abc1efgh' @@ -271,7 +271,7 @@ from start to the end of the string. >> 'abcdefghijklmno'.slice(NaN, 5) -abcde +'abcde' @@ -299,7 +299,7 @@ or from start to the end of the string. >> 'abcdefghijklmno'.substr(3, 5) -defgh +'defgh' @@ -311,7 +311,7 @@ from start to the end of the string. >> 'abcdefghijklmno'.substring(3, 5) -de +'de' @@ -329,7 +329,7 @@ The method supports only simple Unicode folding. >> 'ΑΒΓΔ'.toLowerCase() -αβγδ +'αβγδ' @@ -349,7 +349,7 @@ >> 'αβγδ'.toUTF8().toString('base64url') -zrHOss6zzrQ +'zrHOss6zzrQ' @@ -359,7 +359,7 @@ The method supports only simple Unicode folding. >> 'αβγδ'.toUpperCase() -ΑΒΓΔ +'ΑΒΓΔ' @@ -381,7 +381,7 @@ Removes whitespaces from both ends of a string. >> ' abc '.trim() -abc +'abc' @@ -393,7 +393,11 @@ a limit on the number of splits to be found. >> 'abc'.split('') -a,b,c +[ + 'a', + 'b', + 'c' +] @@ -404,7 +408,7 @@ representing the UTF-8 encoding of the character >> encodeURI('012αβγδ') -012%CE%B1%CE%B2%CE%B3%CE%B4 +'012%CE%B1%CE%B2%CE%B3%CE%B4' @@ -415,7 +419,7 @@ representing the UTF-8 encoding of the character. >> encodeURIComponent('[@?=') -%5B%40%3F%3D +'%5B%40%3F%3D' @@ -424,7 +428,7 @@ Decodes a previously encoded URI. >> decodeURI('012%CE%B1%CE%B2%CE%B3%CE%B4') -012αβγδ +'012αβγδ' @@ -433,7 +437,7 @@ Decodes an encoded component of a previously encoded URI. >> decodeURIComponent('%5B%40%3F%3D') -[@?= +'[@?=' @@ -490,25 +494,22 @@ 1 >> JSON.stringify(json) -{"a":1,"b":true} +'{"a":1,"b":true}' >> JSON.stringify(json, undefined, 1) -{ -"a": 1, -"b": true -} +'{\n "a": 1,\n "b": true\n}' >> JSON.stringify({ x: [10, undefined, function(){}] }) -{"x":[10,null,null]} +'{"x":[10,null,null]}' >> JSON.stringify({"a":1, "toJSON": function() {return "xxx"}}) -"xxx" +'"xxx"' # Example with function replacer >> function replacer(key, value) {return (typeof value === 'string') ? undefined : value} >>JSON.stringify({a:1, b:"b", c:true}, replacer) -{"a":1,"c":true} +'{"a":1,"c":true}' @@ -581,7 +582,7 @@ undefined >> cr.createHash('sha1').update('A').update('B').digest('base64url') -BtlFlCqiamG-GMPiK_GbvKjdK10 +'BtlFlCqiamG-GMPiK_GbvKjdK10' @@ -617,7 +618,7 @@ undefined >> cr.createHmac('sha1', 'secret.key').update('AB').digest('base64url') -Oglm93xn23_MkiaEq_e9u8zk374 +'Oglm93xn23_MkiaEq_e9u8zk374'