# HG changeset patch # User Yaroslav Zhuravlev # Date 1601500325 -3600 # Node ID a29676472a1145111041201665b95068af2be8d7 # Parent 94ebfbcd68bbc5942aaa4cbebd3c1dadde132177 Added Buffer object info to some njs methods. diff --git a/xml/en/docs/njs/reference.xml b/xml/en/docs/njs/reference.xml --- a/xml/en/docs/njs/reference.xml +++ b/xml/en/docs/njs/reference.xml @@ -9,7 +9,7 @@
+ rev="55">
@@ -923,7 +923,12 @@ The encoding can be hex, base64, and base64url. -If encoding is not provided, a byte string is returned. +If encoding is not provided, a Buffer object +(0.4.4) is returned. + +Before version (0.4.4), +a byte string was returned instead of a Buffer object. + @@ -960,7 +965,12 @@ The encoding can be hex, base64, and base64url. -If encoding is not provided, a byte string is returned. +If encoding is not provided, a Buffer object +(0.4.4) is returned. + +Before version 0.4.4, +a byte string was returned instead of a Buffer object. + @@ -1032,6 +1042,8 @@ try { Synchronously appends specified data to a file with provided filename. +The data is expected to be a string +or a Buffer object (0.4.4). If the file does not exist, it will be created. The options parameter is expected to be an object with the following keys: @@ -1083,8 +1095,9 @@ or an object with the following keys: encoding -encoding, by default is not specified. -The encoding can be utf8. +encoding, by default is utf8. +The encoding can be utf8 and buffer +(0.4.4). withFileTypes @@ -1104,8 +1117,14 @@ Synchronously returns the contents of th with provided filename. The options parameter holds string that specifies encoding. -If not specified, a byte string is returned. -If utf8 encoding is specified, a Unicode string is returned. +If an encoding is specified, a string is returned, +otherwise, a Buffer object +(0.4.4) is returned. + +Before version 0.4.4, +a byte string was returned +if encoding was not specified. + Otherwise, options is expected to be an object with the following keys: @@ -1113,7 +1132,13 @@ an object with the following keys: encoding encoding, by default is not specified. -The encoding can be utf8 +The encoding can be utf8, +hex +(0.4.4), +base64 +(0.4.4), +base64url +(0.4.4). flag @@ -1128,7 +1153,7 @@ by default is r undefined >> var file = fs.readFileSync('/file/path.tar.gz') undefined ->> var gzipped = /^\x1f\x8b/.test(file); gzipped +>> var gzipped = file.slice(0,2).toString('hex') === '1f8b'; gzipped true @@ -1187,6 +1212,8 @@ Synchronously unlinks a file by Synchronously writes data to a file with provided filename. +The data is expected to be a string +or a Buffer object (0.4.4). If the file does not exist, it will be created, if the file exists, it will be replaced. The options parameter is expected to be diff --git a/xml/ru/docs/njs/reference.xml b/xml/ru/docs/njs/reference.xml --- a/xml/ru/docs/njs/reference.xml +++ b/xml/ru/docs/njs/reference.xml @@ -9,7 +9,7 @@
+ rev="55">
@@ -925,7 +925,12 @@ clearTimeout(t); hex, base64 и base64url. -Если кодировка не указана, то будет возвращена байтовая строка. +Если кодировка не указана, то будет возвращен объект буфера +(0.4.4). + +До версии 0.4.4 +вместо объекта буфера возвращалась байтовая строка. + @@ -1035,6 +1040,8 @@ try { Синхронно добавляет указанные данные в файл с указанным именем. +Данными могут быть строка +или объект буфера (0.4.4. Если файл не существует, то он будет создан. Параметр options должен быть объектом со следующими ключами: @@ -1086,8 +1093,9 @@ try { кодировка -кодировка, по умолчанию не указана. -Кодировка может быть utf8. +кодировка, по умолчанию utf8. +Кодировка может быть utf8 и буфер +(0.4.4). withFileTypes @@ -1107,10 +1115,14 @@ try { с указанным именем. Параметр options хранит строку, которая задаёт кодировку. -Если кодировка не указана, -то будет возвращена байтовая строка. -Если указана кодировка utf8, -то будет возвращена строка Unicode. +Если кодировка указана, то будет возвращена строка, +иначе будет возвращён объект буфера +(0.4.4). + +До версии 0.4.4 +возвращалась байтовая строка +в случае, если не была указана кодировка. + Иначе ожидается, что options является объектом с ключами: @@ -1118,7 +1130,13 @@ try { кодировка кодировка, по умолчанию не указана. -Кодировка может быть utf8 +Кодировка может быть utf8, +hex +(0.4.4), +base64 +(0.4.4), +base64url +(0.4.4). флаг @@ -1133,7 +1151,7 @@ try { undefined >> var file = fs.readFileSync('/file/path.tar.gz') undefined ->> var gzipped = /^\x1f\x8b/.test(file); gzipped +>> var gzipped = file.slice(0,2).toString('hex') === '1f8b'; gzipped true @@ -1191,6 +1209,8 @@ undefined Синхронно записывает данные в файл с указанным именем. +Данными могут быть строка +или объект буфера (0.4.4. Если файл не существует, то он будет создан. Если файл существует, то он будет заменён. Параметр options должен быть