From 78cdd4baa41af8a51146dcda3d1932c0011a8a78 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 9 Mar 2017 23:15:14 -0800 Subject: [PATCH 01/23] test: include all stdio strings for fork() test-child-process-fork-stdio-string-variant was only testing 'pipe' for its `stdio` value. Add `inherit` and `ignore`. Also added a `common.mustCall()` to verify that the `message` event is triggered. PR-URL: https://github.com/nodejs/node/pull/11783 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Santiago Gimeno --- ...t-child-process-fork-stdio-string-variant.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-child-process-fork-stdio-string-variant.js b/test/parallel/test-child-process-fork-stdio-string-variant.js index 51c943da090..5c69850216a 100644 --- a/test/parallel/test-child-process-fork-stdio-string-variant.js +++ b/test/parallel/test-child-process-fork-stdio-string-variant.js @@ -12,16 +12,19 @@ const childScript = `${common.fixturesDir}/child-process-spawn-node`; const errorRegexp = /^TypeError: Incorrect value of stdio option:/; const malFormedOpts = {stdio: '33'}; const payload = {hello: 'world'}; -const stringOpts = {stdio: 'pipe'}; assert.throws(() => fork(childScript, malFormedOpts), errorRegexp); -const child = fork(childScript, stringOpts); +function test(stringVariant) { + const child = fork(childScript, {stdio: stringVariant}); -child.on('message', (message) => { - assert.deepStrictEqual(message, {foo: 'bar'}); -}); + child.on('message', common.mustCall((message) => { + assert.deepStrictEqual(message, {foo: 'bar'}); + })); -child.send(payload); + child.send(payload); -child.on('exit', common.mustCall((code) => assert.strictEqual(code, 0))); + child.on('exit', common.mustCall((code) => assert.strictEqual(code, 0))); +} + +['pipe', 'inherit', 'ignore'].forEach(test); From ea5a2f4e2b477ae589a22ffc0659e244491c7d05 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 10 Mar 2017 09:43:48 -0800 Subject: [PATCH 02/23] doc: improve child_process `maxBuffer` text `maxBuffer` information in child_process.md used atypical formatting. This uses a single consistent style for all instances of `maxBuffer` information. PR-URL: https://github.com/nodejs/node/pull/11791 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- doc/api/child_process.md | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 7ea5a6ea98c..7c1f5373d99 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -135,8 +135,9 @@ added: v0.1.90 understand the `-c` switch on UNIX or `/d /s /c` on Windows. On Windows, command line parsing should be compatible with `cmd.exe`.) * `timeout` {number} (Default: `0`) - * [`maxBuffer`][] {number} largest amount of data (in bytes) allowed on - stdout or stderr - if exceeded child process is killed (Default: `200*1024`) + * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or + stderr. (Default: `200*1024`) If exceeded, the child process is terminated. + See caveat at [`maxBuffer` and Unicode][]. * `killSignal` {string|integer} (Default: `'SIGTERM'`) * `uid` {number} Sets the user identity of the process. (See setuid(2).) * `gid` {number} Sets the group identity of the process. (See setgid(2).) @@ -212,8 +213,9 @@ added: v0.1.91 * `env` {Object} Environment key-value pairs * `encoding` {string} (Default: `'utf8'`) * `timeout` {number} (Default: `0`) - * [`maxBuffer`][] {number} largest amount of data (in bytes) allowed on - stdout or stderr - if exceeded child process is killed (Default: `200*1024`) + * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or + stderr. (Default: `200*1024`) If exceeded, the child process is terminated. + See caveat at [`maxBuffer` and Unicode][]. * `killSignal` {string|integer} (Default: `'SIGTERM'`) * `uid` {number} Sets the user identity of the process. (See setuid(2).) * `gid` {number} Sets the group identity of the process. (See setgid(2).) @@ -618,8 +620,9 @@ changes: is allowed to run. (Default: `undefined`) * `killSignal` {string|integer} The signal value to be used when the spawned process will be killed. (Default: `'SIGTERM'`) - * [`maxBuffer`][] {number} largest amount of data (in bytes) allowed on - stdout or stderr - if exceeded child process is killed + * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or + stderr. (Default: `200*1024`) If exceeded, the child process is terminated. + See caveat at [`maxBuffer` and Unicode][]. * `encoding` {string} The encoding used for all stdio inputs and outputs. (Default: `'buffer'`) * Returns: {Buffer|string} The stdout from the command @@ -664,8 +667,9 @@ changes: is allowed to run. (Default: `undefined`) * `killSignal` {string|integer} The signal value to be used when the spawned process will be killed. (Default: `'SIGTERM'`) - * [`maxBuffer`][] {number} largest amount of data (in bytes) allowed on - stdout or stderr - if exceeded child process is killed + * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or + stderr. (Default: `200*1024`) If exceeded, the child process is terminated. + See caveat at [`maxBuffer` and Unicode][]. * `encoding` {string} The encoding used for all stdio inputs and outputs. (Default: `'buffer'`) * Returns: {Buffer|string} The stdout from the command @@ -716,8 +720,9 @@ changes: is allowed to run. (Default: `undefined`) * `killSignal` {string|integer} The signal value to be used when the spawned process will be killed. (Default: `'SIGTERM'`) - * [`maxBuffer`][] {number} largest amount of data (in bytes) allowed on - stdout or stderr - if exceeded child process is killed + * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or + stderr. (Default: `200*1024`) If exceeded, the child process is terminated. + See caveat at [`maxBuffer` and Unicode][]. * `encoding` {string} The encoding used for all stdio inputs and outputs. (Default: `'buffer'`) * `shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses @@ -1235,7 +1240,7 @@ to `stdout` although there are only 4 characters. [`Error`]: errors.html#errors_class_error [`EventEmitter`]: events.html#events_class_eventemitter [`JSON.stringify()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify -[`maxBuffer`]: #child_process_maxbuffer_and_unicode +[`maxBuffer` and Unicode]: #child_process_maxbuffer_and_unicode [`net.Server`]: net.html#net_class_net_server [`net.Socket`]: net.html#net_class_net_socket [`options.detached`]: #child_process_options_detached From 471aa19ffa5f61d3f50fa6566b283c7ee0e9d74a Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 9 Mar 2017 10:31:54 +0100 Subject: [PATCH 03/23] build: add node_use_openssl check to install.py When configuring --without-ssl and then running make install openssl headers will be copied from deps/openssl to the target installation directory. This commit adds a check for is node_use_openssl is set in which case the headers are not copied. PR-URL: https://github.com/nodejs/node/pull/11766 Reviewed-By: Colin Ihrig Reviewed-By: Ben Noordhuis Reviewed-By: Brian White --- tools/install.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/install.py b/tools/install.py index 4f155376eaf..d1100352c6a 100755 --- a/tools/install.py +++ b/tools/install.py @@ -165,7 +165,8 @@ def headers(action): if 'false' == variables.get('node_shared_libuv'): subdir_files('deps/uv/include', 'include/node/', action) - if 'false' == variables.get('node_shared_openssl'): + if 'true' == variables.get('node_use_openssl') and \ + 'false' == variables.get('node_shared_openssl'): subdir_files('deps/openssl/openssl/include/openssl', 'include/node/openssl/', action) subdir_files('deps/openssl/config/archs', 'include/node/openssl/archs', action) action(['deps/openssl/config/opensslconf.h'], 'include/node/openssl/') From 1d1dbcafa8a2deca2417e976650d0ad7a01a38c2 Mon Sep 17 00:00:00 2001 From: Franziska Hinkelmann Date: Fri, 10 Mar 2017 11:22:27 +0100 Subject: [PATCH 04/23] doc: update to current V8 versions Update the documentation to the correct V8 versions in the guide *Maintaining V8 in Node.js*. PR-URL: https://github.com/nodejs/node/pull/11787 Reviewed-By: James M Snell --- doc/guides/maintaining-V8.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/guides/maintaining-V8.md b/doc/guides/maintaining-V8.md index 4bfed3790f5..e57b73bcf91 100644 --- a/doc/guides/maintaining-V8.md +++ b/doc/guides/maintaining-V8.md @@ -93,11 +93,11 @@ includes the following branches1: 2017-04-01 - 5.4 + 5.5 - 2016-10-18 + 2016-12-06 - ~2016-12-01 + 2017-01-24 @@ -107,11 +107,11 @@ includes the following branches1: N/A - 5.4 + 5.6 - 2016-10-18 + 2017-01-31 - ~2016-12-01 + 2017-03-07 From 3be1db8702f0e2737bf0fceedd4a58b3ddd4ce99 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Fri, 10 Mar 2017 12:13:49 +0100 Subject: [PATCH 05/23] test: fix flaky test-http-set-timeout-server It can happen that the connection and server is closed before the second reponse has been processed by server. In this case, the `res.setTimeout()` callback will never be called causing the test to fail. Fix this by only closing the connection and server when the 2nd has been received. PR-URL: https://github.com/nodejs/node/pull/11790 Fixes: https://github.com/nodejs/node/issues/11768 Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig Reviewed-By: Gibson Fahnestock --- test/parallel/test-http-set-timeout-server.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-http-set-timeout-server.js b/test/parallel/test-http-set-timeout-server.js index 43b74069ac0..0420a21cb4c 100644 --- a/test/parallel/test-http-set-timeout-server.js +++ b/test/parallel/test-http-set-timeout-server.js @@ -138,10 +138,13 @@ test(function serverRequestNotTimeoutAfterEnd(cb) { test(function serverResponseTimeoutWithPipeline(cb) { let caughtTimeout = ''; + let secReceived = false; process.on('exit', function() { assert.strictEqual(caughtTimeout, '/2'); }); const server = http.createServer(function(req, res) { + if (req.url === '/2') + secReceived = true; const s = res.setTimeout(50, function() { caughtTimeout += req.url; }); @@ -149,9 +152,11 @@ test(function serverResponseTimeoutWithPipeline(cb) { if (req.url === '/1') res.end(); }); server.on('timeout', function(socket) { - socket.destroy(); - server.close(); - cb(); + if (secReceived) { + socket.destroy(); + server.close(); + cb(); + } }); server.listen(common.mustCall(function() { const port = server.address().port; From 6ff495bfde3e14e370e60912cab28687b419fddd Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Mon, 13 Mar 2017 05:25:26 -0500 Subject: [PATCH 06/23] doc: add missing changelog heading for 7.7.2 When the release was cut, the changelog heading in CHANGELOG_V7 was accidentally omitted. PR-URL: https://github.com/nodejs/node/pull/11823 Fixes: https://github.com/nodejs/node/issues/11822 Reviewed-By: Gibson Fahnestock Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Jeremiah Senkpiel --- doc/changelogs/CHANGELOG_V7.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelogs/CHANGELOG_V7.md b/doc/changelogs/CHANGELOG_V7.md index 53c6b345ba4..ff76e64a2c9 100644 --- a/doc/changelogs/CHANGELOG_V7.md +++ b/doc/changelogs/CHANGELOG_V7.md @@ -6,6 +6,7 @@ +7.7.2
7.7.1
7.7.0
7.6.0
From d3418b13190d142112270dcacf33d5542170729d Mon Sep 17 00:00:00 2001 From: Alexey Orlenko Date: Fri, 10 Mar 2017 12:07:15 +0200 Subject: [PATCH 07/23] doc: fix stylistic issues in api/net.md * Change var to const in an example of server creation. * Add missing semicolons. * Use `console` syntax highlighting in `telnet` and `nc` invocation examples and add shell prompt symbols to be consistent with the rest of the documentation. PR-URL: https://github.com/nodejs/node/pull/11786 Reviewed-By: Luigi Pinca Reviewed-By: Joyee Cheung Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- doc/api/net.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/api/net.md b/doc/api/net.md index d20e6bf767e..f1df6911859 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -40,7 +40,7 @@ double-backslashes, such as: ```js net.createServer().listen( - path.join('\\\\?\\pipe', process.cwd(), 'myctl')) + path.join('\\\\?\\pipe', process.cwd(), 'myctl')); ``` ## Class: net.Server @@ -107,7 +107,7 @@ Returns an object with `port`, `family`, and `address` properties: Example: ```js -var server = net.createServer((socket) => { +const server = net.createServer((socket) => { socket.end('goodbye\n'); }).on('error', (err) => { // handle errors here @@ -758,7 +758,7 @@ socket.setTimeout(3000); socket.on('timeout', () => { console.log('socket timeout'); socket.end(); -}) +}); ``` If `timeout` is 0, then the existing idle timeout is disabled. @@ -997,8 +997,8 @@ server.listen(8124, () => { Test this by using `telnet`: -```sh -telnet localhost 8124 +```console +$ telnet localhost 8124 ``` To listen on the socket `/tmp/echo.sock` the third line from the last would @@ -1012,8 +1012,8 @@ server.listen('/tmp/echo.sock', () => { Use `nc` to connect to a UNIX domain socket server: -```js -nc -U /tmp/echo.sock +```console +$ nc -U /tmp/echo.sock ``` ## net.isIP(input) From 879d6663eafdfd6e07111e7a38652cadbb1d17bd Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Tue, 14 Mar 2017 18:51:36 +0100 Subject: [PATCH 08/23] net: remove an unused internal module `assertPort` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A module `assertPort` in `lib/internal/net.js` is not used anymore. Refs: https://github.com/nodejs/node/pull/11667 PR-URL: https://github.com/nodejs/node/pull/11812 Reviewed-By: James M Snell Reviewed-By: Evan Lucas Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig Reviewed-By: Joyee Cheung --- lib/internal/net.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/internal/net.js b/lib/internal/net.js index 8f279cad160..ce8f549bdfa 100644 --- a/lib/internal/net.js +++ b/lib/internal/net.js @@ -9,13 +9,6 @@ function isLegalPort(port) { return +port === (+port >>> 0) && port <= 0xFFFF; } - -function assertPort(port) { - if (typeof port !== 'undefined' && !isLegalPort(port)) - throw new RangeError('"port" argument must be >= 0 and < 65536'); -} - module.exports = { - isLegalPort, - assertPort + isLegalPort }; From 92bcc13be00ef73c4989f1c8ad92c0f4a4c0b911 Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Tue, 14 Mar 2017 20:43:39 +0100 Subject: [PATCH 09/23] test: test resolveObject with an empty path Add a case to test an URL object that has no path at all for `url.resolveObject`. PR-URL: https://github.com/nodejs/node/pull/11811 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Yuta Hiroto Reviewed-By: Joyee Cheung --- test/parallel/test-url-relative.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/parallel/test-url-relative.js b/test/parallel/test-url-relative.js index aff0eb76f88..cf379e591d6 100644 --- a/test/parallel/test-url-relative.js +++ b/test/parallel/test-url-relative.js @@ -368,6 +368,9 @@ const relativeTests2 = [ ['https://example.com/foo', 'https://user:password@example.com', 'https://user:password@example.com/foo'], + + // No path at all + ['#hash1', '#hash2', '#hash1'] ]; relativeTests2.forEach(function(relativeTest) { const a = url.resolve(relativeTest[1], relativeTest[0]); From d77a7588cf4f356955e85d91e638a01120195e6b Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Fri, 3 Feb 2017 17:34:47 -0800 Subject: [PATCH 10/23] url: spec-compliant URLSearchParams serializer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/11626 Reviewed-By: Joyee Cheung Reviewed-By: Michaël Zasso Reviewed-By: James M Snell Reviewed-By: Daijiro Wachi --- ...cy-vs-whatwg-url-searchparams-serialize.js | 2 +- lib/internal/url.js | 105 ++++++++++++++++-- test/fixtures/url-tests.js | 2 +- test/parallel/test-whatwg-url-constructor.js | 6 +- ...est-whatwg-url-searchparams-constructor.js | 4 +- ...est-whatwg-url-searchparams-stringifier.js | 20 ++-- test/parallel/test-whatwg-url-searchparams.js | 2 +- 7 files changed, 111 insertions(+), 30 deletions(-) diff --git a/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js b/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js index 7e56b5fba6e..2b8d2c36a81 100644 --- a/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js +++ b/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js @@ -7,7 +7,7 @@ const inputs = require('../fixtures/url-inputs.js').searchParams; const bench = common.createBenchmark(main, { type: Object.keys(inputs), method: ['legacy', 'whatwg'], - n: [1e5] + n: [1e6] }); function useLegacy(n, input, prop) { diff --git a/lib/internal/url.js b/lib/internal/url.js index 4af9e34f91b..005f5b66476 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -1,7 +1,7 @@ 'use strict'; const util = require('util'); -const { StorageObject } = require('internal/querystring'); +const { hexTable, StorageObject } = require('internal/querystring'); const binding = process.binding('url'); const context = Symbol('context'); const cannotBeBase = Symbol('cannot-be-base'); @@ -597,18 +597,99 @@ function getParamsFromObject(obj) { return values; } -function getObjectFromParams(array) { - const obj = new StorageObject(); - for (var i = 0; i < array.length; i += 2) { - const name = array[i]; - const value = array[i + 1]; - if (obj[name]) { - obj[name].push(value); - } else { - obj[name] = [value]; +// Adapted from querystring's implementation. +// Ref: https://url.spec.whatwg.org/#concept-urlencoded-byte-serializer +const noEscape = [ +//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00 - 0x0F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x10 - 0x1F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, // 0x20 - 0x2F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 0x30 - 0x3F + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 - 0x4F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 0x50 - 0x5F + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 - 0x6F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 // 0x70 - 0x7F +]; + +// Special version of hexTable that uses `+` for U+0020 SPACE. +const paramHexTable = hexTable.slice(); +paramHexTable[0x20] = '+'; + +function escapeParam(str) { + const len = str.length; + if (len === 0) + return ''; + + var out = ''; + var lastPos = 0; + + for (var i = 0; i < len; i++) { + var c = str.charCodeAt(i); + + // ASCII + if (c < 0x80) { + if (noEscape[c] === 1) + continue; + if (lastPos < i) + out += str.slice(lastPos, i); + lastPos = i + 1; + out += paramHexTable[c]; + continue; + } + + if (lastPos < i) + out += str.slice(lastPos, i); + + // Multi-byte characters ... + if (c < 0x800) { + lastPos = i + 1; + out += paramHexTable[0xC0 | (c >> 6)] + + paramHexTable[0x80 | (c & 0x3F)]; + continue; + } + if (c < 0xD800 || c >= 0xE000) { + lastPos = i + 1; + out += paramHexTable[0xE0 | (c >> 12)] + + paramHexTable[0x80 | ((c >> 6) & 0x3F)] + + paramHexTable[0x80 | (c & 0x3F)]; + continue; } + // Surrogate pair + ++i; + var c2; + if (i < len) + c2 = str.charCodeAt(i) & 0x3FF; + else { + // This branch should never happen because all URLSearchParams entries + // should already be converted to USVString. But, included for + // completion's sake anyway. + c2 = 0; + } + lastPos = i + 1; + c = 0x10000 + (((c & 0x3FF) << 10) | c2); + out += paramHexTable[0xF0 | (c >> 18)] + + paramHexTable[0x80 | ((c >> 12) & 0x3F)] + + paramHexTable[0x80 | ((c >> 6) & 0x3F)] + + paramHexTable[0x80 | (c & 0x3F)]; } - return obj; + if (lastPos === 0) + return str; + if (lastPos < len) + return out + str.slice(lastPos); + return out; +} + +// application/x-www-form-urlencoded serializer +// Ref: https://url.spec.whatwg.org/#concept-urlencoded-serializer +function serializeParams(array) { + const len = array.length; + if (len === 0) + return ''; + + var output = `${escapeParam(array[0])}=${escapeParam(array[1])}`; + for (var i = 2; i < len; i += 2) + output += `&${escapeParam(array[i])}=${escapeParam(array[i + 1])}`; + return output; } // Mainly to mitigate func-name-matching ESLint rule @@ -993,7 +1074,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', { throw new TypeError('Value of `this` is not a URLSearchParams'); } - return querystring.stringify(getObjectFromParams(this[searchParams])); + return serializeParams(this[searchParams]); } }); diff --git a/test/fixtures/url-tests.js b/test/fixtures/url-tests.js index 0e510eb366d..a4e7de9f26b 100644 --- a/test/fixtures/url-tests.js +++ b/test/fixtures/url-tests.js @@ -4639,7 +4639,7 @@ module.exports = "port": "", "pathname": "/foo/bar", "search": "??a=b&c=d", - // "searchParams": "%3Fa=b&c=d", + "searchParams": "%3Fa=b&c=d", "hash": "" }, "# Scheme only", diff --git a/test/parallel/test-whatwg-url-constructor.js b/test/parallel/test-whatwg-url-constructor.js index c5d70b3f4c1..c2773b9af10 100644 --- a/test/parallel/test-whatwg-url-constructor.js +++ b/test/parallel/test-whatwg-url-constructor.js @@ -120,12 +120,12 @@ function runURLSearchParamTests() { // And in the other direction, altering searchParams propagates // back to 'search'. searchParams.append('i', ' j ') - // assert_equals(url.search, '?e=f&g=h&i=+j+') - // assert_equals(url.searchParams.toString(), 'e=f&g=h&i=+j+') + assert_equals(url.search, '?e=f&g=h&i=+j+') + assert_equals(url.searchParams.toString(), 'e=f&g=h&i=+j+') assert_equals(searchParams.get('i'), ' j ') searchParams.set('e', 'updated') - // assert_equals(url.search, '?e=updated&g=h&i=+j+') + assert_equals(url.search, '?e=updated&g=h&i=+j+') assert_equals(searchParams.get('e'), 'updated') var url2 = bURL('http://example.org/file??a=b&c=d') diff --git a/test/parallel/test-whatwg-url-searchparams-constructor.js b/test/parallel/test-whatwg-url-searchparams-constructor.js index 236d0139609..da459fe99c7 100644 --- a/test/parallel/test-whatwg-url-searchparams-constructor.js +++ b/test/parallel/test-whatwg-url-searchparams-constructor.js @@ -11,7 +11,7 @@ const { /* eslint-disable */ var params; // Strict mode fix for WPT. /* WPT Refs: - https://github.com/w3c/web-platform-tests/blob/405394a/url/urlsearchparams-constructor.html + https://github.com/w3c/web-platform-tests/blob/e94c604916/url/urlsearchparams-constructor.html License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html */ test(function() { @@ -154,7 +154,7 @@ test(function() { }, "Constructor with sequence of sequences of strings"); [ -// { "input": {"+": "%C2"}, "output": [[" ", "\uFFFD"]], "name": "object with +" }, + { "input": {"+": "%C2"}, "output": [["+", "%C2"]], "name": "object with +" }, { "input": {c: "x", a: "?"}, "output": [["c", "x"], ["a", "?"]], "name": "object with two keys" }, { "input": [["c", "x"], ["a", "?"]], "output": [["c", "x"], ["a", "?"]], "name": "array with two keys" } ].forEach((val) => { diff --git a/test/parallel/test-whatwg-url-searchparams-stringifier.js b/test/parallel/test-whatwg-url-searchparams-stringifier.js index 5f751b1c503..ac09979e027 100644 --- a/test/parallel/test-whatwg-url-searchparams-stringifier.js +++ b/test/parallel/test-whatwg-url-searchparams-stringifier.js @@ -10,14 +10,14 @@ const { test, assert_equals } = common.WPT; https://github.com/w3c/web-platform-tests/blob/8791bed/url/urlsearchparams-stringifier.html License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html */ -// test(function() { -// var params = new URLSearchParams(); -// params.append('a', 'b c'); -// assert_equals(params + '', 'a=b+c'); -// params.delete('a'); -// params.append('a b', 'c'); -// assert_equals(params + '', 'a+b=c'); -// }, 'Serialize space'); +test(function() { + var params = new URLSearchParams(); + params.append('a', 'b c'); + assert_equals(params + '', 'a=b+c'); + params.delete('a'); + params.append('a b', 'c'); + assert_equals(params + '', 'a+b=c'); +}, 'Serialize space'); test(function() { var params = new URLSearchParams(); @@ -114,8 +114,8 @@ test(function() { var params; params = new URLSearchParams('a=b&c=d&&e&&'); assert_equals(params.toString(), 'a=b&c=d&e='); - // params = new URLSearchParams('a = b &a=b&c=d%20'); - // assert_equals(params.toString(), 'a+=+b+&a=b&c=d+'); + params = new URLSearchParams('a = b &a=b&c=d%20'); + assert_equals(params.toString(), 'a+=+b+&a=b&c=d+'); // The lone '=' _does_ survive the roundtrip. params = new URLSearchParams('a=&a=b'); assert_equals(params.toString(), 'a=&a=b'); diff --git a/test/parallel/test-whatwg-url-searchparams.js b/test/parallel/test-whatwg-url-searchparams.js index e0d18265967..7d6df646407 100644 --- a/test/parallel/test-whatwg-url-searchparams.js +++ b/test/parallel/test-whatwg-url-searchparams.js @@ -7,7 +7,7 @@ const URL = require('url').URL; // Tests below are not from WPT. const serialized = 'a=a&a=1&a=true&a=undefined&a=null&a=%EF%BF%BD' + '&a=%EF%BF%BD&a=%F0%9F%98%80&a=%EF%BF%BD%EF%BF%BD' + - '&a=%5Bobject%20Object%5D'; + '&a=%5Bobject+Object%5D'; const values = ['a', 1, true, undefined, null, '\uD83D', '\uDE00', '\uD83D\uDE00', '\uDE00\uD83D', {}]; const normalizedValues = ['a', '1', 'true', 'undefined', 'null', '\uFFFD', From 39d9afe279e9d66f983bc06294cb38243e54d637 Mon Sep 17 00:00:00 2001 From: Blake Embrey Date: Fri, 13 Nov 2015 16:40:08 -0800 Subject: [PATCH 11/23] repl: refactor `LineParser` implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the core logic from `LineParser` should fail handling into the recoverable error check for the REPL default eval. PR-URL: https://github.com/nodejs/node/pull/6171 Reviewed-By: James M Snell Reviewed-By: Michaël Zasso --- lib/repl.js | 262 +++++++++++++++---------------------- test/parallel/test-repl.js | 9 +- 2 files changed, 114 insertions(+), 157 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index b00666267a6..e4364e7d11c 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -99,105 +99,6 @@ exports.writer = util.inspect; exports._builtinLibs = internalModule.builtinLibs; -class LineParser { - - constructor() { - this.reset(); - } - - reset() { - this._literal = null; - this.shouldFail = false; - this.blockComment = false; - this.regExpLiteral = false; - this.prevTokenChar = null; - } - - parseLine(line) { - var previous = null; - this.shouldFail = false; - const wasWithinStrLiteral = this._literal !== null; - - for (const current of line) { - if (previous === '\\') { - // valid escaping, skip processing. previous doesn't matter anymore - previous = null; - continue; - } - - if (!this._literal) { - if (this.regExpLiteral && current === '/') { - this.regExpLiteral = false; - previous = null; - continue; - } - if (previous === '*' && current === '/') { - if (this.blockComment) { - this.blockComment = false; - previous = null; - continue; - } else { - this.shouldFail = true; - break; - } - } - - // ignore rest of the line if `current` and `previous` are `/`s - if (previous === current && previous === '/' && !this.blockComment) { - break; - } - - if (previous === '/') { - if (current === '*') { - this.blockComment = true; - } else if ( - // Distinguish between a division operator and the start of a regex - // by examining the non-whitespace character that precedes the / - [null, '(', '[', '{', '}', ';'].includes(this.prevTokenChar) - ) { - this.regExpLiteral = true; - } - previous = null; - } - } - - if (this.blockComment || this.regExpLiteral) continue; - - if (current === this._literal) { - this._literal = null; - } else if (current === '\'' || current === '"') { - this._literal = this._literal || current; - } - - if (current.trim() && current !== '/') this.prevTokenChar = current; - - previous = current; - } - - const isWithinStrLiteral = this._literal !== null; - - if (!wasWithinStrLiteral && !isWithinStrLiteral) { - // Current line has nothing to do with String literals, trim both ends - line = line.trim(); - } else if (wasWithinStrLiteral && !isWithinStrLiteral) { - // was part of a string literal, but it is over now, trim only the end - line = line.trimRight(); - } else if (isWithinStrLiteral && !wasWithinStrLiteral) { - // was not part of a string literal, but it is now, trim only the start - line = line.trimLeft(); - } - - const lastChar = line.charAt(line.length - 1); - - this.shouldFail = this.shouldFail || - ((!this._literal && lastChar === '\\') || - (this._literal && lastChar !== '\\')); - - return line; - } -} - - function REPLServer(prompt, stream, eval_, @@ -249,8 +150,6 @@ function REPLServer(prompt, self.breakEvalOnSigint = !!breakEvalOnSigint; self.editorMode = false; - self._inTemplateLiteral = false; - // just for backwards compat, see github.com/joyent/node/pull/7127 self.rli = this; @@ -262,29 +161,20 @@ function REPLServer(prompt, eval_ = eval_ || defaultEval; - function preprocess(code) { - let cmd = code; - if (/^\s*\{/.test(cmd) && /\}\s*$/.test(cmd)) { + function defaultEval(code, context, file, cb) { + var err, result, script, wrappedErr; + var wrappedCmd = false; + var input = code; + + if (/^\s*\{/.test(code) && /\}\s*$/.test(code)) { // It's confusing for `{ a : 1 }` to be interpreted as a block // statement rather than an object literal. So, we first try // to wrap it in parentheses, so that it will be interpreted as // an expression. - cmd = `(${cmd})`; - self.wrappedCmd = true; + code = `(${code.trim()})\n`; + wrappedCmd = true; } - // Append a \n so that it will be either - // terminated, or continued onto the next expression if it's an - // unexpected end of input. - return `${cmd}\n`; - } - function defaultEval(code, context, file, cb) { - // Remove trailing new line - code = code.replace(/\n$/, ''); - code = preprocess(code); - - var input = code; - var err, result, wrappedErr; // first, create the Script object to check the syntax if (code === '\n') @@ -298,22 +188,22 @@ function REPLServer(prompt, // value for statements and declarations that don't return a value. code = `'use strict'; void 0;\n${code}`; } - var script = vm.createScript(code, { + script = vm.createScript(code, { filename: file, displayErrors: true }); } catch (e) { debug('parse error %j', code, e); - if (self.wrappedCmd) { - self.wrappedCmd = false; + if (wrappedCmd) { + wrappedCmd = false; // unwrap and try again - code = `${input.substring(1, input.length - 2)}\n`; + code = input; wrappedErr = e; continue; } // preserve original error for wrapped command const error = wrappedErr || e; - if (isRecoverableError(error, self)) + if (isRecoverableError(error, code)) err = new Recoverable(error); else err = error; @@ -400,7 +290,6 @@ function REPLServer(prompt, (_, pre, line) => pre + (line - 1)); } top.outputStream.write((e.stack || e) + '\n'); - top.lineParser.reset(); top.bufferedCommand = ''; top.lines.level = []; top.displayPrompt(); @@ -427,7 +316,6 @@ function REPLServer(prompt, self.outputStream = output; self.resetContext(); - self.lineParser = new LineParser(); self.bufferedCommand = ''; self.lines.level = []; @@ -490,7 +378,6 @@ function REPLServer(prompt, sawSIGINT = false; } - self.lineParser.reset(); self.bufferedCommand = ''; self.lines.level = []; self.displayPrompt(); @@ -498,6 +385,7 @@ function REPLServer(prompt, self.on('line', function onLine(cmd) { debug('line %j', cmd); + cmd = cmd || ''; sawSIGINT = false; if (self.editorMode) { @@ -515,23 +403,28 @@ function REPLServer(prompt, return; } - // leading whitespaces in template literals should not be trimmed. - if (self._inTemplateLiteral) { - self._inTemplateLiteral = false; - } else { - cmd = self.lineParser.parseLine(cmd); - } + // Check REPL keywords and empty lines against a trimmed line input. + const trimmedCmd = cmd.trim(); // Check to see if a REPL keyword was used. If it returns true, // display next prompt and return. - if (cmd && cmd.charAt(0) === '.' && isNaN(parseFloat(cmd))) { - var matches = cmd.match(/^\.([^\s]+)\s*(.*)$/); - var keyword = matches && matches[1]; - var rest = matches && matches[2]; - if (self.parseREPLKeyword(keyword, rest) === true) { - return; - } else if (!self.bufferedCommand) { - self.outputStream.write('Invalid REPL keyword\n'); + if (trimmedCmd) { + if (trimmedCmd.charAt(0) === '.' && isNaN(parseFloat(trimmedCmd))) { + const matches = trimmedCmd.match(/^\.([^\s]+)\s*(.*)$/); + const keyword = matches && matches[1]; + const rest = matches && matches[2]; + if (self.parseREPLKeyword(keyword, rest) === true) { + return; + } + if (!self.bufferedCommand) { + self.outputStream.write('Invalid REPL keyword\n'); + finish(null); + return; + } + } + } else { + // Print a new line when hitting enter. + if (!self.bufferedCommand) { finish(null); return; } @@ -546,12 +439,10 @@ function REPLServer(prompt, debug('finish', e, ret); self.memory(cmd); - self.wrappedCmd = false; if (e && !self.bufferedCommand && cmd.trim().startsWith('npm ')) { self.outputStream.write('npm should be run outside of the ' + 'node repl, in your normal shell.\n' + '(Press Control-D to exit.)\n'); - self.lineParser.reset(); self.bufferedCommand = ''; self.displayPrompt(); return; @@ -559,8 +450,7 @@ function REPLServer(prompt, // If error was SyntaxError and not JSON.parse error if (e) { - if (e instanceof Recoverable && !self.lineParser.shouldFail && - !sawCtrlD) { + if (e instanceof Recoverable && !sawCtrlD) { // Start buffering data like that: // { // ... x: 1 @@ -574,7 +464,6 @@ function REPLServer(prompt, } // Clear buffer if no SyntaxErrors - self.lineParser.reset(); self.bufferedCommand = ''; sawCtrlD = false; @@ -1234,7 +1123,6 @@ function defineDefaultCommands(repl) { repl.defineCommand('break', { help: 'Sometimes you get stuck, this gets you out', action: function() { - this.lineParser.reset(); this.bufferedCommand = ''; this.displayPrompt(); } @@ -1249,7 +1137,6 @@ function defineDefaultCommands(repl) { repl.defineCommand('clear', { help: clearMessage, action: function() { - this.lineParser.reset(); this.bufferedCommand = ''; if (!this.useGlobal) { this.outputStream.write('Clearing context...\n'); @@ -1370,20 +1257,13 @@ REPLServer.prototype.convertToContext = util.deprecate(function(cmd) { return cmd; }, 'replServer.convertToContext() is deprecated', 'DEP0024'); -function bailOnIllegalToken(parser) { - return parser._literal === null && - !parser.blockComment && - !parser.regExpLiteral; -} - // If the error is that we've unexpectedly ended the input, // then let the user try to recover by adding more input. -function isRecoverableError(e, self) { +function isRecoverableError(e, code) { if (e && e.name === 'SyntaxError') { var message = e.message; if (message === 'Unterminated template literal' || message === 'Missing } in template expression') { - self._inTemplateLiteral = true; return true; } @@ -1393,11 +1273,81 @@ function isRecoverableError(e, self) { return true; if (message === 'Invalid or unexpected token') - return !bailOnIllegalToken(self.lineParser); + return isCodeRecoverable(code); } return false; } +// Check whether a code snippet should be forced to fail in the REPL. +function isCodeRecoverable(code) { + var current, previous, stringLiteral; + var isBlockComment = false; + var isSingleComment = false; + var isRegExpLiteral = false; + var lastChar = code.charAt(code.length - 2); + var prevTokenChar = null; + + for (var i = 0; i < code.length; i++) { + previous = current; + current = code[i]; + + if (previous === '\\' && (stringLiteral || isRegExpLiteral)) { + current = null; + continue; + } + + if (stringLiteral) { + if (stringLiteral === current) { + stringLiteral = null; + } + continue; + } else { + if (isRegExpLiteral && current === '/') { + isRegExpLiteral = false; + continue; + } + + if (isBlockComment && previous === '*' && current === '/') { + isBlockComment = false; + continue; + } + + if (isSingleComment && current === '\n') { + isSingleComment = false; + continue; + } + + if (isBlockComment || isRegExpLiteral || isSingleComment) continue; + + if (current === '/' && previous === '/') { + isSingleComment = true; + continue; + } + + if (previous === '/') { + if (current === '*') { + isBlockComment = true; + } else if ( + // Distinguish between a division operator and the start of a regex + // by examining the non-whitespace character that precedes the / + [null, '(', '[', '{', '}', ';'].includes(prevTokenChar) + ) { + isRegExpLiteral = true; + } + continue; + } + + if (current.trim()) prevTokenChar = current; + } + + if (current === '\'' || current === '"') { + stringLiteral = current; + } + } + + return stringLiteral ? lastChar === '\\' : isBlockComment; +} + function Recoverable(err) { this.err = err; } diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 7e426eb54ee..b6de1985698 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -407,7 +407,14 @@ function error_test() { { client: client_unix, send: '(function() {\nif (false) {} /bar"/;\n}())', expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix - } + }, + + // Newline within template string maintains whitespace. + { client: client_unix, send: '`foo \n`', + expect: prompt_multiline + '\'foo \\n\'\n' + prompt_unix }, + // Whitespace is not evaluated. + { client: client_unix, send: ' \t \n', + expect: prompt_unix } ]); } From c9bc3e50edf192aac7a051c1dd585d9df5c43c79 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sat, 4 Mar 2017 18:54:48 +0800 Subject: [PATCH 12/23] test: fail when child dies in fork-net Previously when the child dies with errors in this test, the parent will just hang and timeout, the errors in the child would be swallowed. This makes it fail so at least there is more information about why this test fails. Also removes the unnecessary child.kill() call. PR-URL: https://github.com/nodejs/node/pull/11684 Ref: https://github.com/nodejs/node/pull/11667 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-child-process-fork-net.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-child-process-fork-net.js b/test/parallel/test-child-process-fork-net.js index 1dec70aca8c..42994007e83 100644 --- a/test/parallel/test-child-process-fork-net.js +++ b/test/parallel/test-child-process-fork-net.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const fork = require('child_process').fork; const net = require('net'); @@ -81,9 +81,10 @@ if (process.argv[2] === 'child') { const child = fork(process.argv[1], ['child']); - child.on('exit', function() { - console.log('CHILD: died'); - }); + child.on('exit', common.mustCall(function(code, signal) { + const message = `CHILD: died with ${code}, ${signal}`; + assert.strictEqual(code, 0, message); + })); // send net.Server to child and test by connecting const testServer = function(callback) { @@ -192,7 +193,6 @@ if (process.argv[2] === 'child') { testSocket(function() { socketSuccess = true; - child.kill(); }); }); From bc26c62524c0522d6a4d03d33032e32984b39a25 Mon Sep 17 00:00:00 2001 From: "Italo A. Casas" Date: Tue, 14 Mar 2017 10:38:22 -0400 Subject: [PATCH 13/23] 2017-03-14, Version 7.7.3 (Current) Notable changes: * module: The [module loading global fallback] (https://nodejs.org/dist/latest-v6.x/docs/api/modules.html#modules_loading_from_the_global_folders) to the Node executable's directory now works correctly on Windows. (Richard Lau) [#9283](https://github.com/nodejs/node/pull/9283) * net: `Socket.prototype.connect` now once again functions without a callback. (Juwan Yoo) [#11762](https://github.com/nodejs/node/pull/11762) * url: `URL.prototype.origin` now properly specified an opaque return of `'null'` for `file://` URLs. (Brian White) [#11691](https://github.com/nodejs/node/pull/11691) PR-URL: https://github.com/nodejs/node/pull/11831 --- CHANGELOG.md | 3 ++- doc/changelogs/CHANGELOG_V7.md | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2bab714999..49d686356e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,8 @@ release. -7.7.2
+7.7.3
+7.7.2
7.7.1
7.7.0
7.6.0
diff --git a/doc/changelogs/CHANGELOG_V7.md b/doc/changelogs/CHANGELOG_V7.md index ff76e64a2c9..45dda5d2edd 100644 --- a/doc/changelogs/CHANGELOG_V7.md +++ b/doc/changelogs/CHANGELOG_V7.md @@ -6,6 +6,7 @@ +7.7.3
7.7.2
7.7.1
7.7.0
@@ -30,6 +31,45 @@ * [io.js](CHANGELOG_IOJS.md) * [Archive](CHANGELOG_ARCHIVE.md) + +## 2017-03-14, Version 7.7.3 (Current), @italoacasas + +### Notable changes + +* **module**: The [module loading global fallback](https://nodejs.org/dist/latest-v6.x/docs/api/modules.html#modules_loading_from_the_global_folders) to the Node executable's directory now works correctly on Windows. (Richard Lau) [#9283](https://github.com/nodejs/node/pull/9283) +* **net**: `Socket.prototype.connect` now once again functions without a callback. (Juwan Yoo) [#11762](https://github.com/nodejs/node/pull/11762) +* **url**: `URL.prototype.origin` now properly specified an opaque return of `'null'` for `file://` URLs. (Brian White) [#11691](https://github.com/nodejs/node/pull/11691) + +### Commits + +* [[`542a3735a7`](https://github.com/nodejs/node/commit/542a3735a7)] - **build**: add node_use_openssl check to install.py (Daniel Bevenius) [#11766](https://github.com/nodejs/node/pull/11766) +* [[`2fcefeeda0`](https://github.com/nodejs/node/commit/2fcefeeda0)] - **dgram**: refactor dgram to module.exports (Claudio Rodriguez) [#11696](https://github.com/nodejs/node/pull/11696) +* [[`dd3e6adaa7`](https://github.com/nodejs/node/commit/dd3e6adaa7)] - **doc**: add missing changelog heading for 7.7.2 (Evan Lucas) [#11823](https://github.com/nodejs/node/pull/11823) +* [[`b543fd441c`](https://github.com/nodejs/node/commit/b543fd441c)] - **doc**: update to current V8 versions (Franziska Hinkelmann) [#11787](https://github.com/nodejs/node/pull/11787) +* [[`6cc7b30c62`](https://github.com/nodejs/node/commit/6cc7b30c62)] - **doc**: improve child_process `maxBuffer` text (Rich Trott) [#11791](https://github.com/nodejs/node/pull/11791) +* [[`188cbc6eea`](https://github.com/nodejs/node/commit/188cbc6eea)] - **doc**: package main can be directory with an index (Bradley Farias) [#11581](https://github.com/nodejs/node/pull/11581) +* [[`a20aa0ee48`](https://github.com/nodejs/node/commit/a20aa0ee48)] - **doc**: http cleanup and missing argument types (Amelia Clarke) [#11681](https://github.com/nodejs/node/pull/11681) +* [[`8a1b2b4417`](https://github.com/nodejs/node/commit/8a1b2b4417)] - **doc**: reduce font size on smaller screens (Gibson Fahnestock) [#11695](https://github.com/nodejs/node/pull/11695) +* [[`5bea8b42d9`](https://github.com/nodejs/node/commit/5bea8b42d9)] - **doc**: fix occurences of "the the" (Jeroen Mandersloot) [#11711](https://github.com/nodejs/node/pull/11711) +* [[`517c3af21a`](https://github.com/nodejs/node/commit/517c3af21a)] - **doc**: fix process links to console.log/error (Sam Roberts) [#11718](https://github.com/nodejs/node/pull/11718) +* [[`108449b6ff`](https://github.com/nodejs/node/commit/108449b6ff)] - **doc**: add Franziska Hinkelmann to the CTC (Rod Vagg) [#11488](https://github.com/nodejs/node/pull/11488) +* [[`9c3cf13cbc`](https://github.com/nodejs/node/commit/9c3cf13cbc)] - **doc**: argument types for https methods (Amelia Clarke) [#11681](https://github.com/nodejs/node/pull/11681) +* [[`103458772a`](https://github.com/nodejs/node/commit/103458772a)] - **module**: fix loading from global folders on Windows (Richard Lau) [#9283](https://github.com/nodejs/node/pull/9283) +* [[`1dff218cd1`](https://github.com/nodejs/node/commit/1dff218cd1)] - **net**: allow missing callback for Socket.connect (Juwan Yoo) [#11762](https://github.com/nodejs/node/pull/11762) +* [[`52f0092f54`](https://github.com/nodejs/node/commit/52f0092f54)] - **s390**: enable march=z196 (Junliang Yan) [#11730](https://github.com/nodejs/node/pull/11730) +* [[`032becdc28`](https://github.com/nodejs/node/commit/032becdc28)] - **src**: add missing #include \ (Steven R. Loomis) [#11754](https://github.com/nodejs/node/issues/11754) +* [[`1da2afcc26`](https://github.com/nodejs/node/commit/1da2afcc26)] - **src**: drop the NODE_ISOLATE_SLOT macro (Anna Henningsen) [#11692](https://github.com/nodejs/node/pull/11692) +* [[`734ddbe77b`](https://github.com/nodejs/node/commit/734ddbe77b)] - **test**: fix flaky test-http-set-timeout-server (Santiago Gimeno) [#11790](https://github.com/nodejs/node/pull/11790) +* [[`aaf8536dbc`](https://github.com/nodejs/node/commit/aaf8536dbc)] - **test**: add test for loading from global folders (Richard Lau) [#9283](https://github.com/nodejs/node/pull/9283) +* [[`c01c7a490a`](https://github.com/nodejs/node/commit/c01c7a490a)] - **test**: add script to create 0-dns-cert.pem (Shigeki Ohtsu) [#11579](https://github.com/nodejs/node/pull/11579) +* [[`4477e15217`](https://github.com/nodejs/node/commit/4477e15217)] - **test**: add regex in test_cyclic_link_protection (Clarence Dimitri CHARLES) [#11622](https://github.com/nodejs/node/pull/11622) +* [[`3d55cf06b1`](https://github.com/nodejs/node/commit/3d55cf06b1)] - **test**: add more WHATWG URL origin tests (Brian White) [#11691](https://github.com/nodejs/node/pull/11691) +* [[`a98d963082`](https://github.com/nodejs/node/commit/a98d963082)] - **test**: increase coverage of console (DavidCai) [#11653](https://github.com/nodejs/node/pull/11653) +* [[`1af0fa4b84`](https://github.com/nodejs/node/commit/1af0fa4b84)] - **test**: test buffer behavior when zeroFill undefined (Rich Trott) [#11706](https://github.com/nodejs/node/pull/11706) +* [[`1e52ba3b3d`](https://github.com/nodejs/node/commit/1e52ba3b3d)] - **test**: limit lint rule disabling in message test (Rich Trott) [#11724](https://github.com/nodejs/node/pull/11724) +* [[`5e7baa5a72`](https://github.com/nodejs/node/commit/5e7baa5a72)] - **tools**: add links to the stability index reference (Michael Cox) [#11664](https://github.com/nodejs/node/pull/11664) +* [[`c5874d1bd4`](https://github.com/nodejs/node/commit/c5874d1bd4)] - **url**: remove invalid file protocol check (Brian White) [#11691](https://github.com/nodejs/node/pull/11691) + ## 2017-03-08, Version 7.7.2 (Current), @evanlucas From 22819446123efb68313f2ae385e57d1e780f6b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Kraj=C4=8Dovi=C4=8D?= Date: Sun, 12 Mar 2017 16:09:32 +0100 Subject: [PATCH 14/23] test: add regex to assert.throws Make sure test matches this specific error message. PR-URL: https://github.com/nodejs/node/pull/11815 Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Yuta Hiroto Reviewed-By: James M Snell --- test/parallel/test-vm-run-in-new-context.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-vm-run-in-new-context.js b/test/parallel/test-vm-run-in-new-context.js index 04bc3bf4a1e..0da73ea6a90 100644 --- a/test/parallel/test-vm-run-in-new-context.js +++ b/test/parallel/test-vm-run-in-new-context.js @@ -38,7 +38,7 @@ assert.strictEqual('passed', result); console.error('thrown error'); assert.throws(function() { vm.runInNewContext('throw new Error(\'test\');'); -}); +}, /^Error: test$/); global.hello = 5; vm.runInNewContext('hello = 2'); From e494e427c93a55d8f716e9d771324bc5837c79a8 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sun, 12 Mar 2017 13:11:13 +0200 Subject: [PATCH 15/23] doc: var -> let / const in events.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/11810 Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Gibson Fahnestock Reviewed-By: James M Snell --- doc/api/events.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/api/events.md b/doc/api/events.md index 5f12cfe3191..0cc9a0206b5 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -98,7 +98,7 @@ listener will be invoked _every time_ the named event is emitted. ```js const myEmitter = new MyEmitter(); -var m = 0; +let m = 0; myEmitter.on('event', () => { console.log(++m); }); @@ -114,7 +114,7 @@ the listener is unregistered and *then* called. ```js const myEmitter = new MyEmitter(); -var m = 0; +let m = 0; myEmitter.once('event', () => { console.log(++m); }); @@ -502,7 +502,7 @@ Removes the specified `listener` from the listener array for the event named `eventName`. ```js -var callback = (stream) => { +const callback = (stream) => { console.log('someone connected!'); }; server.on('connection', callback); @@ -524,12 +524,12 @@ events will behave as expected. ```js const myEmitter = new MyEmitter(); -var callbackA = () => { +const callbackA = () => { console.log('A'); myEmitter.removeListener('event', callbackB); }; -var callbackB = () => { +const callbackB = () => { console.log('B'); }; From 4d52d12fd1254cc2c9edd8ebfbc2fce5571d9be7 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sun, 12 Mar 2017 13:14:00 +0200 Subject: [PATCH 16/23] doc: console.log() -> console.error() in events.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/11810 Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Gibson Fahnestock Reviewed-By: James M Snell --- doc/api/events.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/events.md b/doc/api/events.md index 0cc9a0206b5..7c72245ced6 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -148,7 +148,7 @@ can be used. (_Note, however, that the `domain` module has been deprecated_) const myEmitter = new MyEmitter(); process.on('uncaughtException', (err) => { - console.log('whoops! there was an error'); + console.error('whoops! there was an error'); }); myEmitter.emit('error', new Error('whoops!')); @@ -160,7 +160,7 @@ As a best practice, listeners should always be added for the `'error'` events. ```js const myEmitter = new MyEmitter(); myEmitter.on('error', (err) => { - console.log('whoops! there was an error'); + console.error('whoops! there was an error'); }); myEmitter.emit('error', new Error('whoops!')); // Prints: whoops! there was an error From 8b03221b281042d84e4b946c157eb168a49f7a87 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 11 Mar 2017 23:26:50 +0300 Subject: [PATCH 17/23] doc: correct comment error in stream.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix comment about remove listener (not setting) PR-URL: https://github.com/nodejs/node/pull/11804 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Michaël Zasso Reviewed-By: Brian White --- doc/api/stream.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index c48dfe05080..75cba6fd514 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1016,7 +1016,7 @@ function parseHeader(stream, callback) { const remaining = split.join('\n\n'); const buf = Buffer.from(remaining, 'utf8'); stream.removeListener('error', callback); - // set the readable listener before unshifting + // remove the readable listener before unshifting stream.removeListener('readable', onReadable); if (buf.length) stream.unshift(buf); From 38ba0c25d474b76b2132abd8a83c0e6248cf720d Mon Sep 17 00:00:00 2001 From: Amelia Clarke Date: Sat, 11 Mar 2017 00:15:20 -0800 Subject: [PATCH 18/23] doc: missing argument types for events methods Refs: https://github.com/nodejs/node/issues/9399 PR-URL: https://github.com/nodejs/node/pull/11802 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Brian White --- doc/api/events.md | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/doc/api/events.md b/doc/api/events.md index 7c72245ced6..5c0614b68bf 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -185,7 +185,7 @@ added and `'removeListener'` when existing listeners are removed. added: v0.1.26 --> -* `eventName` {string|symbol} The name of the event being listened for +* `eventName` {any} The name of the event being listened for * `listener` {Function} The event handler function The `EventEmitter` instance will emit its own `'newListener'` event *before* @@ -229,7 +229,7 @@ changes: now yields the original listener function. --> -* `eventName` {string|symbol} The event name +* `eventName` {any} The event name * `listener` {Function} The event handler function The `'removeListener'` event is emitted *after* the `listener` is removed. @@ -296,6 +296,8 @@ Its `name` property is set to `'MaxListenersExceededWarning'`. +- `eventName` {any} +- `listener` {Function} Alias for `emitter.on(eventName, listener)`. @@ -303,6 +305,8 @@ Alias for `emitter.on(eventName, listener)`. +- `eventName` {any} +- `...args` {any} Synchronously calls each of the listeners registered for the event named `eventName`, in the order they were registered, passing the supplied arguments @@ -345,7 +349,7 @@ set by [`emitter.setMaxListeners(n)`][] or defaults to added: v3.2.0 --> -* `eventName` {string|symbol} The name of the event being listened for +* `eventName` {any} The name of the event being listened for Returns the number of listeners listening to the event named `eventName`. @@ -358,6 +362,7 @@ changes: description: For listeners attached using `.once()` this returns the original listeners instead of wrapper functions now. --> +- `eventName` {any} Returns a copy of the array of listeners for the event named `eventName`. @@ -374,7 +379,7 @@ console.log(util.inspect(server.listeners('connection'))); added: v0.1.101 --> -* `eventName` {string|symbol} The name of the event. +* `eventName` {any} The name of the event. * `listener` {Function} The callback function Adds the `listener` function to the end of the listeners array for the @@ -410,7 +415,7 @@ myEE.emit('foo'); added: v0.3.0 --> -* `eventName` {string|symbol} The name of the event. +* `eventName` {any} The name of the event. * `listener` {Function} The callback function Adds a **one time** `listener` function for the event named `eventName`. The @@ -443,7 +448,7 @@ myEE.emit('foo'); added: v6.0.0 --> -* `eventName` {string|symbol} The name of the event. +* `eventName` {any} The name of the event. * `listener` {Function} The callback function Adds the `listener` function to the *beginning* of the listeners array for the @@ -465,7 +470,7 @@ Returns a reference to the `EventEmitter`, so that calls can be chained. added: v6.0.0 --> -* `eventName` {string|symbol} The name of the event. +* `eventName` {any} The name of the event. * `listener` {Function} The callback function Adds a **one time** `listener` function for the event named `eventName` to the @@ -484,6 +489,7 @@ Returns a reference to the `EventEmitter`, so that calls can be chained. +- `eventName` {any} Removes all listeners, or those of the specified `eventName`. @@ -497,6 +503,8 @@ Returns a reference to the `EventEmitter`, so that calls can be chained. +- `eventName` {any} +- `listener` {Function} Removes the specified `listener` from the listener array for the event named `eventName`. @@ -564,6 +572,7 @@ Returns a reference to the `EventEmitter`, so that calls can be chained. +- `n` {integer} By default EventEmitters will print a warning if more than `10` listeners are added for a particular event. This is a useful default that helps finding From 73e2d0bce61410a86ab7dacf180562fcea92f69c Mon Sep 17 00:00:00 2001 From: Amelia Clarke Date: Fri, 10 Mar 2017 22:30:48 -0800 Subject: [PATCH 19/23] doc: argument types for crypto methods Refs: https://github.com/nodejs/node/issues/9399 PR-URL: https://github.com/nodejs/node/pull/11799 Reviewed-By: James M Snell Reviewed-By: Joyee Cheung --- doc/api/crypto.md | 219 +++++++++++++++++++++++++++++++--------------- 1 file changed, 147 insertions(+), 72 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index e901edf5fd3..9557273a9b7 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -62,11 +62,9 @@ const cert2 = crypto.Certificate(); - -The `spkac` data structure includes a public key and a challenge. The -`certificate.exportChallenge()` returns the challenge component in the -form of a Node.js [`Buffer`][]. The `spkac` argument can be either a string -or a [`Buffer`][]. +- `spkac` {string | Buffer} +- Returns {Buffer} The challenge component of the `spkac` data structure, which +includes a public key and a challenge. ```js const cert = require('crypto').Certificate(); @@ -80,11 +78,9 @@ console.log(challenge.toString('utf8')); - -The `spkac` data structure includes a public key and a challenge. The -`certificate.exportPublicKey()` returns the public key component in the -form of a Node.js [`Buffer`][]. The `spkac` argument can be either a string -or a [`Buffer`][]. +- `spkac` {string | Buffer} +- Returns {Buffer} The public key component of the `spkac` data structure, +which includes a public key and a challenge. ```js const cert = require('crypto').Certificate(); @@ -98,9 +94,9 @@ console.log(publicKey); - -Returns `true` if the given `spkac` data structure is valid, `false` otherwise. -The `spkac` argument must be a Node.js [`Buffer`][]. +- `spkac` {Buffer} +- Returns {boolean} `true` if the given `spkac` data structure is valid, `false` +otherwise. ```js const cert = require('crypto').Certificate(); @@ -176,6 +172,7 @@ console.log(encrypted); +- `output_encoding` {string} Returns any remaining enciphered contents. If `output_encoding` parameter is one of `'latin1'`, `'base64'` or `'hex'`, a string is returned. @@ -189,6 +186,8 @@ once will result in an error being thrown. +- `buffer` {Buffer} +- Returns the {Cipher} for method chaining. When using an authenticated encryption mode (only `GCM` is currently supported), the `cipher.setAAD()` method sets the value used for the @@ -196,8 +195,6 @@ _additional authenticated data_ (AAD) input parameter. The `cipher.setAAD()` method must be called before [`cipher.update()`][]. -Returns `this` for method chaining. - ### cipher.getAuthTag() +- `auto_padding` {boolean} Defaults to `true`. +- Returns the {Cipher} for method chaining. When using block encryption algorithms, the `Cipher` class will automatically add padding to the input data to the appropriate block size. To disable the @@ -227,8 +226,6 @@ using `0x0` instead of PKCS padding. The `cipher.setAutoPadding()` method must be called before [`cipher.final()`][]. -Returns `this` for method chaining. - ### cipher.update(data[, input_encoding][, output_encoding]) +- `data` {string | Buffer} +- `input_encoding` {string} +- `output_encoding` {string} Updates the cipher with `data`. If the `input_encoding` argument is given, its value must be one of `'utf8'`, `'ascii'`, or `'latin1'` and the `data` @@ -322,6 +322,7 @@ console.log(decrypted); +- `output_encoding` {string} Returns any remaining deciphered contents. If `output_encoding` parameter is one of `'latin1'`, `'ascii'` or `'utf8'`, a string is returned. @@ -339,6 +340,8 @@ changes: pr-url: https://github.com/nodejs/node/pull/9398 description: This method now returns a reference to `decipher`. --> +- `buffer` {Buffer} +- Returns the {Cipher} for method chaining. When using an authenticated encryption mode (only `GCM` is currently supported), the `decipher.setAAD()` method sets the value used for the @@ -346,8 +349,6 @@ _additional authenticated data_ (AAD) input parameter. The `decipher.setAAD()` method must be called before [`decipher.update()`][]. -Returns `this` for method chaining. - ### decipher.setAuthTag(buffer) +- `buffer` {Buffer} +- Returns the {Cipher} for method chaining. When using an authenticated encryption mode (only `GCM` is currently supported), the `decipher.setAuthTag()` method is used to pass in the @@ -366,12 +369,12 @@ cipher text should be discarded due to failed authentication. The `decipher.setAuthTag()` method must be called before [`decipher.final()`][]. -Returns `this` for method chaining. - -### decipher.setAutoPadding(auto_padding=true) +### decipher.setAutoPadding([auto_padding]) +- `auto_padding` {boolean} Defaults to `true`. +- Returns the {Cipher} for method chaining. When data has been encrypted without standard block padding, calling `decipher.setAutoPadding(false)` will disable automatic padding to prevent @@ -383,8 +386,6 @@ multiple of the ciphers block size. The `decipher.setAutoPadding()` method must be called before [`decipher.final()`][]. -Returns `this` for method chaining. - ### decipher.update(data[, input_encoding][, output_encoding]) +- `data` {string | Buffer} +- `input_encoding` {string} +- `output_encoding` {string} Updates the decipher with `data`. If the `input_encoding` argument is given, its value must be one of `'latin1'`, `'base64'`, or `'hex'` and the `data` @@ -444,6 +448,9 @@ assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex')); +- `other_public_key` {string | Buffer} +- `input_encoding` {string} +- `output_encoding` {string} Computes the shared secret using `other_public_key` as the other party's public key and returns the computed shared secret. The supplied @@ -459,6 +466,7 @@ If `output_encoding` is given a string is returned; otherwise, a +- `encoding` {string} Generates private and public Diffie-Hellman key values, and returns the public key in the specified `encoding`. This key should be @@ -470,6 +478,7 @@ or `'base64'`. If `encoding` is provided a string is returned; otherwise a +- `encoding` {string} Returns the Diffie-Hellman generator in the specified `encoding`, which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a string is @@ -479,6 +488,7 @@ returned; otherwise a [`Buffer`][] is returned. +- `encoding` {string} Returns the Diffie-Hellman prime in the specified `encoding`, which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a string is @@ -488,6 +498,7 @@ returned; otherwise a [`Buffer`][] is returned. +- `encoding` {string} Returns the Diffie-Hellman private key in the specified `encoding`, which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a @@ -497,6 +508,7 @@ string is returned; otherwise a [`Buffer`][] is returned. +- `encoding` {string} Returns the Diffie-Hellman public key in the specified `encoding`, which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a @@ -506,6 +518,8 @@ string is returned; otherwise a [`Buffer`][] is returned. +- `private_key` {string | Buffer} +- `encoding` {string} Sets the Diffie-Hellman private key. If the `encoding` argument is provided and is either `'latin1'`, `'hex'`, or `'base64'`, `private_key` is expected @@ -516,6 +530,8 @@ to be a [`Buffer`][]. +- `public_key` {string | Buffer} +- `encoding` {string} Sets the Diffie-Hellman public key. If the `encoding` argument is provided and is either `'latin1'`, `'hex'` or `'base64'`, `public_key` is expected @@ -577,6 +593,9 @@ changes: pr-url: https://github.com/nodejs/node/pull/5522 description: The default `input_encoding` changed from `binary` to `utf8`. --> +- `other_public_key` {string | Buffer} +- `input_encoding` {string} +- `output_encoding` {string} Computes the shared secret using `other_public_key` as the other party's public key and returns the computed shared secret. The supplied @@ -592,6 +611,8 @@ If `output_encoding` is given a string will be returned; otherwise a +- `encoding` {string} +- `format` {string} Defaults to `uncompressed`. Generates private and public EC Diffie-Hellman key values, and returns the public key in the specified `format` and `encoding`. This key should be @@ -609,15 +630,18 @@ is returned. +- `encoding` {string} Returns the EC Diffie-Hellman private key in the specified `encoding`, which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a string is returned; otherwise a [`Buffer`][] is returned. -### ecdh.getPublicKey([encoding[, format]]) +### ecdh.getPublicKey([encoding][, format]) +- `encoding` {string} +- `format` {string} Defaults to `uncompressed`. Returns the EC Diffie-Hellman public key in the specified `encoding` and `format`. @@ -634,6 +658,8 @@ returned. +- `private_key` {string | Buffer} +- `encoding` {string} Sets the EC Diffie-Hellman private key. The `encoding` can be `'latin1'`, `'hex'` or `'base64'`. If `encoding` is provided, `private_key` is expected @@ -650,6 +676,9 @@ deprecated: v5.2.0 > Stability: 0 - Deprecated +- `public_key` {string | Buffer} +- `encoding` {string} + Sets the EC Diffie-Hellman public key. Key encoding can be `'latin1'`, `'hex'` or `'base64'`. If `encoding` is provided `public_key` is expected to be a string; otherwise a [`Buffer`][] is expected. @@ -747,6 +776,7 @@ console.log(hash.digest('hex')); +- `encoding` {string} Calculates the digest of all of the data passed to be hashed (using the [`hash.update()`][] method). The `encoding` can be `'hex'`, `'latin1'` or @@ -764,6 +794,8 @@ changes: pr-url: https://github.com/nodejs/node/pull/5522 description: The default `input_encoding` changed from `binary` to `utf8`. --> +- `data` {string | Buffer} +- `input_encoding` {string} Updates the hash content with the given `data`, the encoding of which is given in `input_encoding` and can be `'utf8'`, `'ascii'` or @@ -834,6 +866,7 @@ console.log(hmac.digest('hex')); +- `encoding` {string} Calculates the HMAC digest of all of the data passed using [`hmac.update()`][]. The `encoding` can be `'hex'`, `'latin1'` or `'base64'`. If `encoding` is @@ -850,6 +883,8 @@ changes: pr-url: https://github.com/nodejs/node/pull/5522 description: The default `input_encoding` changed from `binary` to `utf8`. --> +- `data` {string | Buffer} +- `input_encoding` {string} Updates the `Hmac` content with the given `data`, the encoding of which is given in `input_encoding` and can be `'utf8'`, `'ascii'` or @@ -929,6 +964,10 @@ console.log(sign.sign(privateKey).toString('hex')); +- `private_key` {string | Object} + - `key` {string} + - `passphrase` {string} +- `output_format` {string} Calculates the signature on all the data passed through using either [`sign.update()`][] or [`sign.write()`][stream-writable-write]. @@ -955,6 +994,8 @@ changes: pr-url: https://github.com/nodejs/node/pull/5522 description: The default `input_encoding` changed from `binary` to `utf8`. --> +- `data` {string | Buffer} +- `input_encoding` {string} Updates the `Sign` content with the given `data`, the encoding of which is given in `input_encoding` and can be `'utf8'`, `'ascii'` or @@ -1017,6 +1058,8 @@ changes: pr-url: https://github.com/nodejs/node/pull/5522 description: The default `input_encoding` changed from `binary` to `utf8`. --> +- `data` {string | Buffer} +- `input_encoding` {string} Updates the `Verify` content with the given `data`, the encoding of which is given in `input_encoding` and can be `'utf8'`, `'ascii'` or @@ -1030,10 +1073,13 @@ This can be called many times with new data as it is streamed. +- `object` {string} +- `signature` {string | Buffer} +- `signature_format` {string} Verifies the provided data using the given `object` and `signature`. The `object` argument is a string containing a PEM encoded object, which can be -one an RSA public key, a DSA public key, or an X.509 certificate. +an RSA public key, a DSA public key, or an X.509 certificate. The `signature` argument is the previously calculated signature for the data, in the `signature_format` which can be `'latin1'`, `'hex'` or `'base64'`. If a `signature_format` is specified, the `signature` is expected to be a @@ -1084,6 +1130,8 @@ currently in use. Setting to true requires a FIPS build of Node.js. +- `algorithm` {string} +- `password` {string | Buffer} Creates and returns a `Cipher` object that uses the given `algorithm` and `password`. @@ -1108,6 +1156,9 @@ their own using [`crypto.pbkdf2()`][] and to use [`crypto.createCipheriv()`][] to create the `Cipher` object. ### crypto.createCipheriv(algorithm, key, iv) +- `algorithm` {string} +- `key` {string | Buffer} +- `iv` {string | Buffer} Creates and returns a `Cipher` object, with the given `algorithm`, `key` and initialization vector (`iv`). @@ -1142,6 +1193,8 @@ called. +- `algorithm` {string} +- `password` {string | Buffer} Creates and returns a `Decipher` object that uses the given `algorithm` and `password` (key). @@ -1162,6 +1215,9 @@ to create the `Decipher` object. +- `algorithm` {string} +- `key` {string | Buffer} +- `iv` {string | Buffer} Creates and returns a `Decipher` object that uses the given `algorithm`, `key` and initialization vector (`iv`). @@ -1183,6 +1239,10 @@ changes: description: The default for the encoding parameters changed from `binary` to `utf8`. --> +- `prime` {string | Buffer} +- `prime_encoding` {string} +- `generator` {number | string | Buffer} Defaults to `2`. +- `generator_encoding` {string} Creates a `DiffieHellman` key exchange object using the supplied `prime` and an optional specific `generator`. @@ -1203,6 +1263,8 @@ otherwise either a number or [`Buffer`][] is expected. +- `prime_length` {number} +- `generator` {number | string | Buffer} Defaults to `2`. Creates a `DiffieHellman` key exchange object and generates a prime of `prime_length` bits using an optional specific numeric `generator`. @@ -1212,6 +1274,7 @@ If `generator` is not specified, the value `2` is used. +- `curve_name` {string} Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a predefined curve specified by the `curve_name` string. Use @@ -1223,6 +1286,7 @@ and description of each available elliptic curve. +- `algorithm` {string} Creates and returns a `Hash` object that can be used to generate hash digests using the given `algorithm`. @@ -1256,6 +1320,8 @@ input.on('readable', () => { +- `algorithm` {string} +- `key` {string | Buffer} Creates and returns an `Hmac` object that uses the given `algorithm` and `key`. @@ -1290,6 +1356,7 @@ input.on('readable', () => { +- `algorithm` {string} Creates and returns a `Sign` object that uses the given `algorithm`. Use [`crypto.getHashes()`][] to obtain an array of names of the available @@ -1299,6 +1366,7 @@ signing algorithms. +- `algorithm` {string} Creates and returns a `Verify` object that uses the given algorithm. Use [`crypto.getHashes()`][] to obtain an array of names of the available @@ -1336,6 +1404,7 @@ console.log(curves); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...] +- `group_name` {string} Creates a predefined `DiffieHellman` key exchange object. The supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in @@ -1396,6 +1465,14 @@ changes: description: The default encoding for `password` if it is a string changed from `binary` to `utf8`. --> +- `password` {string} +- `salt` {string} +- `iterations` {number} +- `keylen` {number} +- `digest` {string} +- `callback` {Function} + - `err` {Error} + - `derivedKey` {Buffer} Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2) implementation. A selected HMAC digest algorithm specified by `digest` is @@ -1418,9 +1495,9 @@ Example: ```js const crypto = require('crypto'); -crypto.pbkdf2('secret', 'salt', 100000, 512, 'sha512', (err, key) => { +crypto.pbkdf2('secret', 'salt', 100000, 512, 'sha512', (err, derivedKey) => { if (err) throw err; - console.log(key.toString('hex')); // '3745e48...aa39b34' + console.log(derivedKey.toString('hex')); // '3745e48...aa39b34' }); ``` @@ -1440,6 +1517,11 @@ changes: description: The default encoding for `password` if it is a string changed from `binary` to `utf8`. --> +- `password` {string} +- `salt` {string} +- `iterations` {number} +- `keylen` {number} +- `digest` {string} Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2) implementation. A selected HMAC digest algorithm specified by `digest` is @@ -1472,95 +1554,84 @@ An array of supported digest functions can be retrieved using +- `private_key` {Object | string} + - `key` {string} A PEM encoded private key. + - `passphrase` {string} An optional passphrase for the private key. + - `padding` {crypto.constants} An optional padding value defined in + `crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`, + `RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`. +- `buffer` {Buffer} Decrypts `buffer` with `private_key`. `private_key` can be an object or a string. If `private_key` is a string, it is treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`. -If `private_key` is an object, it is interpreted as a hash object with the -keys: - -* `key`: {string} - PEM encoded private key -* `passphrase`: {string} - Optional passphrase for the private key -* `padding` : An optional padding value, one of the following: - * `crypto.constants.RSA_NO_PADDING` - * `crypto.constants.RSA_PKCS1_PADDING` - * `crypto.constants.RSA_PKCS1_OAEP_PADDING` - -All paddings are defined in `crypto.constants`. ### crypto.privateEncrypt(private_key, buffer) +- `private_key` {Object | string} + - `key` {string} A PEM encoded private key. + - `passphrase` {string} An optional passphrase for the private key. + - `padding` {crypto.constants} An optional padding value defined in + `crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING` or + `RSA_PKCS1_PADDING`. +- `buffer` {Buffer} Encrypts `buffer` with `private_key`. `private_key` can be an object or a string. If `private_key` is a string, it is treated as the key with no passphrase and will use `RSA_PKCS1_PADDING`. -If `private_key` is an object, it is interpreted as a hash object with the -keys: - -* `key`: {string} - PEM encoded private key -* `passphrase`: {string} - Optional passphrase for the private key -* `padding` : An optional padding value, one of the following: - * `crypto.constants.RSA_NO_PADDING` - * `crypto.constants.RSA_PKCS1_PADDING` - -All paddings are defined in `crypto.constants`. ### crypto.publicDecrypt(public_key, buffer) +- `private_key` {Object | string} + - `key` {string} A PEM encoded private key. + - `passphrase` {string} An optional passphrase for the private key. + - `padding` {crypto.constants} An optional padding value defined in + `crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`, + `RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`. +- `buffer` {Buffer} Decrypts `buffer` with `public_key`. `public_key` can be an object or a string. If `public_key` is a string, it is treated as the key with no passphrase and will use `RSA_PKCS1_PADDING`. -If `public_key` is an object, it is interpreted as a hash object with the -keys: - -* `key`: {string} - PEM encoded public key -* `passphrase`: {string} - Optional passphrase for the private key -* `padding` : An optional padding value, one of the following: - * `crypto.constants.RSA_NO_PADDING` - * `crypto.constants.RSA_PKCS1_PADDING` - * `crypto.constants.RSA_PKCS1_OAEP_PADDING` Because RSA public keys can be derived from private keys, a private key may be passed instead of a public key. -All paddings are defined in `crypto.constants`. - ### crypto.publicEncrypt(public_key, buffer) +- `private_key` {Object | string} + - `key` {string} A PEM encoded private key. + - `passphrase` {string} An optional passphrase for the private key. + - `padding` {crypto.constants} An optional padding value defined in + `crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`, + `RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`. +- `buffer` {Buffer} Encrypts `buffer` with `public_key`. `public_key` can be an object or a string. If `public_key` is a string, it is treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`. -If `public_key` is an object, it is interpreted as a hash object with the -keys: - -* `key`: {string} - PEM encoded public key -* `passphrase`: {string} - Optional passphrase for the private key -* `padding` : An optional padding value, one of the following: - * `crypto.constants.RSA_NO_PADDING` - * `crypto.constants.RSA_PKCS1_PADDING` - * `crypto.constants.RSA_PKCS1_OAEP_PADDING` Because RSA public keys can be derived from private keys, a private key may be passed instead of a public key. -All paddings are defined in `crypto.constants`. - ### crypto.randomBytes(size[, callback]) +- `size` {number} +- `callback` {Function} + - `err` {Error} + - `buf` {Buffer} Generates cryptographically strong pseudo-random data. The `size` argument is a number indicating the number of bytes to generate. @@ -1599,6 +1670,8 @@ time is right after boot, when the whole system is still low on entropy. +- `engine` {string} +- `flags` {crypto.constants} Defaults to `crypto.constants.ENGINE_METHOD_ALL`. Load and set the `engine` for some or all OpenSSL functions (selected by flags). @@ -1626,6 +1699,8 @@ is a bit field taking one of or a mix of the following flags (defined in +- `a` {Buffer} +- `b` {Buffer} Returns true if `a` is equal to `b`, without leaking timing information that would allow an attacker to guess one of the values. This is suitable for From 27f4c9407f1b052512e2bbd8262a627ab785fa20 Mon Sep 17 00:00:00 2001 From: Gaara Date: Fri, 10 Mar 2017 10:52:43 +0800 Subject: [PATCH 20/23] doc: fix a typo in api/process.md Fix a mistyped module name in example REPL sessions found in the description of the 'warning' event: it should be `events` instead of `event`. PR-URL: https://github.com/nodejs/node/pull/11780 Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- doc/api/process.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/process.md b/doc/api/process.md index 0ff80980f9c..2e9b655f28c 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -298,7 +298,7 @@ too many listeners have been added to an event ```txt $ node -> event.defaultMaxListeners = 1; +> events.defaultMaxListeners = 1; > process.on('foo', () => {}); > process.on('foo', () => {}); > (node:38638) Warning: Possible EventEmitter memory leak detected. 2 foo @@ -311,7 +311,7 @@ adds a custom handler to the `'warning'` event: ```txt $ node --no-warnings > var p = process.on('warning', (warning) => console.warn('Do not do that!')); -> event.defaultMaxListeners = 1; +> events.defaultMaxListeners = 1; > process.on('foo', () => {}); > process.on('foo', () => {}); > Do not do that! From 205f4e500654d38e12df38b0d45925a5850046bb Mon Sep 17 00:00:00 2001 From: Alexey Orlenko Date: Wed, 8 Mar 2017 02:37:35 +0200 Subject: [PATCH 21/23] test: fix repl-function-redefinition-edge-case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `test/known_issues/test-repl-function-redefinition-edge-case.js` had been introduced as a part of https://github.com/nodejs/node/pull/7624 but the meat of the test became fixed in 007386ee81ceeffd65c2248869717b0717db3e46. Despite that, the test continued to fail since it was broken itself: there was a missing colon in the expected output. This commit adds the missing colon and moves the test from `test/known_issues` to `test/parallel`. PR-URL: https://github.com/nodejs/node/pull/11772 Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso Reviewed-By: James M Snell Reviewed-By: Michael Dawson Reviewed-By: Colin Ihrig --- .../test-repl-function-definition-edge-case.js} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename test/{known_issues/test-repl-function-redefinition-edge-case.js => parallel/test-repl-function-definition-edge-case.js} (95%) diff --git a/test/known_issues/test-repl-function-redefinition-edge-case.js b/test/parallel/test-repl-function-definition-edge-case.js similarity index 95% rename from test/known_issues/test-repl-function-redefinition-edge-case.js rename to test/parallel/test-repl-function-definition-edge-case.js index 03b721fba7e..1e3063e3db5 100644 --- a/test/known_issues/test-repl-function-redefinition-edge-case.js +++ b/test/parallel/test-repl-function-definition-edge-case.js @@ -13,7 +13,7 @@ r.input.emit('data', 'function a() { return 42; } (1)\n'); r.input.emit('data', 'a\n'); r.input.emit('data', '.exit'); -const expected = '1\n[Function a]\n'; +const expected = '1\n[Function: a]\n'; const got = r.output.accumulator.join(''); assert.strictEqual(got, expected); From 1faf136bfdfcf74fefcb507ff25db7b3fcb17ca7 Mon Sep 17 00:00:00 2001 From: Amelia Clarke Date: Wed, 8 Mar 2017 21:33:31 -0800 Subject: [PATCH 22/23] doc: argument types for dns methods Refs: https://github.com/nodejs/node/issues/9399 PR-URL: https://github.com/nodejs/node/pull/11764 Reviewed-By: Anna Henningsen Reviewed-By: Timothy Gu Reviewed-By: James M Snell Reviewed-By: Michael Dawson Reviewed-By: Colin Ihrig --- doc/api/dns.md | 139 +++++++++++++++++++++++++++++++------------------ 1 file changed, 89 insertions(+), 50 deletions(-) diff --git a/doc/api/dns.md b/doc/api/dns.md index 7f075be3114..45d494eab3b 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -70,33 +70,25 @@ changes: pr-url: https://github.com/nodejs/node/pull/744 description: The `all` option is supported now. --> +- `hostname` {string} +- `options` {integer | Object} + - `family` {integer} The record family. Must be `4` or `6`. IPv4 + and IPv6 addresses are both returned by default. + - `hints` {number} One or more [supported `getaddrinfo` flags][]. Multiple + flags may be passed by bitwise `OR`ing their values. + - `all` {boolean} When `true`, the callback returns all resolved addresses in + an array. Otherwise, returns a single address. Defaults to `false`. +- `callback` {Function} + - `err` {Error} + - `address` {string} A string representation of an IPv4 or IPv6 address. + - `family` {integer} `4` or `6`, denoting the family of `address`. Resolves a hostname (e.g. `'nodejs.org'`) into the first found A (IPv4) or -AAAA (IPv6) record. `options` can be an object or integer. If `options` is -not provided, then IPv4 and IPv6 addresses are both valid. If `options` is -an integer, then it must be `4` or `6`. - -Alternatively, `options` can be an object containing these properties: - -* `family` {number} - The record family. If present, must be the integer - `4` or `6`. If not provided, both IP v4 and v6 addresses are accepted. -* `hints`: {number} - If present, it should be one or more of the supported - `getaddrinfo` flags. If `hints` is not provided, then no flags are passed to - `getaddrinfo`. Multiple flags can be passed through `hints` by bitwise - `OR`ing their values. - See [supported `getaddrinfo` flags][] for more information on supported - flags. -* `all`: {boolean} - When `true`, the callback returns all resolved addresses - in an array, otherwise returns a single address. Defaults to `false`. - -All properties are optional. - -The `callback` function has arguments `(err, address, family)`. `address` is a -string representation of an IPv4 or IPv6 address. `family` is either the -integer `4` or `6` and denotes the family of `address` (not necessarily the -value initially passed to `lookup`). - -With the `all` option set to `true`, the arguments change to +AAAA (IPv6) record. All `option` properties are optional. If `options` is an +integer, then it must be `4` or `6` – if `options` is not provided, then IPv4 +and IPv6 addresses are both returned if found. + +With the `all` option set to `true`, the arguments for `callback` change to `(err, addresses)`, with `addresses` being an array of objects with the properties `address` and `family`. @@ -147,6 +139,12 @@ on some operating systems (e.g FreeBSD 10.1). +- `address` {string} +- `port` {number} +- `callback` {Function} + - `err` {Error} + - `hostname` {string} e.g. `example.com` + - `service` {string} e.g. `http` Resolves the given `address` and `port` into a hostname and service using the operating system's underlying `getnameinfo` implementation. @@ -155,10 +153,7 @@ If `address` is not a valid IP address, a `TypeError` will be thrown. The `port` will be coerced to a number. If it is not a legal port, a `TypeError` will be thrown. -The callback has arguments `(err, hostname, service)`. The `hostname` and -`service` arguments are strings (e.g. `'localhost'` and `'http'` respectively). - -On error, `err` is an [`Error`][] object, where `err.code` is the error code. +On an error, `err` is an [`Error`][] object, where `err.code` is the error code. ```js const dns = require('dns'); @@ -172,6 +167,11 @@ dns.lookupService('127.0.0.1', 22, (err, hostname, service) => { +- `hostname` {string} +- `rrtype` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {string[] | Object[] | string[][] | Object} Uses the DNS protocol to resolve a hostname (e.g. `'nodejs.org'`) into an array of the record types specified by `rrtype`. @@ -208,18 +208,21 @@ changes: description: This method now supports passing `options`, specifically `options.ttl`. --> +- `hostname` {string} Hostname to resolve. +- `options` {Object} + - `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record. + When `true`, the callback receives an array of + `{ address: '1.2.3.4', ttl: 60 }` objects rather than an array of strings, + with the TTL expressed in seconds. +- `callback` {Function} + - `err` {Error} + - `addresses` {string[] | Object[]} Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of IPv4 addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`). -* `hostname` {string} Hostname to resolve. -* `options` {Object} - * `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record. - The callback receives an array of `{ address: '1.2.3.4', ttl: 60 }` objects - rather than an array of strings. The TTL is expressed in seconds. -* `callback` {Function} An `(err, result)` callback function. ## dns.resolve6(hostname[, options], callback) +- `hostname` {string} Hostname to resolve. +- `options` {Object} + - `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record. + When `true`, the callback receives an array of + `{ address: '0:1:2:3:4:5:6:7', ttl: 60 }` objects rather than an array of + strings, with the TTL expressed in seconds. +- `callback` {Function} + - `err` {Error} + - `addresses` {string[] | Object[]} Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of IPv6 addresses. -* `hostname` {string} Hostname to resolve. -* `options` {Object} - * `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record. - The callback receives an array of `{ address: '0:1:2:3:4:5:6:7', ttl: 60 }` - objects rather than an array of strings. The TTL is expressed in seconds. -* `callback` {Function} An `(err, result)` callback function. ## dns.resolveCname(hostname, callback) +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {string[]} Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The `addresses` argument passed to the `callback` function @@ -256,6 +266,10 @@ will contain an array of canonical name records available for the `hostname` +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {Object[]} Uses the DNS protocol to resolve mail exchange records (`MX` records) for the `hostname`. The `addresses` argument passed to the `callback` function will @@ -266,11 +280,14 @@ property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`). +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {Object[]} Uses the DNS protocol to resolve regular expression based records (`NAPTR` -records) for the `hostname`. The `callback` function has arguments -`(err, addresses)`. The `addresses` argument passed to the `callback` function -will contain an array of objects with the following properties: +records) for the `hostname`. The `addresses` argument passed to the `callback` +function will contain an array of objects with the following properties: * `flags` * `service` @@ -296,16 +313,24 @@ For example: +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {string[]} Uses the DNS protocol to resolve name server records (`NS` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of name server records available for `hostname` (e.g. `['ns1.example.com', 'ns2.example.com']`). -## dns.resolvePtr(hostname, callback) +## dns.resolvePtr(hostname) +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {string[]} Uses the DNS protocol to resolve pointer records (`PTR` records) for the `hostname`. The `addresses` argument passed to the `callback` function will @@ -315,9 +340,13 @@ be an array of strings containing the reply records. +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `address` {Object} Uses the DNS protocol to resolve a start of authority record (`SOA` record) for -the `hostname`. The `addresses` argument passed to the `callback` function will +the `hostname`. The `address` argument passed to the `callback` function will be an object with the following properties: * `nsname` @@ -344,6 +373,10 @@ be an object with the following properties: +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {Object[]} Uses the DNS protocol to resolve service records (`SRV` records) for the `hostname`. The `addresses` argument passed to the `callback` function will @@ -367,6 +400,10 @@ be an array of objects with the following properties: +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {string[][]} Uses the DNS protocol to resolve text queries (`TXT` records) for the `hostname`. The `addresses` argument passed to the `callback` function is @@ -379,13 +416,14 @@ treated separately. +- `ip` {string} +- `callback` {Function} + - `err` {Error} + - `hostnames` {string[]} Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an array of hostnames. -The `callback` function has arguments `(err, hostnames)`, where `hostnames` -is an array of resolved hostnames for the given `ip`. - On error, `err` is an [`Error`][] object, where `err.code` is one of the [DNS error codes][]. @@ -393,11 +431,12 @@ one of the [DNS error codes][]. +- `servers` {string[]} Sets the IP addresses of the servers to be used when resolving. The `servers` argument is an array of IPv4 or IPv6 addresses. -If a port specified on the address it will be removed. +If a port is specified on the address, it will be removed. An error will be thrown if an invalid address is provided. From 7acc482432c7b961a52a4a081a87b05f882cf1dd Mon Sep 17 00:00:00 2001 From: Alexey Orlenko Date: Fri, 10 Mar 2017 05:00:04 +0200 Subject: [PATCH 23/23] test: add arrow functions to test-util-inspect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even though arrow functions and ES5 anonymous functions are technically the same for util.js, it won't hurt to test both. The same goes for async functions. PR-URL: https://github.com/nodejs/node/pull/11781 Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Michaël Zasso Reviewed-By: Daniel Bevenius Reviewed-By: Luigi Pinca Reviewed-By: Michael Dawson Reviewed-By: Colin Ihrig Reviewed-By: Timothy Gu --- test/parallel/test-util-inspect.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index e0a06e97db6..c5af77eccf5 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -30,7 +30,9 @@ assert.strictEqual(util.inspect(false), 'false'); assert.strictEqual(util.inspect(''), "''"); assert.strictEqual(util.inspect('hello'), "'hello'"); assert.strictEqual(util.inspect(function() {}), '[Function]'); +assert.strictEqual(util.inspect(() => {}), '[Function]'); assert.strictEqual(util.inspect(async function() {}), '[AsyncFunction]'); +assert.strictEqual(util.inspect(async () => {}), '[AsyncFunction]'); assert.strictEqual(util.inspect(function*() {}), '[GeneratorFunction]'); assert.strictEqual(util.inspect(undefined), 'undefined'); assert.strictEqual(util.inspect(null), 'null'); @@ -51,8 +53,11 @@ assert.strictEqual(util.inspect([1, [2, 3]]), '[ 1, [ 2, 3 ] ]'); assert.strictEqual(util.inspect({}), '{}'); assert.strictEqual(util.inspect({a: 1}), '{ a: 1 }'); assert.strictEqual(util.inspect({a: function() {}}), '{ a: [Function: a] }'); +assert.strictEqual(util.inspect({a: () => {}}), '{ a: [Function: a] }'); assert.strictEqual(util.inspect({a: async function() {}}), '{ a: [AsyncFunction: a] }'); +assert.strictEqual(util.inspect({a: async () => {}}), + '{ a: [AsyncFunction: a] }'); assert.strictEqual(util.inspect({a: function*() {}}), '{ a: [GeneratorFunction: a] }'); assert.strictEqual(util.inspect({a: 1, b: 2}), '{ a: 1, b: 2 }');