From 4994b7f92377b95880592af988017218007f9f9d Mon Sep 17 00:00:00 2001 From: Peter Marton Date: Thu, 19 Oct 2017 20:16:02 +0200 Subject: [PATCH 01/59] http: add options to http.createServer() This adds the optional options argument to `http.createServer()`. It contains two options: the `IncomingMessage` and `ServerReponse` option. Backport-PR-URL: https://github.com/nodejs/node/pull/20456 PR-URL: https://github.com/nodejs/node/pull/15752 Reviewed-By: Matteo Collina Reviewed-By: Anatoli Papirovski Reviewed-By: James M Snell Reviewed-By: Evan Lucas --- doc/api/http.md | 15 +++++- doc/api/https.md | 4 +- lib/_http_common.js | 10 +++- lib/_http_server.js | 23 +++++++-- lib/https.js | 8 ++- ...st-http-server-options-incoming-message.js | 41 +++++++++++++++ ...est-http-server-options-server-response.js | 35 +++++++++++++ ...t-https-server-options-incoming-message.js | 51 +++++++++++++++++++ ...st-https-server-options-server-response.js | 47 +++++++++++++++++ 9 files changed, 223 insertions(+), 11 deletions(-) create mode 100644 test/parallel/test-http-server-options-incoming-message.js create mode 100644 test/parallel/test-http-server-options-server-response.js create mode 100644 test/parallel/test-https-server-options-incoming-message.js create mode 100644 test/parallel/test-https-server-options-server-response.js diff --git a/doc/api/http.md b/doc/api/http.md index 7331d8bc5d96..284f35c68b44 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -1663,10 +1663,21 @@ A collection of all the standard HTTP response status codes, and the short description of each. For example, `http.STATUS_CODES[404] === 'Not Found'`. -## http.createServer([requestListener]) +## http.createServer([options][, requestListener]) +changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/15752 + description: The `options` argument is supported now. +--> +- `options` {Object} + * `IncomingMessage` {http.IncomingMessage} Specifies the IncomingMessage class + to be used. Useful for extending the original `IncomingMessage`. Defaults + to: `IncomingMessage` + * `ServerResponse` {http.ServerResponse} Specifies the ServerResponse class to + be used. Useful for extending the original `ServerResponse`. Defaults to: + `ServerResponse` - `requestListener` {Function} * Returns: {http.Server} diff --git a/doc/api/https.md b/doc/api/https.md index daf10ac4a2bb..490c3f477f9d 100644 --- a/doc/api/https.md +++ b/doc/api/https.md @@ -65,7 +65,8 @@ See [`http.Server#keepAliveTimeout`][]. -- `options` {Object} Accepts `options` from [`tls.createServer()`][] and [`tls.createSecureContext()`][]. +- `options` {Object} Accepts `options` from [`tls.createServer()`][], + [`tls.createSecureContext()`][] and [`http.createServer()`][]. - `requestListener` {Function} A listener to be added to the `request` event. Example: @@ -255,6 +256,7 @@ const req = https.request(options, (res) => { [`http.Server#setTimeout()`]: http.html#http_server_settimeout_msecs_callback [`http.Server#timeout`]: http.html#http_server_timeout [`http.Server`]: http.html#http_class_http_server +[`http.createServer()`]: http.html#httpcreateserveroptions-requestlistener [`http.close()`]: http.html#http_server_close_callback [`http.get()`]: http.html#http_http_get_options_callback [`http.request()`]: http.html#http_http_request_options_callback diff --git a/lib/_http_common.js b/lib/_http_common.js index 381ffeb807a8..9f8f7f524b84 100644 --- a/lib/_http_common.js +++ b/lib/_http_common.js @@ -34,6 +34,7 @@ const { const debug = require('util').debuglog('http'); +const kIncomingMessage = Symbol('IncomingMessage'); const kOnHeaders = HTTPParser.kOnHeaders | 0; const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; const kOnBody = HTTPParser.kOnBody | 0; @@ -73,7 +74,11 @@ function parserOnHeadersComplete(versionMajor, versionMinor, headers, method, parser._url = ''; } - parser.incoming = new IncomingMessage(parser.socket); + // Parser is also used by http client + var ParserIncomingMessage = parser.socket && parser.socket.server ? + parser.socket.server[kIncomingMessage] : IncomingMessage; + + parser.incoming = new ParserIncomingMessage(parser.socket); parser.incoming.httpVersionMajor = versionMajor; parser.incoming.httpVersionMinor = versionMinor; parser.incoming.httpVersion = `${versionMajor}.${versionMinor}`; @@ -353,5 +358,6 @@ module.exports = { freeParser, httpSocketSetup, methods, - parsers + parsers, + kIncomingMessage }; diff --git a/lib/_http_server.js b/lib/_http_server.js index be591c437ca0..78da88ba1eed 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -33,6 +33,7 @@ const { continueExpression, chunkExpression, httpSocketSetup, + kIncomingMessage, _checkInvalidHeaderChar: checkInvalidHeaderChar } = require('_http_common'); const { OutgoingMessage } = require('_http_outgoing'); @@ -41,6 +42,9 @@ const { defaultTriggerAsyncIdScope, getOrSetAsyncId } = require('internal/async_hooks'); +const { IncomingMessage } = require('_http_incoming'); + +const kServerResponse = Symbol('ServerResponse'); const STATUS_CODES = { 100: 'Continue', @@ -260,9 +264,19 @@ function writeHead(statusCode, reason, obj) { // Docs-only deprecated: DEP0063 ServerResponse.prototype.writeHeader = ServerResponse.prototype.writeHead; +function Server(options, requestListener) { + if (!(this instanceof Server)) return new Server(options, requestListener); + + if (typeof options === 'function') { + requestListener = options; + options = {}; + } else if (options == null || typeof options === 'object') { + options = util._extend({}, options); + } + + this[kIncomingMessage] = options.IncomingMessage || IncomingMessage; + this[kServerResponse] = options.ServerResponse || ServerResponse; -function Server(requestListener) { - if (!(this instanceof Server)) return new Server(requestListener); net.Server.call(this, { allowHalfOpen: true }); if (requestListener) { @@ -578,7 +592,7 @@ function parserOnIncoming(server, socket, state, req, keepAlive) { } } - var res = new ServerResponse(req); + var res = new server[kServerResponse](req); res._onPendingData = updateOutgoingData.bind(undefined, socket, state); res.shouldKeepAlive = keepAlive; @@ -681,5 +695,6 @@ module.exports = { STATUS_CODES, Server, ServerResponse, - _connectionListener: connectionListener + _connectionListener: connectionListener, + kServerResponse }; diff --git a/lib/https.js b/lib/https.js index 6fcd9f65ce78..a2aea08ac9cb 100644 --- a/lib/https.js +++ b/lib/https.js @@ -30,6 +30,9 @@ const util = require('util'); const { inherits } = util; const debug = util.debuglog('https'); const { urlToOptions, searchParamsSymbol } = require('internal/url'); +const { IncomingMessage, ServerResponse } = require('http'); +const { kIncomingMessage } = require('_http_common'); +const { kServerResponse } = require('_http_server'); function Server(opts, requestListener) { if (!(this instanceof Server)) return new Server(opts, requestListener); @@ -51,9 +54,10 @@ function Server(opts, requestListener) { opts.ALPNProtocols = ['http/1.1']; } - tls.Server.call(this, opts, http._connectionListener); + this[kIncomingMessage] = opts.IncomingMessage || IncomingMessage; + this[kServerResponse] = opts.ServerResponse || ServerResponse; - this.httpAllowHalfOpen = false; + tls.Server.call(this, opts, http._connectionListener); if (requestListener) { this.addListener('request', requestListener); diff --git a/test/parallel/test-http-server-options-incoming-message.js b/test/parallel/test-http-server-options-incoming-message.js new file mode 100644 index 000000000000..a4bfa1b7646f --- /dev/null +++ b/test/parallel/test-http-server-options-incoming-message.js @@ -0,0 +1,41 @@ +'use strict'; + +/** + * This test covers http.Server({ IncomingMessage }) option: + * With IncomingMessage option the server should use + * the new class for creating req Object instead of the default + * http.IncomingMessage. + */ +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); + +class MyIncomingMessage extends http.IncomingMessage { + getUserAgent() { + return this.headers['user-agent'] || 'unknown'; + } +} + +const server = http.Server({ + IncomingMessage: MyIncomingMessage +}, common.mustCall(function(req, res) { + assert.strictEqual(req.getUserAgent(), 'node-test'); + res.statusCode = 200; + res.end(); +})); +server.listen(); + +server.on('listening', function makeRequest() { + http.get({ + port: this.address().port, + headers: { + 'User-Agent': 'node-test' + } + }, (res) => { + assert.strictEqual(res.statusCode, 200); + res.on('end', () => { + server.close(); + }); + res.resume(); + }); +}); diff --git a/test/parallel/test-http-server-options-server-response.js b/test/parallel/test-http-server-options-server-response.js new file mode 100644 index 000000000000..f5adf39bed6d --- /dev/null +++ b/test/parallel/test-http-server-options-server-response.js @@ -0,0 +1,35 @@ +'use strict'; + +/** + * This test covers http.Server({ ServerResponse }) option: + * With ServerResponse option the server should use + * the new class for creating res Object instead of the default + * http.ServerResponse. + */ +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); + +class MyServerResponse extends http.ServerResponse { + status(code) { + return this.writeHead(code, { 'Content-Type': 'text/plain' }); + } +} + +const server = http.Server({ + ServerResponse: MyServerResponse +}, common.mustCall(function(req, res) { + res.status(200); + res.end(); +})); +server.listen(); + +server.on('listening', function makeRequest() { + http.get({ port: this.address().port }, (res) => { + assert.strictEqual(res.statusCode, 200); + res.on('end', () => { + server.close(); + }); + res.resume(); + }); +}); diff --git a/test/parallel/test-https-server-options-incoming-message.js b/test/parallel/test-https-server-options-incoming-message.js new file mode 100644 index 000000000000..102ee56751b8 --- /dev/null +++ b/test/parallel/test-https-server-options-incoming-message.js @@ -0,0 +1,51 @@ +'use strict'; + +/** + * This test covers http.Server({ IncomingMessage }) option: + * With IncomingMessage option the server should use + * the new class for creating req Object instead of the default + * http.IncomingMessage. + */ +const common = require('../common'); +const fixtures = require('../common/fixtures'); + +if (!common.hasCrypto) + common.skip('missing crypto'); + +const assert = require('assert'); +const http = require('http'); +const https = require('https'); + +class MyIncomingMessage extends http.IncomingMessage { + getUserAgent() { + return this.headers['user-agent'] || 'unknown'; + } +} + +const server = https.createServer({ + key: fixtures.readKey('agent1-key.pem'), + cert: fixtures.readKey('agent1-cert.pem'), + ca: fixtures.readKey('ca1-cert.pem'), + IncomingMessage: MyIncomingMessage +}, common.mustCall(function(req, res) { + assert.strictEqual(req.getUserAgent(), 'node-test'); + res.statusCode = 200; + res.end(); +})); +server.listen(); + +server.on('listening', function makeRequest() { + https.get({ + port: this.address().port, + rejectUnauthorized: false, + headers: { + 'User-Agent': 'node-test' + } + }, (res) => { + assert.strictEqual(res.statusCode, 200); + res.on('end', () => { + server.close(); + }); + res.resume(); + }); +}); diff --git a/test/parallel/test-https-server-options-server-response.js b/test/parallel/test-https-server-options-server-response.js new file mode 100644 index 000000000000..8745415f8b65 --- /dev/null +++ b/test/parallel/test-https-server-options-server-response.js @@ -0,0 +1,47 @@ +'use strict'; + +/** + * This test covers http.Server({ ServerResponse }) option: + * With ServerResponse option the server should use + * the new class for creating res Object instead of the default + * http.ServerResponse. + */ +const common = require('../common'); +const fixtures = require('../common/fixtures'); + +if (!common.hasCrypto) + common.skip('missing crypto'); + +const assert = require('assert'); +const http = require('http'); +const https = require('https'); + +class MyServerResponse extends http.ServerResponse { + status(code) { + return this.writeHead(code, { 'Content-Type': 'text/plain' }); + } +} + +const server = https.createServer({ + key: fixtures.readKey('agent1-key.pem'), + cert: fixtures.readKey('agent1-cert.pem'), + ca: fixtures.readKey('ca1-cert.pem'), + ServerResponse: MyServerResponse +}, common.mustCall(function(req, res) { + res.status(200); + res.end(); +})); +server.listen(); + +server.on('listening', function makeRequest() { + https.get({ + port: this.address().port, + rejectUnauthorized: false + }, (res) => { + assert.strictEqual(res.statusCode, 200); + res.on('end', () => { + server.close(); + }); + res.resume(); + }); +}); From 5bfc1d1fb13494a1ef0e7bdb336181b241a83548 Mon Sep 17 00:00:00 2001 From: Peter Marton Date: Fri, 27 Oct 2017 09:18:59 +0200 Subject: [PATCH 02/59] http2: add http fallback options to .createServer This adds the Http1IncomingMessage and Http1ServerReponse options to http2.createServer(). Backport-PR-URL: https://github.com/nodejs/node/pull/20456 PR-URL: https://github.com/nodejs/node/pull/15752 Reviewed-By: Matteo Collina Reviewed-By: Anatoli Papirovski Reviewed-By: James M Snell Reviewed-By: Evan Lucas --- doc/api/http2.md | 10 +++ lib/internal/http2/core.js | 15 +++- ...ttp2-https-fallback-http-server-options.js | 90 +++++++++++++++++++ 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-http2-https-fallback-http-server-options.js diff --git a/doc/api/http2.md b/doc/api/http2.md index 58f923ab3b33..f3322da4c2e4 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -1698,6 +1698,10 @@ changes: pr-url: https://github.com/nodejs/node/pull/16676 description: Added the `maxHeaderListPairs` option with a default limit of 128 header pairs. + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/15752 + description: Added the `Http1IncomingMessage` and `Http1ServerResponse` + option. --> * `options` {Object} @@ -1747,6 +1751,12 @@ changes: used to determine the padding. See [Using options.selectPadding][]. * `settings` {HTTP/2 Settings Object} The initial settings to send to the remote peer upon connection. + * `Http1IncomingMessage` {http.IncomingMessage} Specifies the IncomingMessage + class to used for HTTP/1 fallback. Useful for extending the original + `http.IncomingMessage`. **Default:** `http.IncomingMessage` + * `Http1ServerResponse` {http.ServerResponse} Specifies the ServerResponse + class to used for HTTP/1 fallback. Useful for extending the original + `http.ServerResponse`. **Default:** `http.ServerResponse` * `onRequestHandler` {Function} See [Compatibility API][] * Returns: {Http2Server} diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index cbaf908246bd..361f4eeb6498 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -5,6 +5,7 @@ require('internal/util').assertCrypto(); const { async_id_symbol } = process.binding('async_wrap'); +const http = require('http'); const binding = process.binding('http2'); const assert = require('assert'); const { Buffer } = require('buffer'); @@ -67,6 +68,8 @@ const NETServer = net.Server; const TLSServer = tls.Server; const kInspect = require('internal/util').customInspectSymbol; +const { kIncomingMessage } = require('_http_common'); +const { kServerResponse } = require('_http_server'); const kAlpnProtocol = Symbol('alpnProtocol'); const kAuthority = Symbol('authority'); @@ -2485,8 +2488,11 @@ function connectionListener(socket) { if (socket.alpnProtocol === false || socket.alpnProtocol === 'http/1.1') { // Fallback to HTTP/1.1 - if (options.allowHTTP1 === true) + if (options.allowHTTP1 === true) { + socket.server[kIncomingMessage] = options.Http1IncomingMessage; + socket.server[kServerResponse] = options.Http1ServerResponse; return httpConnectionListener.call(this, socket); + } // Let event handler deal with the socket debug(`Unknown protocol from ${socket.remoteAddress}:${socket.remotePort}`); if (!this.emit('unknownProtocol', socket)) { @@ -2526,6 +2532,13 @@ function initializeOptions(options) { options.allowHalfOpen = true; assertIsObject(options.settings, 'options.settings'); options.settings = Object.assign({}, options.settings); + + // Used only with allowHTTP1 + options.Http1IncomingMessage = options.Http1IncomingMessage || + http.IncomingMessage; + options.Http1ServerResponse = options.Http1ServerResponse || + http.ServerResponse; + return options; } diff --git a/test/parallel/test-http2-https-fallback-http-server-options.js b/test/parallel/test-http2-https-fallback-http-server-options.js new file mode 100644 index 000000000000..20e2b122a24e --- /dev/null +++ b/test/parallel/test-http2-https-fallback-http-server-options.js @@ -0,0 +1,90 @@ +// Flags: --expose-http2 +'use strict'; + +const common = require('../common'); +const fixtures = require('../common/fixtures'); + +if (!common.hasCrypto) + common.skip('missing crypto'); + +const assert = require('assert'); +const url = require('url'); +const tls = require('tls'); +const http2 = require('http2'); +const https = require('https'); +const http = require('http'); + +const key = fixtures.readKey('agent8-key.pem'); +const cert = fixtures.readKey('agent8-cert.pem'); +const ca = fixtures.readKey('fake-startcom-root-cert.pem'); + +function onRequest(request, response) { + const { socket: { alpnProtocol } } = request.httpVersion === '2.0' ? + request.stream.session : request; + response.status(200); + response.end(JSON.stringify({ + alpnProtocol, + httpVersion: request.httpVersion, + userAgent: request.getUserAgent() + })); +} + +class MyIncomingMessage extends http.IncomingMessage { + getUserAgent() { + return this.headers['user-agent'] || 'unknown'; + } +} + +class MyServerResponse extends http.ServerResponse { + status(code) { + return this.writeHead(code, { 'Content-Type': 'application/json' }); + } +} + +// HTTP/2 & HTTP/1.1 server +{ + const server = http2.createSecureServer( + { + cert, + key, allowHTTP1: true, + Http1IncomingMessage: MyIncomingMessage, + Http1ServerResponse: MyServerResponse + }, + common.mustCall(onRequest, 1) + ); + + server.listen(0); + + server.on('listening', common.mustCall(() => { + const { port } = server.address(); + const origin = `https://localhost:${port}`; + + // HTTP/1.1 client + https.get( + Object.assign(url.parse(origin), { + secureContext: tls.createSecureContext({ ca }), + headers: { 'User-Agent': 'node-test' } + }), + common.mustCall((response) => { + assert.strictEqual(response.statusCode, 200); + assert.strictEqual(response.statusMessage, 'OK'); + assert.strictEqual( + response.headers['content-type'], + 'application/json' + ); + + response.setEncoding('utf8'); + let raw = ''; + response.on('data', (chunk) => { raw += chunk; }); + response.on('end', common.mustCall(() => { + const { alpnProtocol, httpVersion, userAgent } = JSON.parse(raw); + assert.strictEqual(alpnProtocol, false); + assert.strictEqual(httpVersion, '1.1'); + assert.strictEqual(userAgent, 'node-test'); + + server.close(); + })); + }) + ); + })); +} From 852b99672515bc23d522c560bdcc9cdc72535620 Mon Sep 17 00:00:00 2001 From: Peter Marton Date: Thu, 5 Oct 2017 14:24:12 +0200 Subject: [PATCH 03/59] http2: add req and res options to server creation Add optional Http2ServerRequest and Http2ServerResponse options to createServer and createSecureServer. Allows custom req & res classes that extend the default ones to be used without overriding the prototype. Backport-PR-URL: https://github.com/nodejs/node/pull/20456 PR-URL: https://github.com/nodejs/node/pull/15560 Reviewed-By: James M Snell Reviewed-By: Matteo Collina Reviewed-By: Anatoli Papirovski Reviewed-By: Anna Henningsen --- doc/api/http2.md | 8 ++++ lib/internal/http2/compat.js | 8 ++-- lib/internal/http2/core.js | 10 ++++- .../test-http2-options-server-request.js | 40 +++++++++++++++++++ .../test-http2-options-server-response.js | 34 ++++++++++++++++ 5 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 test/parallel/test-http2-options-server-request.js create mode 100644 test/parallel/test-http2-options-server-response.js diff --git a/doc/api/http2.md b/doc/api/http2.md index f3322da4c2e4..040b98187457 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -1757,6 +1757,14 @@ changes: * `Http1ServerResponse` {http.ServerResponse} Specifies the ServerResponse class to used for HTTP/1 fallback. Useful for extending the original `http.ServerResponse`. **Default:** `http.ServerResponse` + * `Http2ServerRequest` {http2.Http2ServerRequest} Specifies the + Http2ServerRequest class to use. + Useful for extending the original `Http2ServerRequest`. + **Default:** `Http2ServerRequest` + * `Http2ServerResponse` {htt2.Http2ServerResponse} Specifies the + Http2ServerResponse class to use. + Useful for extending the original `Http2ServerResponse`. + **Default:** `Http2ServerResponse` * `onRequestHandler` {Function} See [Compatibility API][] * Returns: {Http2Server} diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index b5dd81c80f40..5e6c51377e94 100644 --- a/lib/internal/http2/compat.js +++ b/lib/internal/http2/compat.js @@ -661,11 +661,11 @@ class Http2ServerResponse extends Stream { } } -function onServerStream(stream, headers, flags, rawHeaders) { +function onServerStream(ServerRequest, ServerResponse, + stream, headers, flags, rawHeaders) { const server = this; - const request = new Http2ServerRequest(stream, headers, undefined, - rawHeaders); - const response = new Http2ServerResponse(stream); + const request = new ServerRequest(stream, headers, undefined, rawHeaders); + const response = new ServerResponse(stream); // Check for the CONNECT method const method = headers[HTTP2_HEADER_METHOD]; diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 361f4eeb6498..68bfbb043b0b 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -2539,6 +2539,10 @@ function initializeOptions(options) { options.Http1ServerResponse = options.Http1ServerResponse || http.ServerResponse; + options.Http2ServerRequest = options.Http2ServerRequest || + Http2ServerRequest; + options.Http2ServerResponse = options.Http2ServerResponse || + Http2ServerResponse; return options; } @@ -2604,7 +2608,11 @@ class Http2Server extends NETServer { function setupCompat(ev) { if (ev === 'request') { this.removeListener('newListener', setupCompat); - this.on('stream', onServerStream); + this.on('stream', onServerStream.bind( + this, + this[kOptions].Http2ServerRequest, + this[kOptions].Http2ServerResponse) + ); } } diff --git a/test/parallel/test-http2-options-server-request.js b/test/parallel/test-http2-options-server-request.js new file mode 100644 index 000000000000..2143d379823d --- /dev/null +++ b/test/parallel/test-http2-options-server-request.js @@ -0,0 +1,40 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); +const assert = require('assert'); +const h2 = require('http2'); + +class MyServerRequest extends h2.Http2ServerRequest { + getUserAgent() { + return this.headers['user-agent'] || 'unknown'; + } +} + +const server = h2.createServer({ + Http2ServerRequest: MyServerRequest +}, (req, res) => { + assert.strictEqual(req.getUserAgent(), 'node-test'); + + res.writeHead(200, { 'Content-Type': 'text/plain' }); + res.end(); +}); +server.listen(0); + +server.on('listening', common.mustCall(() => { + + const client = h2.connect(`http://localhost:${server.address().port}`); + const req = client.request({ + ':path': '/', + 'User-Agent': 'node-test' + }); + + req.on('response', common.mustCall()); + + req.resume(); + req.on('end', common.mustCall(() => { + server.close(); + client.destroy(); + })); +})); diff --git a/test/parallel/test-http2-options-server-response.js b/test/parallel/test-http2-options-server-response.js new file mode 100644 index 000000000000..6f1ae1881d22 --- /dev/null +++ b/test/parallel/test-http2-options-server-response.js @@ -0,0 +1,34 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); +const h2 = require('http2'); + +class MyServerResponse extends h2.Http2ServerResponse { + status(code) { + return this.writeHead(code, { 'Content-Type': 'text/plain' }); + } +} + +const server = h2.createServer({ + Http2ServerResponse: MyServerResponse +}, (req, res) => { + res.status(200); + res.end(); +}); +server.listen(0); + +server.on('listening', common.mustCall(() => { + + const client = h2.connect(`http://localhost:${server.address().port}`); + const req = client.request({ ':path': '/' }); + + req.on('response', common.mustCall()); + + req.resume(); + req.on('end', common.mustCall(() => { + server.close(); + client.destroy(); + })); +})); From 0829b54254720ee5a76af4f542f1f321628342ee Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Mon, 19 Feb 2018 23:26:45 +0200 Subject: [PATCH 04/59] doc: fix typo in http2.md Backport-PR-URL: https://github.com/nodejs/node/pull/20456 PR-URL: https://github.com/nodejs/node/pull/18872 Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson --- doc/api/http2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/http2.md b/doc/api/http2.md index 040b98187457..cfa018bce231 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -1761,7 +1761,7 @@ changes: Http2ServerRequest class to use. Useful for extending the original `Http2ServerRequest`. **Default:** `Http2ServerRequest` - * `Http2ServerResponse` {htt2.Http2ServerResponse} Specifies the + * `Http2ServerResponse` {http2.Http2ServerResponse} Specifies the Http2ServerResponse class to use. Useful for extending the original `Http2ServerResponse`. **Default:** `Http2ServerResponse` From f7d96acb6d990b4d68116214e3ab351def63b1d7 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 18 May 2018 09:58:37 +0200 Subject: [PATCH 05/59] http2: pass session to DEBUG_HTTP2SESSION2 When configure with --debug-http2 --debug-nghttp2 the following compilation error is generated: DEBUG_HTTP2SESSION2(this, "fatal error receiving data: %d", ret); ^ ../src/node_http2.cc:1690:27: error: invalid use of 'this' outside of a non-static member function 1 errors generated. OnStreamReadImpl is static and I think the intention was to pass in the session variable here. PR-URL: https://github.com/nodejs/node/pull/20815 Refs: https://github.com/nodejs/node/issues/20806 Reviewed-By: James M Snell Reviewed-By: Anatoli Papirovski --- src/node_http2.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_http2.cc b/src/node_http2.cc index b31878582301..4aa9fceec18c 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -1687,7 +1687,7 @@ void Http2Session::OnStreamReadImpl(ssize_t nread, // ssize_t to int. Cast here so that the < 0 check actually works on // Windows. if (static_cast(ret) < 0) { - DEBUG_HTTP2SESSION2(this, "fatal error receiving data: %d", ret); + DEBUG_HTTP2SESSION2(session, "fatal error receiving data: %d", ret); Local argv[1] = { Integer::New(isolate, ret), From 83cd22e521acbaa32c8caab1f0878972c607bb56 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Fri, 10 Nov 2017 17:31:46 -0500 Subject: [PATCH 06/59] tools: speed up lint-md-build by using package-lock.json PR-URL: https://github.com/nodejs/node/pull/16945 Fixes: https://github.com/nodejs/node/issues/16628 Reviewed-By: Gibson Fahnestock Reviewed-By: Daijiro Wachi Reviewed-By: Joyee Cheung Reviewed-By: Gireesh Punathil Reviewed-By: Colin Ihrig Reviewed-By: Khaidi Chu Reviewed-By: James M Snell --- .gitignore | 4 +- tools/remark-cli/package-lock.json | 1145 +++++++++++++++++ .../remark-preset-lint-node/package-lock.json | 448 +++++++ 3 files changed, 1595 insertions(+), 2 deletions(-) create mode 100644 tools/remark-cli/package-lock.json create mode 100644 tools/remark-preset-lint-node/package-lock.json diff --git a/.gitignore b/.gitignore index 190333f4b8f3..40838bcc7fa8 100644 --- a/.gitignore +++ b/.gitignore @@ -106,8 +106,8 @@ deps/npm/node_modules/.bin/ # test artifacts tools/faketime -tools/remark-cli -tools/remark-preset-lint-node +tools/remark-cli/node_modules +tools/remark-preset-lint-node/node_modules icu_config.gypi *.tap diff --git a/tools/remark-cli/package-lock.json b/tools/remark-cli/package-lock.json new file mode 100644 index 000000000000..527bdf364fdf --- /dev/null +++ b/tools/remark-cli/package-lock.json @@ -0,0 +1,1145 @@ +{ + "name": "remark-cli", + "version": "3.0.1", + "lockfileVersion": 1, + "preserveSymlinks": "1", + "requires": true, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" + }, + "anymatch": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz", + "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", + "requires": { + "micromatch": "2.3.11", + "normalize-path": "2.1.1" + } + }, + "argparse": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", + "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=", + "requires": { + "sprintf-js": "1.0.3" + } + }, + "arr-diff": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", + "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", + "requires": { + "arr-flatten": "1.1.0" + } + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==" + }, + "array-iterate": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-iterate/-/array-iterate-1.1.1.tgz", + "integrity": "sha1-hlv3+K851rCYLGCQKRSsdrwBCPY=" + }, + "array-unique": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", + "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=" + }, + "async-each": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", + "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=" + }, + "bail": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bail/-/bail-1.0.2.tgz", + "integrity": "sha1-99bBcxYwqfnw1NNe0fli4gdKF2Q=" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "binary-extensions": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.10.0.tgz", + "integrity": "sha1-muuabF6IY4qtFx4Wf1kAq+JINdA=" + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", + "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", + "requires": { + "expand-range": "1.8.2", + "preserve": "0.2.0", + "repeat-element": "1.1.2" + } + }, + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" + }, + "ccount": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/ccount/-/ccount-1.0.2.tgz", + "integrity": "sha1-U7ai+BW7d7nChx97mnLDol8djok=" + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + } + }, + "character-entities": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-1.2.1.tgz", + "integrity": "sha1-92hxvl72bdt/j440eOzDdMJ9bco=" + }, + "character-entities-html4": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-1.1.1.tgz", + "integrity": "sha1-NZoqSg9+KdPcKsmb2+Ie45Q46lA=" + }, + "character-entities-legacy": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-1.1.1.tgz", + "integrity": "sha1-9Ad53xoQGHK7UQo9KV4fzPFHIC8=" + }, + "character-reference-invalid": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.1.tgz", + "integrity": "sha1-lCg191Dk7GGjCOYMLvjMEBEgLvw=" + }, + "chokidar": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", + "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", + "requires": { + "anymatch": "1.3.2", + "async-each": "1.0.1", + "glob-parent": "2.0.0", + "inherits": "2.0.3", + "is-binary-path": "1.0.1", + "is-glob": "2.0.1", + "path-is-absolute": "1.0.1", + "readdirp": "2.1.0" + } + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "collapse-white-space": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-1.0.3.tgz", + "integrity": "sha1-S5BvZw5aljqHt2sOFolkM0G2Ajw=" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "concat-stream": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", + "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", + "requires": { + "inherits": "2.0.3", + "readable-stream": "2.3.3", + "typedarray": "0.0.6" + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", + "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=" + }, + "error-ex": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", + "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", + "requires": { + "is-arrayish": "0.2.1" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==" + }, + "expand-brackets": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", + "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", + "requires": { + "is-posix-bracket": "0.1.1" + } + }, + "expand-range": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", + "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", + "requires": { + "fill-range": "2.2.3" + } + }, + "extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", + "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" + }, + "extglob": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", + "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", + "requires": { + "is-extglob": "1.0.0" + } + }, + "fault": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fault/-/fault-1.0.1.tgz", + "integrity": "sha1-3o01Df1IviS13BsChn4IcbkTUJI=", + "requires": { + "format": "0.2.2" + } + }, + "filename-regex": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", + "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=" + }, + "fill-range": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", + "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", + "requires": { + "is-number": "2.1.0", + "isobject": "2.1.0", + "randomatic": "1.1.7", + "repeat-element": "1.1.2", + "repeat-string": "1.6.1" + } + }, + "fn-name": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fn-name/-/fn-name-2.0.1.tgz", + "integrity": "sha1-UhTXU3pNBqSjAcDMJi/rhBiAAuc=" + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=" + }, + "for-own": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", + "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", + "requires": { + "for-in": "1.0.2" + } + }, + "format": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/format/-/format-0.2.2.tgz", + "integrity": "sha1-1hcBB+nv3E7TDJ3DkBbflCtctYs=" + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "glob-base": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", + "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", + "requires": { + "glob-parent": "2.0.0", + "is-glob": "2.0.1" + } + }, + "glob-parent": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", + "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", + "requires": { + "is-glob": "2.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + }, + "has": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", + "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", + "requires": { + "function-bind": "1.1.1" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "requires": { + "ansi-regex": "2.1.1" + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=" + }, + "ignore": { + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ini": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", + "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=" + }, + "is-alphabetical": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.1.tgz", + "integrity": "sha1-x3B5zJHU76x3W+EDS/LSQ/lebwg=" + }, + "is-alphanumeric": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-alphanumeric/-/is-alphanumeric-1.0.0.tgz", + "integrity": "sha1-Spzvcdr0wAHB2B1j0UDPU/1oifQ=" + }, + "is-alphanumerical": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.1.tgz", + "integrity": "sha1-37SqTRCF4zvbYcLe6cgOnGwZ9Ts=", + "requires": { + "is-alphabetical": "1.0.1", + "is-decimal": "1.0.1" + } + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" + }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "requires": { + "binary-extensions": "1.10.0" + } + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, + "is-decimal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-1.0.1.tgz", + "integrity": "sha1-9ftqlJlq2ejjdh+/vQkfH8qMToI=" + }, + "is-dotfile": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", + "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=" + }, + "is-empty": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-empty/-/is-empty-1.2.0.tgz", + "integrity": "sha1-3pu1snhzigWgsJpX4ftNSjQan2s=" + }, + "is-equal-shallow": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", + "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", + "requires": { + "is-primitive": "2.0.0" + } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=" + }, + "is-extglob": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", + "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=" + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-glob": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", + "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", + "requires": { + "is-extglob": "1.0.0" + } + }, + "is-hexadecimal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.1.tgz", + "integrity": "sha1-bghLvJIGH7sJcexYts5tQE4k2mk=" + }, + "is-hidden": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-hidden/-/is-hidden-1.1.1.tgz", + "integrity": "sha512-175UKecS8+U4hh2PSY0j4xnm2GKYzvSKnbh+naC93JjuBA7LgIo6YxlbcsSo6seFBdQO3RuIcH980yvqqD/2cA==" + }, + "is-number": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", + "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", + "requires": { + "kind-of": "3.2.2" + } + }, + "is-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz", + "integrity": "sha1-iVJojF7C/9awPsyF52ngKQMINHA=" + }, + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=" + }, + "is-posix-bracket": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", + "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=" + }, + "is-primitive": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", + "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=" + }, + "is-whitespace-character": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-whitespace-character/-/is-whitespace-character-1.0.1.tgz", + "integrity": "sha1-muAXbzKCtlRXoZks2whPil+DPjs=" + }, + "is-word-character": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-word-character/-/is-word-character-1.0.1.tgz", + "integrity": "sha1-WgP6HqkazopusMfNdw64bWXIvvs=" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "requires": { + "isarray": "1.0.0" + } + }, + "js-yaml": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.10.0.tgz", + "integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==", + "requires": { + "argparse": "1.0.9", + "esprima": "4.0.0" + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.6" + } + }, + "load-plugin": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/load-plugin/-/load-plugin-2.2.1.tgz", + "integrity": "sha512-raqInsJNdPGpzZyb+FjjJYmXsjIm8fIiOjOmqmUTGPyCXDMeEK3p4x4Xm1ZCNp43UmfDTWvo7pZkB2fKbD5AAA==", + "requires": { + "npm-prefix": "1.2.0", + "resolve-from": "2.0.0" + } + }, + "longest-streak": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-2.0.2.tgz", + "integrity": "sha512-TmYTeEYxiAmSVdpbnQDXGtvYOIRsCMg89CVZzwzc2o7GFL1CjoiRPjH5ec0NFAVlAx3fVof9dX/t6KKRAo2OWA==" + }, + "markdown-escapes": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/markdown-escapes/-/markdown-escapes-1.0.1.tgz", + "integrity": "sha1-GZTfLTr0gR3lmmcUk0wrIpJzRRg=" + }, + "markdown-extensions": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/markdown-extensions/-/markdown-extensions-1.1.0.tgz", + "integrity": "sha1-+6Dxouu09BI9JbepO8NXksEfUE4=" + }, + "markdown-table": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-1.1.1.tgz", + "integrity": "sha1-Sz3ToTPRUYuO8NvHCb8qG0gkvIw=" + }, + "mdast-util-compact": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-compact/-/mdast-util-compact-1.0.1.tgz", + "integrity": "sha1-zbX4TitqLTEU3zO9BdnLMuPECDo=", + "requires": { + "unist-util-modify-children": "1.1.1", + "unist-util-visit": "1.1.3" + } + }, + "micromatch": { + "version": "2.3.11", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", + "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", + "requires": { + "arr-diff": "2.0.0", + "array-unique": "0.2.1", + "braces": "1.8.5", + "expand-brackets": "0.1.5", + "extglob": "0.3.2", + "filename-regex": "2.0.1", + "is-extglob": "1.0.0", + "is-glob": "2.0.1", + "kind-of": "3.2.2", + "normalize-path": "2.1.1", + "object.omit": "2.0.1", + "parse-glob": "3.0.4", + "regex-cache": "0.4.4" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "1.1.8" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "requires": { + "remove-trailing-separator": "1.1.0" + } + }, + "npm-prefix": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/npm-prefix/-/npm-prefix-1.2.0.tgz", + "integrity": "sha1-5hlFX3B0ulTMZtbQ033Z8b5ry8A=", + "requires": { + "rc": "1.2.2", + "shellsubstitute": "1.2.0", + "untildify": "2.1.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, + "object.omit": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", + "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", + "requires": { + "for-own": "0.1.5", + "is-extendable": "0.1.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1.0.2" + } + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" + }, + "parse-entities": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-1.1.1.tgz", + "integrity": "sha1-gRLYhHExnyerrk1klksSL+ThuJA=", + "requires": { + "character-entities": "1.2.1", + "character-entities-legacy": "1.1.1", + "character-reference-invalid": "1.1.1", + "is-alphanumerical": "1.0.1", + "is-decimal": "1.0.1", + "is-hexadecimal": "1.0.1" + } + }, + "parse-glob": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", + "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", + "requires": { + "glob-base": "0.3.0", + "is-dotfile": "1.0.3", + "is-extglob": "1.0.0", + "is-glob": "2.0.1" + } + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "requires": { + "error-ex": "1.3.1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "preserve": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", + "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=" + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" + }, + "randomatic": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", + "requires": { + "is-number": "3.0.0", + "kind-of": "4.0.0" + }, + "dependencies": { + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "rc": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.2.tgz", + "integrity": "sha1-2M6ctX6NZNnHut2YdsfDTL48cHc=", + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.4", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + } + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "readdirp": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", + "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", + "requires": { + "graceful-fs": "4.1.11", + "minimatch": "3.0.4", + "readable-stream": "2.3.3", + "set-immediate-shim": "1.0.1" + } + }, + "regex-cache": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", + "requires": { + "is-equal-shallow": "0.1.3" + } + }, + "remark": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/remark/-/remark-7.0.1.tgz", + "integrity": "sha1-pd5NrPq/D2CkmCbvJMR5gH+QS/s=", + "requires": { + "remark-parse": "3.0.1", + "remark-stringify": "3.0.1", + "unified": "6.1.5" + } + }, + "remark-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-3.0.1.tgz", + "integrity": "sha1-G5+EGkTY9PvyJGhQJlRZpOs1TIA=", + "requires": { + "collapse-white-space": "1.0.3", + "has": "1.0.1", + "is-alphabetical": "1.0.1", + "is-decimal": "1.0.1", + "is-whitespace-character": "1.0.1", + "is-word-character": "1.0.1", + "markdown-escapes": "1.0.1", + "parse-entities": "1.1.1", + "repeat-string": "1.6.1", + "state-toggle": "1.0.0", + "trim": "0.0.1", + "trim-trailing-lines": "1.1.0", + "unherit": "1.1.0", + "unist-util-remove-position": "1.1.1", + "vfile-location": "2.0.2", + "xtend": "4.0.1" + } + }, + "remark-stringify": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-3.0.1.tgz", + "integrity": "sha1-eSQr6+CnUggbWAlRb6DAbt7Aac8=", + "requires": { + "ccount": "1.0.2", + "is-alphanumeric": "1.0.0", + "is-decimal": "1.0.1", + "is-whitespace-character": "1.0.1", + "longest-streak": "2.0.2", + "markdown-escapes": "1.0.1", + "markdown-table": "1.1.1", + "mdast-util-compact": "1.0.1", + "parse-entities": "1.1.1", + "repeat-string": "1.6.1", + "state-toggle": "1.0.0", + "stringify-entities": "1.3.1", + "unherit": "1.1.0", + "xtend": "4.0.1" + } + }, + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=" + }, + "repeat-element": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", + "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=" + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=" + }, + "replace-ext": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz", + "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=" + }, + "resolve-from": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", + "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=" + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + }, + "set-immediate-shim": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", + "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=" + }, + "shellsubstitute": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shellsubstitute/-/shellsubstitute-1.2.0.tgz", + "integrity": "sha1-5PcCpQxRiw9v6YRRiQ1wWvKba3A=" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "state-toggle": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/state-toggle/-/state-toggle-1.0.0.tgz", + "integrity": "sha1-0g+aYWu08MO5i5GSLSW2QKorxCU=" + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "stringify-entities": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-1.3.1.tgz", + "integrity": "sha1-sVDsLXKsTBtfMktR+2soyc3/BYw=", + "requires": { + "character-entities-html4": "1.1.1", + "character-entities-legacy": "1.1.1", + "is-alphanumerical": "1.0.1", + "is-hexadecimal": "1.0.1" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=" + }, + "to-vfile": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/to-vfile/-/to-vfile-2.1.2.tgz", + "integrity": "sha512-o8o2CXU2LDxh4OsvG9bGRXkIhcvk+bWKqWQECLcjfMNy2b8rl4kuFAZeTcPM5obK1mrvQ4iS3AcdopFDluq1jQ==", + "requires": { + "is-buffer": "1.1.6", + "vfile": "2.2.0" + } + }, + "trim": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", + "integrity": "sha1-WFhUf2spB1fulczMZm+1AITEYN0=" + }, + "trim-trailing-lines": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/trim-trailing-lines/-/trim-trailing-lines-1.1.0.tgz", + "integrity": "sha1-eu+7eAjfnWafbaLkOMrIxGradoQ=" + }, + "trough": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trough/-/trough-1.0.1.tgz", + "integrity": "sha1-qf2LA5Swro//guBjOgo2zK1bX4Y=" + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, + "unherit": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.0.tgz", + "integrity": "sha1-a5qu379z3xdWrZ4xbdmBiFhAzX0=", + "requires": { + "inherits": "2.0.3", + "xtend": "4.0.1" + } + }, + "unified": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/unified/-/unified-6.1.5.tgz", + "integrity": "sha1-cWk3hyYhpjE15iztLzrGoGPG+4c=", + "requires": { + "bail": "1.0.2", + "extend": "3.0.1", + "is-plain-obj": "1.1.0", + "trough": "1.0.1", + "vfile": "2.2.0", + "x-is-function": "1.0.4", + "x-is-string": "0.1.0" + } + }, + "unified-args": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/unified-args/-/unified-args-3.1.1.tgz", + "integrity": "sha1-bM7oFbXEtYNCfM8pQ6Xp/Lw4zFE=", + "requires": { + "camelcase": "4.1.0", + "chalk": "1.1.3", + "chokidar": "1.7.0", + "minimist": "1.2.0", + "text-table": "0.2.0", + "unified-engine": "3.1.1" + } + }, + "unified-engine": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/unified-engine/-/unified-engine-3.1.1.tgz", + "integrity": "sha1-eSVBgm306XtkDM3ZDspiE1bkyec=", + "requires": { + "concat-stream": "1.6.0", + "debug": "2.6.9", + "fault": "1.0.1", + "fn-name": "2.0.1", + "glob": "7.1.2", + "has": "1.0.1", + "ignore": "3.3.7", + "is-empty": "1.2.0", + "is-hidden": "1.1.1", + "is-object": "1.0.1", + "js-yaml": "3.10.0", + "load-plugin": "2.2.1", + "parse-json": "2.2.0", + "to-vfile": "2.1.2", + "trough": "1.0.1", + "vfile-reporter": "3.1.0", + "vfile-statistics": "1.1.0", + "x-is-function": "1.0.4", + "x-is-string": "0.1.0", + "xtend": "4.0.1" + } + }, + "unist-util-modify-children": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/unist-util-modify-children/-/unist-util-modify-children-1.1.1.tgz", + "integrity": "sha1-ZtfmpEnm9nIguXarPLi166w55R0=", + "requires": { + "array-iterate": "1.1.1" + } + }, + "unist-util-remove-position": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-1.1.1.tgz", + "integrity": "sha1-WoXBVV/BugwQG4ZwfRXlD6TIcbs=", + "requires": { + "unist-util-visit": "1.1.3" + } + }, + "unist-util-stringify-position": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-1.1.1.tgz", + "integrity": "sha1-PMvcU2ee7W7PN3fdf14yKcG2qjw=" + }, + "unist-util-visit": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.1.3.tgz", + "integrity": "sha1-7CaOcxudJ3p5pbWqBkOZDkBdYAs=" + }, + "untildify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/untildify/-/untildify-2.1.0.tgz", + "integrity": "sha1-F+soB5h/dpUunASF/DEdBqgmouA=", + "requires": { + "os-homedir": "1.0.2" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "vfile": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-2.2.0.tgz", + "integrity": "sha1-zkek+zNZIrIz5TXbD32BIdj87U4=", + "requires": { + "is-buffer": "1.1.6", + "replace-ext": "1.0.0", + "unist-util-stringify-position": "1.1.1" + } + }, + "vfile-location": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-2.0.2.tgz", + "integrity": "sha1-02dcWch3SY5JK0dW/2Xkrxp1IlU=" + }, + "vfile-reporter": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/vfile-reporter/-/vfile-reporter-3.1.0.tgz", + "integrity": "sha1-qbOYxebcvIqaCObPQl8JLoajcAA=", + "requires": { + "repeat-string": "1.6.1", + "string-width": "1.0.2", + "supports-color": "4.5.0", + "unist-util-stringify-position": "1.1.1", + "vfile-statistics": "1.1.0" + }, + "dependencies": { + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "requires": { + "has-flag": "2.0.0" + } + } + } + }, + "vfile-statistics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/vfile-statistics/-/vfile-statistics-1.1.0.tgz", + "integrity": "sha1-AhBMYP3u0dEbH3OtZTMLdjSz2JU=" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "x-is-function": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/x-is-function/-/x-is-function-1.0.4.tgz", + "integrity": "sha1-XSlNw9Joy90GJYDgxd93o5HR+h4=" + }, + "x-is-string": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/x-is-string/-/x-is-string-0.1.0.tgz", + "integrity": "sha1-R0tQhlrzpJqcRlfwWs0UVFj3fYI=" + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + } + } +} diff --git a/tools/remark-preset-lint-node/package-lock.json b/tools/remark-preset-lint-node/package-lock.json new file mode 100644 index 000000000000..30008212f552 --- /dev/null +++ b/tools/remark-preset-lint-node/package-lock.json @@ -0,0 +1,448 @@ +{ + "name": "remark-preset-lint-node", + "version": "1.0.0", + "lockfileVersion": 1, + "preserveSymlinks": "1", + "requires": true, + "dependencies": { + "co": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/co/-/co-3.1.0.tgz", + "integrity": "sha1-TqVOpaCJOBUxheFSEMaNkJK8G3g=" + }, + "irregular-plurals": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-1.4.0.tgz", + "integrity": "sha1-LKmwM2UREYVUEvFr5dd8YqRYp2Y=" + }, + "mdast-comment-marker": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/mdast-comment-marker/-/mdast-comment-marker-1.0.2.tgz", + "integrity": "sha1-Hd8O+BH7UkOQF8jSwLkiA18rp0o=" + }, + "mdast-util-heading-style": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/mdast-util-heading-style/-/mdast-util-heading-style-1.0.3.tgz", + "integrity": "sha1-77OQ28iqAWw89XegNJANsn7nJHw=" + }, + "mdast-util-to-string": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-1.0.4.tgz", + "integrity": "sha1-XEVch4yTVfDB5/PotxnPWDaRrPs=" + }, + "plur": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/plur/-/plur-2.1.2.tgz", + "integrity": "sha1-dIJFLBoPUI4+NE6uwxLJHCncZVo=", + "requires": { + "irregular-plurals": "1.4.0" + } + }, + "remark-lint": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/remark-lint/-/remark-lint-6.0.1.tgz", + "integrity": "sha512-wvTTuB5O5pF8SxqahQjjrU3dtuhygYjaGcOZTw+4ACgSE4RBINDlNqN46HjcV3X0ib5GmObJUt5a2mmhtmuTqw==", + "requires": { + "remark-message-control": "4.0.1" + } + }, + "remark-lint-blockquote-indentation": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-blockquote-indentation/-/remark-lint-blockquote-indentation-1.0.1.tgz", + "integrity": "sha512-YrP99MJ3+dQ5JXzq39fUOcYzwcumva/xEM1eFtD2TrQcSdlMLoqYa7gj+aEEhZCjlA5BssTiVoWWW0RjyPPGZw==", + "requires": { + "mdast-util-to-string": "1.0.4", + "plur": "2.1.2", + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-checkbox-character-style": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-checkbox-character-style/-/remark-lint-checkbox-character-style-1.0.1.tgz", + "integrity": "sha512-AF+1UrsVyrYYbK8Mg5TXr/IxaepgMspejPKuflK+TKOYKmMxOHUjdk2kIBBulj+hZCp+yz7lq3ifr8N2Vqg9BA==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3", + "vfile-location": "2.0.2" + } + }, + "remark-lint-checkbox-content-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-checkbox-content-indent/-/remark-lint-checkbox-content-indent-1.0.1.tgz", + "integrity": "sha512-cCPzu1HSQUevFsfJ7mmwj/v76ZWYBSbBu/GmFJE57G10BCEv1pCHuxJYjGKbXPcQXU5NTvIH9fuHWRVdM3hwdA==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3", + "vfile-location": "2.0.2" + } + }, + "remark-lint-code-block-style": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-code-block-style/-/remark-lint-code-block-style-1.0.1.tgz", + "integrity": "sha512-FRUMhhKwCruH4vkatdMhVO4WlYpysV1NmMILVoK/k+/7uFLSfgvlqo66nzhpMdWL8TQHqdo0LhiXuetGC2WjsQ==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-definition-spacing": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-definition-spacing/-/remark-lint-definition-spacing-1.0.1.tgz", + "integrity": "sha512-ewzdlFfpTSP11ZuiOln0yfz6Y03aWtgJmLVQNfF1spaT1gURaShjs8Hiilbo719bz96DgvXSZLP6UnkSiZL1vg==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-fenced-code-flag": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-fenced-code-flag/-/remark-lint-fenced-code-flag-1.0.1.tgz", + "integrity": "sha512-P24T9DRe/nnywPFRpE1UAXAVzN1CX6HmINr15UHbQZo1Cy8KYt7uV9YOR0/XzphtnO/AFenAqZyf7tchW5AUNQ==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-fenced-code-marker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-fenced-code-marker/-/remark-lint-fenced-code-marker-1.0.1.tgz", + "integrity": "sha512-mX7xAMl5m7xGX+YtOtyXIyv+egD4IQAm6DPGdfunI734QwODwcoBydtpTD56jrY+48nVcQ/anFYT1Blg3Xk3sQ==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-file-extension": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-file-extension/-/remark-lint-file-extension-1.0.1.tgz", + "integrity": "sha512-K1Pf5oviaFyCs0FhZqaNZ2odgd5KoV6AlA4nNAMxyylB0Y6t0mYpzECoLSS5Bgxf6f8Op9YbuM2cbjBAsv0dIA==", + "requires": { + "unified-lint-rule": "1.0.2" + } + }, + "remark-lint-final-definition": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-final-definition/-/remark-lint-final-definition-1.0.1.tgz", + "integrity": "sha512-DK6bphJdQ0xSOQAn+8wOyLIVc3SZW2+ZzCMCLkQnVtHiQ9GHMzFiCkeE3Cq+OClsMI5Yn8wFTHZHPUn58VhNEQ==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-final-newline": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-final-newline/-/remark-lint-final-newline-1.0.1.tgz", + "integrity": "sha512-neztZuEBw2ka9N35Ap0ZfBqPPA/TNSksGQNq0G9VWL370+s+6k+GUEaq7cjcQACYt310oWl4bx5ukbmo/7L5WA==", + "requires": { + "unified-lint-rule": "1.0.2" + } + }, + "remark-lint-first-heading-level": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/remark-lint-first-heading-level/-/remark-lint-first-heading-level-1.1.1.tgz", + "integrity": "sha512-R11L8arXZy+uAZIioSRVWhp4f6Oere/Q071INTX8g4uvuZrC/uKDjxa3iZ6dlWCfLijC0z/s2JbeqwYbV5QrCA==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-hard-break-spaces": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/remark-lint-hard-break-spaces/-/remark-lint-hard-break-spaces-1.0.2.tgz", + "integrity": "sha512-uh7LqHgRPCphiCvRzBVA4D0Ml2IqPaw89lWJdQ6HvYiV8ChB/OFLBapHi6OKW7NVVVPPJsElPMB/UPUsKFaPTg==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-heading-style": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-heading-style/-/remark-lint-heading-style-1.0.1.tgz", + "integrity": "sha512-m9Gqr091YdxUtG69xdXYH8fSd3+nsrsMamB/qSWpVSZuWQKZ1mRotr1LO9NphJh6vhw8IfBtG07wgEDn6b40sQ==", + "requires": { + "mdast-util-heading-style": "1.0.3", + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-no-auto-link-without-protocol": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-auto-link-without-protocol/-/remark-lint-no-auto-link-without-protocol-1.0.1.tgz", + "integrity": "sha512-MHl0hNtF8Rc0lg6iuVP7/0rnp4uZadm3S07/1TiFeqzU22KFxxzcC8980Q4+I8oPZE0d1x80h9DmkNAVFwhDjQ==", + "requires": { + "mdast-util-to-string": "1.0.4", + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-no-blockquote-without-caret": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-no-blockquote-without-caret/-/remark-lint-no-blockquote-without-caret-1.0.0.tgz", + "integrity": "sha1-gd0i3V8EVOupwqU3u6Jgh0ShrW8=", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3", + "vfile-location": "2.0.2" + } + }, + "remark-lint-no-duplicate-definitions": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-duplicate-definitions/-/remark-lint-no-duplicate-definitions-1.0.1.tgz", + "integrity": "sha512-3I0V3UVJ0gkDKZahSZ0xdFmklecr5SMwXcWbVBzXvHR59LqgjMVHFI7G/QZ6k2imOl1X22YVRz+mpMjacu2Ipw==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-no-file-name-articles": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-file-name-articles/-/remark-lint-no-file-name-articles-1.0.1.tgz", + "integrity": "sha512-SzebnFnilrsINA6QZP1YqPa3SrfSotrLkRWl5FUCoVshBvEFNKJFWXj6Xyt4NjWQ5tJWFtOMysAuHdGT+Odhjg==", + "requires": { + "unified-lint-rule": "1.0.2" + } + }, + "remark-lint-no-file-name-consecutive-dashes": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-file-name-consecutive-dashes/-/remark-lint-no-file-name-consecutive-dashes-1.0.1.tgz", + "integrity": "sha512-YP2HBwA00yeD7phvxp4ftiqbfBPfYHPgPfcEcb8oNa1WlUh/58cs9DbSHWKsZG+XLkvEaheC6qUQG02jEKZHPA==", + "requires": { + "unified-lint-rule": "1.0.2" + } + }, + "remark-lint-no-file-name-outer-dashes": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/remark-lint-no-file-name-outer-dashes/-/remark-lint-no-file-name-outer-dashes-1.0.2.tgz", + "integrity": "sha512-BVEwLrA4kipalgKrxhncpgtmh6eUmHBH1ggC+X3csYR4X5vXv4vHQqpov4I1vMyWxMLMBnq7lTL3Iqp0CS4vwg==", + "requires": { + "unified-lint-rule": "1.0.2" + } + }, + "remark-lint-no-heading-content-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-heading-content-indent/-/remark-lint-no-heading-content-indent-1.0.1.tgz", + "integrity": "sha512-VHOqVx3Qb9tckHu/DkpQjBqlXQHcfabKaSuiXdeH+G0sfgWOxL0KCmA6fsUqUdj7xJ8Q7YpH/c3wb3nZ/85d+Q==", + "requires": { + "mdast-util-heading-style": "1.0.3", + "plur": "2.1.2", + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-no-heading-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-heading-indent/-/remark-lint-no-heading-indent-1.0.1.tgz", + "integrity": "sha512-NbNZQj+/S6v510FscCTjg/du3KzI0p2CHzqlHRw+4Evryo1O9G7cgSaTT8TC4Eb/h4gGFAPwXuaSKW8noWWBcQ==", + "requires": { + "plur": "2.1.2", + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-no-inline-padding": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-inline-padding/-/remark-lint-no-inline-padding-1.0.1.tgz", + "integrity": "sha512-nRl6vA45ZPdMz3/rVMZw7WRRqLFuMrzhdkrbrGLjwBovdIeD/IGCEbDA5NR60g2xT9V5dAmKogvHEH1bIr8SdQ==", + "requires": { + "mdast-util-to-string": "1.0.4", + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-no-multiple-toplevel-headings": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-multiple-toplevel-headings/-/remark-lint-no-multiple-toplevel-headings-1.0.1.tgz", + "integrity": "sha512-LFfgjF3NKFkt0tGNnJ8Exf8+DrVcMRwek5qu5mvh2KrZnmSpm5flYWzUy2UnnIyicDL3CZYC/r3Fjz6CeBYgZA==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-no-shell-dollars": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-shell-dollars/-/remark-lint-no-shell-dollars-1.0.1.tgz", + "integrity": "sha512-YryHem73PTxjCkuC4HONJWHsmrLyXmF7r+cCH36Ys3vuWsfAbwkbOwpyuPB4KXn+6fHaTUfz/B5BPp3iwzJwyA==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-no-shortcut-reference-image": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-shortcut-reference-image/-/remark-lint-no-shortcut-reference-image-1.0.1.tgz", + "integrity": "sha512-nUQ+4xB5hKZTCl9gvg7c+W1T3ddsnjgu4zwRza2Bn+21cKmUzx+z9dvlZ4aVuNGmxuWHbKI8/ZkKuB8Eu27vJw==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-no-table-indentation": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-table-indentation/-/remark-lint-no-table-indentation-1.0.1.tgz", + "integrity": "sha512-QrtT1GvJmAoNsWh+gmHFajFlM+ubm9rd3Cbz2OYPix8ZM6g907aIfG2NusJFXL9D8/CExQWYhlBvelFBbHgqbQ==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-no-tabs": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-tabs/-/remark-lint-no-tabs-1.0.1.tgz", + "integrity": "sha512-sFNCjz3MpX2TKo4vvo9s6iX8C0MsTmw10iC0F6mk3FKZ694bkHnEQOPhz5oyZIodV+QJ2wKqpZkuyXruIshjtA==", + "requires": { + "unified-lint-rule": "1.0.2", + "vfile-location": "2.0.2" + } + }, + "remark-lint-no-unused-definitions": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-unused-definitions/-/remark-lint-no-unused-definitions-1.0.1.tgz", + "integrity": "sha512-weNwWXvoSBmB3L2Yh8oxY0ylF6L5b/PjFbOhzBU4SlnpFOMfTn3rwNxOxbTrDS8MG2JTPVTaFn4ajXr/zkbH0Q==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-rule-style": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-rule-style/-/remark-lint-rule-style-1.0.1.tgz", + "integrity": "sha512-dzH+K6DcPIIMBq6LUQgE4dR9TiQGZrQOoULD7m0Y0lIb2EoR2FK5Zd4TgZg/LnvTs6fid37t0xFoaY4/lXV/5Q==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-strong-marker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-strong-marker/-/remark-lint-strong-marker-1.0.1.tgz", + "integrity": "sha512-+bwWKWAqDwqd21Vw+ndqVFh5V27Dp4MKhk9AUlKmcvgJYHuvQ8UfWQdpZcP218ps/4EbwTfyi33TaPyXqOTlXA==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-table-cell-padding": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-table-cell-padding/-/remark-lint-table-cell-padding-1.0.1.tgz", + "integrity": "sha512-o3WwC9YysXbQKf0D5nvhhJPcLagqedLwGdifukdgyaKvuIQVbtWbNv1/UOdB3LL+D+2fUrwrCmnQ8J3E1r0lBw==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-lint-table-pipes": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-table-pipes/-/remark-lint-table-pipes-1.0.1.tgz", + "integrity": "sha512-VHfDRvcovLBl/cvSjwDoA0xRizdZU33A6F2qFD9A5hu1sDWgGxMLg5m2MOvFlRkUVxSwUv47cuD0/yxB4THYXQ==", + "requires": { + "unified-lint-rule": "1.0.2", + "unist-util-generated": "1.1.1", + "unist-util-position": "3.0.0", + "unist-util-visit": "1.1.3" + } + }, + "remark-message-control": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/remark-message-control/-/remark-message-control-4.0.1.tgz", + "integrity": "sha1-KRPNYLMW2fnzkKp/NGOdIM9VmW0=", + "requires": { + "mdast-comment-marker": "1.0.2", + "trim": "0.0.1", + "unist-util-visit": "1.1.3", + "vfile-location": "2.0.2" + } + }, + "sliced": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", + "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" + }, + "trim": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", + "integrity": "sha1-WFhUf2spB1fulczMZm+1AITEYN0=" + }, + "unified-lint-rule": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-1.0.2.tgz", + "integrity": "sha512-WkqwMC1aijHE17W3Z1co7aTI+Dzo1jHdwhI66fTClU1yOTbzAsTqlOD6eeR/MI9235Y3nu2jMDcm8GCeq4gaLg==", + "requires": { + "wrapped": "1.0.1" + } + }, + "unist-util-generated": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/unist-util-generated/-/unist-util-generated-1.1.1.tgz", + "integrity": "sha1-mfFseJWayFTe58YVwpGSTIv03n8=" + }, + "unist-util-position": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-3.0.0.tgz", + "integrity": "sha1-5uHgPu64HF4a/lU+jUrfvXwNj4I=" + }, + "unist-util-visit": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.1.3.tgz", + "integrity": "sha1-7CaOcxudJ3p5pbWqBkOZDkBdYAs=" + }, + "vfile-location": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-2.0.2.tgz", + "integrity": "sha1-02dcWch3SY5JK0dW/2Xkrxp1IlU=" + }, + "wrapped": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/wrapped/-/wrapped-1.0.1.tgz", + "integrity": "sha1-x4PZ2Aeyc+mwHoUWgKk4yHyQckI=", + "requires": { + "co": "3.1.0", + "sliced": "1.0.1" + } + } + } +} From bdbef5f7b72059064c0f01fc4b5089db97c8ff6d Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 11 Nov 2017 14:41:22 +0100 Subject: [PATCH 07/59] src: remove superfluous check in backtrace_posix.cc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The error check doesn't matter because a failure would be ignored as part of the loop condition. PR-URL: https://github.com/nodejs/node/pull/16950 Reviewed-By: Colin Ihrig Reviewed-By: Michaël Zasso Reviewed-By: Refael Ackermann Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil --- src/backtrace_posix.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/backtrace_posix.cc b/src/backtrace_posix.cc index 0c69d820e721..c7a6bea1938a 100644 --- a/src/backtrace_posix.cc +++ b/src/backtrace_posix.cc @@ -25,9 +25,6 @@ void DumpBacktrace(FILE* fp) { #if HAVE_EXECINFO_H void* frames[256]; const int size = backtrace(frames, arraysize(frames)); - if (size <= 0) { - return; - } for (int i = 1; i < size; i += 1) { void* frame = frames[i]; fprintf(fp, "%2d: ", i); From 141e3e920c87460341d87c877c6bf095b9430f87 Mon Sep 17 00:00:00 2001 From: Andreas Madsen Date: Wed, 31 Jan 2018 17:12:09 +0100 Subject: [PATCH 08/59] trace_events: add file pattern cli option Allow the user to specify the filepath for the trace_events log file using a template string. Backport-PR-URL: https://github.com/nodejs/node/pull/19145 PR-URL: https://github.com/nodejs/node/pull/18480 Reviewed-By: Ali Ijaz Sheikh Reviewed-By: Richard Lau Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- doc/api/cli.md | 9 ++++++ doc/api/tracing.md | 13 ++++++++ doc/node.1 | 5 ++++ src/node.cc | 17 ++++++++++- src/tracing/agent.cc | 5 ++-- src/tracing/agent.h | 2 +- src/tracing/node_trace_writer.cc | 26 ++++++++++++---- src/tracing/node_trace_writer.h | 4 ++- test/parallel/test-cli-node-options.js | 2 ++ .../test-trace-events-file-pattern.js | 30 +++++++++++++++++++ 10 files changed, 103 insertions(+), 10 deletions(-) create mode 100644 test/parallel/test-trace-events-file-pattern.js diff --git a/doc/api/cli.md b/doc/api/cli.md index 3192d846e779..63af8ba5ac85 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -238,6 +238,14 @@ added: v7.7.0 A comma separated list of categories that should be traced when trace event tracing is enabled using `--trace-events-enabled`. +### `--trace-event-file-pattern` + + +Template string specifying the filepath for the trace event data, it +supports `${rotation}` and `${pid}`. + ### `--zero-fill-buffers` + +* `err` {number} +* Returns: {string} + +Returns the string name for a numeric error code that comes from a Node.js API. +The mapping between error codes and error names is platform-dependent. +See [Common System Errors][] for the names of common errors. + +```js +fs.access('file/that/does/not/exist', (err) => { + const name = util.getSystemErrorName(err.errno); + console.error(name); // ENOENT +}); +``` + ## util.inherits(constructor, superConstructor) +- `icu-system.gyp` is an alternate build file used when `--with-intl=system-icu` is invoked. It builds against the `pkg-config` located ICU. +- `iculslocs.cc` is source for the `iculslocs` utility, invoked by `icutrim.py` as part of repackaging. Not used separately. See source for more details. +- `no-op.cc` — empty function to convince gyp to use a C++ compiler. +- `README.md` — you are here +- `shrink-icu-src.py` — this is used during upgrade (see guide below) ## How to upgrade ICU @@ -12,13 +23,13 @@ make ``` -(The equivalent `vcbuild.bat` commands should work also. Note that we use the `.tgz` and not the `.zip` here, -that is because of line endings.) +> _Note_ in theory, the equivalent `vcbuild.bat` commands should work also, +but the commands below are makefile-centric. -- (note- may need to make changes in `icu-generic.gyp` or `tools/icu/patches` for -version specific stuff) +- If there are ICU version-specific changes needed, you may need to make changes in `icu-generic.gyp` or add patch files to `tools/icu/patches`. + - Specifically, look for the lists in `sources!` in the `icu-generic.gyp` for files to exclude. -- Verify the node build works +- Verify the node build works: ```shell make test-ci @@ -27,13 +38,12 @@ make test-ci Also running + ```js new Intl.DateTimeFormat('es', {month: 'long'}).format(new Date(9E8)); ``` …Should return `January` not `enero`. -(TODO here: improve [testing](https://github.com/nodejs/Intl/issues/16)) - - Now, copy `deps/icu` over to `deps/icu-small` @@ -43,25 +53,25 @@ python tools/icu/shrink-icu-src.py - Now, do a clean rebuild of node to test: -(TODO: fix this when these options become default) - ```shell -./configure --with-intl=small-icu --with-icu-source=deps/icu-small +make -k distclean +./configure make ``` - Test this newly default-generated Node.js + ```js process.versions.icu; new Intl.DateTimeFormat('es', {month: 'long'}).format(new Date(9E8)); ``` -(should return your updated ICU version number, and also `January` again.) +(This should print your updated ICU version number, and also `January` again.) -- You are ready to check in the updated `deps/small-icu`. -This is a big commit, so make this a separate commit from other changes. +You are ready to check in the updated `deps/small-icu`. This is a big commit, +so make this a separate commit from the smaller changes. - Now, rebuild the Node license. @@ -85,22 +95,23 @@ make test-ci - commit the change to `configure` along with the updated `LICENSE` file. + - Note: To simplify review, I often will “pre-land” this patch, meaning that I run the patch through `curl -L https://github.com/nodejs/node/pull/xxx.patch | git am -3 --whitespace=fix` per the collaborator’s guide… and then push that patched branch into my PR's branch. This reduces the whitespace changes that show up in the PR, since the final land will eliminate those anyway. + ----- -## Notes about these tools +## Postscript about the tools -The files in this directory were written for the node.js effort. It's -the intent of their author (Steven R. Loomis / srl295) to merge them -upstream into ICU, pending much discussion within the ICU-PMC. +The files in this directory were written for the node.js effort. +It was the intent of their author (Steven R. Loomis / srl295) to +merge them upstream into ICU, pending much discussion within the +ICU-TC. `icu_small.json` is somewhat node-specific as it specifies a "small ICU" configuration file for the `icutrim.py` script. `icutrim.py` and `iculslocs.cpp` may themselves be superseded by components built into -ICU in the future. - -The following tickets were opened during this work, and their -resolution may inform the reader as to the current state of icu-trim -upstream: +ICU in the future. As of this writing, however, the tools are separate +entities within Node, although theyare being scrutinized by interested +members of the ICU-TC. The “upstream” ICU bugs are given below. * [#10919](http://bugs.icu-project.org/trac/ticket/10919) (experimental branch - may copy any source patches here) @@ -108,7 +119,3 @@ upstream: (data packaging improvements) * [#10923](http://bugs.icu-project.org/trac/ticket/10923) (rewrite data building in python) - -When/if components (not including the `.json` file) are merged into -ICU, this code and `configure` will be updated to detect and use those -variants rather than the ones in this directory. From de963dac91dd357e654623591328dd9d90716ebd Mon Sep 17 00:00:00 2001 From: Anatoli Papirovski Date: Mon, 29 Jan 2018 20:08:21 -0500 Subject: [PATCH 46/59] tools: fix icu readme lint error PR-URL: https://github.com/nodejs/node/pull/18445 Reviewed-By: Colin Ihrig Reviewed-By: Vse Mozhet Byt --- tools/icu/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/icu/README.md b/tools/icu/README.md index 1eb9f4f0684f..c08c82d0cfe3 100644 --- a/tools/icu/README.md +++ b/tools/icu/README.md @@ -24,7 +24,7 @@ make ``` > _Note_ in theory, the equivalent `vcbuild.bat` commands should work also, -but the commands below are makefile-centric. +> but the commands below are makefile-centric. - If there are ICU version-specific changes needed, you may need to make changes in `icu-generic.gyp` or add patch files to `tools/icu/patches`. - Specifically, look for the lists in `sources!` in the `icu-generic.gyp` for files to exclude. From 1a3c2966b6a2fa5bf57cfd1a7f3f9589ce4ff6f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=88=9A?= Date: Sun, 14 Jan 2018 23:34:18 +0800 Subject: [PATCH 47/59] stream: delete redundant code In `Writable.prototype.end()`, `state.ending` is true after calling `endWritable()` and it doesn't reset to false. In `Writable.prototype.uncork()`, `state.finished` must be false if `state.bufferedRequest` is true. PR-URL: https://github.com/nodejs/node/pull/18145 Reviewed-By: Ruben Bridgewater Reviewed-By: Matteo Collina --- lib/_stream_writable.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index ca7d0bd2755b..3e6de8fee2fc 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -307,7 +307,6 @@ Writable.prototype.uncork = function() { if (!state.writing && !state.corked && - !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); @@ -569,7 +568,7 @@ Writable.prototype.end = function(chunk, encoding, cb) { } // ignore unnecessary end() calls. - if (!state.ending && !state.finished) + if (!state.ending) endWritable(this, state, cb); }; From 4b2792a01bcf8069d071ec324103f68c16cffc35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=88=9A?= Date: Mon, 15 Jan 2018 14:45:11 +0800 Subject: [PATCH 48/59] stream: delete redundant code `state.corkedRequestsFree` of a writable stream is always not null. PR-URL: https://github.com/nodejs/node/pull/18145 Reviewed-By: Ruben Bridgewater Reviewed-By: Matteo Collina --- lib/_stream_writable.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 3e6de8fee2fc..acae6f083eab 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -638,11 +638,9 @@ function onCorkedFinish(corkReq, state, err) { cb(err); entry = entry.next; } - if (state.corkedRequestsFree) { - state.corkedRequestsFree.next = corkReq; - } else { - state.corkedRequestsFree = corkReq; - } + + // reuse the free corkReq. + state.corkedRequestsFree.next = corkReq; } Object.defineProperty(Writable.prototype, 'destroyed', { From 16a3c7c51efbeb429fa891bad7d1773a715e9c74 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 23 Jan 2018 13:14:21 +0100 Subject: [PATCH 49/59] benchmark: fix platform in basename-win32 It should say `win32` and not `posix`. PR-URL: https://github.com/nodejs/node/pull/18320 Reviewed-By: James M Snell --- benchmark/path/basename-win32.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/benchmark/path/basename-win32.js b/benchmark/path/basename-win32.js index 6966e4fe81e1..37ee891f93a3 100644 --- a/benchmark/path/basename-win32.js +++ b/benchmark/path/basename-win32.js @@ -1,6 +1,6 @@ 'use strict'; const common = require('../common.js'); -const path = require('path'); +const { win32 } = require('path'); const bench = common.createBenchmark(main, { pathext: [ @@ -20,7 +20,6 @@ const bench = common.createBenchmark(main, { function main(conf) { const n = +conf.n; - const p = path.win32; var input = String(conf.pathext); var ext; const extIdx = input.indexOf('|'); @@ -31,7 +30,7 @@ function main(conf) { bench.start(); for (var i = 0; i < n; i++) { - p.basename(input, ext); + win32.basename(pathext, ext); } bench.end(n); } From 57d8ae47896307e2d70b7874fb12086bcbb20afc Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 23 Jan 2018 13:15:59 +0100 Subject: [PATCH 50/59] benchmark: fix variables not being set Due to the destructuring the outer variables were not set anymore. PR-URL: https://github.com/nodejs/node/pull/18320 Reviewed-By: James M Snell --- benchmark/tls/tls-connect.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/benchmark/tls/tls-connect.js b/benchmark/tls/tls-connect.js index 628b040ee88c..65d1b101c410 100644 --- a/benchmark/tls/tls-connect.js +++ b/benchmark/tls/tls-connect.js @@ -11,7 +11,6 @@ const bench = common.createBenchmark(main, { var clientConn = 0; var serverConn = 0; -var server; var dur; var concurrency; var running = true; @@ -28,7 +27,7 @@ function main(conf) { ciphers: 'AES256-GCM-SHA384' }; - server = tls.createServer(options, onConnection); + const server = tls.createServer(options, onConnection); server.listen(common.PORT, onListening); } From d4bc6c01a4b3f9ee82a1a0b82c98688f7b86ea34 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 23 Jan 2018 13:17:21 +0100 Subject: [PATCH 51/59] benchmark: (assert) refactor PR-URL: https://github.com/nodejs/node/pull/18320 Reviewed-By: James M Snell --- benchmark/assert/deepequal-buffer.js | 49 +++--------- benchmark/assert/deepequal-map.js | 2 +- benchmark/assert/deepequal-object.js | 51 +++--------- .../deepequal-prims-and-objs-big-array-set.js | 77 ++++++------------- .../deepequal-prims-and-objs-big-loop.js | 45 ++--------- benchmark/assert/deepequal-set.js | 2 +- benchmark/assert/deepequal-typedarrays.js | 44 ++--------- 7 files changed, 63 insertions(+), 207 deletions(-) diff --git a/benchmark/assert/deepequal-buffer.js b/benchmark/assert/deepequal-buffer.js index d4495af69b48..9556a81ec3b1 100644 --- a/benchmark/assert/deepequal-buffer.js +++ b/benchmark/assert/deepequal-buffer.js @@ -13,11 +13,7 @@ const bench = common.createBenchmark(main, { ] }); -function main(conf) { - const n = +conf.n; - const len = +conf.len; - var i; - +function main({ len, n, method }) { const data = Buffer.allocUnsafe(len + 1); const actual = Buffer.alloc(len); const expected = Buffer.alloc(len); @@ -26,40 +22,13 @@ function main(conf) { data.copy(expected); data.copy(expectedWrong); - switch (conf.method) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'deepEqual': - bench.start(); - for (i = 0; i < n; ++i) { - // eslint-disable-next-line no-restricted-properties - assert.deepEqual(actual, expected); - } - bench.end(n); - break; - case 'deepStrictEqual': - bench.start(); - for (i = 0; i < n; ++i) { - assert.deepStrictEqual(actual, expected); - } - bench.end(n); - break; - case 'notDeepEqual': - bench.start(); - for (i = 0; i < n; ++i) { - // eslint-disable-next-line no-restricted-properties - assert.notDeepEqual(actual, expectedWrong); - } - bench.end(n); - break; - case 'notDeepStrictEqual': - bench.start(); - for (i = 0; i < n; ++i) { - assert.notDeepStrictEqual(actual, expectedWrong); - } - bench.end(n); - break; - default: - throw new Error('Unsupported method'); + // eslint-disable-next-line no-restricted-properties + const fn = method !== '' ? assert[method] : assert.deepEqual; + const value2 = method.includes('not') ? expectedWrong : expected; + + bench.start(); + for (var i = 0; i < n; ++i) { + fn(actual, value2); } + bench.end(n); } diff --git a/benchmark/assert/deepequal-map.js b/benchmark/assert/deepequal-map.js index 4976f2619834..97dd447b1adc 100644 --- a/benchmark/assert/deepequal-map.js +++ b/benchmark/assert/deepequal-map.js @@ -120,6 +120,6 @@ function main(conf) { benchmark(assert.notDeepEqual, n, values, values2); break; default: - throw new Error('Unsupported method'); + throw new Error(`Unsupported method ${method}`); } } diff --git a/benchmark/assert/deepequal-object.js b/benchmark/assert/deepequal-object.js index 4ad370440838..4c95006b3b8b 100644 --- a/benchmark/assert/deepequal-object.js +++ b/benchmark/assert/deepequal-object.js @@ -25,51 +25,22 @@ function createObj(source, add = '') { })); } -function main(conf) { - const size = conf.size; - // TODO: Fix this "hack" - const n = conf.n / size; - var i; +function main({ size, n, method }) { + // TODO: Fix this "hack". `n` should not be manipulated. + n = n / size; const source = Array.apply(null, Array(size)); const actual = createObj(source); const expected = createObj(source); const expectedWrong = createObj(source, '4'); - switch (conf.method) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'deepEqual': - bench.start(); - for (i = 0; i < n; ++i) { - // eslint-disable-next-line no-restricted-properties - assert.deepEqual(actual, expected); - } - bench.end(n); - break; - case 'deepStrictEqual': - bench.start(); - for (i = 0; i < n; ++i) { - assert.deepStrictEqual(actual, expected); - } - bench.end(n); - break; - case 'notDeepEqual': - bench.start(); - for (i = 0; i < n; ++i) { - // eslint-disable-next-line no-restricted-properties - assert.notDeepEqual(actual, expectedWrong); - } - bench.end(n); - break; - case 'notDeepStrictEqual': - bench.start(); - for (i = 0; i < n; ++i) { - assert.notDeepStrictEqual(actual, expectedWrong); - } - bench.end(n); - break; - default: - throw new Error('Unsupported method'); + // eslint-disable-next-line no-restricted-properties + const fn = method !== '' ? assert[method] : assert.deepEqual; + const value2 = method.includes('not') ? expectedWrong : expected; + + bench.start(); + for (var i = 0; i < n; ++i) { + fn(actual, value2); } + bench.end(n); } diff --git a/benchmark/assert/deepequal-prims-and-objs-big-array-set.js b/benchmark/assert/deepequal-prims-and-objs-big-array-set.js index 19337d782823..d2517a48c243 100644 --- a/benchmark/assert/deepequal-prims-and-objs-big-array-set.js +++ b/benchmark/assert/deepequal-prims-and-objs-big-array-set.js @@ -30,14 +30,19 @@ const bench = common.createBenchmark(main, { ] }); -function main(conf) { - const prim = primValues[conf.prim]; - const n = +conf.n; - const len = +conf.len; +function run(fn, n, actual, expected) { + bench.start(); + for (var i = 0; i < n; ++i) { + fn(actual, expected); + } + bench.end(n); +} + +function main({ n, len, primitive, method }) { + const prim = primValues[primitive]; const actual = []; const expected = []; const expectedWrong = []; - var i; for (var x = 0; x < len; x++) { actual.push(prim); @@ -52,70 +57,38 @@ function main(conf) { const expectedSet = new Set(expected); const expectedWrongSet = new Set(expectedWrong); - switch (conf.method) { + switch (method) { + // Empty string falls through to next line as default, mostly for tests. case '': - // Empty string falls through to next line as default, mostly for tests. case 'deepEqual_Array': - bench.start(); - for (i = 0; i < n; ++i) { - // eslint-disable-next-line no-restricted-properties - assert.deepEqual(actual, expected); - } - bench.end(n); + // eslint-disable-next-line no-restricted-properties + run(assert.deepEqual, n, actual, expected); break; case 'deepStrictEqual_Array': - bench.start(); - for (i = 0; i < n; ++i) { - assert.deepStrictEqual(actual, expected); - } - bench.end(n); + run(assert.deepStrictEqual, n, actual, expected); break; case 'notDeepEqual_Array': - bench.start(); - for (i = 0; i < n; ++i) { - // eslint-disable-next-line no-restricted-properties - assert.notDeepEqual(actual, expectedWrong); - } - bench.end(n); + // eslint-disable-next-line no-restricted-properties + run(assert.notDeepEqual, n, actual, expectedWrong); break; case 'notDeepStrictEqual_Array': - bench.start(); - for (i = 0; i < n; ++i) { - assert.notDeepStrictEqual(actual, expectedWrong); - } - bench.end(n); + run(assert.notDeepStrictEqual, n, actual, expectedWrong); break; case 'deepEqual_Set': - bench.start(); - for (i = 0; i < n; ++i) { - // eslint-disable-next-line no-restricted-properties - assert.deepEqual(actualSet, expectedSet); - } - bench.end(n); + // eslint-disable-next-line no-restricted-properties + run(assert.deepEqual, n, actualSet, expectedSet); break; case 'deepStrictEqual_Set': - bench.start(); - for (i = 0; i < n; ++i) { - assert.deepStrictEqual(actualSet, expectedSet); - } - bench.end(n); + run(assert.deepStrictEqual, n, actualSet, expectedSet); break; case 'notDeepEqual_Set': - bench.start(); - for (i = 0; i < n; ++i) { - // eslint-disable-next-line no-restricted-properties - assert.notDeepEqual(actualSet, expectedWrongSet); - } - bench.end(n); + // eslint-disable-next-line no-restricted-properties + run(assert.notDeepEqual, n, actualSet, expectedWrongSet); break; case 'notDeepStrictEqual_Set': - bench.start(); - for (i = 0; i < n; ++i) { - assert.notDeepStrictEqual(actualSet, expectedWrongSet); - } - bench.end(n); + run(assert.notDeepStrictEqual, n, actualSet, expectedWrongSet); break; default: - throw new Error('Unsupported method'); + throw new Error(`Unsupported method "${method}"`); } } diff --git a/benchmark/assert/deepequal-prims-and-objs-big-loop.js b/benchmark/assert/deepequal-prims-and-objs-big-loop.js index 4a345f27c20f..2bfc9d627631 100644 --- a/benchmark/assert/deepequal-prims-and-objs-big-loop.js +++ b/benchmark/assert/deepequal-prims-and-objs-big-loop.js @@ -30,43 +30,14 @@ function main(conf) { const actual = prim; const expected = prim; const expectedWrong = 'b'; - var i; - // Creates new array to avoid loop invariant code motion - switch (conf.method) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'deepEqual': - bench.start(); - for (i = 0; i < n; ++i) { - // eslint-disable-next-line no-restricted-properties - assert.deepEqual([actual], [expected]); - } - bench.end(n); - break; - case 'deepStrictEqual': - bench.start(); - for (i = 0; i < n; ++i) { - assert.deepStrictEqual([actual], [expected]); - } - bench.end(n); - break; - case 'notDeepEqual': - bench.start(); - for (i = 0; i < n; ++i) { - // eslint-disable-next-line no-restricted-properties - assert.notDeepEqual([actual], [expectedWrong]); - } - bench.end(n); - break; - case 'notDeepStrictEqual': - bench.start(); - for (i = 0; i < n; ++i) { - assert.notDeepStrictEqual([actual], [expectedWrong]); - } - bench.end(n); - break; - default: - throw new Error('Unsupported method'); + // eslint-disable-next-line no-restricted-properties + const fn = method !== '' ? assert[method] : assert.deepEqual; + const value2 = method.includes('not') ? expectedWrong : expected; + + bench.start(); + for (var i = 0; i < n; ++i) { + fn([actual], [value2]); } + bench.end(n); } diff --git a/benchmark/assert/deepequal-set.js b/benchmark/assert/deepequal-set.js index aa0ebc064886..ea679e2333b6 100644 --- a/benchmark/assert/deepequal-set.js +++ b/benchmark/assert/deepequal-set.js @@ -129,6 +129,6 @@ function main(conf) { benchmark(assert.notDeepEqual, n, values, values2); break; default: - throw new Error('Unsupported method'); + throw new Error(`Unsupported method "${method}"`); } } diff --git a/benchmark/assert/deepequal-typedarrays.js b/benchmark/assert/deepequal-typedarrays.js index 8e8cc4b083a7..e6cfb867c621 100644 --- a/benchmark/assert/deepequal-typedarrays.js +++ b/benchmark/assert/deepequal-typedarrays.js @@ -35,42 +35,14 @@ function main(conf) { const expectedWrong = Buffer.alloc(len); const wrongIndex = Math.floor(len / 2); expectedWrong[wrongIndex] = 123; - var i; - switch (conf.method) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'deepEqual': - bench.start(); - for (i = 0; i < n; ++i) { - // eslint-disable-next-line no-restricted-properties - assert.deepEqual(actual, expected); - } - bench.end(n); - break; - case 'deepStrictEqual': - bench.start(); - for (i = 0; i < n; ++i) { - assert.deepStrictEqual(actual, expected); - } - bench.end(n); - break; - case 'notDeepEqual': - bench.start(); - for (i = 0; i < n; ++i) { - // eslint-disable-next-line no-restricted-properties - assert.notDeepEqual(actual, expectedWrong); - } - bench.end(n); - break; - case 'notDeepStrictEqual': - bench.start(); - for (i = 0; i < n; ++i) { - assert.notDeepStrictEqual(actual, expectedWrong); - } - bench.end(n); - break; - default: - throw new Error('Unsupported method'); + // eslint-disable-next-line no-restricted-properties + const fn = method !== '' ? assert[method] : assert.deepEqual; + const value2 = method.includes('not') ? expectedWrong : expected; + + bench.start(); + for (var i = 0; i < n; ++i) { + fn(actual, value2); } + bench.end(n); } From 03e42dfbfc1195a799970d7aef979241fd00b42c Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 23 Jan 2018 13:17:39 +0100 Subject: [PATCH 52/59] benchmark: (buffer) refactor PR-URL: https://github.com/nodejs/node/pull/18320 Reviewed-By: James M Snell --- benchmark/buffers/buffer-bytelength.js | 3 +- benchmark/buffers/buffer-compare-offset.js | 28 +++++------ benchmark/buffers/buffer-creation.js | 49 +++++++------------ benchmark/buffers/buffer-hex.js | 5 +- benchmark/buffers/buffer-iterate.js | 12 ----- benchmark/buffers/buffer-read-float.js | 41 ++++++++++++++++ .../buffers/buffer-read-with-byteLength.js | 32 ++++++++++++ benchmark/buffers/buffer-read.js | 18 +++---- benchmark/buffers/buffer-write.js | 36 ++++++-------- benchmark/buffers/buffer_zero.js | 12 ++--- 10 files changed, 130 insertions(+), 106 deletions(-) create mode 100644 benchmark/buffers/buffer-read-float.js create mode 100644 benchmark/buffers/buffer-read-with-byteLength.js diff --git a/benchmark/buffers/buffer-bytelength.js b/benchmark/buffers/buffer-bytelength.js index fc6dfcf2301e..24a94d731984 100644 --- a/benchmark/buffers/buffer-bytelength.js +++ b/benchmark/buffers/buffer-bytelength.js @@ -21,10 +21,9 @@ function main(conf) { const encoding = conf.encoding; var strings = []; - var results; + var results = [ len * 16 ]; if (encoding === 'buffer') { strings = [ Buffer.alloc(len * 16, 'a') ]; - results = [ len * 16 ]; } else { for (const string of chars) { // Strings must be built differently, depending on encoding diff --git a/benchmark/buffers/buffer-compare-offset.js b/benchmark/buffers/buffer-compare-offset.js index 96719abfbe56..551fcd2f0cec 100644 --- a/benchmark/buffers/buffer-compare-offset.js +++ b/benchmark/buffers/buffer-compare-offset.js @@ -8,28 +8,22 @@ const bench = common.createBenchmark(main, { }); function compareUsingSlice(b0, b1, len, iter) { - var i; - bench.start(); - for (i = 0; i < iter; i++) + for (var i = 0; i < iter; i++) Buffer.compare(b0.slice(1, len), b1.slice(1, len)); - bench.end(iter / 1e6); } function compareUsingOffset(b0, b1, len, iter) { - var i; - bench.start(); - for (i = 0; i < iter; i++) + for (var i = 0; i < iter; i++) b0.compare(b1, 1, len, 1, len); - bench.end(iter / 1e6); } -function main(conf) { - const iter = (conf.millions >>> 0) * 1e6; - const size = (conf.size >>> 0); - const method = - conf.method === 'slice' ? compareUsingSlice : compareUsingOffset; - method(Buffer.alloc(size, 'a'), - Buffer.alloc(size, 'b'), - size >> 1, - iter); +function main({ millions, size, method }) { + const iter = millions * 1e6; + const fn = method === 'slice' ? compareUsingSlice : compareUsingOffset; + bench.start(); + fn(Buffer.alloc(size, 'a'), + Buffer.alloc(size, 'b'), + size >> 1, + iter); + bench.end(millions); } diff --git a/benchmark/buffers/buffer-creation.js b/benchmark/buffers/buffer-creation.js index 4ca0a049228f..a7b340131eb8 100644 --- a/benchmark/buffers/buffer-creation.js +++ b/benchmark/buffers/buffer-creation.js @@ -15,54 +15,39 @@ const bench = common.createBenchmark(main, { n: [1024] }); -function main(conf) { - const len = +conf.len; - const n = +conf.n; - switch (conf.type) { +function main({ len, n, type }) { + let fn, i; + switch (type) { case '': case 'fast-alloc': - bench.start(); - for (let i = 0; i < n * 1024; i++) { - Buffer.alloc(len); - } - bench.end(n); + fn = Buffer.alloc; break; case 'fast-alloc-fill': bench.start(); - for (let i = 0; i < n * 1024; i++) { + for (i = 0; i < n * 1024; i++) { Buffer.alloc(len, 0); } bench.end(n); - break; + return; case 'fast-allocUnsafe': - bench.start(); - for (let i = 0; i < n * 1024; i++) { - Buffer.allocUnsafe(len); - } - bench.end(n); + fn = Buffer.allocUnsafe; break; case 'slow-allocUnsafe': - bench.start(); - for (let i = 0; i < n * 1024; i++) { - Buffer.allocUnsafeSlow(len); - } - bench.end(n); + fn = Buffer.allocUnsafeSlow; break; case 'slow': - bench.start(); - for (let i = 0; i < n * 1024; i++) { - SlowBuffer(len); - } - bench.end(n); + fn = SlowBuffer; break; case 'buffer()': - bench.start(); - for (let i = 0; i < n * 1024; i++) { - Buffer(len); - } - bench.end(n); + fn = Buffer; break; default: - assert.fail(null, null, 'Should not get here'); + assert.fail('Should not get here'); + } + + bench.start(); + for (i = 0; i < n * 1024; i++) { + fn(len); } + bench.end(n); } diff --git a/benchmark/buffers/buffer-hex.js b/benchmark/buffers/buffer-hex.js index d05bb832b306..110c0ebc428a 100644 --- a/benchmark/buffers/buffer-hex.js +++ b/benchmark/buffers/buffer-hex.js @@ -11,15 +11,16 @@ function main(conf) { const len = conf.len | 0; const n = conf.n | 0; const buf = Buffer.alloc(len); + var i; - for (let i = 0; i < buf.length; i++) + for (i = 0; i < buf.length; i++) buf[i] = i & 0xff; const hex = buf.toString('hex'); bench.start(); - for (let i = 0; i < n; i += 1) + for (i = 0; i < n; i += 1) Buffer.from(hex, 'hex'); bench.end(n); diff --git a/benchmark/buffers/buffer-iterate.js b/benchmark/buffers/buffer-iterate.js index 4e911caa72ce..430280e0158d 100644 --- a/benchmark/buffers/buffer-iterate.js +++ b/benchmark/buffers/buffer-iterate.js @@ -26,33 +26,23 @@ function main(conf) { methods[method](buffer, conf.n); } - function benchFor(buffer, n) { - bench.start(); - for (var k = 0; k < n; k++) { for (var i = 0; i < buffer.length; i++) { assert(buffer[i] === 0); } } - - bench.end(n); } function benchForOf(buffer, n) { - bench.start(); - for (var k = 0; k < n; k++) { for (const b of buffer) { assert(b === 0); } } - bench.end(n); } function benchIterator(buffer, n) { - bench.start(); - for (var k = 0; k < n; k++) { const iter = buffer[Symbol.iterator](); var cur = iter.next(); @@ -63,6 +53,4 @@ function benchIterator(buffer, n) { } } - - bench.end(n); } diff --git a/benchmark/buffers/buffer-read-float.js b/benchmark/buffers/buffer-read-float.js new file mode 100644 index 000000000000..afd9edf55783 --- /dev/null +++ b/benchmark/buffers/buffer-read-float.js @@ -0,0 +1,41 @@ +'use strict'; +const common = require('../common.js'); + +const bench = common.createBenchmark(main, { + noAssert: ['false', 'true'], + type: ['Double', 'Float'], + endian: ['BE', 'LE'], + value: ['zero', 'big', 'small', 'inf', 'nan'], + millions: [1] +}); + +function main({ noAssert, millions, type, endian, value }) { + noAssert = noAssert === 'true'; + type = type || 'Double'; + const buff = Buffer.alloc(8); + const fn = `read${type}${endian}`; + const values = { + Double: { + zero: 0, + big: 2 ** 1023, + small: 2 ** -1074, + inf: Infinity, + nan: NaN, + }, + Float: { + zero: 0, + big: 2 ** 127, + small: 2 ** -149, + inf: Infinity, + nan: NaN, + }, + }; + + buff[`write${type}${endian}`](values[type][value], 0, noAssert); + + bench.start(); + for (var i = 0; i !== millions * 1e6; i++) { + buff[fn](0, noAssert); + } + bench.end(millions); +} diff --git a/benchmark/buffers/buffer-read-with-byteLength.js b/benchmark/buffers/buffer-read-with-byteLength.js new file mode 100644 index 000000000000..9fe5e6f4bf43 --- /dev/null +++ b/benchmark/buffers/buffer-read-with-byteLength.js @@ -0,0 +1,32 @@ +'use strict'; +const common = require('../common.js'); + +const types = [ + 'IntBE', + 'IntLE', + 'UIntBE', + 'UIntLE' +]; + +const bench = common.createBenchmark(main, { + noAssert: ['false', 'true'], + buffer: ['fast', 'slow'], + type: types, + millions: [1], + byteLength: [1, 2, 4, 6] +}); + +function main({ millions, noAssert, buf, type, byteLength }) { + noAssert = noAssert === 'true'; + type = type || 'UInt8'; + const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer; + const buff = new clazz(8); + const fn = `read${type}`; + + buff.writeDoubleLE(0, 0, noAssert); + bench.start(); + for (var i = 0; i !== millions * 1e6; i++) { + buff[fn](0, byteLength, noAssert); + } + bench.end(millions); +} diff --git a/benchmark/buffers/buffer-read.js b/benchmark/buffers/buffer-read.js index 339da75befce..86dd84157a29 100644 --- a/benchmark/buffers/buffer-read.js +++ b/benchmark/buffers/buffer-read.js @@ -25,21 +25,17 @@ const bench = common.createBenchmark(main, { millions: [1] }); -function main(conf) { - const noAssert = conf.noAssert === 'true'; - const len = +conf.millions * 1e6; - const clazz = conf.buf === 'fast' ? Buffer : require('buffer').SlowBuffer; +function main({ noAssert, millions, buf, type }) { + noAssert = noAssert === 'true'; + const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer; const buff = new clazz(8); const type = conf.type || 'UInt8'; const fn = `read${type}`; buff.writeDoubleLE(0, 0, noAssert); - const testFunction = new Function('buff', ` - for (var i = 0; i !== ${len}; i++) { - buff.${fn}(0, ${JSON.stringify(noAssert)}); - } - `); bench.start(); - testFunction(buff); - bench.end(len / 1e6); + for (var i = 0; i !== millions * 1e6; i++) { + buff[fn](0, noAssert); + } + bench.end(millions); } diff --git a/benchmark/buffers/buffer-write.js b/benchmark/buffers/buffer-write.js index b500a13dedcc..6da591035ca5 100644 --- a/benchmark/buffers/buffer-write.js +++ b/benchmark/buffers/buffer-write.js @@ -45,39 +45,31 @@ const mod = { writeUInt32LE: UINT32 }; -function main(conf) { - const noAssert = conf.noAssert === 'true'; - const len = +conf.millions * 1e6; - const clazz = conf.buf === 'fast' ? Buffer : require('buffer').SlowBuffer; +function main({ noAssert, millions, buf, type }) { + const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer; const buff = new clazz(8); const type = conf.type || 'UInt8'; const fn = `write${type}`; if (/Int/.test(fn)) - benchInt(buff, fn, len, noAssert); + benchInt(buff, fn, millions, noAssert); else - benchFloat(buff, fn, len, noAssert); + benchFloat(buff, fn, millions, noAssert); } -function benchInt(buff, fn, len, noAssert) { +function benchInt(buff, fn, millions, noAssert) { const m = mod[fn]; - const testFunction = new Function('buff', ` - for (var i = 0; i !== ${len}; i++) { - buff.${fn}(i & ${m}, 0, ${JSON.stringify(noAssert)}); - } - `); bench.start(); - testFunction(buff); - bench.end(len / 1e6); + for (var i = 0; i !== millions * 1e6; i++) { + buff[fn](i & m, 0, noAssert); + } + bench.end(millions); } -function benchFloat(buff, fn, len, noAssert) { - const testFunction = new Function('buff', ` - for (var i = 0; i !== ${len}; i++) { - buff.${fn}(i, 0, ${JSON.stringify(noAssert)}); - } - `); +function benchFloat(buff, fn, millions, noAssert) { bench.start(); - testFunction(buff); - bench.end(len / 1e6); + for (var i = 0; i !== millions * 1e6; i++) { + buff[fn](i, 0, noAssert); + } + bench.end(millions); } diff --git a/benchmark/buffers/buffer_zero.js b/benchmark/buffers/buffer_zero.js index 06ca50bbb99e..1263732dce8e 100644 --- a/benchmark/buffers/buffer_zero.js +++ b/benchmark/buffers/buffer_zero.js @@ -10,14 +10,10 @@ const bench = common.createBenchmark(main, { const zeroBuffer = Buffer.alloc(0); const zeroString = ''; -function main(conf) { - const n = +conf.n; - bench.start(); - - if (conf.type === 'buffer') - for (let i = 0; i < n * 1024; i++) Buffer.from(zeroBuffer); - else if (conf.type === 'string') - for (let i = 0; i < n * 1024; i++) Buffer.from(zeroString); +function main({ n, type }) { + const data = type === 'buffer' ? zeroBuffer : zeroString; + bench.start(); + for (var i = 0; i < n * 1024; i++) Buffer.from(data); bench.end(n); } From e4e349007dee70d048a2ff6af922de25cc633cdf Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 23 Jan 2018 13:17:56 +0100 Subject: [PATCH 53/59] benchmark: (crypto) refactor PR-URL: https://github.com/nodejs/node/pull/18320 Reviewed-By: James M Snell --- benchmark/crypto/aes-gcm-throughput.js | 8 ++++---- benchmark/crypto/cipher-stream.js | 19 +++++++++---------- benchmark/crypto/get-ciphers.js | 6 ++---- benchmark/crypto/hash-stream-creation.js | 15 +++++++-------- benchmark/crypto/hash-stream-throughput.js | 15 +++++++-------- .../crypto/rsa-encrypt-decrypt-throughput.js | 6 +++--- .../crypto/rsa-sign-verify-throughput.js | 6 +++--- 7 files changed, 35 insertions(+), 40 deletions(-) diff --git a/benchmark/crypto/aes-gcm-throughput.js b/benchmark/crypto/aes-gcm-throughput.js index 246455de78ad..5c1e71e72805 100644 --- a/benchmark/crypto/aes-gcm-throughput.js +++ b/benchmark/crypto/aes-gcm-throughput.js @@ -8,13 +8,13 @@ const bench = common.createBenchmark(main, { len: [1024, 4 * 1024, 16 * 1024, 64 * 1024, 256 * 1024, 1024 * 1024] }); -function main(conf) { - const message = Buffer.alloc(conf.len, 'b'); - const key = crypto.randomBytes(keylen[conf.cipher]); +function main({ n, len, cipher }) { + const message = Buffer.alloc(len, 'b'); + const key = crypto.randomBytes(keylen[cipher]); const iv = crypto.randomBytes(12); const associate_data = Buffer.alloc(16, 'z'); bench.start(); - AEAD_Bench(conf.cipher, message, associate_data, key, iv, conf.n, conf.len); + AEAD_Bench(cipher, message, associate_data, key, iv, n, len); } function AEAD_Bench(cipher, message, associate_data, key, iv, n, len) { diff --git a/benchmark/crypto/cipher-stream.js b/benchmark/crypto/cipher-stream.js index ca36bd736d9a..64f6ff7b7292 100644 --- a/benchmark/crypto/cipher-stream.js +++ b/benchmark/crypto/cipher-stream.js @@ -9,8 +9,7 @@ const bench = common.createBenchmark(main, { api: ['legacy', 'stream'] }); -function main(conf) { - var api = conf.api; +function main({ api, cipher, type, len, writes }) { if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) { console.error('Crypto streams not available until v0.10'); // use the legacy, just so that we can compare them. @@ -33,25 +32,25 @@ function main(conf) { // alice_secret and bob_secret should be the same assert(alice_secret === bob_secret); - const alice_cipher = crypto.createCipher(conf.cipher, alice_secret); - const bob_cipher = crypto.createDecipher(conf.cipher, bob_secret); + const alice_cipher = crypto.createCipher(cipher, alice_secret); + const bob_cipher = crypto.createDecipher(cipher, bob_secret); var message; var encoding; - switch (conf.type) { + switch (type) { case 'asc': - message = 'a'.repeat(conf.len); + message = 'a'.repeat(len); encoding = 'ascii'; break; case 'utf': - message = 'ü'.repeat(conf.len / 2); + message = 'ü'.repeat(len / 2); encoding = 'utf8'; break; case 'buf': - message = Buffer.alloc(conf.len, 'b'); + message = Buffer.alloc(len, 'b'); break; default: - throw new Error(`unknown message type: ${conf.type}`); + throw new Error(`unknown message type: ${type}`); } const fn = api === 'stream' ? streamWrite : legacyWrite; @@ -59,7 +58,7 @@ function main(conf) { // write data as fast as possible to alice, and have bob decrypt. // use old API for comparison to v0.8 bench.start(); - fn(alice_cipher, bob_cipher, message, encoding, conf.writes); + fn(alice_cipher, bob_cipher, message, encoding, writes); } function streamWrite(alice, bob, message, encoding, writes) { diff --git a/benchmark/crypto/get-ciphers.js b/benchmark/crypto/get-ciphers.js index 3f5ad17ad387..d4c10a2427d3 100644 --- a/benchmark/crypto/get-ciphers.js +++ b/benchmark/crypto/get-ciphers.js @@ -7,12 +7,10 @@ const bench = common.createBenchmark(main, { v: ['crypto', 'tls'] }); -function main(conf) { - const n = +conf.n; - const v = conf.v; +function main({ n, v }) { const method = require(v).getCiphers; var i = 0; - // first call to getChipers will dominate the results + // First call to getChipers will dominate the results if (n > 1) { for (; i < n; i++) method(); diff --git a/benchmark/crypto/hash-stream-creation.js b/benchmark/crypto/hash-stream-creation.js index 5ac5a4f70b5c..faaa12a9e5d4 100644 --- a/benchmark/crypto/hash-stream-creation.js +++ b/benchmark/crypto/hash-stream-creation.js @@ -13,8 +13,7 @@ const bench = common.createBenchmark(main, { api: ['legacy', 'stream'] }); -function main(conf) { - var api = conf.api; +function main({ api, type, len, out, writes, algo }) { if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) { console.error('Crypto streams not available until v0.10'); // use the legacy, just so that we can compare them. @@ -23,26 +22,26 @@ function main(conf) { var message; var encoding; - switch (conf.type) { + switch (type) { case 'asc': - message = 'a'.repeat(conf.len); + message = 'a'.repeat(len); encoding = 'ascii'; break; case 'utf': - message = 'ü'.repeat(conf.len / 2); + message = 'ü'.repeat(len / 2); encoding = 'utf8'; break; case 'buf': - message = Buffer.alloc(conf.len, 'b'); + message = Buffer.alloc(len, 'b'); break; default: - throw new Error(`unknown message type: ${conf.type}`); + throw new Error(`unknown message type: ${type}`); } const fn = api === 'stream' ? streamWrite : legacyWrite; bench.start(); - fn(conf.algo, message, encoding, conf.writes, conf.len, conf.out); + fn(algo, message, encoding, writes, len, out); } function legacyWrite(algo, message, encoding, writes, len, outEnc) { diff --git a/benchmark/crypto/hash-stream-throughput.js b/benchmark/crypto/hash-stream-throughput.js index 21ec3c7902b3..934e7a0b11bd 100644 --- a/benchmark/crypto/hash-stream-throughput.js +++ b/benchmark/crypto/hash-stream-throughput.js @@ -12,8 +12,7 @@ const bench = common.createBenchmark(main, { api: ['legacy', 'stream'] }); -function main(conf) { - var api = conf.api; +function main({ api, type, len, algo, writes }) { if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) { console.error('Crypto streams not available until v0.10'); // use the legacy, just so that we can compare them. @@ -22,26 +21,26 @@ function main(conf) { var message; var encoding; - switch (conf.type) { + switch (type) { case 'asc': - message = 'a'.repeat(conf.len); + message = 'a'.repeat(len); encoding = 'ascii'; break; case 'utf': - message = 'ü'.repeat(conf.len / 2); + message = 'ü'.repeat(len / 2); encoding = 'utf8'; break; case 'buf': - message = Buffer.alloc(conf.len, 'b'); + message = Buffer.alloc(len, 'b'); break; default: - throw new Error(`unknown message type: ${conf.type}`); + throw new Error(`unknown message type: ${type}`); } const fn = api === 'stream' ? streamWrite : legacyWrite; bench.start(); - fn(conf.algo, message, encoding, conf.writes, conf.len); + fn(algo, message, encoding, writes, len); } function legacyWrite(algo, message, encoding, writes, len) { diff --git a/benchmark/crypto/rsa-encrypt-decrypt-throughput.js b/benchmark/crypto/rsa-encrypt-decrypt-throughput.js index edab5ae08f7d..40b69c31f977 100644 --- a/benchmark/crypto/rsa-encrypt-decrypt-throughput.js +++ b/benchmark/crypto/rsa-encrypt-decrypt-throughput.js @@ -22,10 +22,10 @@ const bench = common.createBenchmark(main, { len: [16, 32, 64] }); -function main(conf) { - const message = Buffer.alloc(conf.len, 'b'); +function main({ len, algo, keylen, n }) { + const message = Buffer.alloc(len, 'b'); bench.start(); - StreamWrite(conf.algo, conf.keylen, message, conf.n, conf.len); + StreamWrite(algo, keylen, message, n, len); } function StreamWrite(algo, keylen, message, n, len) { diff --git a/benchmark/crypto/rsa-sign-verify-throughput.js b/benchmark/crypto/rsa-sign-verify-throughput.js index bcde3a43d4d7..3a0373b57d0b 100644 --- a/benchmark/crypto/rsa-sign-verify-throughput.js +++ b/benchmark/crypto/rsa-sign-verify-throughput.js @@ -23,10 +23,10 @@ const bench = common.createBenchmark(main, { len: [1024, 102400, 2 * 102400, 3 * 102400, 1024 * 1024] }); -function main(conf) { - const message = Buffer.alloc(conf.len, 'b'); +function main({ len, algo, keylen, writes }) { + const message = Buffer.alloc(len, 'b'); bench.start(); - StreamWrite(conf.algo, conf.keylen, message, conf.writes, conf.len); + StreamWrite(algo, keylen, message, writes, len); } function StreamWrite(algo, keylen, message, writes, len) { From ecb3fd515eb7de57203da287628c87d2c1801e4c Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 23 Jan 2018 13:18:12 +0100 Subject: [PATCH 54/59] benchmark: (url) refactor PR-URL: https://github.com/nodejs/node/pull/18320 Reviewed-By: James M Snell --- .../url/legacy-vs-whatwg-url-get-prop.js | 4 +- benchmark/url/legacy-vs-whatwg-url-parse.js | 4 +- ...legacy-vs-whatwg-url-searchparams-parse.js | 4 +- ...cy-vs-whatwg-url-searchparams-serialize.js | 4 +- .../url/legacy-vs-whatwg-url-serialize.js | 4 +- benchmark/url/url-searchparams-iteration.js | 2 +- benchmark/url/url-searchparams-read.js | 45 +++---------------- benchmark/url/url-searchparams-sort.js | 3 +- 8 files changed, 17 insertions(+), 53 deletions(-) diff --git a/benchmark/url/legacy-vs-whatwg-url-get-prop.js b/benchmark/url/legacy-vs-whatwg-url-get-prop.js index 229a4e60652b..f55c0f5783ec 100644 --- a/benchmark/url/legacy-vs-whatwg-url-get-prop.js +++ b/benchmark/url/legacy-vs-whatwg-url-get-prop.js @@ -78,7 +78,7 @@ function main(conf) { const input = inputs[type]; if (!input) { - throw new Error('Unknown input type'); + throw new Error(`Unknown input type "${type}"`); } var noDead; // Avoid dead code elimination. @@ -90,7 +90,7 @@ function main(conf) { noDead = useWHATWG(n, input); break; default: - throw new Error('Unknown method'); + throw new Error(`Unknown method "${method}"`); } assert.ok(noDead); diff --git a/benchmark/url/legacy-vs-whatwg-url-parse.js b/benchmark/url/legacy-vs-whatwg-url-parse.js index ec386b7b8559..aefb70a72136 100644 --- a/benchmark/url/legacy-vs-whatwg-url-parse.js +++ b/benchmark/url/legacy-vs-whatwg-url-parse.js @@ -38,7 +38,7 @@ function main(conf) { const input = inputs[type]; if (!input) { - throw new Error('Unknown input type'); + throw new Error(`Unknown input type "${type}"`); } var noDead; // Avoid dead code elimination. @@ -50,7 +50,7 @@ function main(conf) { noDead = useWHATWG(n, input); break; default: - throw new Error('Unknown method'); + throw new Error(`Unknown method ${method}`); } assert.ok(noDead); diff --git a/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js b/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js index b4a80af4e5ea..c2ec24ad3a51 100644 --- a/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js +++ b/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js @@ -35,7 +35,7 @@ function main(conf) { const input = inputs[type]; if (!input) { - throw new Error('Unknown input type'); + throw new Error(`Unknown input type "${type}"`); } switch (method) { @@ -46,6 +46,6 @@ function main(conf) { useWHATWG(n, input); break; default: - throw new Error('Unknown method'); + throw new Error(`Unknown method ${method}`); } } diff --git a/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js b/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js index 2b8d2c36a810..c7284572bd2f 100644 --- a/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js +++ b/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js @@ -37,7 +37,7 @@ function main(conf) { const input = inputs[type]; if (!input) { - throw new Error('Unknown input type'); + throw new Error(`Unknown input type "${type}"`); } switch (method) { @@ -48,6 +48,6 @@ function main(conf) { useWHATWG(n, input); break; default: - throw new Error('Unknown method'); + throw new Error(`Unknown method ${method}`); } } diff --git a/benchmark/url/legacy-vs-whatwg-url-serialize.js b/benchmark/url/legacy-vs-whatwg-url-serialize.js index 35b459a10c0e..2d1492192c0a 100644 --- a/benchmark/url/legacy-vs-whatwg-url-serialize.js +++ b/benchmark/url/legacy-vs-whatwg-url-serialize.js @@ -40,7 +40,7 @@ function main(conf) { const input = inputs[type]; if (!input) { - throw new Error('Unknown input type'); + throw new Error(`Unknown input type "${type}"`); } var noDead; // Avoid dead code elimination. @@ -52,7 +52,7 @@ function main(conf) { noDead = useWHATWG(n, input); break; default: - throw new Error('Unknown method'); + throw new Error(`Unknown method ${method}`); } assert.ok(noDead); diff --git a/benchmark/url/url-searchparams-iteration.js b/benchmark/url/url-searchparams-iteration.js index 0f4b71a0a183..6984cf3ce3b6 100644 --- a/benchmark/url/url-searchparams-iteration.js +++ b/benchmark/url/url-searchparams-iteration.js @@ -56,6 +56,6 @@ function main(conf) { iterator(n); break; default: - throw new Error('Unknown method'); + throw new Error(`Unknown method ${method}`); } } diff --git a/benchmark/url/url-searchparams-read.js b/benchmark/url/url-searchparams-read.js index 762ffcca03d6..0cf66dabbc36 100644 --- a/benchmark/url/url-searchparams-read.js +++ b/benchmark/url/url-searchparams-read.js @@ -10,49 +10,14 @@ const bench = common.createBenchmark(main, { const str = 'one=single&two=first&three=first&two=2nd&three=2nd&three=3rd'; -function get(n, param) { +function main({ method, param, n }) { const params = new URLSearchParams(str); + const fn = params[method]; + if (!fn) + throw new Error(`Unknown method ${method}`); bench.start(); for (var i = 0; i < n; i += 1) - params.get(param); + fn(param); bench.end(n); } - -function getAll(n, param) { - const params = new URLSearchParams(str); - - bench.start(); - for (var i = 0; i < n; i += 1) - params.getAll(param); - bench.end(n); -} - -function has(n, param) { - const params = new URLSearchParams(str); - - bench.start(); - for (var i = 0; i < n; i += 1) - params.has(param); - bench.end(n); -} - -function main(conf) { - const method = conf.method; - const param = conf.param; - const n = conf.n | 0; - - switch (method) { - case 'get': - get(n, param); - break; - case 'getAll': - getAll(n, param); - break; - case 'has': - has(n, param); - break; - default: - throw new Error('Unknown method'); - } -} diff --git a/benchmark/url/url-searchparams-sort.js b/benchmark/url/url-searchparams-sort.js index 677ce511cf3e..d37740b67098 100644 --- a/benchmark/url/url-searchparams-sort.js +++ b/benchmark/url/url-searchparams-sort.js @@ -38,9 +38,8 @@ function main(conf) { const params = new URLSearchParams(); const array = getParams(input); - var i; bench.start(); - for (i = 0; i < n; i++) { + for (var i = 0; i < n; i++) { params[searchParams] = array.slice(); params.sort(); } From cf8a4af8ed0a1fe961168615b95051d8624fc53d Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 23 Jan 2018 13:18:30 +0100 Subject: [PATCH 55/59] benchmark: (es) refactor PR-URL: https://github.com/nodejs/node/pull/18320 Reviewed-By: James M Snell --- benchmark/es/defaultparams-bench.js | 28 ++++------ benchmark/es/destructuring-bench.js | 23 ++++---- benchmark/es/destructuring-object-bench.js | 23 ++++---- benchmark/es/foreach-bench.js | 46 ++++++++-------- benchmark/es/map-bench.js | 61 +++++++++++----------- benchmark/es/restparams-bench.js | 41 +++++++-------- benchmark/es/spread-bench.js | 21 +++++--- benchmark/es/string-concatenations.js | 6 ++- benchmark/es/string-repeat.js | 2 +- 9 files changed, 131 insertions(+), 120 deletions(-) diff --git a/benchmark/es/defaultparams-bench.js b/benchmark/es/defaultparams-bench.js index 1393abbe5439..a00b50137c1a 100644 --- a/benchmark/es/defaultparams-bench.js +++ b/benchmark/es/defaultparams-bench.js @@ -20,37 +20,31 @@ function defaultParams(x = 1, y = 2) { assert.strictEqual(y, 2); } -function runOldStyleDefaults(n) { - - var i = 0; +function runOldStyleDefaults(millions) { bench.start(); - for (; i < n; i++) + for (var i = 0; i < millions * 1e6; i++) oldStyleDefaults(); - bench.end(n / 1e6); + bench.end(millions); } -function runDefaultParams(n) { - - var i = 0; +function runDefaultParams(millions) { bench.start(); - for (; i < n; i++) + for (var i = 0; i < millions * 1e6; i++) defaultParams(); - bench.end(n / 1e6); + bench.end(millions); } -function main(conf) { - const n = +conf.millions * 1e6; - - switch (conf.method) { +function main({ millions, method }) { + switch (method) { case '': // Empty string falls through to next line as default, mostly for tests. case 'withoutdefaults': - runOldStyleDefaults(n); + runOldStyleDefaults(millions); break; case 'withdefaults': - runDefaultParams(n); + runDefaultParams(millions); break; default: - throw new Error('Unexpected method'); + throw new Error(`Unexpected method "${method}"`); } } diff --git a/benchmark/es/destructuring-bench.js b/benchmark/es/destructuring-bench.js index a6c9a81ae028..c508c49d7316 100644 --- a/benchmark/es/destructuring-bench.js +++ b/benchmark/es/destructuring-bench.js @@ -8,10 +8,10 @@ const bench = common.createBenchmark(main, { millions: [100] }); -function runSwapManual(n) { +function runSwapManual(millions) { var x, y, r; bench.start(); - for (var i = 0; i < n; i++) { + for (var i = 0; i < millions * 1e6; i++) { x = 1, y = 2; r = x; x = y; @@ -19,34 +19,39 @@ function runSwapManual(n) { assert.strictEqual(x, 2); assert.strictEqual(y, 1); } - bench.end(n / 1e6); + bench.end(millions); } -function runSwapDestructured(n) { +function runSwapDestructured(millions) { var x, y; bench.start(); - for (var i = 0; i < n; i++) { + for (var i = 0; i < millions * 1e6; i++) { x = 1, y = 2; [x, y] = [y, x]; assert.strictEqual(x, 2); assert.strictEqual(y, 1); } - bench.end(n / 1e6); + bench.end(millions); } +<<<<<<< HEAD function main(conf) { const n = +conf.millions * 1e6; switch (conf.method) { +======= +function main({ millions, method }) { + switch (method) { +>>>>>>> 2072f343ad... benchmark: (es) refactor case '': // Empty string falls through to next line as default, mostly for tests. case 'swap': - runSwapManual(n); + runSwapManual(millions); break; case 'destructure': - runSwapDestructured(n); + runSwapDestructured(millions); break; default: - throw new Error('Unexpected method'); + throw new Error(`Unexpected method "${method}"`); } } diff --git a/benchmark/es/destructuring-object-bench.js b/benchmark/es/destructuring-object-bench.js index 63e085a24244..71494df86226 100644 --- a/benchmark/es/destructuring-object-bench.js +++ b/benchmark/es/destructuring-object-bench.js @@ -7,45 +7,50 @@ const bench = common.createBenchmark(main, { millions: [100] }); -function runNormal(n) { +function runNormal(millions) { var i = 0; const o = { x: 0, y: 1 }; bench.start(); - for (; i < n; i++) { + for (; i < millions * 1e6; i++) { /* eslint-disable no-unused-vars */ const x = o.x; const y = o.y; const r = o.r || 2; /* eslint-enable no-unused-vars */ } - bench.end(n / 1e6); + bench.end(millions); } -function runDestructured(n) { +function runDestructured(millions) { var i = 0; const o = { x: 0, y: 1 }; bench.start(); - for (; i < n; i++) { + for (; i < millions * 1e6; i++) { /* eslint-disable no-unused-vars */ const { x, y, r = 2 } = o; /* eslint-enable no-unused-vars */ } - bench.end(n / 1e6); + bench.end(millions); } +<<<<<<< HEAD function main(conf) { const n = +conf.millions * 1e6; switch (conf.method) { +======= +function main({ millions, method }) { + switch (method) { +>>>>>>> 2072f343ad... benchmark: (es) refactor case '': // Empty string falls through to next line as default, mostly for tests. case 'normal': - runNormal(n); + runNormal(millions); break; case 'destructureObject': - runDestructured(n); + runDestructured(millions); break; default: - throw new Error('Unexpected method'); + throw new Error(`Unexpected method "${method}"`); } } diff --git a/benchmark/es/foreach-bench.js b/benchmark/es/foreach-bench.js index 62aa02236fc7..60bf8d71a4b5 100644 --- a/benchmark/es/foreach-bench.js +++ b/benchmark/es/foreach-bench.js @@ -8,58 +8,58 @@ const bench = common.createBenchmark(main, { millions: [5] }); -function useFor(n, items, count) { - var i, j; +function useFor(millions, items, count) { bench.start(); - for (i = 0; i < n; i++) { - for (j = 0; j < count; j++) { + for (var i = 0; i < millions * 1e6; i++) { + for (var j = 0; j < count; j++) { /* eslint-disable no-unused-vars */ const item = items[j]; /* esline-enable no-unused-vars */ } } - bench.end(n / 1e6); + bench.end(millions); } -function useForOf(n, items) { - var i, item; +function useForOf(millions, items) { + var item; bench.start(); - for (i = 0; i < n; i++) { + for (var i = 0; i < millions * 1e6; i++) { for (item of items) {} } - bench.end(n / 1e6); + bench.end(millions); } -function useForIn(n, items) { - var i, j, item; +function useForIn(millions, items) { bench.start(); - for (i = 0; i < n; i++) { - for (j in items) { + for (var i = 0; i < millions * 1e6; i++) { + for (var j in items) { /* eslint-disable no-unused-vars */ - item = items[j]; + const item = items[j]; /* esline-enable no-unused-vars */ } } - bench.end(n / 1e6); + bench.end(millions); } -function useForEach(n, items) { - var i; +function useForEach(millions, items) { bench.start(); - for (i = 0; i < n; i++) { + for (var i = 0; i < millions * 1e6; i++) { items.forEach((item) => {}); } - bench.end(n / 1e6); + bench.end(millions); } +<<<<<<< HEAD function main(conf) { const n = +conf.millions * 1e6; const count = +conf.count; +======= +function main({ millions, count, method }) { +>>>>>>> 2072f343ad... benchmark: (es) refactor const items = new Array(count); - var i; var fn; - for (i = 0; i < count; i++) + for (var i = 0; i < count; i++) items[i] = i; switch (conf.method) { @@ -78,7 +78,7 @@ function main(conf) { fn = useForEach; break; default: - throw new Error('Unexpected method'); + throw new Error(`Unexpected method "${method}"`); } - fn(n, items, count); + fn(millions, items, count); } diff --git a/benchmark/es/map-bench.js b/benchmark/es/map-bench.js index 035ed1a22aaf..03f4511dae5f 100644 --- a/benchmark/es/map-bench.js +++ b/benchmark/es/map-bench.js @@ -11,63 +11,59 @@ const bench = common.createBenchmark(main, { millions: [1] }); -function runObject(n) { +function runObject(millions) { const m = {}; - var i = 0; bench.start(); - for (; i < n; i++) { + for (var i = 0; i < millions * 1e6; i++) { m[`i${i}`] = i; m[`s${i}`] = String(i); assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]); m[`i${i}`] = undefined; m[`s${i}`] = undefined; } - bench.end(n / 1e6); + bench.end(millions); } -function runNullProtoObject(n) { +function runNullProtoObject(millions) { const m = Object.create(null); - var i = 0; bench.start(); - for (; i < n; i++) { + for (var i = 0; i < millions * 1e6; i++) { m[`i${i}`] = i; m[`s${i}`] = String(i); assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]); m[`i${i}`] = undefined; m[`s${i}`] = undefined; } - bench.end(n / 1e6); + bench.end(millions); } -function runNullProtoLiteralObject(n) { +function runNullProtoLiteralObject(millions) { const m = { __proto__: null }; - var i = 0; bench.start(); - for (; i < n; i++) { + for (var i = 0; i < millions * 1e6; i++) { m[`i${i}`] = i; m[`s${i}`] = String(i); assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]); m[`i${i}`] = undefined; m[`s${i}`] = undefined; } - bench.end(n / 1e6); + bench.end(millions); } function StorageObject() {} StorageObject.prototype = Object.create(null); -function runStorageObject(n) { +function runStorageObject(millions) { const m = new StorageObject(); - var i = 0; bench.start(); - for (; i < n; i++) { + for (var i = 0; i < millions * 1e6; i++) { m[`i${i}`] = i; m[`s${i}`] = String(i); assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]); m[`i${i}`] = undefined; m[`s${i}`] = undefined; } - bench.end(n / 1e6); + bench.end(millions); } function fakeMap() { @@ -80,59 +76,62 @@ function fakeMap() { }; } -function runFakeMap(n) { +function runFakeMap(millions) { const m = fakeMap(); - var i = 0; bench.start(); - for (; i < n; i++) { + for (var i = 0; i < millions * 1e6; i++) { m.set(`i${i}`, i); m.set(`s${i}`, String(i)); assert.strictEqual(String(m.get(`i${i}`)), m.get(`s${i}`)); m.set(`i${i}`, undefined); m.set(`s${i}`, undefined); } - bench.end(n / 1e6); + bench.end(millions); } -function runMap(n) { +function runMap(millions) { const m = new Map(); - var i = 0; bench.start(); - for (; i < n; i++) { + for (var i = 0; i < millions * 1e6; i++) { m.set(`i${i}`, i); m.set(`s${i}`, String(i)); assert.strictEqual(String(m.get(`i${i}`)), m.get(`s${i}`)); m.set(`i${i}`, undefined); m.set(`s${i}`, undefined); } - bench.end(n / 1e6); + bench.end(millions); } +<<<<<<< HEAD function main(conf) { const n = +conf.millions * 1e6; switch (conf.method) { +======= +function main({ millions, method }) { + switch (method) { +>>>>>>> 2072f343ad... benchmark: (es) refactor case '': // Empty string falls through to next line as default, mostly for tests. case 'object': - runObject(n); + runObject(millions); break; case 'nullProtoObject': - runNullProtoObject(n); + runNullProtoObject(millions); break; case 'nullProtoLiteralObject': - runNullProtoLiteralObject(n); + runNullProtoLiteralObject(millions); break; case 'storageObject': - runStorageObject(n); + runStorageObject(millions); break; case 'fakeMap': - runFakeMap(n); + runFakeMap(millions); break; case 'map': - runMap(n); + runMap(millions); break; default: - throw new Error('Unexpected method'); + throw new Error(`Unexpected method "${method}"`); } } diff --git a/benchmark/es/restparams-bench.js b/benchmark/es/restparams-bench.js index 32fa985dedb8..faf7d6ab772b 100644 --- a/benchmark/es/restparams-bench.js +++ b/benchmark/es/restparams-bench.js @@ -33,49 +33,46 @@ function useArguments() { assert.strictEqual(arguments[3], 'b'); } -function runCopyArguments(n) { - - var i = 0; - bench.start(); - for (; i < n; i++) +function runCopyArguments(millions) { + for (var i = 0; i < millions * 1e6; i++) copyArguments(1, 2, 'a', 'b'); - bench.end(n / 1e6); } -function runRestArguments(n) { - - var i = 0; - bench.start(); - for (; i < n; i++) +function runRestArguments(millions) { + for (var i = 0; i < millions * 1e6; i++) restArguments(1, 2, 'a', 'b'); - bench.end(n / 1e6); } -function runUseArguments(n) { - - var i = 0; - bench.start(); - for (; i < n; i++) +function runUseArguments(millions) { + for (var i = 0; i < millions * 1e6; i++) useArguments(1, 2, 'a', 'b'); - bench.end(n / 1e6); } +<<<<<<< HEAD function main(conf) { const n = +conf.millions * 1e6; switch (conf.method) { +======= +function main({ millions, method }) { + var fn; + switch (method) { +>>>>>>> 2072f343ad... benchmark: (es) refactor case '': // Empty string falls through to next line as default, mostly for tests. case 'copy': - runCopyArguments(n); + fn = runCopyArguments; break; case 'rest': - runRestArguments(n); + fn = runRestArguments; break; case 'arguments': - runUseArguments(n); + fn = runUseArguments; break; default: - throw new Error('Unexpected method'); + throw new Error(`Unexpected method "${method}"`); } + bench.start(); + fn(millions); + bench.end(millions); } diff --git a/benchmark/es/spread-bench.js b/benchmark/es/spread-bench.js index b6dfb5963e7a..c20d7fa22aaa 100644 --- a/benchmark/es/spread-bench.js +++ b/benchmark/es/spread-bench.js @@ -23,11 +23,18 @@ function makeTest(count, rest) { } } +<<<<<<< HEAD function main(conf) { const n = +conf.millions * 1e6; const ctx = conf.context === 'context' ? {} : null; var fn = makeTest(conf.count, conf.rest); const args = new Array(conf.count); +======= +function main({ millions, context, count, rest, method }) { + const ctx = context === 'context' ? {} : null; + var fn = makeTest(count, rest); + const args = new Array(count); +>>>>>>> 2072f343ad... benchmark: (es) refactor var i; for (i = 0; i < conf.count; i++) args[i] = i; @@ -37,25 +44,25 @@ function main(conf) { // Empty string falls through to next line as default, mostly for tests. case 'apply': bench.start(); - for (i = 0; i < n; i++) + for (i = 0; i < millions * 1e6; i++) fn.apply(ctx, args); - bench.end(n / 1e6); + bench.end(millions); break; case 'spread': if (ctx !== null) fn = fn.bind(ctx); bench.start(); - for (i = 0; i < n; i++) + for (i = 0; i < millions * 1e6; i++) fn(...args); - bench.end(n / 1e6); + bench.end(millions); break; case 'call-spread': bench.start(); - for (i = 0; i < n; i++) + for (i = 0; i < millions * 1e6; i++) fn.call(ctx, ...args); - bench.end(n / 1e6); + bench.end(millions); break; default: - throw new Error('Unexpected method'); + throw new Error(`Unexpected method "${method}"`); } } diff --git a/benchmark/es/string-concatenations.js b/benchmark/es/string-concatenations.js index b7f5c319361c..a91568904954 100644 --- a/benchmark/es/string-concatenations.js +++ b/benchmark/es/string-concatenations.js @@ -16,10 +16,14 @@ const configs = { const bench = common.createBenchmark(main, configs); +<<<<<<< HEAD function main(conf) { const n = +conf.n; +======= +function main({ n, mode }) { +>>>>>>> 2072f343ad... benchmark: (es) refactor const str = 'abc'; const num = 123; @@ -65,7 +69,7 @@ function main(conf) { bench.end(n); break; default: - throw new Error('Unexpected method'); + throw new Error(`Unexpected method "${mode}"`); } return string; diff --git a/benchmark/es/string-repeat.js b/benchmark/es/string-repeat.js index 1ddc7db78c7f..c1c8ce8cd0ce 100644 --- a/benchmark/es/string-repeat.js +++ b/benchmark/es/string-repeat.js @@ -35,7 +35,7 @@ function main(conf) { bench.end(n); break; default: - throw new Error('Unexpected method'); + throw new Error(`Unexpected method "${mode}"`); } assert.strictEqual([...str].length, size); From 8a977570468f46ba745e57314ee4646f1946b3e3 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 23 Jan 2018 13:18:55 +0100 Subject: [PATCH 56/59] benchmark: (http(2)) refactor PR-URL: https://github.com/nodejs/node/pull/18320 Reviewed-By: James M Snell --- benchmark/http/bench-parser.js | 7 +--- benchmark/http/simple.js | 3 +- benchmark/http/upgrade.js | 51 ++++++++++++++++++++++++++++++ benchmark/http2/respond-with-fd.js | 3 +- benchmark/http2/simple.js | 5 +-- benchmark/http2/write.js | 3 +- 6 files changed, 56 insertions(+), 16 deletions(-) create mode 100644 benchmark/http/upgrade.js diff --git a/benchmark/http/bench-parser.js b/benchmark/http/bench-parser.js index 1bc661e72891..d629fe67e59e 100644 --- a/benchmark/http/bench-parser.js +++ b/benchmark/http/bench-parser.js @@ -14,10 +14,7 @@ const bench = common.createBenchmark(main, { n: [1e5], }); - -function main(conf) { - const len = conf.len >>> 0; - const n = conf.n >>> 0; +function main({ len, n }) { var header = `GET /hello HTTP/1.1${CRLF}Content-Type: text/plain${CRLF}`; for (var i = 0; i < len; i++) { @@ -28,7 +25,6 @@ function main(conf) { processHeader(Buffer.from(header), n); } - function processHeader(header, n) { const parser = newParser(REQUEST); @@ -40,7 +36,6 @@ function processHeader(header, n) { bench.end(n); } - function newParser(type) { const parser = new HTTPParser(type); diff --git a/benchmark/http/simple.js b/benchmark/http/simple.js index 544aad496883..0d80daa82d90 100644 --- a/benchmark/http/simple.js +++ b/benchmark/http/simple.js @@ -1,6 +1,5 @@ 'use strict'; const common = require('../common.js'); -const PORT = common.PORT; const bench = common.createBenchmark(main, { // unicode confuses ab on os x. @@ -15,7 +14,7 @@ const bench = common.createBenchmark(main, { function main(conf) { process.env.PORT = PORT; var server = require('../fixtures/simple-http-server.js') - .listen(PORT) + .listen(common.PORT) .on('listening', function() { const path = `/${conf.type}/${conf.len}/${conf.chunks}/${conf.res}/${conf.chunkedEnc}`; diff --git a/benchmark/http/upgrade.js b/benchmark/http/upgrade.js new file mode 100644 index 000000000000..6b39323396a2 --- /dev/null +++ b/benchmark/http/upgrade.js @@ -0,0 +1,51 @@ +'use strict'; + +const common = require('../common.js'); +const net = require('net'); + +const bench = common.createBenchmark(main, { + n: [5, 1000] +}); + +const reqData = 'GET / HTTP/1.1\r\n' + + 'Upgrade: WebSocket\r\n' + + 'Connection: Upgrade\r\n' + + '\r\n' + + 'WjN}|M(6'; + +const resData = 'HTTP/1.1 101 Web Socket Protocol Handshake\r\n' + + 'Upgrade: WebSocket\r\n' + + 'Connection: Upgrade\r\n' + + '\r\n\r\n'; + +function main({ n }) { + var server = require('../fixtures/simple-http-server.js') + .listen(common.PORT) + .on('listening', function() { + bench.start(); + doBench(server.address(), n, function() { + bench.end(n); + server.close(); + }); + }) + .on('upgrade', function(req, socket, upgradeHead) { + socket.resume(); + socket.write(resData); + socket.end(); + }); +} + +function doBench(address, count, done) { + if (count === 0) { + done(); + return; + } + + const conn = net.createConnection(address.port); + conn.write(reqData); + conn.resume(); + + conn.on('end', function() { + doBench(address, count - 1, done); + }); +} diff --git a/benchmark/http2/respond-with-fd.js b/benchmark/http2/respond-with-fd.js index 791e5f3d1e7d..ea29c70fffc1 100644 --- a/benchmark/http2/respond-with-fd.js +++ b/benchmark/http2/respond-with-fd.js @@ -1,7 +1,6 @@ 'use strict'; const common = require('../common.js'); -const PORT = common.PORT; const path = require('path'); const fs = require('fs'); @@ -29,7 +28,7 @@ function main(conf) { stream.respondWithFD(fd); stream.on('error', (err) => {}); }); - server.listen(PORT, () => { + server.listen(common.PORT, () => { bench.http({ path: '/', requests: n, diff --git a/benchmark/http2/simple.js b/benchmark/http2/simple.js index e8cb3ddee2df..5595c289d1d9 100644 --- a/benchmark/http2/simple.js +++ b/benchmark/http2/simple.js @@ -1,11 +1,8 @@ 'use strict'; const common = require('../common.js'); -const PORT = common.PORT; - const path = require('path'); const fs = require('fs'); - const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html'); const bench = common.createBenchmark(main, { @@ -27,7 +24,7 @@ function main(conf) { out.pipe(stream); stream.on('error', (err) => {}); }); - server.listen(PORT, () => { + server.listen(common.PORT, () => { bench.http({ path: '/', requests: n, diff --git a/benchmark/http2/write.js b/benchmark/http2/write.js index 91b9c8f0c5c0..4793d1821ba5 100644 --- a/benchmark/http2/write.js +++ b/benchmark/http2/write.js @@ -1,7 +1,6 @@ 'use strict'; const common = require('../common.js'); -const PORT = common.PORT; const bench = common.createBenchmark(main, { streams: [100, 200, 1000], @@ -29,7 +28,7 @@ function main(conf) { } write(); }); - server.listen(PORT, () => { + server.listen(common.PORT, () => { bench.http({ path: '/', requests: 10000, From b18674167af8f1d2591307beab14ddb6a1ae76ba Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 23 Jan 2018 13:19:14 +0100 Subject: [PATCH 57/59] benchmark: (timers) refactor PR-URL: https://github.com/nodejs/node/pull/18320 Reviewed-By: James M Snell --- benchmark/timers/set-immediate-breadth.js | 2 +- benchmark/timers/set-immediate-depth-args.js | 2 +- benchmark/timers/timers-cancel-pooled.js | 2 +- benchmark/timers/timers-cancel-unpooled.js | 2 +- benchmark/timers/timers-insert-unpooled.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/benchmark/timers/set-immediate-breadth.js b/benchmark/timers/set-immediate-breadth.js index 3d8b03834263..7b61c1521e4d 100644 --- a/benchmark/timers/set-immediate-breadth.js +++ b/benchmark/timers/set-immediate-breadth.js @@ -9,7 +9,7 @@ function main(conf) { const N = +conf.millions * 1e6; process.on('exit', function() { - bench.end(N / 1e6); + bench.end(millions); }); function cb() {} diff --git a/benchmark/timers/set-immediate-depth-args.js b/benchmark/timers/set-immediate-depth-args.js index 1f12ae6ec73f..654e0df9084c 100644 --- a/benchmark/timers/set-immediate-depth-args.js +++ b/benchmark/timers/set-immediate-depth-args.js @@ -9,7 +9,7 @@ function main(conf) { const N = +conf.millions * 1e6; process.on('exit', function() { - bench.end(N / 1e6); + bench.end(millions); }); function cb3(n, arg2, arg3) { diff --git a/benchmark/timers/timers-cancel-pooled.js b/benchmark/timers/timers-cancel-pooled.js index 2e834cc4db53..7e6105c4ad6c 100644 --- a/benchmark/timers/timers-cancel-pooled.js +++ b/benchmark/timers/timers-cancel-pooled.js @@ -28,5 +28,5 @@ function main(conf) { } function cb() { - assert(false, 'Timer should not call callback'); + assert.fail('Timer should not call callback'); } diff --git a/benchmark/timers/timers-cancel-unpooled.js b/benchmark/timers/timers-cancel-unpooled.js index ca3c0dbcd92c..8f8dee8be5ae 100644 --- a/benchmark/timers/timers-cancel-unpooled.js +++ b/benchmark/timers/timers-cancel-unpooled.js @@ -22,5 +22,5 @@ function main(conf) { } function cb() { - assert(false, `Timer ${this._idleTimeout} should not call callback`); + assert.fail(`Timer ${this._idleTimeout} should not call callback`); } diff --git a/benchmark/timers/timers-insert-unpooled.js b/benchmark/timers/timers-insert-unpooled.js index 984156258620..6eabdf499e14 100644 --- a/benchmark/timers/timers-insert-unpooled.js +++ b/benchmark/timers/timers-insert-unpooled.js @@ -23,5 +23,5 @@ function main(conf) { } function cb() { - assert(false, `Timer ${this._idleTimeout} should not call callback`); + assert.fail(`Timer ${this._idleTimeout} should not call callback`); } From ab4365e6480ea577b32e45b98f4e2ea092437cef Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 23 Jan 2018 13:19:30 +0100 Subject: [PATCH 58/59] benchmark: refactor PR-URL: https://github.com/nodejs/node/pull/18320 Reviewed-By: James M Snell --- benchmark/async_hooks/gc-tracking.js | 12 ++++++++--- benchmark/dgram/bind-params.js | 14 ++++++------- benchmark/domain/domain-fn-args.js | 11 +--------- benchmark/fs/bench-realpath.js | 4 +--- benchmark/fs/bench-realpathSync.js | 25 ++++------------------ benchmark/fs/write-stream-throughput.js | 7 ------- benchmark/misc/freelist.js | 3 +-- benchmark/misc/function_call/index.js | 8 +++---- benchmark/misc/object-property-bench.js | 2 +- benchmark/misc/punycode.js | 5 ++--- benchmark/module/module-loader.js | 28 ++++++++++++------------- benchmark/tls/convertprotocols.js | 11 +++++----- benchmark/util/format.js | 3 ++- benchmark/util/inspect-array.js | 2 ++ benchmark/v8/get-stats.js | 7 ++----- benchmark/vm/run-in-context.js | 4 +--- benchmark/vm/run-in-this-context.js | 4 +--- 17 files changed, 55 insertions(+), 95 deletions(-) diff --git a/benchmark/async_hooks/gc-tracking.js b/benchmark/async_hooks/gc-tracking.js index c71c1b07aa54..a206cc1ef438 100644 --- a/benchmark/async_hooks/gc-tracking.js +++ b/benchmark/async_hooks/gc-tracking.js @@ -21,25 +21,31 @@ function endAfterGC(n) { }); } +<<<<<<< HEAD function main(conf) { const n = +conf.n; switch (conf.method) { +======= +function main({ n, method }) { + var i; + switch (method) { +>>>>>>> 1b6cb94761... benchmark: refactor case 'trackingEnabled': bench.start(); - for (let i = 0; i < n; i++) { + for (i = 0; i < n; i++) { new AsyncResource('foobar'); } endAfterGC(n); break; case 'trackingDisabled': bench.start(); - for (let i = 0; i < n; i++) { + for (i = 0; i < n; i++) { new AsyncResource('foobar', { requireManualDestroy: true }); } endAfterGC(n); break; default: - throw new Error('Unsupported method'); + throw new Error(`Unsupported method "${method}"`); } } diff --git a/benchmark/dgram/bind-params.js b/benchmark/dgram/bind-params.js index 411bef98adcf..ea1f430eed92 100644 --- a/benchmark/dgram/bind-params.js +++ b/benchmark/dgram/bind-params.js @@ -12,14 +12,14 @@ const configs = { const bench = common.createBenchmark(main, configs); const noop = () => {}; -function main(conf) { - const n = +conf.n; - const port = conf.port === 'true' ? 0 : undefined; - const address = conf.address === 'true' ? '0.0.0.0' : undefined; +function main({ n, port, address }) { + port = port === 'true' ? 0 : undefined; + address = address === 'true' ? '0.0.0.0' : undefined; + var i; if (port !== undefined && address !== undefined) { bench.start(); - for (let i = 0; i < n; i++) { + for (i = 0; i < n; i++) { dgram.createSocket('udp4').bind(port, address) .on('error', noop) .unref(); @@ -27,7 +27,7 @@ function main(conf) { bench.end(n); } else if (port !== undefined) { bench.start(); - for (let i = 0; i < n; i++) { + for (i = 0; i < n; i++) { dgram.createSocket('udp4') .bind(port) .on('error', noop) @@ -36,7 +36,7 @@ function main(conf) { bench.end(n); } else if (port === undefined && address === undefined) { bench.start(); - for (let i = 0; i < n; i++) { + for (i = 0; i < n; i++) { dgram.createSocket('udp4') .bind() .on('error', noop) diff --git a/benchmark/domain/domain-fn-args.js b/benchmark/domain/domain-fn-args.js index 0b98d1767406..606b9f058161 100644 --- a/benchmark/domain/domain-fn-args.js +++ b/benchmark/domain/domain-fn-args.js @@ -30,15 +30,6 @@ function main(conf) { bench.end(n); } -function fn(a, b, c) { - if (!a) - a = 1; - - if (!b) - b = 2; - - if (!c) - c = 3; - +function fn(a = 1, b = 2, c = 3) { return a + b + c; } diff --git a/benchmark/fs/bench-realpath.js b/benchmark/fs/bench-realpath.js index 881bd0031f00..9b9887f2a651 100644 --- a/benchmark/fs/bench-realpath.js +++ b/benchmark/fs/bench-realpath.js @@ -19,10 +19,8 @@ function main(conf) { bench.start(); if (pathType === 'relative') relativePath(n); - else if (pathType === 'resolved') - resolvedPath(n); else - throw new Error(`unknown "pathType": ${pathType}`); + resolvedPath(n); } function relativePath(n) { diff --git a/benchmark/fs/bench-realpathSync.js b/benchmark/fs/bench-realpathSync.js index 2239d9748af6..7a01bd18cb72 100644 --- a/benchmark/fs/bench-realpathSync.js +++ b/benchmark/fs/bench-realpathSync.js @@ -14,28 +14,11 @@ const bench = common.createBenchmark(main, { }); -function main(conf) { - const n = conf.n >>> 0; - const pathType = conf.pathType; - +function main({ n, pathType }) { + const path = pathType === 'relative' ? relative_path : resolved_path; bench.start(); - if (pathType === 'relative') - relativePath(n); - else if (pathType === 'resolved') - resolvedPath(n); - else - throw new Error(`unknown "pathType": ${pathType}`); - bench.end(n); -} - -function relativePath(n) { for (var i = 0; i < n; i++) { - fs.realpathSync(relative_path); - } -} - -function resolvedPath(n) { - for (var i = 0; i < n; i++) { - fs.realpathSync(resolved_path); + fs.realpathSync(path); } + bench.end(n); } diff --git a/benchmark/fs/write-stream-throughput.js b/benchmark/fs/write-stream-throughput.js index 08f059156f2c..fc15ed1a4346 100644 --- a/benchmark/fs/write-stream-throughput.js +++ b/benchmark/fs/write-stream-throughput.js @@ -39,7 +39,6 @@ function main(conf) { try { fs.unlinkSync(filename); } catch (e) {} var started = false; - var ending = false; var ended = false; var f = fs.createWriteStream(filename); @@ -55,15 +54,9 @@ function main(conf) { function write() { - // don't try to write after we end, even if a 'drain' event comes. - // v0.8 streams are so sloppy! - if (ending) - return; - if (!started) { started = true; setTimeout(function() { - ending = true; f.end(); }, dur * 1000); bench.start(); diff --git a/benchmark/misc/freelist.js b/benchmark/misc/freelist.js index 461f4b3e4c89..6aa5a2148ff9 100644 --- a/benchmark/misc/freelist.js +++ b/benchmark/misc/freelist.js @@ -13,7 +13,6 @@ function main(conf) { const n = conf.n; const poolSize = 1000; const list = new FreeList('test', poolSize, Object); - var i; var j; const used = []; @@ -24,7 +23,7 @@ function main(conf) { bench.start(); - for (i = 0; i < n; i++) { + for (var i = 0; i < n; i++) { // Return all the items to the pool for (j = 0; j < poolSize; j++) { list.free(used[j]); diff --git a/benchmark/misc/function_call/index.js b/benchmark/misc/function_call/index.js index 6a2595d2ae18..f45abb463f3d 100644 --- a/benchmark/misc/function_call/index.js +++ b/benchmark/misc/function_call/index.js @@ -31,12 +31,10 @@ const bench = common.createBenchmark(main, { millions: [1, 10, 50] }); -function main(conf) { - const n = +conf.millions * 1e6; - - const fn = conf.type === 'cxx' ? cxx : js; +function main({ millions, type }) { + const fn = type === 'cxx' ? cxx : js; bench.start(); - for (var i = 0; i < n; i++) { + for (var i = 0; i < millions * 1e6; i++) { fn(); } bench.end(+conf.millions); diff --git a/benchmark/misc/object-property-bench.js b/benchmark/misc/object-property-bench.js index d6afd4e9c0bc..f985e3ebafa5 100644 --- a/benchmark/misc/object-property-bench.js +++ b/benchmark/misc/object-property-bench.js @@ -78,6 +78,6 @@ function main(conf) { runSymbol(n); break; default: - throw new Error('Unexpected method'); + throw new Error(`Unexpected method "${method}"`); } } diff --git a/benchmark/misc/punycode.js b/benchmark/misc/punycode.js index 40bcd7030200..4851a3bae45d 100644 --- a/benchmark/misc/punycode.js +++ b/benchmark/misc/punycode.js @@ -55,9 +55,8 @@ function runPunycode(n, val) { } function runICU(n, val) { - var i = 0; bench.start(); - for (; i < n; i++) + for (var i = 0; i < n; i++) usingICU(val); bench.end(n); } @@ -78,6 +77,6 @@ function main(conf) { } // fallthrough default: - throw new Error('Unexpected method'); + throw new Error(`Unexpected method "${method}"`); } } diff --git a/benchmark/module/module-loader.js b/benchmark/module/module-loader.js index a0b8f7b68926..58d4dcf81c93 100644 --- a/benchmark/module/module-loader.js +++ b/benchmark/module/module-loader.js @@ -12,13 +12,11 @@ const bench = common.createBenchmark(main, { useCache: ['true', 'false'] }); -function main(conf) { - const n = +conf.thousands * 1e3; - +function main({ thousands, fullPath, useCache }) { tmpdir.refresh(); try { fs.mkdirSync(benchmarkDirectory); } catch (e) {} - for (var i = 0; i <= n; i++) { + for (var i = 0; i <= thousands * 1e3; i++) { fs.mkdirSync(`${benchmarkDirectory}${i}`); fs.writeFileSync( `${benchmarkDirectory}${i}/package.json`, @@ -30,38 +28,38 @@ function main(conf) { ); } - if (conf.fullPath === 'true') - measureFull(n, conf.useCache === 'true'); + if (fullPath === 'true') + measureFull(thousands, useCache === 'true'); else - measureDir(n, conf.useCache === 'true'); + measureDir(thousands, useCache === 'true'); tmpdir.refresh(); } -function measureFull(n, useCache) { +function measureFull(thousands, useCache) { var i; if (useCache) { - for (i = 0; i <= n; i++) { + for (i = 0; i <= thousands * 1e3; i++) { require(`${benchmarkDirectory}${i}/index.js`); } } bench.start(); - for (i = 0; i <= n; i++) { + for (i = 0; i <= thousands * 1e3; i++) { require(`${benchmarkDirectory}${i}/index.js`); } - bench.end(n / 1e3); + bench.end(thousands); } -function measureDir(n, useCache) { +function measureDir(thousands, useCache) { var i; if (useCache) { - for (i = 0; i <= n; i++) { + for (i = 0; i <= thousands * 1e3; i++) { require(`${benchmarkDirectory}${i}`); } } bench.start(); - for (i = 0; i <= n; i++) { + for (i = 0; i <= thousands * 1e3; i++) { require(`${benchmarkDirectory}${i}`); } - bench.end(n / 1e3); + bench.end(thousands); } diff --git a/benchmark/tls/convertprotocols.js b/benchmark/tls/convertprotocols.js index 5d561455051a..9f4969344d1b 100644 --- a/benchmark/tls/convertprotocols.js +++ b/benchmark/tls/convertprotocols.js @@ -7,17 +7,16 @@ const bench = common.createBenchmark(main, { n: [1, 50000] }); -function main(conf) { - const n = +conf.n; - - var i = 0; +function main({ n }) { + const input = ['ABC', 'XYZ123', 'FOO']; var m = {}; // First call dominates results if (n > 1) { - tls.convertNPNProtocols(['ABC', 'XYZ123', 'FOO'], m); + tls.convertNPNProtocols(input, m); m = {}; } bench.start(); - for (; i < n; i++) tls.convertNPNProtocols(['ABC', 'XYZ123', 'FOO'], m); + for (var i = 0; i < n; i++) + tls.convertNPNProtocols(input, m); bench.end(n); } diff --git a/benchmark/util/format.js b/benchmark/util/format.js index 6f171318ee28..042b8a93ccfc 100644 --- a/benchmark/util/format.js +++ b/benchmark/util/format.js @@ -21,7 +21,8 @@ const bench = common.createBenchmark(main, { }); function main({ n, type }) { - const [first, second] = inputs[type]; + // For testing, if supplied with an empty type, default to string. + const [first, second] = inputs[type || 'string']; bench.start(); for (var i = 0; i < n; i++) { diff --git a/benchmark/util/inspect-array.js b/benchmark/util/inspect-array.js index 751e2c3c2deb..8b3c54aeb942 100644 --- a/benchmark/util/inspect-array.js +++ b/benchmark/util/inspect-array.js @@ -23,6 +23,8 @@ function main({ n, len, type }) { opts = { showHidden: true }; arr = arr.fill('denseArray'); break; + // For testing, if supplied with an empty type, default to denseArray. + case '': case 'denseArray': arr = arr.fill('denseArray'); break; diff --git a/benchmark/v8/get-stats.js b/benchmark/v8/get-stats.js index 96de75723971..84a0655f5db4 100644 --- a/benchmark/v8/get-stats.js +++ b/benchmark/v8/get-stats.js @@ -11,12 +11,9 @@ const bench = common.createBenchmark(main, { n: [1e6] }); -function main(conf) { - const n = +conf.n; - const method = conf.method; - var i = 0; +function main({ method, n }) { bench.start(); - for (; i < n; i++) + for (var i = 0; i < n; i++) v8[method](); bench.end(n); } diff --git a/benchmark/vm/run-in-context.js b/benchmark/vm/run-in-context.js index 6e26a6d0ebeb..f249f219bebc 100644 --- a/benchmark/vm/run-in-context.js +++ b/benchmark/vm/run-in-context.js @@ -19,12 +19,10 @@ function main(conf) { if (withSigintListener) process.on('SIGINT', () => {}); - var i = 0; - const contextifiedSandbox = vm.createContext(); bench.start(); - for (; i < n; i++) + for (var i = 0; i < n; i++) vm.runInContext('0', contextifiedSandbox, options); bench.end(n); } diff --git a/benchmark/vm/run-in-this-context.js b/benchmark/vm/run-in-this-context.js index a0c737f46954..b297b7a2eb7a 100644 --- a/benchmark/vm/run-in-this-context.js +++ b/benchmark/vm/run-in-this-context.js @@ -19,10 +19,8 @@ function main(conf) { if (withSigintListener) process.on('SIGINT', () => {}); - var i = 0; - bench.start(); - for (; i < n; i++) + for (var i = 0; i < n; i++) vm.runInThisContext('0', options); bench.end(n); } From 4829211801891bf34d20c0be750802fe831009b0 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Wed, 6 Jun 2018 16:20:16 +0530 Subject: [PATCH 59/59] fixup! benchmark: (es) refactor --- benchmark/async_hooks/gc-tracking.js | 7 ------- benchmark/es/destructuring-bench.js | 7 ------- benchmark/es/destructuring-object-bench.js | 7 ------- benchmark/es/foreach-bench.js | 7 ------- benchmark/es/map-bench.js | 7 ------- benchmark/es/restparams-bench.js | 7 ------- benchmark/es/spread-bench.js | 8 -------- benchmark/es/string-concatenations.js | 4 ---- 8 files changed, 54 deletions(-) diff --git a/benchmark/async_hooks/gc-tracking.js b/benchmark/async_hooks/gc-tracking.js index a206cc1ef438..d74b2bac463e 100644 --- a/benchmark/async_hooks/gc-tracking.js +++ b/benchmark/async_hooks/gc-tracking.js @@ -21,16 +21,9 @@ function endAfterGC(n) { }); } -<<<<<<< HEAD -function main(conf) { - const n = +conf.n; - - switch (conf.method) { -======= function main({ n, method }) { var i; switch (method) { ->>>>>>> 1b6cb94761... benchmark: refactor case 'trackingEnabled': bench.start(); for (i = 0; i < n; i++) { diff --git a/benchmark/es/destructuring-bench.js b/benchmark/es/destructuring-bench.js index c508c49d7316..2168940bdc44 100644 --- a/benchmark/es/destructuring-bench.js +++ b/benchmark/es/destructuring-bench.js @@ -34,15 +34,8 @@ function runSwapDestructured(millions) { bench.end(millions); } -<<<<<<< HEAD -function main(conf) { - const n = +conf.millions * 1e6; - - switch (conf.method) { -======= function main({ millions, method }) { switch (method) { ->>>>>>> 2072f343ad... benchmark: (es) refactor case '': // Empty string falls through to next line as default, mostly for tests. case 'swap': diff --git a/benchmark/es/destructuring-object-bench.js b/benchmark/es/destructuring-object-bench.js index 71494df86226..a84977c59bc2 100644 --- a/benchmark/es/destructuring-object-bench.js +++ b/benchmark/es/destructuring-object-bench.js @@ -33,15 +33,8 @@ function runDestructured(millions) { bench.end(millions); } -<<<<<<< HEAD -function main(conf) { - const n = +conf.millions * 1e6; - - switch (conf.method) { -======= function main({ millions, method }) { switch (method) { ->>>>>>> 2072f343ad... benchmark: (es) refactor case '': // Empty string falls through to next line as default, mostly for tests. case 'normal': diff --git a/benchmark/es/foreach-bench.js b/benchmark/es/foreach-bench.js index 60bf8d71a4b5..0eb19093de7e 100644 --- a/benchmark/es/foreach-bench.js +++ b/benchmark/es/foreach-bench.js @@ -49,14 +49,7 @@ function useForEach(millions, items) { bench.end(millions); } -<<<<<<< HEAD -function main(conf) { - const n = +conf.millions * 1e6; - const count = +conf.count; - -======= function main({ millions, count, method }) { ->>>>>>> 2072f343ad... benchmark: (es) refactor const items = new Array(count); var fn; for (var i = 0; i < count; i++) diff --git a/benchmark/es/map-bench.js b/benchmark/es/map-bench.js index 03f4511dae5f..445031aa9831 100644 --- a/benchmark/es/map-bench.js +++ b/benchmark/es/map-bench.js @@ -102,15 +102,8 @@ function runMap(millions) { bench.end(millions); } -<<<<<<< HEAD -function main(conf) { - const n = +conf.millions * 1e6; - - switch (conf.method) { -======= function main({ millions, method }) { switch (method) { ->>>>>>> 2072f343ad... benchmark: (es) refactor case '': // Empty string falls through to next line as default, mostly for tests. case 'object': diff --git a/benchmark/es/restparams-bench.js b/benchmark/es/restparams-bench.js index faf7d6ab772b..6ad766f10f16 100644 --- a/benchmark/es/restparams-bench.js +++ b/benchmark/es/restparams-bench.js @@ -48,16 +48,9 @@ function runUseArguments(millions) { useArguments(1, 2, 'a', 'b'); } -<<<<<<< HEAD -function main(conf) { - const n = +conf.millions * 1e6; - - switch (conf.method) { -======= function main({ millions, method }) { var fn; switch (method) { ->>>>>>> 2072f343ad... benchmark: (es) refactor case '': // Empty string falls through to next line as default, mostly for tests. case 'copy': diff --git a/benchmark/es/spread-bench.js b/benchmark/es/spread-bench.js index c20d7fa22aaa..06361fe8aa63 100644 --- a/benchmark/es/spread-bench.js +++ b/benchmark/es/spread-bench.js @@ -23,18 +23,10 @@ function makeTest(count, rest) { } } -<<<<<<< HEAD -function main(conf) { - const n = +conf.millions * 1e6; - const ctx = conf.context === 'context' ? {} : null; - var fn = makeTest(conf.count, conf.rest); - const args = new Array(conf.count); -======= function main({ millions, context, count, rest, method }) { const ctx = context === 'context' ? {} : null; var fn = makeTest(count, rest); const args = new Array(count); ->>>>>>> 2072f343ad... benchmark: (es) refactor var i; for (i = 0; i < conf.count; i++) args[i] = i; diff --git a/benchmark/es/string-concatenations.js b/benchmark/es/string-concatenations.js index a91568904954..e381259870cd 100644 --- a/benchmark/es/string-concatenations.js +++ b/benchmark/es/string-concatenations.js @@ -16,14 +16,10 @@ const configs = { const bench = common.createBenchmark(main, configs); -<<<<<<< HEAD function main(conf) { const n = +conf.n; -======= -function main({ n, mode }) { ->>>>>>> 2072f343ad... benchmark: (es) refactor const str = 'abc'; const num = 123;