From 61968843906fc6dc0729fd453343b28358e787c6 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 8 Oct 2018 16:22:48 -0400 Subject: [PATCH 001/328] doc: add WebAssembly to globals PR-URL: https://github.com/nodejs/node/pull/23339 Reviewed-By: Rich Trott Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Trivikram Kamat Reviewed-By: Vse Mozhet Byt Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen --- doc/api/globals.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/api/globals.md b/doc/api/globals.md index a9aaefeefa1203..0277f7db603ef8 100644 --- a/doc/api/globals.md +++ b/doc/api/globals.md @@ -156,6 +156,19 @@ added: v10.0.0 The WHATWG `URLSearchParams` class. See the [`URLSearchParams`][] section. +## WebAssembly + + + + +* {Object} + +The object that acts as the namespace for all W3C +[WebAssembly][webassembly-org] related functionality. See the +[Mozilla Developer Network][webassembly-mdn] for usage and compatibility. + [`__dirname`]: modules.html#modules_dirname [`__filename`]: modules.html#modules_filename [`clearImmediate`]: timers.html#timers_clearimmediate_immediate @@ -175,3 +188,5 @@ The WHATWG `URLSearchParams` class. See the [`URLSearchParams`][] section. [built-in objects]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects [module system documentation]: modules.html [timers]: timers.html +[webassembly-mdn]: https://developer.mozilla.org/en-US/docs/WebAssembly +[webassembly-org]: https://webassembly.org From 1e119eb6ae99d9d81aa6ad597b79f88aff73b026 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 8 Oct 2018 19:17:18 -0700 Subject: [PATCH 002/328] doc: remove style instruction that is not followed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove style guide instruction to place punctuation inside parentehses and quotation marks. Those are not universally correct and we do not follow those rules in cases where they are not correct. PR-URL: https://github.com/nodejs/node/pull/23346 Reviewed-By: Trivikram Kamat Reviewed-By: Sakthipriyan Vairamani Reviewed-By: James M Snell Reviewed-By: Сковорода Никита Андреевич --- doc/STYLE_GUIDE.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/STYLE_GUIDE.md b/doc/STYLE_GUIDE.md index 5d0f4f14eb2a22..6d41a77e91a3c5 100644 --- a/doc/STYLE_GUIDE.md +++ b/doc/STYLE_GUIDE.md @@ -24,8 +24,6 @@ clause — a subject, verb, and an object. * Outside of the wrapping element if the wrapping element contains only a fragment of a clause. -* Place end-of-sentence punctuation inside wrapping elements — periods go - inside parentheses and quotes, not after. * Documents must start with a level-one heading. * Prefer affixing links to inlining links — prefer `[a link][]` to `[a link](http://example.com)`. From ab90013836d5dade4bdd317823d76ddb7c16e7fb Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 8 Oct 2018 19:47:20 -0700 Subject: [PATCH 003/328] doc: remove personal pronoun from domain.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per the Style Guide, remove the use of the personal pronoun _you_ from the formal API documentation for `domain`. PR-URL: https://github.com/nodejs/node/pull/23347 Reviewed-By: Colin Ihrig Reviewed-By: Vse Mozhet Byt Reviewed-By: Anna Henningsen Reviewed-By: Sakthipriyan Vairamani Reviewed-By: James M Snell Reviewed-By: Michael Dawson Reviewed-By: Сковорода Никита Андреевич --- doc/api/domain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/domain.md b/doc/api/domain.md index 8227f9eb186212..3cd021f9d43ad8 100644 --- a/doc/api/domain.md +++ b/doc/api/domain.md @@ -38,7 +38,7 @@ Domain error handlers are not a substitute for closing down a process when an error occurs. By the very nature of how [`throw`][] works in JavaScript, there is almost -never any way to safely "pick up where you left off", without leaking +never any way to safely "pick up where it left off", without leaking references, or creating some other sort of undefined brittle state. The safest way to respond to a thrown error is to shut down the From 6603592ab4393a75f585dbf7b2085c2bfcb37a73 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 8 Oct 2018 19:48:23 -0700 Subject: [PATCH 004/328] doc: remove personal pronoun from worker_threads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per the Style Guide, remove the use of the personal pronoun _you_ from the formal API documentation for `worker_threads`. PR-URL: https://github.com/nodejs/node/pull/23347 Reviewed-By: Colin Ihrig Reviewed-By: Vse Mozhet Byt Reviewed-By: Anna Henningsen Reviewed-By: Sakthipriyan Vairamani Reviewed-By: James M Snell Reviewed-By: Michael Dawson Reviewed-By: Сковорода Никита Андреевич --- doc/api/worker_threads.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md index 37751c21bbb44d..b73787174cdc96 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -154,8 +154,8 @@ added: v10.5.0 --> Disables further sending of messages on either side of the connection. -This method can be called once you know that no further communication -will happen over this `MessagePort`. +This method can be called when no further communication will happen over this +`MessagePort`. ### port.postMessage(value[, transferList]) >=1.2.0 <1.3.0 // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 -function replaceTildes(comp, loose) { +function replaceTildes(comp, options) { return comp.trim().split(/\s+/).map(function(comp) { - return replaceTilde(comp, loose); + return replaceTilde(comp, options); }).join(' '); } -function replaceTilde(comp, loose) { - var r = loose ? re[TILDELOOSE] : re[TILDE]; +function replaceTilde(comp, options) { + if (!options || typeof options !== 'object') + options = { loose: !!options, includePrerelease: false } + var r = options.loose ? re[TILDELOOSE] : re[TILDE]; return comp.replace(r, function(_, M, m, p, pr) { debug('tilde', comp, _, M, m, p, pr); var ret; @@ -936,15 +957,17 @@ function replaceTilde(comp, loose) { // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 // ^1.2.3 --> >=1.2.3 <2.0.0 // ^1.2.0 --> >=1.2.0 <2.0.0 -function replaceCarets(comp, loose) { +function replaceCarets(comp, options) { return comp.trim().split(/\s+/).map(function(comp) { - return replaceCaret(comp, loose); + return replaceCaret(comp, options); }).join(' '); } -function replaceCaret(comp, loose) { - debug('caret', comp, loose); - var r = loose ? re[CARETLOOSE] : re[CARET]; +function replaceCaret(comp, options) { + debug('caret', comp, options); + if (!options || typeof options !== 'object') + options = { loose: !!options, includePrerelease: false } + var r = options.loose ? re[CARETLOOSE] : re[CARET]; return comp.replace(r, function(_, M, m, p, pr) { debug('caret', comp, _, M, m, p, pr); var ret; @@ -991,16 +1014,18 @@ function replaceCaret(comp, loose) { }); } -function replaceXRanges(comp, loose) { - debug('replaceXRanges', comp, loose); +function replaceXRanges(comp, options) { + debug('replaceXRanges', comp, options); return comp.split(/\s+/).map(function(comp) { - return replaceXRange(comp, loose); + return replaceXRange(comp, options); }).join(' '); } -function replaceXRange(comp, loose) { +function replaceXRange(comp, options) { comp = comp.trim(); - var r = loose ? re[XRANGELOOSE] : re[XRANGE]; + if (!options || typeof options !== 'object') + options = { loose: !!options, includePrerelease: false } + var r = options.loose ? re[XRANGELOOSE] : re[XRANGE]; return comp.replace(r, function(ret, gtlt, M, m, p, pr) { debug('xRange', comp, ret, gtlt, M, m, p, pr); var xM = isX(M); @@ -1064,8 +1089,8 @@ function replaceXRange(comp, loose) { // Because * is AND-ed with everything else in the comparator, // and '' means "any version", just remove the *s entirely. -function replaceStars(comp, loose) { - debug('replaceStars', comp, loose); +function replaceStars(comp, options) { + debug('replaceStars', comp, options); // Looseness is ignored here. star is always as loose as it gets! return comp.trim().replace(re[STAR], ''); } @@ -1109,22 +1134,25 @@ Range.prototype.test = function(version) { return false; if (typeof version === 'string') - version = new SemVer(version, this.loose); + version = new SemVer(version, this.options); for (var i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version)) + if (testSet(this.set[i], version, this.options)) return true; } return false; }; -function testSet(set, version) { +function testSet(set, version, options) { for (var i = 0; i < set.length; i++) { if (!set[i].test(version)) return false; } - if (version.prerelease.length) { + if (!options) + options = {} + + if (version.prerelease.length && !options.includePrerelease) { // Find the set of versions that are allowed to have prereleases // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 // That should allow `1.2.3-pr.2` to pass. @@ -1152,9 +1180,9 @@ function testSet(set, version) { } exports.satisfies = satisfies; -function satisfies(version, range, loose) { +function satisfies(version, range, options) { try { - range = new Range(range, loose); + range = new Range(range, options); } catch (er) { return false; } @@ -1162,19 +1190,19 @@ function satisfies(version, range, loose) { } exports.maxSatisfying = maxSatisfying; -function maxSatisfying(versions, range, loose) { +function maxSatisfying(versions, range, options) { var max = null; var maxSV = null; try { - var rangeObj = new Range(range, loose); + var rangeObj = new Range(range, options); } catch (er) { return null; } versions.forEach(function (v) { - if (rangeObj.test(v)) { // satisfies(v, range, loose) + if (rangeObj.test(v)) { // satisfies(v, range, options) if (!max || maxSV.compare(v) === -1) { // compare(max, v, true) max = v; - maxSV = new SemVer(max, loose); + maxSV = new SemVer(max, options); } } }) @@ -1182,19 +1210,19 @@ function maxSatisfying(versions, range, loose) { } exports.minSatisfying = minSatisfying; -function minSatisfying(versions, range, loose) { +function minSatisfying(versions, range, options) { var min = null; var minSV = null; try { - var rangeObj = new Range(range, loose); + var rangeObj = new Range(range, options); } catch (er) { return null; } versions.forEach(function (v) { - if (rangeObj.test(v)) { // satisfies(v, range, loose) + if (rangeObj.test(v)) { // satisfies(v, range, options) if (!min || minSV.compare(v) === 1) { // compare(min, v, true) min = v; - minSV = new SemVer(min, loose); + minSV = new SemVer(min, options); } } }) @@ -1202,11 +1230,11 @@ function minSatisfying(versions, range, loose) { } exports.validRange = validRange; -function validRange(range, loose) { +function validRange(range, options) { try { // Return '*' instead of '' so that truthiness works. // This will throw if it's invalid anyway - return new Range(range, loose).range || '*'; + return new Range(range, options).range || '*'; } catch (er) { return null; } @@ -1214,20 +1242,20 @@ function validRange(range, loose) { // Determine if version is less than all the versions possible in the range exports.ltr = ltr; -function ltr(version, range, loose) { - return outside(version, range, '<', loose); +function ltr(version, range, options) { + return outside(version, range, '<', options); } // Determine if version is greater than all the versions possible in the range. exports.gtr = gtr; -function gtr(version, range, loose) { - return outside(version, range, '>', loose); +function gtr(version, range, options) { + return outside(version, range, '>', options); } exports.outside = outside; -function outside(version, range, hilo, loose) { - version = new SemVer(version, loose); - range = new Range(range, loose); +function outside(version, range, hilo, options) { + version = new SemVer(version, options); + range = new Range(range, options); var gtfn, ltefn, ltfn, comp, ecomp; switch (hilo) { @@ -1250,7 +1278,7 @@ function outside(version, range, hilo, loose) { } // If it satisifes the range it is not outside - if (satisfies(version, range, loose)) { + if (satisfies(version, range, options)) { return false; } @@ -1269,9 +1297,9 @@ function outside(version, range, hilo, loose) { } high = high || comparator; low = low || comparator; - if (gtfn(comparator.semver, high.semver, loose)) { + if (gtfn(comparator.semver, high.semver, options)) { high = comparator; - } else if (ltfn(comparator.semver, low.semver, loose)) { + } else if (ltfn(comparator.semver, low.semver, options)) { low = comparator; } }); @@ -1295,15 +1323,15 @@ function outside(version, range, hilo, loose) { } exports.prerelease = prerelease; -function prerelease(version, loose) { - var parsed = parse(version, loose); +function prerelease(version, options) { + var parsed = parse(version, options); return (parsed && parsed.prerelease.length) ? parsed.prerelease : null; } exports.intersects = intersects; -function intersects(r1, r2, loose) { - r1 = new Range(r1, loose) - r2 = new Range(r2, loose) +function intersects(r1, r2, options) { + r1 = new Range(r1, options) + r2 = new Range(r2, options) return r1.intersects(r2) } diff --git a/tools/node_modules/eslint/node_modules/table/LICENSE b/tools/node_modules/eslint/node_modules/table/LICENSE index 7e84ea3afc0677..6c41d45cd765c2 100644 --- a/tools/node_modules/eslint/node_modules/table/LICENSE +++ b/tools/node_modules/eslint/node_modules/table/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016, Gajus Kuizinas (http://gajus.com/) +Copyright (c) 2018, Gajus Kuizinas (http://gajus.com/) All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/tools/node_modules/eslint/node_modules/table/README.md b/tools/node_modules/eslint/node_modules/table/README.md index 14e3934ea52efe..1e47185c170563 100644 --- a/tools/node_modules/eslint/node_modules/table/README.md +++ b/tools/node_modules/eslint/node_modules/table/README.md @@ -1,9 +1,11 @@ # Table -[![Travis build status](http://img.shields.io/travis/gajus/table/master.svg?style=flat)](https://travis-ci.org/gajus/table) -[![NPM version](http://img.shields.io/npm/v/table.svg?style=flat)](https://www.npmjs.com/package/table) -[![js-canonical-style](https://img.shields.io/badge/code%20style-canonical-brightgreen.svg?style=flat)](https://github.com/gajus/canonical) +[![Travis build status](http://img.shields.io/travis/gajus/table/master.svg?style=flat-square)](https://travis-ci.org/gajus/table) +[![Coveralls](https://img.shields.io/coveralls/gajus/table.svg?style=flat-square)](https://coveralls.io/github/gajus/table) +[![NPM version](http://img.shields.io/npm/v/table.svg?style=flat-square)](https://www.npmjs.org/package/table) +[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical) +[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social&label=Follow)](https://twitter.com/kuizinas) * [Table](#table) * [Features](#table-features) @@ -96,7 +98,7 @@ data = [ * Used to dynamically tell table whether to draw a line separating rows or not. * The default behavior is to always return true. * - * @typedef {function} drawJoin + * @typedef {function} drawHorizontalLine * @param {number} index * @param {number} size * @return {boolean} @@ -107,7 +109,7 @@ data = [ * @property {table~border} border * @property {table~columns[]} columns Column specific configuration. * @property {table~columns} columnDefault Default values for all columns. Column specific settings overwrite the default values. - * @property {table~drawJoin} drawHorizontalLine + * @property {table~drawHorizontalLine} drawHorizontalLine */ /** @@ -296,7 +298,7 @@ data = [ options = { /** - * @typedef {function} drawJoin + * @typedef {function} drawHorizontalLine * @param {number} index * @param {number} size * @return {boolean} @@ -309,6 +311,7 @@ options = { output = table(data, options); console.log(output); + ``` ``` @@ -321,6 +324,7 @@ console.log(output); ╟────┼────┼────╢ ║ 4A │ 4B │ 4C ║ ╚════╧════╧════╝ + ``` diff --git a/tools/node_modules/eslint/node_modules/table/dist/alignString.js b/tools/node_modules/eslint/node_modules/table/dist/alignString.js index 3a948d3afd69c7..a599ce8f9b5e1a 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/alignString.js +++ b/tools/node_modules/eslint/node_modules/table/dist/alignString.js @@ -1,58 +1,54 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; -var _lodash = require('lodash'); +var _lodash = _interopRequireDefault(require("lodash")); -var _lodash2 = _interopRequireDefault(_lodash); - -var _stringWidth = require('string-width'); - -var _stringWidth2 = _interopRequireDefault(_stringWidth); +var _stringWidth = _interopRequireDefault(require("string-width")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const alignments = ['left', 'right', 'center']; - /** * @param {string} subject * @param {number} width * @returns {string} */ + const alignLeft = (subject, width) => { return subject + ' '.repeat(width); }; - /** * @param {string} subject * @param {number} width * @returns {string} */ + + const alignRight = (subject, width) => { return ' '.repeat(width) + subject; }; - /** * @param {string} subject * @param {number} width * @returns {string} */ + + const alignCenter = (subject, width) => { let halfWidth; - halfWidth = width / 2; if (halfWidth % 2 === 0) { return ' '.repeat(halfWidth) + subject + ' '.repeat(halfWidth); } else { halfWidth = Math.floor(halfWidth); - return ' '.repeat(halfWidth) + subject + ' '.repeat(halfWidth + 1); } }; - /** * Pads a string to the left and/or right to position the subject * text in a desired alignment within a container. @@ -63,24 +59,24 @@ const alignCenter = (subject, width) => { * @returns {string} */ -exports.default = (subject, containerWidth, alignment) => { - if (!_lodash2.default.isString(subject)) { + +const alignString = (subject, containerWidth, alignment) => { + if (!_lodash.default.isString(subject)) { throw new TypeError('Subject parameter value must be a string.'); } - if (!_lodash2.default.isNumber(containerWidth)) { + if (!_lodash.default.isNumber(containerWidth)) { throw new TypeError('Container width parameter value must be a number.'); } - const subjectWidth = (0, _stringWidth2.default)(subject); + const subjectWidth = (0, _stringWidth.default)(subject); if (subjectWidth > containerWidth) { // console.log('subjectWidth', subjectWidth, 'containerWidth', containerWidth, 'subject', subject); - throw new Error('Subject parameter value width cannot be greater than the container width.'); } - if (!_lodash2.default.isString(alignment)) { + if (!_lodash.default.isString(alignment)) { throw new TypeError('Alignment parameter value must be a string.'); } @@ -103,4 +99,8 @@ exports.default = (subject, containerWidth, alignment) => { } return alignCenter(subject, availableWidth); -}; \ No newline at end of file +}; + +var _default = alignString; +exports.default = _default; +//# sourceMappingURL=alignString.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/alignString.js.flow b/tools/node_modules/eslint/node_modules/table/dist/alignString.js.flow new file mode 100644 index 00000000000000..16936a44c14dcf --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/alignString.js.flow @@ -0,0 +1,96 @@ +import _ from 'lodash'; +import stringWidth from 'string-width'; + +const alignments = [ + 'left', + 'right', + 'center' +]; + +/** + * @param {string} subject + * @param {number} width + * @returns {string} + */ +const alignLeft = (subject, width) => { + return subject + ' '.repeat(width); +}; + +/** + * @param {string} subject + * @param {number} width + * @returns {string} + */ +const alignRight = (subject, width) => { + return ' '.repeat(width) + subject; +}; + +/** + * @param {string} subject + * @param {number} width + * @returns {string} + */ +const alignCenter = (subject, width) => { + let halfWidth; + + halfWidth = width / 2; + + if (halfWidth % 2 === 0) { + return ' '.repeat(halfWidth) + subject + ' '.repeat(halfWidth); + } else { + halfWidth = Math.floor(halfWidth); + + return ' '.repeat(halfWidth) + subject + ' '.repeat(halfWidth + 1); + } +}; + +/** + * Pads a string to the left and/or right to position the subject + * text in a desired alignment within a container. + * + * @param {string} subject + * @param {number} containerWidth + * @param {string} alignment One of the valid options (left, right, center). + * @returns {string} + */ +export default (subject, containerWidth, alignment) => { + if (!_.isString(subject)) { + throw new TypeError('Subject parameter value must be a string.'); + } + + if (!_.isNumber(containerWidth)) { + throw new TypeError('Container width parameter value must be a number.'); + } + + const subjectWidth = stringWidth(subject); + + if (subjectWidth > containerWidth) { + // console.log('subjectWidth', subjectWidth, 'containerWidth', containerWidth, 'subject', subject); + + throw new Error('Subject parameter value width cannot be greater than the container width.'); + } + + if (!_.isString(alignment)) { + throw new TypeError('Alignment parameter value must be a string.'); + } + + if (alignments.indexOf(alignment) === -1) { + throw new Error('Alignment parameter value must be a known alignment parameter value (left, right, center).'); + } + + if (subjectWidth === 0) { + return ' '.repeat(containerWidth); + } + + const availableWidth = containerWidth - subjectWidth; + + if (alignment === 'left') { + return alignLeft(subject, availableWidth); + } + + if (alignment === 'right') { + return alignRight(subject, availableWidth); + } + + return alignCenter(subject, availableWidth); +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/alignString.js.map b/tools/node_modules/eslint/node_modules/table/dist/alignString.js.map new file mode 100644 index 00000000000000..8420a3b3f31543 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/alignString.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/alignString.js"],"names":["alignments","alignLeft","subject","width","repeat","alignRight","alignCenter","halfWidth","Math","floor","containerWidth","alignment","_","isString","TypeError","isNumber","subjectWidth","Error","indexOf","availableWidth"],"mappings":";;;;;;;AAAA;;AACA;;;;AAEA,MAAMA,UAAU,GAAG,CACjB,MADiB,EAEjB,OAFiB,EAGjB,QAHiB,CAAnB;AAMA;;;;;;AAKA,MAAMC,SAAS,GAAG,CAACC,OAAD,EAAUC,KAAV,KAAoB;AACpC,SAAOD,OAAO,GAAG,IAAIE,MAAJ,CAAWD,KAAX,CAAjB;AACD,CAFD;AAIA;;;;;;;AAKA,MAAME,UAAU,GAAG,CAACH,OAAD,EAAUC,KAAV,KAAoB;AACrC,SAAO,IAAIC,MAAJ,CAAWD,KAAX,IAAoBD,OAA3B;AACD,CAFD;AAIA;;;;;;;AAKA,MAAMI,WAAW,GAAG,CAACJ,OAAD,EAAUC,KAAV,KAAoB;AACtC,MAAII,SAAJ;AAEAA,EAAAA,SAAS,GAAGJ,KAAK,GAAG,CAApB;;AAEA,MAAII,SAAS,GAAG,CAAZ,KAAkB,CAAtB,EAAyB;AACvB,WAAO,IAAIH,MAAJ,CAAWG,SAAX,IAAwBL,OAAxB,GAAkC,IAAIE,MAAJ,CAAWG,SAAX,CAAzC;AACD,GAFD,MAEO;AACLA,IAAAA,SAAS,GAAGC,IAAI,CAACC,KAAL,CAAWF,SAAX,CAAZ;AAEA,WAAO,IAAIH,MAAJ,CAAWG,SAAX,IAAwBL,OAAxB,GAAkC,IAAIE,MAAJ,CAAWG,SAAS,GAAG,CAAvB,CAAzC;AACD;AACF,CAZD;AAcA;;;;;;;;;;;qBASgBL,O,EAASQ,c,EAAgBC,S,KAAc;AACrD,MAAI,CAACC,gBAAEC,QAAF,CAAWX,OAAX,CAAL,EAA0B;AACxB,UAAM,IAAIY,SAAJ,CAAc,2CAAd,CAAN;AACD;;AAED,MAAI,CAACF,gBAAEG,QAAF,CAAWL,cAAX,CAAL,EAAiC;AAC/B,UAAM,IAAII,SAAJ,CAAc,mDAAd,CAAN;AACD;;AAED,QAAME,YAAY,GAAG,0BAAYd,OAAZ,CAArB;;AAEA,MAAIc,YAAY,GAAGN,cAAnB,EAAmC;AACjC;AAEA,UAAM,IAAIO,KAAJ,CAAU,2EAAV,CAAN;AACD;;AAED,MAAI,CAACL,gBAAEC,QAAF,CAAWF,SAAX,CAAL,EAA4B;AAC1B,UAAM,IAAIG,SAAJ,CAAc,6CAAd,CAAN;AACD;;AAED,MAAId,UAAU,CAACkB,OAAX,CAAmBP,SAAnB,MAAkC,CAAC,CAAvC,EAA0C;AACxC,UAAM,IAAIM,KAAJ,CAAU,4FAAV,CAAN;AACD;;AAED,MAAID,YAAY,KAAK,CAArB,EAAwB;AACtB,WAAO,IAAIZ,MAAJ,CAAWM,cAAX,CAAP;AACD;;AAED,QAAMS,cAAc,GAAGT,cAAc,GAAGM,YAAxC;;AAEA,MAAIL,SAAS,KAAK,MAAlB,EAA0B;AACxB,WAAOV,SAAS,CAACC,OAAD,EAAUiB,cAAV,CAAhB;AACD;;AAED,MAAIR,SAAS,KAAK,OAAlB,EAA2B;AACzB,WAAON,UAAU,CAACH,OAAD,EAAUiB,cAAV,CAAjB;AACD;;AAED,SAAOb,WAAW,CAACJ,OAAD,EAAUiB,cAAV,CAAlB;AACD,C","sourcesContent":["import _ from 'lodash';\nimport stringWidth from 'string-width';\n\nconst alignments = [\n 'left',\n 'right',\n 'center'\n];\n\n/**\n * @param {string} subject\n * @param {number} width\n * @returns {string}\n */\nconst alignLeft = (subject, width) => {\n return subject + ' '.repeat(width);\n};\n\n/**\n * @param {string} subject\n * @param {number} width\n * @returns {string}\n */\nconst alignRight = (subject, width) => {\n return ' '.repeat(width) + subject;\n};\n\n/**\n * @param {string} subject\n * @param {number} width\n * @returns {string}\n */\nconst alignCenter = (subject, width) => {\n let halfWidth;\n\n halfWidth = width / 2;\n\n if (halfWidth % 2 === 0) {\n return ' '.repeat(halfWidth) + subject + ' '.repeat(halfWidth);\n } else {\n halfWidth = Math.floor(halfWidth);\n\n return ' '.repeat(halfWidth) + subject + ' '.repeat(halfWidth + 1);\n }\n};\n\n/**\n * Pads a string to the left and/or right to position the subject\n * text in a desired alignment within a container.\n *\n * @param {string} subject\n * @param {number} containerWidth\n * @param {string} alignment One of the valid options (left, right, center).\n * @returns {string}\n */\nexport default (subject, containerWidth, alignment) => {\n if (!_.isString(subject)) {\n throw new TypeError('Subject parameter value must be a string.');\n }\n\n if (!_.isNumber(containerWidth)) {\n throw new TypeError('Container width parameter value must be a number.');\n }\n\n const subjectWidth = stringWidth(subject);\n\n if (subjectWidth > containerWidth) {\n // console.log('subjectWidth', subjectWidth, 'containerWidth', containerWidth, 'subject', subject);\n\n throw new Error('Subject parameter value width cannot be greater than the container width.');\n }\n\n if (!_.isString(alignment)) {\n throw new TypeError('Alignment parameter value must be a string.');\n }\n\n if (alignments.indexOf(alignment) === -1) {\n throw new Error('Alignment parameter value must be a known alignment parameter value (left, right, center).');\n }\n\n if (subjectWidth === 0) {\n return ' '.repeat(containerWidth);\n }\n\n const availableWidth = containerWidth - subjectWidth;\n\n if (alignment === 'left') {\n return alignLeft(subject, availableWidth);\n }\n\n if (alignment === 'right') {\n return alignRight(subject, availableWidth);\n }\n\n return alignCenter(subject, availableWidth);\n};\n"],"file":"alignString.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/alignTableData.js b/tools/node_modules/eslint/node_modules/table/dist/alignTableData.js index eb4078455355d6..e01bd552610836 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/alignTableData.js +++ b/tools/node_modules/eslint/node_modules/table/dist/alignTableData.js @@ -1,16 +1,13 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; -var _stringWidth = require('string-width'); +var _stringWidth = _interopRequireDefault(require("string-width")); -var _stringWidth2 = _interopRequireDefault(_stringWidth); - -var _alignString = require('./alignString'); - -var _alignString2 = _interopRequireDefault(_alignString); +var _alignString = _interopRequireDefault(require("./alignString")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -19,16 +16,20 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @param {Object} config * @returns {table~row[]} */ -exports.default = (rows, config) => { +const alignTableData = (rows, config) => { return rows.map(cells => { return cells.map((value, index1) => { const column = config.columns[index1]; - if ((0, _stringWidth2.default)(value) === column.width) { + if ((0, _stringWidth.default)(value) === column.width) { return value; } else { - return (0, _alignString2.default)(value, column.width, column.alignment); + return (0, _alignString.default)(value, column.width, column.alignment); } }); }); -}; \ No newline at end of file +}; + +var _default = alignTableData; +exports.default = _default; +//# sourceMappingURL=alignTableData.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/alignTableData.js.flow b/tools/node_modules/eslint/node_modules/table/dist/alignTableData.js.flow new file mode 100644 index 00000000000000..8a7be7a7e7cf5c --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/alignTableData.js.flow @@ -0,0 +1,21 @@ +import stringWidth from 'string-width'; +import alignString from './alignString'; + +/** + * @param {table~row[]} rows + * @param {Object} config + * @returns {table~row[]} + */ +export default (rows, config) => { + return rows.map((cells) => { + return cells.map((value, index1) => { + const column = config.columns[index1]; + + if (stringWidth(value) === column.width) { + return value; + } else { + return alignString(value, column.width, column.alignment); + } + }); + }); +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/alignTableData.js.map b/tools/node_modules/eslint/node_modules/table/dist/alignTableData.js.map new file mode 100644 index 00000000000000..183240f8a43d24 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/alignTableData.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/alignTableData.js"],"names":["rows","config","map","cells","value","index1","column","columns","width","alignment"],"mappings":";;;;;;;AAAA;;AACA;;;;AAEA;;;;;wBAKgBA,I,EAAMC,M,KAAW;AAC/B,SAAOD,IAAI,CAACE,GAAL,CAAUC,KAAD,IAAW;AACzB,WAAOA,KAAK,CAACD,GAAN,CAAU,CAACE,KAAD,EAAQC,MAAR,KAAmB;AAClC,YAAMC,MAAM,GAAGL,MAAM,CAACM,OAAP,CAAeF,MAAf,CAAf;;AAEA,UAAI,0BAAYD,KAAZ,MAAuBE,MAAM,CAACE,KAAlC,EAAyC;AACvC,eAAOJ,KAAP;AACD,OAFD,MAEO;AACL,eAAO,0BAAYA,KAAZ,EAAmBE,MAAM,CAACE,KAA1B,EAAiCF,MAAM,CAACG,SAAxC,CAAP;AACD;AACF,KARM,CAAP;AASD,GAVM,CAAP;AAWD,C","sourcesContent":["import stringWidth from 'string-width';\nimport alignString from './alignString';\n\n/**\n * @param {table~row[]} rows\n * @param {Object} config\n * @returns {table~row[]}\n */\nexport default (rows, config) => {\n return rows.map((cells) => {\n return cells.map((value, index1) => {\n const column = config.columns[index1];\n\n if (stringWidth(value) === column.width) {\n return value;\n } else {\n return alignString(value, column.width, column.alignment);\n }\n });\n });\n};\n"],"file":"alignTableData.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateCellHeight.js b/tools/node_modules/eslint/node_modules/table/dist/calculateCellHeight.js index 7a8973808149b1..2725ee009ea43d 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/calculateCellHeight.js +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateCellHeight.js @@ -1,20 +1,15 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; -var _lodash = require('lodash'); +var _lodash = _interopRequireDefault(require("lodash")); -var _lodash2 = _interopRequireDefault(_lodash); +var _stringWidth = _interopRequireDefault(require("string-width")); -var _stringWidth = require('string-width'); - -var _stringWidth2 = _interopRequireDefault(_stringWidth); - -var _wrapWord = require('./wrapWord'); - -var _wrapWord2 = _interopRequireDefault(_wrapWord); +var _wrapWord = _interopRequireDefault(require("./wrapWord")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -24,10 +19,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @param {boolean} useWrapWord * @returns {number} */ -exports.default = function (value, columnWidth) { - let useWrapWord = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - - if (!_lodash2.default.isString(value)) { +const calculateCellHeight = (value, columnWidth, useWrapWord = false) => { + if (!_lodash.default.isString(value)) { throw new TypeError('Value must be a string.'); } @@ -40,8 +33,12 @@ exports.default = function (value, columnWidth) { } if (useWrapWord) { - return (0, _wrapWord2.default)(value, columnWidth).length; + return (0, _wrapWord.default)(value, columnWidth).length; } - return Math.ceil((0, _stringWidth2.default)(value) / columnWidth); -}; \ No newline at end of file + return Math.ceil((0, _stringWidth.default)(value) / columnWidth); +}; + +var _default = calculateCellHeight; +exports.default = _default; +//# sourceMappingURL=calculateCellHeight.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateCellHeight.js.flow b/tools/node_modules/eslint/node_modules/table/dist/calculateCellHeight.js.flow new file mode 100644 index 00000000000000..94afd3742140e1 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateCellHeight.js.flow @@ -0,0 +1,29 @@ +import _ from 'lodash'; +import stringWidth from 'string-width'; +import wrapWord from './wrapWord'; + +/** + * @param {string} value + * @param {number} columnWidth + * @param {boolean} useWrapWord + * @returns {number} + */ +export default (value, columnWidth, useWrapWord = false) => { + if (!_.isString(value)) { + throw new TypeError('Value must be a string.'); + } + + if (!Number.isInteger(columnWidth)) { + throw new TypeError('Column width must be an integer.'); + } + + if (columnWidth < 1) { + throw new Error('Column width must be greater than 0.'); + } + + if (useWrapWord) { + return wrapWord(value, columnWidth).length; + } + + return Math.ceil(stringWidth(value) / columnWidth); +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateCellHeight.js.map b/tools/node_modules/eslint/node_modules/table/dist/calculateCellHeight.js.map new file mode 100644 index 00000000000000..43ec44038f1408 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateCellHeight.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/calculateCellHeight.js"],"names":["value","columnWidth","useWrapWord","_","isString","TypeError","Number","isInteger","Error","length","Math","ceil"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAEA;;;;;;6BAMgBA,K,EAAOC,W,EAAaC,WAAW,GAAG,K,KAAU;AAC1D,MAAI,CAACC,gBAAEC,QAAF,CAAWJ,KAAX,CAAL,EAAwB;AACtB,UAAM,IAAIK,SAAJ,CAAc,yBAAd,CAAN;AACD;;AAED,MAAI,CAACC,MAAM,CAACC,SAAP,CAAiBN,WAAjB,CAAL,EAAoC;AAClC,UAAM,IAAII,SAAJ,CAAc,kCAAd,CAAN;AACD;;AAED,MAAIJ,WAAW,GAAG,CAAlB,EAAqB;AACnB,UAAM,IAAIO,KAAJ,CAAU,sCAAV,CAAN;AACD;;AAED,MAAIN,WAAJ,EAAiB;AACf,WAAO,uBAASF,KAAT,EAAgBC,WAAhB,EAA6BQ,MAApC;AACD;;AAED,SAAOC,IAAI,CAACC,IAAL,CAAU,0BAAYX,KAAZ,IAAqBC,WAA/B,CAAP;AACD,C","sourcesContent":["import _ from 'lodash';\nimport stringWidth from 'string-width';\nimport wrapWord from './wrapWord';\n\n/**\n * @param {string} value\n * @param {number} columnWidth\n * @param {boolean} useWrapWord\n * @returns {number}\n */\nexport default (value, columnWidth, useWrapWord = false) => {\n if (!_.isString(value)) {\n throw new TypeError('Value must be a string.');\n }\n\n if (!Number.isInteger(columnWidth)) {\n throw new TypeError('Column width must be an integer.');\n }\n\n if (columnWidth < 1) {\n throw new Error('Column width must be greater than 0.');\n }\n\n if (useWrapWord) {\n return wrapWord(value, columnWidth).length;\n }\n\n return Math.ceil(stringWidth(value) / columnWidth);\n};\n"],"file":"calculateCellHeight.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateCellWidthIndex.js b/tools/node_modules/eslint/node_modules/table/dist/calculateCellWidthIndex.js index e6bf927edb7975..82b406015b8288 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/calculateCellWidthIndex.js +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateCellWidthIndex.js @@ -1,12 +1,11 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; -var _stringWidth = require('string-width'); - -var _stringWidth2 = _interopRequireDefault(_stringWidth); +var _stringWidth = _interopRequireDefault(require("string-width")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -16,8 +15,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @param {string[]} cells * @returns {number[]} */ -exports.default = cells => { +const calculateCellWidthIndex = cells => { return cells.map(value => { - return (0, _stringWidth2.default)(value); + return (0, _stringWidth.default)(value); }); -}; \ No newline at end of file +}; + +var _default = calculateCellWidthIndex; +exports.default = _default; +//# sourceMappingURL=calculateCellWidthIndex.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateCellWidthIndex.js.flow b/tools/node_modules/eslint/node_modules/table/dist/calculateCellWidthIndex.js.flow new file mode 100644 index 00000000000000..f6b90dd8c09b89 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateCellWidthIndex.js.flow @@ -0,0 +1,13 @@ +import stringWidth from 'string-width'; + +/** + * Calculates width of each cell contents. + * + * @param {string[]} cells + * @returns {number[]} + */ +export default (cells) => { + return cells.map((value) => { + return stringWidth(value); + }); +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateCellWidthIndex.js.map b/tools/node_modules/eslint/node_modules/table/dist/calculateCellWidthIndex.js.map new file mode 100644 index 00000000000000..99d1f7798da891 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateCellWidthIndex.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/calculateCellWidthIndex.js"],"names":["cells","map","value"],"mappings":";;;;;;;AAAA;;;;AAEA;;;;;;gCAMgBA,K,IAAU;AACxB,SAAOA,KAAK,CAACC,GAAN,CAAWC,KAAD,IAAW;AAC1B,WAAO,0BAAYA,KAAZ,CAAP;AACD,GAFM,CAAP;AAGD,C","sourcesContent":["import stringWidth from 'string-width';\n\n/**\n * Calculates width of each cell contents.\n *\n * @param {string[]} cells\n * @returns {number[]}\n */\nexport default (cells) => {\n return cells.map((value) => {\n return stringWidth(value);\n });\n};\n"],"file":"calculateCellWidthIndex.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js b/tools/node_modules/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js index da366c1423c79a..ea5d4b9a4bab4d 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js @@ -1,12 +1,11 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; -var _calculateCellWidthIndex = require('./calculateCellWidthIndex'); - -var _calculateCellWidthIndex2 = _interopRequireDefault(_calculateCellWidthIndex); +var _calculateCellWidthIndex = _interopRequireDefault(require("./calculateCellWidthIndex")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -16,22 +15,23 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @param {Array[]} rows * @returns {number[]} */ -exports.default = rows => { +const calculateMaximumColumnWidthIndex = rows => { if (!rows[0]) { throw new Error('Dataset must have at least one row.'); } - const columns = Array(rows[0].length).fill(0); - + const columns = new Array(rows[0].length).fill(0); rows.forEach(row => { - const columnWidthIndex = (0, _calculateCellWidthIndex2.default)(row); - + const columnWidthIndex = (0, _calculateCellWidthIndex.default)(row); columnWidthIndex.forEach((valueWidth, index0) => { if (columns[index0] < valueWidth) { columns[index0] = valueWidth; } }); }); - return columns; -}; \ No newline at end of file +}; + +var _default = calculateMaximumColumnWidthIndex; +exports.default = _default; +//# sourceMappingURL=calculateMaximumColumnWidthIndex.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js.flow b/tools/node_modules/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js.flow new file mode 100644 index 00000000000000..5c8c10981cc63b --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js.flow @@ -0,0 +1,27 @@ +import calculateCellWidthIndex from './calculateCellWidthIndex'; + +/** + * Produces an array of values that describe the largest value length (width) in every column. + * + * @param {Array[]} rows + * @returns {number[]} + */ +export default (rows) => { + if (!rows[0]) { + throw new Error('Dataset must have at least one row.'); + } + + const columns = new Array(rows[0].length).fill(0); + + rows.forEach((row) => { + const columnWidthIndex = calculateCellWidthIndex(row); + + columnWidthIndex.forEach((valueWidth, index0) => { + if (columns[index0] < valueWidth) { + columns[index0] = valueWidth; + } + }); + }); + + return columns; +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js.map b/tools/node_modules/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js.map new file mode 100644 index 00000000000000..c30f4ceecd2782 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/calculateMaximumColumnWidthIndex.js"],"names":["rows","Error","columns","Array","length","fill","forEach","row","columnWidthIndex","valueWidth","index0"],"mappings":";;;;;;;AAAA;;;;AAEA;;;;;;yCAMgBA,I,IAAS;AACvB,MAAI,CAACA,IAAI,CAAC,CAAD,CAAT,EAAc;AACZ,UAAM,IAAIC,KAAJ,CAAU,qCAAV,CAAN;AACD;;AAED,QAAMC,OAAO,GAAG,IAAIC,KAAJ,CAAUH,IAAI,CAAC,CAAD,CAAJ,CAAQI,MAAlB,EAA0BC,IAA1B,CAA+B,CAA/B,CAAhB;AAEAL,EAAAA,IAAI,CAACM,OAAL,CAAcC,GAAD,IAAS;AACpB,UAAMC,gBAAgB,GAAG,sCAAwBD,GAAxB,CAAzB;AAEAC,IAAAA,gBAAgB,CAACF,OAAjB,CAAyB,CAACG,UAAD,EAAaC,MAAb,KAAwB;AAC/C,UAAIR,OAAO,CAACQ,MAAD,CAAP,GAAkBD,UAAtB,EAAkC;AAChCP,QAAAA,OAAO,CAACQ,MAAD,CAAP,GAAkBD,UAAlB;AACD;AACF,KAJD;AAKD,GARD;AAUA,SAAOP,OAAP;AACD,C","sourcesContent":["import calculateCellWidthIndex from './calculateCellWidthIndex';\n\n/**\n * Produces an array of values that describe the largest value length (width) in every column.\n *\n * @param {Array[]} rows\n * @returns {number[]}\n */\nexport default (rows) => {\n if (!rows[0]) {\n throw new Error('Dataset must have at least one row.');\n }\n\n const columns = new Array(rows[0].length).fill(0);\n\n rows.forEach((row) => {\n const columnWidthIndex = calculateCellWidthIndex(row);\n\n columnWidthIndex.forEach((valueWidth, index0) => {\n if (columns[index0] < valueWidth) {\n columns[index0] = valueWidth;\n }\n });\n });\n\n return columns;\n};\n"],"file":"calculateMaximumColumnWidthIndex.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeightIndex.js b/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeightIndex.js index 2976ec43344c67..ad98db4040048c 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeightIndex.js +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeightIndex.js @@ -1,16 +1,13 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; -var _lodash = require('lodash'); +var _lodash = _interopRequireDefault(require("lodash")); -var _lodash2 = _interopRequireDefault(_lodash); - -var _calculateCellHeight = require('./calculateCellHeight'); - -var _calculateCellHeight2 = _interopRequireDefault(_calculateCellHeight); +var _calculateCellHeight = _interopRequireDefault(require("./calculateCellHeight")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -21,28 +18,27 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @param {Object} config * @returns {number[]} */ -exports.default = (rows, config) => { +const calculateRowHeightIndex = (rows, config) => { const tableWidth = rows[0].length; - const rowSpanIndex = []; - rows.forEach(cells => { - const cellHeightIndex = Array(tableWidth).fill(1); - + const cellHeightIndex = new Array(tableWidth).fill(1); cells.forEach((value, index1) => { - if (!_lodash2.default.isNumber(config.columns[index1].width)) { + if (!_lodash.default.isNumber(config.columns[index1].width)) { throw new TypeError('column[index].width must be a number.'); } - if (!_lodash2.default.isBoolean(config.columns[index1].wrapWord)) { + if (!_lodash.default.isBoolean(config.columns[index1].wrapWord)) { throw new TypeError('column[index].wrapWord must be a boolean.'); } - cellHeightIndex[index1] = (0, _calculateCellHeight2.default)(value, config.columns[index1].width, config.columns[index1].wrapWord); + cellHeightIndex[index1] = (0, _calculateCellHeight.default)(value, config.columns[index1].width, config.columns[index1].wrapWord); }); - - rowSpanIndex.push(_lodash2.default.max(cellHeightIndex)); + rowSpanIndex.push(_lodash.default.max(cellHeightIndex)); }); - return rowSpanIndex; -}; \ No newline at end of file +}; + +var _default = calculateRowHeightIndex; +exports.default = _default; +//# sourceMappingURL=calculateRowHeightIndex.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeightIndex.js.flow b/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeightIndex.js.flow new file mode 100644 index 00000000000000..268790264860e6 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeightIndex.js.flow @@ -0,0 +1,35 @@ +import _ from 'lodash'; +import calculateCellHeight from './calculateCellHeight'; + +/** + * Calculates the vertical row span index. + * + * @param {Array[]} rows + * @param {Object} config + * @returns {number[]} + */ +export default (rows, config) => { + const tableWidth = rows[0].length; + + const rowSpanIndex = []; + + rows.forEach((cells) => { + const cellHeightIndex = new Array(tableWidth).fill(1); + + cells.forEach((value, index1) => { + if (!_.isNumber(config.columns[index1].width)) { + throw new TypeError('column[index].width must be a number.'); + } + + if (!_.isBoolean(config.columns[index1].wrapWord)) { + throw new TypeError('column[index].wrapWord must be a boolean.'); + } + + cellHeightIndex[index1] = calculateCellHeight(value, config.columns[index1].width, config.columns[index1].wrapWord); + }); + + rowSpanIndex.push(_.max(cellHeightIndex)); + }); + + return rowSpanIndex; +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeightIndex.js.map b/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeightIndex.js.map new file mode 100644 index 00000000000000..bcd21c8e5e4354 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeightIndex.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/calculateRowHeightIndex.js"],"names":["rows","config","tableWidth","length","rowSpanIndex","forEach","cells","cellHeightIndex","Array","fill","value","index1","_","isNumber","columns","width","TypeError","isBoolean","wrapWord","push","max"],"mappings":";;;;;;;AAAA;;AACA;;;;AAEA;;;;;;;iCAOgBA,I,EAAMC,M,KAAW;AAC/B,QAAMC,UAAU,GAAGF,IAAI,CAAC,CAAD,CAAJ,CAAQG,MAA3B;AAEA,QAAMC,YAAY,GAAG,EAArB;AAEAJ,EAAAA,IAAI,CAACK,OAAL,CAAcC,KAAD,IAAW;AACtB,UAAMC,eAAe,GAAG,IAAIC,KAAJ,CAAUN,UAAV,EAAsBO,IAAtB,CAA2B,CAA3B,CAAxB;AAEAH,IAAAA,KAAK,CAACD,OAAN,CAAc,CAACK,KAAD,EAAQC,MAAR,KAAmB;AAC/B,UAAI,CAACC,gBAAEC,QAAF,CAAWZ,MAAM,CAACa,OAAP,CAAeH,MAAf,EAAuBI,KAAlC,CAAL,EAA+C;AAC7C,cAAM,IAAIC,SAAJ,CAAc,uCAAd,CAAN;AACD;;AAED,UAAI,CAACJ,gBAAEK,SAAF,CAAYhB,MAAM,CAACa,OAAP,CAAeH,MAAf,EAAuBO,QAAnC,CAAL,EAAmD;AACjD,cAAM,IAAIF,SAAJ,CAAc,2CAAd,CAAN;AACD;;AAEDT,MAAAA,eAAe,CAACI,MAAD,CAAf,GAA0B,kCAAoBD,KAApB,EAA2BT,MAAM,CAACa,OAAP,CAAeH,MAAf,EAAuBI,KAAlD,EAAyDd,MAAM,CAACa,OAAP,CAAeH,MAAf,EAAuBO,QAAhF,CAA1B;AACD,KAVD;AAYAd,IAAAA,YAAY,CAACe,IAAb,CAAkBP,gBAAEQ,GAAF,CAAMb,eAAN,CAAlB;AACD,GAhBD;AAkBA,SAAOH,YAAP;AACD,C","sourcesContent":["import _ from 'lodash';\nimport calculateCellHeight from './calculateCellHeight';\n\n/**\n * Calculates the vertical row span index.\n *\n * @param {Array[]} rows\n * @param {Object} config\n * @returns {number[]}\n */\nexport default (rows, config) => {\n const tableWidth = rows[0].length;\n\n const rowSpanIndex = [];\n\n rows.forEach((cells) => {\n const cellHeightIndex = new Array(tableWidth).fill(1);\n\n cells.forEach((value, index1) => {\n if (!_.isNumber(config.columns[index1].width)) {\n throw new TypeError('column[index].width must be a number.');\n }\n\n if (!_.isBoolean(config.columns[index1].wrapWord)) {\n throw new TypeError('column[index].wrapWord must be a boolean.');\n }\n\n cellHeightIndex[index1] = calculateCellHeight(value, config.columns[index1].width, config.columns[index1].wrapWord);\n });\n\n rowSpanIndex.push(_.max(cellHeightIndex));\n });\n\n return rowSpanIndex;\n};\n"],"file":"calculateRowHeightIndex.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/createStream.js b/tools/node_modules/eslint/node_modules/table/dist/createStream.js index 83698f0e036e27..f1eb06106e4ca1 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/createStream.js +++ b/tools/node_modules/eslint/node_modules/table/dist/createStream.js @@ -1,46 +1,29 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; -var _lodash = require('lodash'); +var _lodash = _interopRequireDefault(require("lodash")); -var _lodash2 = _interopRequireDefault(_lodash); +var _makeStreamConfig = _interopRequireDefault(require("./makeStreamConfig")); -var _makeStreamConfig = require('./makeStreamConfig'); +var _drawRow = _interopRequireDefault(require("./drawRow")); -var _makeStreamConfig2 = _interopRequireDefault(_makeStreamConfig); +var _drawBorder = require("./drawBorder"); -var _drawRow = require('./drawRow'); +var _stringifyTableData = _interopRequireDefault(require("./stringifyTableData")); -var _drawRow2 = _interopRequireDefault(_drawRow); +var _truncateTableData = _interopRequireDefault(require("./truncateTableData")); -var _drawBorder = require('./drawBorder'); +var _mapDataUsingRowHeightIndex = _interopRequireDefault(require("./mapDataUsingRowHeightIndex")); -var _stringifyTableData = require('./stringifyTableData'); +var _alignTableData = _interopRequireDefault(require("./alignTableData")); -var _stringifyTableData2 = _interopRequireDefault(_stringifyTableData); +var _padTableData = _interopRequireDefault(require("./padTableData")); -var _truncateTableData = require('./truncateTableData'); - -var _truncateTableData2 = _interopRequireDefault(_truncateTableData); - -var _mapDataUsingRowHeightIndex = require('./mapDataUsingRowHeightIndex'); - -var _mapDataUsingRowHeightIndex2 = _interopRequireDefault(_mapDataUsingRowHeightIndex); - -var _alignTableData = require('./alignTableData'); - -var _alignTableData2 = _interopRequireDefault(_alignTableData); - -var _padTableData = require('./padTableData'); - -var _padTableData2 = _interopRequireDefault(_padTableData); - -var _calculateRowHeightIndex = require('./calculateRowHeightIndex'); - -var _calculateRowHeightIndex2 = _interopRequireDefault(_calculateRowHeightIndex); +var _calculateRowHeightIndex = _interopRequireDefault(require("./calculateRowHeightIndex")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -51,90 +34,71 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de */ const prepareData = (data, config) => { let rows; - - rows = (0, _stringifyTableData2.default)(data); - - rows = (0, _truncateTableData2.default)(data, config); - - const rowHeightIndex = (0, _calculateRowHeightIndex2.default)(rows, config); - - rows = (0, _mapDataUsingRowHeightIndex2.default)(rows, rowHeightIndex, config); - rows = (0, _alignTableData2.default)(rows, config); - rows = (0, _padTableData2.default)(rows, config); - + rows = (0, _stringifyTableData.default)(data); + rows = (0, _truncateTableData.default)(data, config); + const rowHeightIndex = (0, _calculateRowHeightIndex.default)(rows, config); + rows = (0, _mapDataUsingRowHeightIndex.default)(rows, rowHeightIndex, config); + rows = (0, _alignTableData.default)(rows, config); + rows = (0, _padTableData.default)(rows, config); return rows; }; - /** * @param {string[]} row * @param {number[]} columnWidthIndex * @param {Object} config * @returns {undefined} */ + + const create = (row, columnWidthIndex, config) => { const rows = prepareData([row], config); - const body = rows.map(literalRow => { - return (0, _drawRow2.default)(literalRow, config.border); + return (0, _drawRow.default)(literalRow, config.border); }).join(''); - let output; - output = ''; - output += (0, _drawBorder.drawBorderTop)(columnWidthIndex, config.border); output += body; output += (0, _drawBorder.drawBorderBottom)(columnWidthIndex, config.border); - - output = _lodash2.default.trimEnd(output); - + output = _lodash.default.trimEnd(output); process.stdout.write(output); }; - /** * @param {string[]} row * @param {number[]} columnWidthIndex * @param {Object} config * @returns {undefined} */ + + const append = (row, columnWidthIndex, config) => { const rows = prepareData([row], config); - const body = rows.map(literalRow => { - return (0, _drawRow2.default)(literalRow, config.border); + return (0, _drawRow.default)(literalRow, config.border); }).join(''); - let output; - output = '\r\u001B[K'; - output += (0, _drawBorder.drawBorderJoin)(columnWidthIndex, config.border); output += body; output += (0, _drawBorder.drawBorderBottom)(columnWidthIndex, config.border); - - output = _lodash2.default.trimEnd(output); - + output = _lodash.default.trimEnd(output); process.stdout.write(output); }; - /** * @param {Object} userConfig * @returns {Object} */ -exports.default = function () { - let userConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - const config = (0, _makeStreamConfig2.default)(userConfig); +const createStream = (userConfig = {}) => { + const config = (0, _makeStreamConfig.default)(userConfig); // @todo Use 'Object.values' when Node.js v6 support is dropped. - const columnWidthIndex = _lodash2.default.mapValues(config.columns, column => { + const columnWidthIndex = _lodash.default.values(_lodash.default.mapValues(config.columns, column => { return column.width + column.paddingLeft + column.paddingRight; - }); + })); let empty; - empty = true; - return { /** * @param {string[]} row @@ -147,11 +111,14 @@ exports.default = function () { if (empty) { empty = false; - return create(row, columnWidthIndex, config); } else { return append(row, columnWidthIndex, config); } } }; -}; \ No newline at end of file +}; + +var _default = createStream; +exports.default = _default; +//# sourceMappingURL=createStream.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/createStream.js.flow b/tools/node_modules/eslint/node_modules/table/dist/createStream.js.flow new file mode 100644 index 00000000000000..1d7d00e399c4a3 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/createStream.js.flow @@ -0,0 +1,124 @@ +import _ from 'lodash'; +import makeStreamConfig from './makeStreamConfig'; +import drawRow from './drawRow'; +import { + drawBorderBottom, + drawBorderJoin, + drawBorderTop +} from './drawBorder'; +import stringifyTableData from './stringifyTableData'; +import truncateTableData from './truncateTableData'; +import mapDataUsingRowHeightIndex from './mapDataUsingRowHeightIndex'; +import alignTableData from './alignTableData'; +import padTableData from './padTableData'; +import calculateRowHeightIndex from './calculateRowHeightIndex'; + +/** + * @param {Array} data + * @param {Object} config + * @returns {Array} + */ +const prepareData = (data, config) => { + let rows; + + rows = stringifyTableData(data); + + rows = truncateTableData(data, config); + + const rowHeightIndex = calculateRowHeightIndex(rows, config); + + rows = mapDataUsingRowHeightIndex(rows, rowHeightIndex, config); + rows = alignTableData(rows, config); + rows = padTableData(rows, config); + + return rows; +}; + +/** + * @param {string[]} row + * @param {number[]} columnWidthIndex + * @param {Object} config + * @returns {undefined} + */ +const create = (row, columnWidthIndex, config) => { + const rows = prepareData([row], config); + + const body = rows.map((literalRow) => { + return drawRow(literalRow, config.border); + }).join(''); + + let output; + + output = ''; + + output += drawBorderTop(columnWidthIndex, config.border); + output += body; + output += drawBorderBottom(columnWidthIndex, config.border); + + output = _.trimEnd(output); + + process.stdout.write(output); +}; + +/** + * @param {string[]} row + * @param {number[]} columnWidthIndex + * @param {Object} config + * @returns {undefined} + */ +const append = (row, columnWidthIndex, config) => { + const rows = prepareData([row], config); + + const body = rows.map((literalRow) => { + return drawRow(literalRow, config.border); + }).join(''); + + let output; + + output = '\r\u001B[K'; + + output += drawBorderJoin(columnWidthIndex, config.border); + output += body; + output += drawBorderBottom(columnWidthIndex, config.border); + + output = _.trimEnd(output); + + process.stdout.write(output); +}; + +/** + * @param {Object} userConfig + * @returns {Object} + */ +export default (userConfig = {}) => { + const config = makeStreamConfig(userConfig); + + // @todo Use 'Object.values' when Node.js v6 support is dropped. + const columnWidthIndex = _.values(_.mapValues(config.columns, (column) => { + return column.width + column.paddingLeft + column.paddingRight; + })); + + let empty; + + empty = true; + + return { + /** + * @param {string[]} row + * @returns {undefined} + */ + write: (row) => { + if (row.length !== config.columnCount) { + throw new Error('Row cell count does not match the config.columnCount.'); + } + + if (empty) { + empty = false; + + return create(row, columnWidthIndex, config); + } else { + return append(row, columnWidthIndex, config); + } + } + }; +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/createStream.js.map b/tools/node_modules/eslint/node_modules/table/dist/createStream.js.map new file mode 100644 index 00000000000000..92cf88794cefc2 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/createStream.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/createStream.js"],"names":["prepareData","data","config","rows","rowHeightIndex","create","row","columnWidthIndex","body","map","literalRow","border","join","output","_","trimEnd","process","stdout","write","append","userConfig","values","mapValues","columns","column","width","paddingLeft","paddingRight","empty","length","columnCount","Error"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEA;;;;;AAKA,MAAMA,WAAW,GAAG,CAACC,IAAD,EAAOC,MAAP,KAAkB;AACpC,MAAIC,IAAJ;AAEAA,EAAAA,IAAI,GAAG,iCAAmBF,IAAnB,CAAP;AAEAE,EAAAA,IAAI,GAAG,gCAAkBF,IAAlB,EAAwBC,MAAxB,CAAP;AAEA,QAAME,cAAc,GAAG,sCAAwBD,IAAxB,EAA8BD,MAA9B,CAAvB;AAEAC,EAAAA,IAAI,GAAG,yCAA2BA,IAA3B,EAAiCC,cAAjC,EAAiDF,MAAjD,CAAP;AACAC,EAAAA,IAAI,GAAG,6BAAeA,IAAf,EAAqBD,MAArB,CAAP;AACAC,EAAAA,IAAI,GAAG,2BAAaA,IAAb,EAAmBD,MAAnB,CAAP;AAEA,SAAOC,IAAP;AACD,CAdD;AAgBA;;;;;;;;AAMA,MAAME,MAAM,GAAG,CAACC,GAAD,EAAMC,gBAAN,EAAwBL,MAAxB,KAAmC;AAChD,QAAMC,IAAI,GAAGH,WAAW,CAAC,CAACM,GAAD,CAAD,EAAQJ,MAAR,CAAxB;AAEA,QAAMM,IAAI,GAAGL,IAAI,CAACM,GAAL,CAAUC,UAAD,IAAgB;AACpC,WAAO,sBAAQA,UAAR,EAAoBR,MAAM,CAACS,MAA3B,CAAP;AACD,GAFY,EAEVC,IAFU,CAEL,EAFK,CAAb;AAIA,MAAIC,MAAJ;AAEAA,EAAAA,MAAM,GAAG,EAAT;AAEAA,EAAAA,MAAM,IAAI,+BAAcN,gBAAd,EAAgCL,MAAM,CAACS,MAAvC,CAAV;AACAE,EAAAA,MAAM,IAAIL,IAAV;AACAK,EAAAA,MAAM,IAAI,kCAAiBN,gBAAjB,EAAmCL,MAAM,CAACS,MAA1C,CAAV;AAEAE,EAAAA,MAAM,GAAGC,gBAAEC,OAAF,CAAUF,MAAV,CAAT;AAEAG,EAAAA,OAAO,CAACC,MAAR,CAAeC,KAAf,CAAqBL,MAArB;AACD,CAlBD;AAoBA;;;;;;;;AAMA,MAAMM,MAAM,GAAG,CAACb,GAAD,EAAMC,gBAAN,EAAwBL,MAAxB,KAAmC;AAChD,QAAMC,IAAI,GAAGH,WAAW,CAAC,CAACM,GAAD,CAAD,EAAQJ,MAAR,CAAxB;AAEA,QAAMM,IAAI,GAAGL,IAAI,CAACM,GAAL,CAAUC,UAAD,IAAgB;AACpC,WAAO,sBAAQA,UAAR,EAAoBR,MAAM,CAACS,MAA3B,CAAP;AACD,GAFY,EAEVC,IAFU,CAEL,EAFK,CAAb;AAIA,MAAIC,MAAJ;AAEAA,EAAAA,MAAM,GAAG,YAAT;AAEAA,EAAAA,MAAM,IAAI,gCAAeN,gBAAf,EAAiCL,MAAM,CAACS,MAAxC,CAAV;AACAE,EAAAA,MAAM,IAAIL,IAAV;AACAK,EAAAA,MAAM,IAAI,kCAAiBN,gBAAjB,EAAmCL,MAAM,CAACS,MAA1C,CAAV;AAEAE,EAAAA,MAAM,GAAGC,gBAAEC,OAAF,CAAUF,MAAV,CAAT;AAEAG,EAAAA,OAAO,CAACC,MAAR,CAAeC,KAAf,CAAqBL,MAArB;AACD,CAlBD;AAoBA;;;;;;sBAIgBO,UAAU,GAAG,E,KAAO;AAClC,QAAMlB,MAAM,GAAG,+BAAiBkB,UAAjB,CAAf,CADkC,CAGlC;;AACA,QAAMb,gBAAgB,GAAGO,gBAAEO,MAAF,CAASP,gBAAEQ,SAAF,CAAYpB,MAAM,CAACqB,OAAnB,EAA6BC,MAAD,IAAY;AACxE,WAAOA,MAAM,CAACC,KAAP,GAAeD,MAAM,CAACE,WAAtB,GAAoCF,MAAM,CAACG,YAAlD;AACD,GAFiC,CAAT,CAAzB;;AAIA,MAAIC,KAAJ;AAEAA,EAAAA,KAAK,GAAG,IAAR;AAEA,SAAO;AACL;;;;AAIAV,IAAAA,KAAK,EAAGZ,GAAD,IAAS;AACd,UAAIA,GAAG,CAACuB,MAAJ,KAAe3B,MAAM,CAAC4B,WAA1B,EAAuC;AACrC,cAAM,IAAIC,KAAJ,CAAU,uDAAV,CAAN;AACD;;AAED,UAAIH,KAAJ,EAAW;AACTA,QAAAA,KAAK,GAAG,KAAR;AAEA,eAAOvB,MAAM,CAACC,GAAD,EAAMC,gBAAN,EAAwBL,MAAxB,CAAb;AACD,OAJD,MAIO;AACL,eAAOiB,MAAM,CAACb,GAAD,EAAMC,gBAAN,EAAwBL,MAAxB,CAAb;AACD;AACF;AAjBI,GAAP;AAmBD,C","sourcesContent":["import _ from 'lodash';\nimport makeStreamConfig from './makeStreamConfig';\nimport drawRow from './drawRow';\nimport {\n drawBorderBottom,\n drawBorderJoin,\n drawBorderTop\n} from './drawBorder';\nimport stringifyTableData from './stringifyTableData';\nimport truncateTableData from './truncateTableData';\nimport mapDataUsingRowHeightIndex from './mapDataUsingRowHeightIndex';\nimport alignTableData from './alignTableData';\nimport padTableData from './padTableData';\nimport calculateRowHeightIndex from './calculateRowHeightIndex';\n\n/**\n * @param {Array} data\n * @param {Object} config\n * @returns {Array}\n */\nconst prepareData = (data, config) => {\n let rows;\n\n rows = stringifyTableData(data);\n\n rows = truncateTableData(data, config);\n\n const rowHeightIndex = calculateRowHeightIndex(rows, config);\n\n rows = mapDataUsingRowHeightIndex(rows, rowHeightIndex, config);\n rows = alignTableData(rows, config);\n rows = padTableData(rows, config);\n\n return rows;\n};\n\n/**\n * @param {string[]} row\n * @param {number[]} columnWidthIndex\n * @param {Object} config\n * @returns {undefined}\n */\nconst create = (row, columnWidthIndex, config) => {\n const rows = prepareData([row], config);\n\n const body = rows.map((literalRow) => {\n return drawRow(literalRow, config.border);\n }).join('');\n\n let output;\n\n output = '';\n\n output += drawBorderTop(columnWidthIndex, config.border);\n output += body;\n output += drawBorderBottom(columnWidthIndex, config.border);\n\n output = _.trimEnd(output);\n\n process.stdout.write(output);\n};\n\n/**\n * @param {string[]} row\n * @param {number[]} columnWidthIndex\n * @param {Object} config\n * @returns {undefined}\n */\nconst append = (row, columnWidthIndex, config) => {\n const rows = prepareData([row], config);\n\n const body = rows.map((literalRow) => {\n return drawRow(literalRow, config.border);\n }).join('');\n\n let output;\n\n output = '\\r\\u001B[K';\n\n output += drawBorderJoin(columnWidthIndex, config.border);\n output += body;\n output += drawBorderBottom(columnWidthIndex, config.border);\n\n output = _.trimEnd(output);\n\n process.stdout.write(output);\n};\n\n/**\n * @param {Object} userConfig\n * @returns {Object}\n */\nexport default (userConfig = {}) => {\n const config = makeStreamConfig(userConfig);\n\n // @todo Use 'Object.values' when Node.js v6 support is dropped.\n const columnWidthIndex = _.values(_.mapValues(config.columns, (column) => {\n return column.width + column.paddingLeft + column.paddingRight;\n }));\n\n let empty;\n\n empty = true;\n\n return {\n /**\n * @param {string[]} row\n * @returns {undefined}\n */\n write: (row) => {\n if (row.length !== config.columnCount) {\n throw new Error('Row cell count does not match the config.columnCount.');\n }\n\n if (empty) {\n empty = false;\n\n return create(row, columnWidthIndex, config);\n } else {\n return append(row, columnWidthIndex, config);\n }\n }\n };\n};\n"],"file":"createStream.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/drawBorder.js b/tools/node_modules/eslint/node_modules/table/dist/drawBorder.js index beae57f1a2885f..cb7c54077a3fd1 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/drawBorder.js +++ b/tools/node_modules/eslint/node_modules/table/dist/drawBorder.js @@ -1,8 +1,10 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.drawBorderTop = exports.drawBorderJoin = exports.drawBorderBottom = exports.drawBorder = void 0; + /** * @typedef drawBorder~parts * @property {string} left @@ -20,10 +22,8 @@ const drawBorder = (columnSizeIndex, parts) => { const columns = columnSizeIndex.map(size => { return parts.body.repeat(size); }).join(parts.join); - return parts.left + columns + parts.right + '\n'; }; - /** * @typedef drawBorderTop~parts * @property {string} topLeft @@ -37,6 +37,10 @@ const drawBorder = (columnSizeIndex, parts) => { * @param {drawBorderTop~parts} parts * @returns {string} */ + + +exports.drawBorder = drawBorder; + const drawBorderTop = (columnSizeIndex, parts) => { return drawBorder(columnSizeIndex, { body: parts.topBody, @@ -45,7 +49,6 @@ const drawBorderTop = (columnSizeIndex, parts) => { right: parts.topRight }); }; - /** * @typedef drawBorderJoin~parts * @property {string} joinLeft @@ -59,6 +62,10 @@ const drawBorderTop = (columnSizeIndex, parts) => { * @param {drawBorderJoin~parts} parts * @returns {string} */ + + +exports.drawBorderTop = drawBorderTop; + const drawBorderJoin = (columnSizeIndex, parts) => { return drawBorder(columnSizeIndex, { body: parts.joinBody, @@ -67,7 +74,6 @@ const drawBorderJoin = (columnSizeIndex, parts) => { right: parts.joinRight }); }; - /** * @typedef drawBorderBottom~parts * @property {string} topLeft @@ -81,6 +87,10 @@ const drawBorderJoin = (columnSizeIndex, parts) => { * @param {drawBorderBottom~parts} parts * @returns {string} */ + + +exports.drawBorderJoin = drawBorderJoin; + const drawBorderBottom = (columnSizeIndex, parts) => { return drawBorder(columnSizeIndex, { body: parts.bottomBody, @@ -90,7 +100,5 @@ const drawBorderBottom = (columnSizeIndex, parts) => { }); }; -exports.drawBorder = drawBorder; exports.drawBorderBottom = drawBorderBottom; -exports.drawBorderJoin = drawBorderJoin; -exports.drawBorderTop = drawBorderTop; \ No newline at end of file +//# sourceMappingURL=drawBorder.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/drawBorder.js.flow b/tools/node_modules/eslint/node_modules/table/dist/drawBorder.js.flow new file mode 100644 index 00000000000000..5d5f5d9ac2e90f --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/drawBorder.js.flow @@ -0,0 +1,95 @@ +/** + * @typedef drawBorder~parts + * @property {string} left + * @property {string} right + * @property {string} body + * @property {string} join + */ + +/** + * @param {number[]} columnSizeIndex + * @param {drawBorder~parts} parts + * @returns {string} + */ +const drawBorder = (columnSizeIndex, parts) => { + const columns = columnSizeIndex + .map((size) => { + return parts.body.repeat(size); + }) + .join(parts.join); + + return parts.left + columns + parts.right + '\n'; +}; + +/** + * @typedef drawBorderTop~parts + * @property {string} topLeft + * @property {string} topRight + * @property {string} topBody + * @property {string} topJoin + */ + +/** + * @param {number[]} columnSizeIndex + * @param {drawBorderTop~parts} parts + * @returns {string} + */ +const drawBorderTop = (columnSizeIndex, parts) => { + return drawBorder(columnSizeIndex, { + body: parts.topBody, + join: parts.topJoin, + left: parts.topLeft, + right: parts.topRight + }); +}; + +/** + * @typedef drawBorderJoin~parts + * @property {string} joinLeft + * @property {string} joinRight + * @property {string} joinBody + * @property {string} joinJoin + */ + +/** + * @param {number[]} columnSizeIndex + * @param {drawBorderJoin~parts} parts + * @returns {string} + */ +const drawBorderJoin = (columnSizeIndex, parts) => { + return drawBorder(columnSizeIndex, { + body: parts.joinBody, + join: parts.joinJoin, + left: parts.joinLeft, + right: parts.joinRight + }); +}; + +/** + * @typedef drawBorderBottom~parts + * @property {string} topLeft + * @property {string} topRight + * @property {string} topBody + * @property {string} topJoin + */ + +/** + * @param {number[]} columnSizeIndex + * @param {drawBorderBottom~parts} parts + * @returns {string} + */ +const drawBorderBottom = (columnSizeIndex, parts) => { + return drawBorder(columnSizeIndex, { + body: parts.bottomBody, + join: parts.bottomJoin, + left: parts.bottomLeft, + right: parts.bottomRight + }); +}; + +export { + drawBorder, + drawBorderBottom, + drawBorderJoin, + drawBorderTop +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/drawBorder.js.map b/tools/node_modules/eslint/node_modules/table/dist/drawBorder.js.map new file mode 100644 index 00000000000000..dfdfccd0f4ee3d --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/drawBorder.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/drawBorder.js"],"names":["drawBorder","columnSizeIndex","parts","columns","map","size","body","repeat","join","left","right","drawBorderTop","topBody","topJoin","topLeft","topRight","drawBorderJoin","joinBody","joinJoin","joinLeft","joinRight","drawBorderBottom","bottomBody","bottomJoin","bottomLeft","bottomRight"],"mappings":";;;;;;;AAAA;;;;;;;;AAQA;;;;;AAKA,MAAMA,UAAU,GAAG,CAACC,eAAD,EAAkBC,KAAlB,KAA4B;AAC7C,QAAMC,OAAO,GAAGF,eAAe,CAC5BG,GADa,CACRC,IAAD,IAAU;AACb,WAAOH,KAAK,CAACI,IAAN,CAAWC,MAAX,CAAkBF,IAAlB,CAAP;AACD,GAHa,EAIbG,IAJa,CAIRN,KAAK,CAACM,IAJE,CAAhB;AAMA,SAAON,KAAK,CAACO,IAAN,GAAaN,OAAb,GAAuBD,KAAK,CAACQ,KAA7B,GAAqC,IAA5C;AACD,CARD;AAUA;;;;;;;;AAQA;;;;;;;;;AAKA,MAAMC,aAAa,GAAG,CAACV,eAAD,EAAkBC,KAAlB,KAA4B;AAChD,SAAOF,UAAU,CAACC,eAAD,EAAkB;AACjCK,IAAAA,IAAI,EAAEJ,KAAK,CAACU,OADqB;AAEjCJ,IAAAA,IAAI,EAAEN,KAAK,CAACW,OAFqB;AAGjCJ,IAAAA,IAAI,EAAEP,KAAK,CAACY,OAHqB;AAIjCJ,IAAAA,KAAK,EAAER,KAAK,CAACa;AAJoB,GAAlB,CAAjB;AAMD,CAPD;AASA;;;;;;;;AAQA;;;;;;;;;AAKA,MAAMC,cAAc,GAAG,CAACf,eAAD,EAAkBC,KAAlB,KAA4B;AACjD,SAAOF,UAAU,CAACC,eAAD,EAAkB;AACjCK,IAAAA,IAAI,EAAEJ,KAAK,CAACe,QADqB;AAEjCT,IAAAA,IAAI,EAAEN,KAAK,CAACgB,QAFqB;AAGjCT,IAAAA,IAAI,EAAEP,KAAK,CAACiB,QAHqB;AAIjCT,IAAAA,KAAK,EAAER,KAAK,CAACkB;AAJoB,GAAlB,CAAjB;AAMD,CAPD;AASA;;;;;;;;AAQA;;;;;;;;;AAKA,MAAMC,gBAAgB,GAAG,CAACpB,eAAD,EAAkBC,KAAlB,KAA4B;AACnD,SAAOF,UAAU,CAACC,eAAD,EAAkB;AACjCK,IAAAA,IAAI,EAAEJ,KAAK,CAACoB,UADqB;AAEjCd,IAAAA,IAAI,EAAEN,KAAK,CAACqB,UAFqB;AAGjCd,IAAAA,IAAI,EAAEP,KAAK,CAACsB,UAHqB;AAIjCd,IAAAA,KAAK,EAAER,KAAK,CAACuB;AAJoB,GAAlB,CAAjB;AAMD,CAPD","sourcesContent":["/**\n * @typedef drawBorder~parts\n * @property {string} left\n * @property {string} right\n * @property {string} body\n * @property {string} join\n */\n\n/**\n * @param {number[]} columnSizeIndex\n * @param {drawBorder~parts} parts\n * @returns {string}\n */\nconst drawBorder = (columnSizeIndex, parts) => {\n const columns = columnSizeIndex\n .map((size) => {\n return parts.body.repeat(size);\n })\n .join(parts.join);\n\n return parts.left + columns + parts.right + '\\n';\n};\n\n/**\n * @typedef drawBorderTop~parts\n * @property {string} topLeft\n * @property {string} topRight\n * @property {string} topBody\n * @property {string} topJoin\n */\n\n/**\n * @param {number[]} columnSizeIndex\n * @param {drawBorderTop~parts} parts\n * @returns {string}\n */\nconst drawBorderTop = (columnSizeIndex, parts) => {\n return drawBorder(columnSizeIndex, {\n body: parts.topBody,\n join: parts.topJoin,\n left: parts.topLeft,\n right: parts.topRight\n });\n};\n\n/**\n * @typedef drawBorderJoin~parts\n * @property {string} joinLeft\n * @property {string} joinRight\n * @property {string} joinBody\n * @property {string} joinJoin\n */\n\n/**\n * @param {number[]} columnSizeIndex\n * @param {drawBorderJoin~parts} parts\n * @returns {string}\n */\nconst drawBorderJoin = (columnSizeIndex, parts) => {\n return drawBorder(columnSizeIndex, {\n body: parts.joinBody,\n join: parts.joinJoin,\n left: parts.joinLeft,\n right: parts.joinRight\n });\n};\n\n/**\n * @typedef drawBorderBottom~parts\n * @property {string} topLeft\n * @property {string} topRight\n * @property {string} topBody\n * @property {string} topJoin\n */\n\n/**\n * @param {number[]} columnSizeIndex\n * @param {drawBorderBottom~parts} parts\n * @returns {string}\n */\nconst drawBorderBottom = (columnSizeIndex, parts) => {\n return drawBorder(columnSizeIndex, {\n body: parts.bottomBody,\n join: parts.bottomJoin,\n left: parts.bottomLeft,\n right: parts.bottomRight\n });\n};\n\nexport {\n drawBorder,\n drawBorderBottom,\n drawBorderJoin,\n drawBorderTop\n};\n"],"file":"drawBorder.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/drawRow.js b/tools/node_modules/eslint/node_modules/table/dist/drawRow.js index 65547fba058caf..800ca25bc3df7e 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/drawRow.js +++ b/tools/node_modules/eslint/node_modules/table/dist/drawRow.js @@ -1,8 +1,9 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; /** * @typedef {Object} drawRow~border @@ -16,6 +17,10 @@ Object.defineProperty(exports, "__esModule", { * @param {drawRow~border} border * @returns {string} */ -exports.default = (columns, border) => { +const drawRow = (columns, border) => { return border.bodyLeft + columns.join(border.bodyJoin) + border.bodyRight + '\n'; -}; \ No newline at end of file +}; + +var _default = drawRow; +exports.default = _default; +//# sourceMappingURL=drawRow.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/drawRow.js.flow b/tools/node_modules/eslint/node_modules/table/dist/drawRow.js.flow new file mode 100644 index 00000000000000..fdeceefa31880a --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/drawRow.js.flow @@ -0,0 +1,15 @@ +/** + * @typedef {Object} drawRow~border + * @property {string} bodyLeft + * @property {string} bodyRight + * @property {string} bodyJoin + */ + +/** + * @param {number[]} columns + * @param {drawRow~border} border + * @returns {string} + */ +export default (columns, border) => { + return border.bodyLeft + columns.join(border.bodyJoin) + border.bodyRight + '\n'; +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/drawRow.js.map b/tools/node_modules/eslint/node_modules/table/dist/drawRow.js.map new file mode 100644 index 00000000000000..4541d1961520d6 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/drawRow.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/drawRow.js"],"names":["columns","border","bodyLeft","join","bodyJoin","bodyRight"],"mappings":";;;;;;;AAAA;;;;;;;AAOA;;;;;iBAKgBA,O,EAASC,M,KAAW;AAClC,SAAOA,MAAM,CAACC,QAAP,GAAkBF,OAAO,CAACG,IAAR,CAAaF,MAAM,CAACG,QAApB,CAAlB,GAAkDH,MAAM,CAACI,SAAzD,GAAqE,IAA5E;AACD,C","sourcesContent":["/**\n * @typedef {Object} drawRow~border\n * @property {string} bodyLeft\n * @property {string} bodyRight\n * @property {string} bodyJoin\n */\n\n/**\n * @param {number[]} columns\n * @param {drawRow~border} border\n * @returns {string}\n */\nexport default (columns, border) => {\n return border.bodyLeft + columns.join(border.bodyJoin) + border.bodyRight + '\\n';\n};\n"],"file":"drawRow.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/drawTable.js b/tools/node_modules/eslint/node_modules/table/dist/drawTable.js index 01e8c3e14d4af6..5585af888f6612 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/drawTable.js +++ b/tools/node_modules/eslint/node_modules/table/dist/drawTable.js @@ -1,14 +1,13 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; -var _drawBorder = require('./drawBorder'); +var _drawBorder = require("./drawBorder"); -var _drawRow = require('./drawRow'); - -var _drawRow2 = _interopRequireDefault(_drawRow); +var _drawRow = _interopRequireDefault(require("./drawRow")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -20,15 +19,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @param {Function} drawHorizontalLine * @returns {string} */ -exports.default = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) => { +const drawTable = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) => { let output; let realRowIndex; let rowHeight; - const rowCount = rows.length; - realRowIndex = 0; - output = ''; if (drawHorizontalLine(realRowIndex, rowCount)) { @@ -36,11 +32,10 @@ exports.default = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLi } rows.forEach((row, index0) => { - output += (0, _drawRow2.default)(row, border); + output += (0, _drawRow.default)(row, border); if (!rowHeight) { rowHeight = rowSpanIndex[realRowIndex]; - realRowIndex++; } @@ -56,4 +51,8 @@ exports.default = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLi } return output; -}; \ No newline at end of file +}; + +var _default = drawTable; +exports.default = _default; +//# sourceMappingURL=drawTable.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/drawTable.js.flow b/tools/node_modules/eslint/node_modules/table/dist/drawTable.js.flow new file mode 100644 index 00000000000000..15ad14cfa2ba12 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/drawTable.js.flow @@ -0,0 +1,52 @@ +import { + drawBorderTop, + drawBorderJoin, + drawBorderBottom +} from './drawBorder'; +import drawRow from './drawRow'; + +/** + * @param {Array} rows + * @param {Object} border + * @param {Array} columnSizeIndex + * @param {Array} rowSpanIndex + * @param {Function} drawHorizontalLine + * @returns {string} + */ +export default (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) => { + let output; + let realRowIndex; + let rowHeight; + + const rowCount = rows.length; + + realRowIndex = 0; + + output = ''; + + if (drawHorizontalLine(realRowIndex, rowCount)) { + output += drawBorderTop(columnSizeIndex, border); + } + + rows.forEach((row, index0) => { + output += drawRow(row, border); + + if (!rowHeight) { + rowHeight = rowSpanIndex[realRowIndex]; + + realRowIndex++; + } + + rowHeight--; + + if (rowHeight === 0 && index0 !== rowCount - 1 && drawHorizontalLine(realRowIndex, rowCount)) { + output += drawBorderJoin(columnSizeIndex, border); + } + }); + + if (drawHorizontalLine(realRowIndex, rowCount)) { + output += drawBorderBottom(columnSizeIndex, border); + } + + return output; +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/drawTable.js.map b/tools/node_modules/eslint/node_modules/table/dist/drawTable.js.map new file mode 100644 index 00000000000000..526336ab999159 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/drawTable.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/drawTable.js"],"names":["rows","border","columnSizeIndex","rowSpanIndex","drawHorizontalLine","output","realRowIndex","rowHeight","rowCount","length","forEach","row","index0"],"mappings":";;;;;;;AAAA;;AAKA;;;;AAEA;;;;;;;;mBAQgBA,I,EAAMC,M,EAAQC,e,EAAiBC,Y,EAAcC,kB,KAAuB;AAClF,MAAIC,MAAJ;AACA,MAAIC,YAAJ;AACA,MAAIC,SAAJ;AAEA,QAAMC,QAAQ,GAAGR,IAAI,CAACS,MAAtB;AAEAH,EAAAA,YAAY,GAAG,CAAf;AAEAD,EAAAA,MAAM,GAAG,EAAT;;AAEA,MAAID,kBAAkB,CAACE,YAAD,EAAeE,QAAf,CAAtB,EAAgD;AAC9CH,IAAAA,MAAM,IAAI,+BAAcH,eAAd,EAA+BD,MAA/B,CAAV;AACD;;AAEDD,EAAAA,IAAI,CAACU,OAAL,CAAa,CAACC,GAAD,EAAMC,MAAN,KAAiB;AAC5BP,IAAAA,MAAM,IAAI,sBAAQM,GAAR,EAAaV,MAAb,CAAV;;AAEA,QAAI,CAACM,SAAL,EAAgB;AACdA,MAAAA,SAAS,GAAGJ,YAAY,CAACG,YAAD,CAAxB;AAEAA,MAAAA,YAAY;AACb;;AAEDC,IAAAA,SAAS;;AAET,QAAIA,SAAS,KAAK,CAAd,IAAmBK,MAAM,KAAKJ,QAAQ,GAAG,CAAzC,IAA8CJ,kBAAkB,CAACE,YAAD,EAAeE,QAAf,CAApE,EAA8F;AAC5FH,MAAAA,MAAM,IAAI,gCAAeH,eAAf,EAAgCD,MAAhC,CAAV;AACD;AACF,GAdD;;AAgBA,MAAIG,kBAAkB,CAACE,YAAD,EAAeE,QAAf,CAAtB,EAAgD;AAC9CH,IAAAA,MAAM,IAAI,kCAAiBH,eAAjB,EAAkCD,MAAlC,CAAV;AACD;;AAED,SAAOI,MAAP;AACD,C","sourcesContent":["import {\n drawBorderTop,\n drawBorderJoin,\n drawBorderBottom\n} from './drawBorder';\nimport drawRow from './drawRow';\n\n/**\n * @param {Array} rows\n * @param {Object} border\n * @param {Array} columnSizeIndex\n * @param {Array} rowSpanIndex\n * @param {Function} drawHorizontalLine\n * @returns {string}\n */\nexport default (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) => {\n let output;\n let realRowIndex;\n let rowHeight;\n\n const rowCount = rows.length;\n\n realRowIndex = 0;\n\n output = '';\n\n if (drawHorizontalLine(realRowIndex, rowCount)) {\n output += drawBorderTop(columnSizeIndex, border);\n }\n\n rows.forEach((row, index0) => {\n output += drawRow(row, border);\n\n if (!rowHeight) {\n rowHeight = rowSpanIndex[realRowIndex];\n\n realRowIndex++;\n }\n\n rowHeight--;\n\n if (rowHeight === 0 && index0 !== rowCount - 1 && drawHorizontalLine(realRowIndex, rowCount)) {\n output += drawBorderJoin(columnSizeIndex, border);\n }\n });\n\n if (drawHorizontalLine(realRowIndex, rowCount)) {\n output += drawBorderBottom(columnSizeIndex, border);\n }\n\n return output;\n};\n"],"file":"drawTable.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/getBorderCharacters.js b/tools/node_modules/eslint/node_modules/table/dist/getBorderCharacters.js index 0a0f599ca39242..0b9b5b00e10212 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/getBorderCharacters.js +++ b/tools/node_modules/eslint/node_modules/table/dist/getBorderCharacters.js @@ -1,8 +1,9 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; /* eslint-disable sort-keys */ @@ -29,23 +30,20 @@ Object.defineProperty(exports, "__esModule", { * @param {string} name * @returns {border} */ -exports.default = name => { +const getBorderCharacters = name => { if (name === 'honeywell') { return { topBody: '═', topJoin: '╤', topLeft: '╔', topRight: '╗', - bottomBody: '═', bottomJoin: '╧', bottomLeft: '╚', bottomRight: '╝', - bodyLeft: '║', bodyRight: '║', bodyJoin: '│', - joinBody: '─', joinLeft: '╟', joinRight: '╢', @@ -59,16 +57,13 @@ exports.default = name => { topJoin: '┬', topLeft: '┌', topRight: '┐', - bottomBody: '─', bottomJoin: '┴', bottomLeft: '└', bottomRight: '┘', - bodyLeft: '│', bodyRight: '│', bodyJoin: '│', - joinBody: '─', joinLeft: '├', joinRight: '┤', @@ -82,16 +77,13 @@ exports.default = name => { topJoin: '+', topLeft: '+', topRight: '+', - bottomBody: '-', bottomJoin: '+', bottomLeft: '+', bottomRight: '+', - bodyLeft: '|', bodyRight: '|', bodyJoin: '|', - joinBody: '-', joinLeft: '|', joinRight: '|', @@ -105,16 +97,13 @@ exports.default = name => { topJoin: '', topLeft: '', topRight: '', - bottomBody: '', bottomJoin: '', bottomLeft: '', bottomRight: '', - bodyLeft: '', bodyRight: '', bodyJoin: '', - joinBody: '', joinLeft: '', joinRight: '', @@ -123,4 +112,8 @@ exports.default = name => { } throw new Error('Unknown border template "' + name + '".'); -}; \ No newline at end of file +}; + +var _default = getBorderCharacters; +exports.default = _default; +//# sourceMappingURL=getBorderCharacters.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/getBorderCharacters.js.flow b/tools/node_modules/eslint/node_modules/table/dist/getBorderCharacters.js.flow new file mode 100644 index 00000000000000..916b3518f9408e --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/getBorderCharacters.js.flow @@ -0,0 +1,120 @@ +/* eslint-disable sort-keys */ + +/** + * @typedef border + * @property {string} topBody + * @property {string} topJoin + * @property {string} topLeft + * @property {string} topRight + * @property {string} bottomBody + * @property {string} bottomJoin + * @property {string} bottomLeft + * @property {string} bottomRight + * @property {string} bodyLeft + * @property {string} bodyRight + * @property {string} bodyJoin + * @property {string} joinBody + * @property {string} joinLeft + * @property {string} joinRight + * @property {string} joinJoin + */ + +/** + * @param {string} name + * @returns {border} + */ +export default (name) => { + if (name === 'honeywell') { + return { + topBody: '═', + topJoin: '╤', + topLeft: '╔', + topRight: '╗', + + bottomBody: '═', + bottomJoin: '╧', + bottomLeft: '╚', + bottomRight: '╝', + + bodyLeft: '║', + bodyRight: '║', + bodyJoin: '│', + + joinBody: '─', + joinLeft: '╟', + joinRight: '╢', + joinJoin: '┼' + }; + } + + if (name === 'norc') { + return { + topBody: '─', + topJoin: '┬', + topLeft: '┌', + topRight: '┐', + + bottomBody: '─', + bottomJoin: '┴', + bottomLeft: '└', + bottomRight: '┘', + + bodyLeft: '│', + bodyRight: '│', + bodyJoin: '│', + + joinBody: '─', + joinLeft: '├', + joinRight: '┤', + joinJoin: '┼' + }; + } + + if (name === 'ramac') { + return { + topBody: '-', + topJoin: '+', + topLeft: '+', + topRight: '+', + + bottomBody: '-', + bottomJoin: '+', + bottomLeft: '+', + bottomRight: '+', + + bodyLeft: '|', + bodyRight: '|', + bodyJoin: '|', + + joinBody: '-', + joinLeft: '|', + joinRight: '|', + joinJoin: '|' + }; + } + + if (name === 'void') { + return { + topBody: '', + topJoin: '', + topLeft: '', + topRight: '', + + bottomBody: '', + bottomJoin: '', + bottomLeft: '', + bottomRight: '', + + bodyLeft: '', + bodyRight: '', + bodyJoin: '', + + joinBody: '', + joinLeft: '', + joinRight: '', + joinJoin: '' + }; + } + + throw new Error('Unknown border template "' + name + '".'); +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/getBorderCharacters.js.map b/tools/node_modules/eslint/node_modules/table/dist/getBorderCharacters.js.map new file mode 100644 index 00000000000000..543426cacf0160 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/getBorderCharacters.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/getBorderCharacters.js"],"names":["name","topBody","topJoin","topLeft","topRight","bottomBody","bottomJoin","bottomLeft","bottomRight","bodyLeft","bodyRight","bodyJoin","joinBody","joinLeft","joinRight","joinJoin","Error"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;;;;;;;;;;;;;;AAmBA;;;;4BAIgBA,I,IAAS;AACvB,MAAIA,IAAI,KAAK,WAAb,EAA0B;AACxB,WAAO;AACLC,MAAAA,OAAO,EAAE,GADJ;AAELC,MAAAA,OAAO,EAAE,GAFJ;AAGLC,MAAAA,OAAO,EAAE,GAHJ;AAILC,MAAAA,QAAQ,EAAE,GAJL;AAMLC,MAAAA,UAAU,EAAE,GANP;AAOLC,MAAAA,UAAU,EAAE,GAPP;AAQLC,MAAAA,UAAU,EAAE,GARP;AASLC,MAAAA,WAAW,EAAE,GATR;AAWLC,MAAAA,QAAQ,EAAE,GAXL;AAYLC,MAAAA,SAAS,EAAE,GAZN;AAaLC,MAAAA,QAAQ,EAAE,GAbL;AAeLC,MAAAA,QAAQ,EAAE,GAfL;AAgBLC,MAAAA,QAAQ,EAAE,GAhBL;AAiBLC,MAAAA,SAAS,EAAE,GAjBN;AAkBLC,MAAAA,QAAQ,EAAE;AAlBL,KAAP;AAoBD;;AAED,MAAIf,IAAI,KAAK,MAAb,EAAqB;AACnB,WAAO;AACLC,MAAAA,OAAO,EAAE,GADJ;AAELC,MAAAA,OAAO,EAAE,GAFJ;AAGLC,MAAAA,OAAO,EAAE,GAHJ;AAILC,MAAAA,QAAQ,EAAE,GAJL;AAMLC,MAAAA,UAAU,EAAE,GANP;AAOLC,MAAAA,UAAU,EAAE,GAPP;AAQLC,MAAAA,UAAU,EAAE,GARP;AASLC,MAAAA,WAAW,EAAE,GATR;AAWLC,MAAAA,QAAQ,EAAE,GAXL;AAYLC,MAAAA,SAAS,EAAE,GAZN;AAaLC,MAAAA,QAAQ,EAAE,GAbL;AAeLC,MAAAA,QAAQ,EAAE,GAfL;AAgBLC,MAAAA,QAAQ,EAAE,GAhBL;AAiBLC,MAAAA,SAAS,EAAE,GAjBN;AAkBLC,MAAAA,QAAQ,EAAE;AAlBL,KAAP;AAoBD;;AAED,MAAIf,IAAI,KAAK,OAAb,EAAsB;AACpB,WAAO;AACLC,MAAAA,OAAO,EAAE,GADJ;AAELC,MAAAA,OAAO,EAAE,GAFJ;AAGLC,MAAAA,OAAO,EAAE,GAHJ;AAILC,MAAAA,QAAQ,EAAE,GAJL;AAMLC,MAAAA,UAAU,EAAE,GANP;AAOLC,MAAAA,UAAU,EAAE,GAPP;AAQLC,MAAAA,UAAU,EAAE,GARP;AASLC,MAAAA,WAAW,EAAE,GATR;AAWLC,MAAAA,QAAQ,EAAE,GAXL;AAYLC,MAAAA,SAAS,EAAE,GAZN;AAaLC,MAAAA,QAAQ,EAAE,GAbL;AAeLC,MAAAA,QAAQ,EAAE,GAfL;AAgBLC,MAAAA,QAAQ,EAAE,GAhBL;AAiBLC,MAAAA,SAAS,EAAE,GAjBN;AAkBLC,MAAAA,QAAQ,EAAE;AAlBL,KAAP;AAoBD;;AAED,MAAIf,IAAI,KAAK,MAAb,EAAqB;AACnB,WAAO;AACLC,MAAAA,OAAO,EAAE,EADJ;AAELC,MAAAA,OAAO,EAAE,EAFJ;AAGLC,MAAAA,OAAO,EAAE,EAHJ;AAILC,MAAAA,QAAQ,EAAE,EAJL;AAMLC,MAAAA,UAAU,EAAE,EANP;AAOLC,MAAAA,UAAU,EAAE,EAPP;AAQLC,MAAAA,UAAU,EAAE,EARP;AASLC,MAAAA,WAAW,EAAE,EATR;AAWLC,MAAAA,QAAQ,EAAE,EAXL;AAYLC,MAAAA,SAAS,EAAE,EAZN;AAaLC,MAAAA,QAAQ,EAAE,EAbL;AAeLC,MAAAA,QAAQ,EAAE,EAfL;AAgBLC,MAAAA,QAAQ,EAAE,EAhBL;AAiBLC,MAAAA,SAAS,EAAE,EAjBN;AAkBLC,MAAAA,QAAQ,EAAE;AAlBL,KAAP;AAoBD;;AAED,QAAM,IAAIC,KAAJ,CAAU,8BAA8BhB,IAA9B,GAAqC,IAA/C,CAAN;AACD,C","sourcesContent":["/* eslint-disable sort-keys */\n\n/**\n * @typedef border\n * @property {string} topBody\n * @property {string} topJoin\n * @property {string} topLeft\n * @property {string} topRight\n * @property {string} bottomBody\n * @property {string} bottomJoin\n * @property {string} bottomLeft\n * @property {string} bottomRight\n * @property {string} bodyLeft\n * @property {string} bodyRight\n * @property {string} bodyJoin\n * @property {string} joinBody\n * @property {string} joinLeft\n * @property {string} joinRight\n * @property {string} joinJoin\n */\n\n/**\n * @param {string} name\n * @returns {border}\n */\nexport default (name) => {\n if (name === 'honeywell') {\n return {\n topBody: '═',\n topJoin: '╤',\n topLeft: '╔',\n topRight: '╗',\n\n bottomBody: '═',\n bottomJoin: '╧',\n bottomLeft: '╚',\n bottomRight: '╝',\n\n bodyLeft: '║',\n bodyRight: '║',\n bodyJoin: '│',\n\n joinBody: '─',\n joinLeft: '╟',\n joinRight: '╢',\n joinJoin: '┼'\n };\n }\n\n if (name === 'norc') {\n return {\n topBody: '─',\n topJoin: '┬',\n topLeft: '┌',\n topRight: '┐',\n\n bottomBody: '─',\n bottomJoin: '┴',\n bottomLeft: '└',\n bottomRight: '┘',\n\n bodyLeft: '│',\n bodyRight: '│',\n bodyJoin: '│',\n\n joinBody: '─',\n joinLeft: '├',\n joinRight: '┤',\n joinJoin: '┼'\n };\n }\n\n if (name === 'ramac') {\n return {\n topBody: '-',\n topJoin: '+',\n topLeft: '+',\n topRight: '+',\n\n bottomBody: '-',\n bottomJoin: '+',\n bottomLeft: '+',\n bottomRight: '+',\n\n bodyLeft: '|',\n bodyRight: '|',\n bodyJoin: '|',\n\n joinBody: '-',\n joinLeft: '|',\n joinRight: '|',\n joinJoin: '|'\n };\n }\n\n if (name === 'void') {\n return {\n topBody: '',\n topJoin: '',\n topLeft: '',\n topRight: '',\n\n bottomBody: '',\n bottomJoin: '',\n bottomLeft: '',\n bottomRight: '',\n\n bodyLeft: '',\n bodyRight: '',\n bodyJoin: '',\n\n joinBody: '',\n joinLeft: '',\n joinRight: '',\n joinJoin: ''\n };\n }\n\n throw new Error('Unknown border template \"' + name + '\".');\n};\n"],"file":"getBorderCharacters.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/index.js b/tools/node_modules/eslint/node_modules/table/dist/index.js index 169eddf080bfb2..1f40e6628d67af 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/index.js +++ b/tools/node_modules/eslint/node_modules/table/dist/index.js @@ -1,24 +1,32 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getBorderCharacters = exports.createStream = exports.table = undefined; - -var _table = require('./table'); - -var _table2 = _interopRequireDefault(_table); - -var _createStream = require('./createStream'); +Object.defineProperty(exports, "table", { + enumerable: true, + get: function get() { + return _table.default; + } +}); +Object.defineProperty(exports, "createStream", { + enumerable: true, + get: function get() { + return _createStream.default; + } +}); +Object.defineProperty(exports, "getBorderCharacters", { + enumerable: true, + get: function get() { + return _getBorderCharacters.default; + } +}); -var _createStream2 = _interopRequireDefault(_createStream); +var _table = _interopRequireDefault(require("./table")); -var _getBorderCharacters = require('./getBorderCharacters'); +var _createStream = _interopRequireDefault(require("./createStream")); -var _getBorderCharacters2 = _interopRequireDefault(_getBorderCharacters); +var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -exports.table = _table2.default; -exports.createStream = _createStream2.default; -exports.getBorderCharacters = _getBorderCharacters2.default; \ No newline at end of file +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/index.js.flow b/tools/node_modules/eslint/node_modules/table/dist/index.js.flow new file mode 100644 index 00000000000000..76cd8301a0eac3 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/index.js.flow @@ -0,0 +1,9 @@ +import table from './table'; +import createStream from './createStream'; +import getBorderCharacters from './getBorderCharacters'; + +export { + table, + createStream, + getBorderCharacters +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/index.js.map b/tools/node_modules/eslint/node_modules/table/dist/index.js.map new file mode 100644 index 00000000000000..2f59e09a1521bf --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA","sourcesContent":["import table from './table';\nimport createStream from './createStream';\nimport getBorderCharacters from './getBorderCharacters';\n\nexport {\n table,\n createStream,\n getBorderCharacters\n};\n"],"file":"index.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/makeConfig.js b/tools/node_modules/eslint/node_modules/table/dist/makeConfig.js index 9444ffe0e2bfa6..0ec93b8628161b 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/makeConfig.js +++ b/tools/node_modules/eslint/node_modules/table/dist/makeConfig.js @@ -1,24 +1,17 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; -var _lodash = require('lodash'); +var _lodash = _interopRequireDefault(require("lodash")); -var _lodash2 = _interopRequireDefault(_lodash); +var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters")); -var _getBorderCharacters = require('./getBorderCharacters'); +var _validateConfig = _interopRequireDefault(require("./validateConfig")); -var _getBorderCharacters2 = _interopRequireDefault(_getBorderCharacters); - -var _validateConfig = require('./validateConfig'); - -var _validateConfig2 = _interopRequireDefault(_validateConfig); - -var _calculateMaximumColumnWidthIndex = require('./calculateMaximumColumnWidthIndex'); - -var _calculateMaximumColumnWidthIndex2 = _interopRequireDefault(_calculateMaximumColumnWidthIndex); +var _calculateMaximumColumnWidthIndex = _interopRequireDefault(require("./calculateMaximumColumnWidthIndex")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -28,12 +21,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @param {Object} border * @returns {Object} */ -const makeBorder = function makeBorder() { - let border = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - return Object.assign({}, (0, _getBorderCharacters2.default)('honeywell'), border); +const makeBorder = (border = {}) => { + return Object.assign({}, (0, _getBorderCharacters.default)('honeywell'), border); }; - /** * Creates a configuration for every column using default * values for the missing configuration properties. @@ -43,14 +33,13 @@ const makeBorder = function makeBorder() { * @param {Object} columnDefault * @returns {Object} */ -const makeColumns = function makeColumns(rows) { - let columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - let columnDefault = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - const maximumColumnWidthIndex = (0, _calculateMaximumColumnWidthIndex2.default)(rows); - _lodash2.default.times(rows[0].length, index => { - if (_lodash2.default.isUndefined(columns[index])) { +const makeColumns = (rows, columns = {}, columnDefault = {}) => { + const maximumColumnWidthIndex = (0, _calculateMaximumColumnWidthIndex.default)(rows); + + _lodash.default.times(rows[0].length, index => { + if (_lodash.default.isUndefined(columns[index])) { columns[index] = {}; } @@ -66,7 +55,6 @@ const makeColumns = function makeColumns(rows) { return columns; }; - /** * Makes a new configuration object out of the userConfig object * using default values for the missing configuration properties. @@ -76,12 +64,11 @@ const makeColumns = function makeColumns(rows) { * @returns {Object} */ -exports.default = function (rows) { - let userConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - (0, _validateConfig2.default)('config.json', userConfig); +const makeConfig = (rows, userConfig = {}) => { + (0, _validateConfig.default)('config.json', userConfig); - const config = _lodash2.default.cloneDeep(userConfig); + const config = _lodash.default.cloneDeep(userConfig); config.border = makeBorder(config.border); config.columns = makeColumns(rows, config.columns, config.columnDefault); @@ -96,4 +83,8 @@ exports.default = function (rows) { } return config; -}; \ No newline at end of file +}; + +var _default = makeConfig; +exports.default = _default; +//# sourceMappingURL=makeConfig.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/makeConfig.js.flow b/tools/node_modules/eslint/node_modules/table/dist/makeConfig.js.flow new file mode 100644 index 00000000000000..9a0ee0afade046 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/makeConfig.js.flow @@ -0,0 +1,72 @@ +import _ from 'lodash'; +import getBorderCharacters from './getBorderCharacters'; +import validateConfig from './validateConfig'; +import calculateMaximumColumnWidthIndex from './calculateMaximumColumnWidthIndex'; + +/** + * Merges user provided border characters with the default border ("honeywell") characters. + * + * @param {Object} border + * @returns {Object} + */ +const makeBorder = (border = {}) => { + return Object.assign({}, getBorderCharacters('honeywell'), border); +}; + +/** + * Creates a configuration for every column using default + * values for the missing configuration properties. + * + * @param {Array[]} rows + * @param {Object} columns + * @param {Object} columnDefault + * @returns {Object} + */ +const makeColumns = (rows, columns = {}, columnDefault = {}) => { + const maximumColumnWidthIndex = calculateMaximumColumnWidthIndex(rows); + + _.times(rows[0].length, (index) => { + if (_.isUndefined(columns[index])) { + columns[index] = {}; + } + + columns[index] = Object.assign({ + alignment: 'left', + paddingLeft: 1, + paddingRight: 1, + truncate: Infinity, + width: maximumColumnWidthIndex[index], + wrapWord: false + }, columnDefault, columns[index]); + }); + + return columns; +}; + +/** + * Makes a new configuration object out of the userConfig object + * using default values for the missing configuration properties. + * + * @param {Array[]} rows + * @param {Object} userConfig + * @returns {Object} + */ +export default (rows, userConfig = {}) => { + validateConfig('config.json', userConfig); + + const config = _.cloneDeep(userConfig); + + config.border = makeBorder(config.border); + config.columns = makeColumns(rows, config.columns, config.columnDefault); + + if (!config.drawHorizontalLine) { + /** + * @returns {boolean} + */ + config.drawHorizontalLine = () => { + return true; + }; + } + + return config; +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/makeConfig.js.map b/tools/node_modules/eslint/node_modules/table/dist/makeConfig.js.map new file mode 100644 index 00000000000000..91b0bdeb9a826e --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/makeConfig.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/makeConfig.js"],"names":["makeBorder","border","Object","assign","makeColumns","rows","columns","columnDefault","maximumColumnWidthIndex","_","times","length","index","isUndefined","alignment","paddingLeft","paddingRight","truncate","Infinity","width","wrapWord","userConfig","config","cloneDeep","drawHorizontalLine"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AAEA;;;;;;AAMA,MAAMA,UAAU,GAAG,CAACC,MAAM,GAAG,EAAV,KAAiB;AAClC,SAAOC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkB,kCAAoB,WAApB,CAAlB,EAAoDF,MAApD,CAAP;AACD,CAFD;AAIA;;;;;;;;;;;AASA,MAAMG,WAAW,GAAG,CAACC,IAAD,EAAOC,OAAO,GAAG,EAAjB,EAAqBC,aAAa,GAAG,EAArC,KAA4C;AAC9D,QAAMC,uBAAuB,GAAG,+CAAiCH,IAAjC,CAAhC;;AAEAI,kBAAEC,KAAF,CAAQL,IAAI,CAAC,CAAD,CAAJ,CAAQM,MAAhB,EAAyBC,KAAD,IAAW;AACjC,QAAIH,gBAAEI,WAAF,CAAcP,OAAO,CAACM,KAAD,CAArB,CAAJ,EAAmC;AACjCN,MAAAA,OAAO,CAACM,KAAD,CAAP,GAAiB,EAAjB;AACD;;AAEDN,IAAAA,OAAO,CAACM,KAAD,CAAP,GAAiBV,MAAM,CAACC,MAAP,CAAc;AAC7BW,MAAAA,SAAS,EAAE,MADkB;AAE7BC,MAAAA,WAAW,EAAE,CAFgB;AAG7BC,MAAAA,YAAY,EAAE,CAHe;AAI7BC,MAAAA,QAAQ,EAAEC,QAJmB;AAK7BC,MAAAA,KAAK,EAAEX,uBAAuB,CAACI,KAAD,CALD;AAM7BQ,MAAAA,QAAQ,EAAE;AANmB,KAAd,EAOdb,aAPc,EAOCD,OAAO,CAACM,KAAD,CAPR,CAAjB;AAQD,GAbD;;AAeA,SAAON,OAAP;AACD,CAnBD;AAqBA;;;;;;;;;;oBAQgBD,I,EAAMgB,UAAU,GAAG,E,KAAO;AACxC,+BAAe,aAAf,EAA8BA,UAA9B;;AAEA,QAAMC,MAAM,GAAGb,gBAAEc,SAAF,CAAYF,UAAZ,CAAf;;AAEAC,EAAAA,MAAM,CAACrB,MAAP,GAAgBD,UAAU,CAACsB,MAAM,CAACrB,MAAR,CAA1B;AACAqB,EAAAA,MAAM,CAAChB,OAAP,GAAiBF,WAAW,CAACC,IAAD,EAAOiB,MAAM,CAAChB,OAAd,EAAuBgB,MAAM,CAACf,aAA9B,CAA5B;;AAEA,MAAI,CAACe,MAAM,CAACE,kBAAZ,EAAgC;AAC9B;;;AAGAF,IAAAA,MAAM,CAACE,kBAAP,GAA4B,MAAM;AAChC,aAAO,IAAP;AACD,KAFD;AAGD;;AAED,SAAOF,MAAP;AACD,C","sourcesContent":["import _ from 'lodash';\nimport getBorderCharacters from './getBorderCharacters';\nimport validateConfig from './validateConfig';\nimport calculateMaximumColumnWidthIndex from './calculateMaximumColumnWidthIndex';\n\n/**\n * Merges user provided border characters with the default border (\"honeywell\") characters.\n *\n * @param {Object} border\n * @returns {Object}\n */\nconst makeBorder = (border = {}) => {\n return Object.assign({}, getBorderCharacters('honeywell'), border);\n};\n\n/**\n * Creates a configuration for every column using default\n * values for the missing configuration properties.\n *\n * @param {Array[]} rows\n * @param {Object} columns\n * @param {Object} columnDefault\n * @returns {Object}\n */\nconst makeColumns = (rows, columns = {}, columnDefault = {}) => {\n const maximumColumnWidthIndex = calculateMaximumColumnWidthIndex(rows);\n\n _.times(rows[0].length, (index) => {\n if (_.isUndefined(columns[index])) {\n columns[index] = {};\n }\n\n columns[index] = Object.assign({\n alignment: 'left',\n paddingLeft: 1,\n paddingRight: 1,\n truncate: Infinity,\n width: maximumColumnWidthIndex[index],\n wrapWord: false\n }, columnDefault, columns[index]);\n });\n\n return columns;\n};\n\n/**\n * Makes a new configuration object out of the userConfig object\n * using default values for the missing configuration properties.\n *\n * @param {Array[]} rows\n * @param {Object} userConfig\n * @returns {Object}\n */\nexport default (rows, userConfig = {}) => {\n validateConfig('config.json', userConfig);\n\n const config = _.cloneDeep(userConfig);\n\n config.border = makeBorder(config.border);\n config.columns = makeColumns(rows, config.columns, config.columnDefault);\n\n if (!config.drawHorizontalLine) {\n /**\n * @returns {boolean}\n */\n config.drawHorizontalLine = () => {\n return true;\n };\n }\n\n return config;\n};\n"],"file":"makeConfig.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/makeStreamConfig.js b/tools/node_modules/eslint/node_modules/table/dist/makeStreamConfig.js index 479de35a7c9777..131c200c01e712 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/makeStreamConfig.js +++ b/tools/node_modules/eslint/node_modules/table/dist/makeStreamConfig.js @@ -1,20 +1,15 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; -var _lodash = require('lodash'); +var _lodash = _interopRequireDefault(require("lodash")); -var _lodash2 = _interopRequireDefault(_lodash); +var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters")); -var _getBorderCharacters = require('./getBorderCharacters'); - -var _getBorderCharacters2 = _interopRequireDefault(_getBorderCharacters); - -var _validateConfig = require('./validateConfig'); - -var _validateConfig2 = _interopRequireDefault(_validateConfig); +var _validateConfig = _interopRequireDefault(require("./validateConfig")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -24,12 +19,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @param {Object} border * @returns {Object} */ -const makeBorder = function makeBorder() { - let border = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - return Object.assign({}, (0, _getBorderCharacters2.default)('honeywell'), border); +const makeBorder = (border = {}) => { + return Object.assign({}, (0, _getBorderCharacters.default)('honeywell'), border); }; - /** * Creates a configuration for every column using default * values for the missing configuration properties. @@ -39,12 +31,11 @@ const makeBorder = function makeBorder() { * @param {Object} columnDefault * @returns {Object} */ -const makeColumns = function makeColumns(columnCount) { - let columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - let columnDefault = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - _lodash2.default.times(columnCount, index => { - if (_lodash2.default.isUndefined(columns[index])) { + +const makeColumns = (columnCount, columns = {}, columnDefault = {}) => { + _lodash.default.times(columnCount, index => { + if (_lodash.default.isUndefined(columns[index])) { columns[index] = {}; } @@ -59,7 +50,6 @@ const makeColumns = function makeColumns(columnCount) { return columns; }; - /** * @typedef {Object} columnConfig * @property {string} alignment @@ -85,12 +75,11 @@ const makeColumns = function makeColumns(columnCount) { * @returns {Object} */ -exports.default = function () { - let userConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - (0, _validateConfig2.default)('streamConfig.json', userConfig); +const makeStreamConfig = (userConfig = {}) => { + (0, _validateConfig.default)('streamConfig.json', userConfig); - const config = _lodash2.default.cloneDeep(userConfig); + const config = _lodash.default.cloneDeep(userConfig); if (!config.columnDefault || !config.columnDefault.width) { throw new Error('Must provide config.columnDefault.width when creating a stream.'); @@ -102,6 +91,9 @@ exports.default = function () { config.border = makeBorder(config.border); config.columns = makeColumns(config.columnCount, config.columns, config.columnDefault); - return config; -}; \ No newline at end of file +}; + +var _default = makeStreamConfig; +exports.default = _default; +//# sourceMappingURL=makeStreamConfig.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/makeStreamConfig.js.flow b/tools/node_modules/eslint/node_modules/table/dist/makeStreamConfig.js.flow new file mode 100644 index 00000000000000..884625a53bb3a0 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/makeStreamConfig.js.flow @@ -0,0 +1,83 @@ +import _ from 'lodash'; +import getBorderCharacters from './getBorderCharacters'; +import validateConfig from './validateConfig'; + +/** + * Merges user provided border characters with the default border ("honeywell") characters. + * + * @param {Object} border + * @returns {Object} + */ +const makeBorder = (border = {}) => { + return Object.assign({}, getBorderCharacters('honeywell'), border); +}; + +/** + * Creates a configuration for every column using default + * values for the missing configuration properties. + * + * @param {number} columnCount + * @param {Object} columns + * @param {Object} columnDefault + * @returns {Object} + */ +const makeColumns = (columnCount, columns = {}, columnDefault = {}) => { + _.times(columnCount, (index) => { + if (_.isUndefined(columns[index])) { + columns[index] = {}; + } + + columns[index] = Object.assign({ + alignment: 'left', + paddingLeft: 1, + paddingRight: 1, + truncate: Infinity, + wrapWord: false + }, columnDefault, columns[index]); + }); + + return columns; +}; + +/** + * @typedef {Object} columnConfig + * @property {string} alignment + * @property {number} width + * @property {number} truncate + * @property {number} paddingLeft + * @property {number} paddingRight + */ + +/** + * @typedef {Object} streamConfig + * @property {columnConfig} columnDefault + * @property {Object} border + * @property {columnConfig[]} + * @property {number} columnCount Number of columns in the table (required). + */ + +/** + * Makes a new configuration object out of the userConfig object + * using default values for the missing configuration properties. + * + * @param {streamConfig} userConfig + * @returns {Object} + */ +export default (userConfig = {}) => { + validateConfig('streamConfig.json', userConfig); + + const config = _.cloneDeep(userConfig); + + if (!config.columnDefault || !config.columnDefault.width) { + throw new Error('Must provide config.columnDefault.width when creating a stream.'); + } + + if (!config.columnCount) { + throw new Error('Must provide config.columnCount.'); + } + + config.border = makeBorder(config.border); + config.columns = makeColumns(config.columnCount, config.columns, config.columnDefault); + + return config; +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/makeStreamConfig.js.map b/tools/node_modules/eslint/node_modules/table/dist/makeStreamConfig.js.map new file mode 100644 index 00000000000000..a0a52ddae04ae7 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/makeStreamConfig.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/makeStreamConfig.js"],"names":["makeBorder","border","Object","assign","makeColumns","columnCount","columns","columnDefault","_","times","index","isUndefined","alignment","paddingLeft","paddingRight","truncate","Infinity","wrapWord","userConfig","config","cloneDeep","width","Error"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAEA;;;;;;AAMA,MAAMA,UAAU,GAAG,CAACC,MAAM,GAAG,EAAV,KAAiB;AAClC,SAAOC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkB,kCAAoB,WAApB,CAAlB,EAAoDF,MAApD,CAAP;AACD,CAFD;AAIA;;;;;;;;;;;AASA,MAAMG,WAAW,GAAG,CAACC,WAAD,EAAcC,OAAO,GAAG,EAAxB,EAA4BC,aAAa,GAAG,EAA5C,KAAmD;AACrEC,kBAAEC,KAAF,CAAQJ,WAAR,EAAsBK,KAAD,IAAW;AAC9B,QAAIF,gBAAEG,WAAF,CAAcL,OAAO,CAACI,KAAD,CAArB,CAAJ,EAAmC;AACjCJ,MAAAA,OAAO,CAACI,KAAD,CAAP,GAAiB,EAAjB;AACD;;AAEDJ,IAAAA,OAAO,CAACI,KAAD,CAAP,GAAiBR,MAAM,CAACC,MAAP,CAAc;AAC7BS,MAAAA,SAAS,EAAE,MADkB;AAE7BC,MAAAA,WAAW,EAAE,CAFgB;AAG7BC,MAAAA,YAAY,EAAE,CAHe;AAI7BC,MAAAA,QAAQ,EAAEC,QAJmB;AAK7BC,MAAAA,QAAQ,EAAE;AALmB,KAAd,EAMdV,aANc,EAMCD,OAAO,CAACI,KAAD,CANR,CAAjB;AAOD,GAZD;;AAcA,SAAOJ,OAAP;AACD,CAhBD;AAkBA;;;;;;;;;AASA;;;;;;;;AAQA;;;;;;;;;0BAOgBY,UAAU,GAAG,E,KAAO;AAClC,+BAAe,mBAAf,EAAoCA,UAApC;;AAEA,QAAMC,MAAM,GAAGX,gBAAEY,SAAF,CAAYF,UAAZ,CAAf;;AAEA,MAAI,CAACC,MAAM,CAACZ,aAAR,IAAyB,CAACY,MAAM,CAACZ,aAAP,CAAqBc,KAAnD,EAA0D;AACxD,UAAM,IAAIC,KAAJ,CAAU,iEAAV,CAAN;AACD;;AAED,MAAI,CAACH,MAAM,CAACd,WAAZ,EAAyB;AACvB,UAAM,IAAIiB,KAAJ,CAAU,kCAAV,CAAN;AACD;;AAEDH,EAAAA,MAAM,CAAClB,MAAP,GAAgBD,UAAU,CAACmB,MAAM,CAAClB,MAAR,CAA1B;AACAkB,EAAAA,MAAM,CAACb,OAAP,GAAiBF,WAAW,CAACe,MAAM,CAACd,WAAR,EAAqBc,MAAM,CAACb,OAA5B,EAAqCa,MAAM,CAACZ,aAA5C,CAA5B;AAEA,SAAOY,MAAP;AACD,C","sourcesContent":["import _ from 'lodash';\nimport getBorderCharacters from './getBorderCharacters';\nimport validateConfig from './validateConfig';\n\n/**\n * Merges user provided border characters with the default border (\"honeywell\") characters.\n *\n * @param {Object} border\n * @returns {Object}\n */\nconst makeBorder = (border = {}) => {\n return Object.assign({}, getBorderCharacters('honeywell'), border);\n};\n\n/**\n * Creates a configuration for every column using default\n * values for the missing configuration properties.\n *\n * @param {number} columnCount\n * @param {Object} columns\n * @param {Object} columnDefault\n * @returns {Object}\n */\nconst makeColumns = (columnCount, columns = {}, columnDefault = {}) => {\n _.times(columnCount, (index) => {\n if (_.isUndefined(columns[index])) {\n columns[index] = {};\n }\n\n columns[index] = Object.assign({\n alignment: 'left',\n paddingLeft: 1,\n paddingRight: 1,\n truncate: Infinity,\n wrapWord: false\n }, columnDefault, columns[index]);\n });\n\n return columns;\n};\n\n/**\n * @typedef {Object} columnConfig\n * @property {string} alignment\n * @property {number} width\n * @property {number} truncate\n * @property {number} paddingLeft\n * @property {number} paddingRight\n */\n\n/**\n * @typedef {Object} streamConfig\n * @property {columnConfig} columnDefault\n * @property {Object} border\n * @property {columnConfig[]}\n * @property {number} columnCount Number of columns in the table (required).\n */\n\n/**\n * Makes a new configuration object out of the userConfig object\n * using default values for the missing configuration properties.\n *\n * @param {streamConfig} userConfig\n * @returns {Object}\n */\nexport default (userConfig = {}) => {\n validateConfig('streamConfig.json', userConfig);\n\n const config = _.cloneDeep(userConfig);\n\n if (!config.columnDefault || !config.columnDefault.width) {\n throw new Error('Must provide config.columnDefault.width when creating a stream.');\n }\n\n if (!config.columnCount) {\n throw new Error('Must provide config.columnCount.');\n }\n\n config.border = makeBorder(config.border);\n config.columns = makeColumns(config.columnCount, config.columns, config.columnDefault);\n\n return config;\n};\n"],"file":"makeStreamConfig.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js b/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js index be0aae4e98ad42..8a7a16e2ce2f22 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js +++ b/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js @@ -1,20 +1,15 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; -var _lodash = require('lodash'); +var _lodash = _interopRequireDefault(require("lodash")); -var _lodash2 = _interopRequireDefault(_lodash); +var _wrapString = _interopRequireDefault(require("./wrapString")); -var _wrapString = require('./wrapString'); - -var _wrapString2 = _interopRequireDefault(_wrapString); - -var _wrapWord = require('./wrapWord'); - -var _wrapWord2 = _interopRequireDefault(_wrapWord); +var _wrapWord = _interopRequireDefault(require("./wrapWord")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -24,34 +19,34 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @param {Object} config * @returns {Array} */ -exports.default = (unmappedRows, rowHeightIndex, config) => { +const mapDataUsingRowHeightIndex = (unmappedRows, rowHeightIndex, config) => { const tableWidth = unmappedRows[0].length; - const mappedRows = unmappedRows.map((cells, index0) => { - const rowHeight = _lodash2.default.times(rowHeightIndex[index0], () => { - return Array(tableWidth).fill(''); - }); - - // rowHeight + const rowHeight = _lodash.default.times(rowHeightIndex[index0], () => { + return new Array(tableWidth).fill(''); + }); // rowHeight // [{row index within rowSaw; index2}] // [{cell index within a virtual row; index1}] + cells.forEach((value, index1) => { let chunkedValue; if (config.columns[index1].wrapWord) { - chunkedValue = (0, _wrapWord2.default)(value, config.columns[index1].width); + chunkedValue = (0, _wrapWord.default)(value, config.columns[index1].width); } else { - chunkedValue = (0, _wrapString2.default)(value, config.columns[index1].width); + chunkedValue = (0, _wrapString.default)(value, config.columns[index1].width); } chunkedValue.forEach((part, index2) => { rowHeight[index2][index1] = part; }); }); - return rowHeight; }); + return _lodash.default.flatten(mappedRows); +}; - return _lodash2.default.flatten(mappedRows); -}; \ No newline at end of file +var _default = mapDataUsingRowHeightIndex; +exports.default = _default; +//# sourceMappingURL=mapDataUsingRowHeightIndex.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow b/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow new file mode 100644 index 00000000000000..89f1869b5daa8a --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow @@ -0,0 +1,41 @@ +import _ from 'lodash'; +import wrapString from './wrapString'; +import wrapWord from './wrapWord'; + +/** + * @param {Array} unmappedRows + * @param {number[]} rowHeightIndex + * @param {Object} config + * @returns {Array} + */ +export default (unmappedRows, rowHeightIndex, config) => { + const tableWidth = unmappedRows[0].length; + + const mappedRows = unmappedRows.map((cells, index0) => { + const rowHeight = _.times(rowHeightIndex[index0], () => { + return new Array(tableWidth).fill(''); + }); + + // rowHeight + // [{row index within rowSaw; index2}] + // [{cell index within a virtual row; index1}] + + cells.forEach((value, index1) => { + let chunkedValue; + + if (config.columns[index1].wrapWord) { + chunkedValue = wrapWord(value, config.columns[index1].width); + } else { + chunkedValue = wrapString(value, config.columns[index1].width); + } + + chunkedValue.forEach((part, index2) => { + rowHeight[index2][index1] = part; + }); + }); + + return rowHeight; + }); + + return _.flatten(mappedRows); +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js.map b/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js.map new file mode 100644 index 00000000000000..3c1cd9844899ed --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/mapDataUsingRowHeightIndex.js"],"names":["unmappedRows","rowHeightIndex","config","tableWidth","length","mappedRows","map","cells","index0","rowHeight","_","times","Array","fill","forEach","value","index1","chunkedValue","columns","wrapWord","width","part","index2","flatten"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAEA;;;;;;oCAMgBA,Y,EAAcC,c,EAAgBC,M,KAAW;AACvD,QAAMC,UAAU,GAAGH,YAAY,CAAC,CAAD,CAAZ,CAAgBI,MAAnC;AAEA,QAAMC,UAAU,GAAGL,YAAY,CAACM,GAAb,CAAiB,CAACC,KAAD,EAAQC,MAAR,KAAmB;AACrD,UAAMC,SAAS,GAAGC,gBAAEC,KAAF,CAAQV,cAAc,CAACO,MAAD,CAAtB,EAAgC,MAAM;AACtD,aAAO,IAAII,KAAJ,CAAUT,UAAV,EAAsBU,IAAtB,CAA2B,EAA3B,CAAP;AACD,KAFiB,CAAlB,CADqD,CAKrD;AACA;AACA;;;AAEAN,IAAAA,KAAK,CAACO,OAAN,CAAc,CAACC,KAAD,EAAQC,MAAR,KAAmB;AAC/B,UAAIC,YAAJ;;AAEA,UAAIf,MAAM,CAACgB,OAAP,CAAeF,MAAf,EAAuBG,QAA3B,EAAqC;AACnCF,QAAAA,YAAY,GAAG,uBAASF,KAAT,EAAgBb,MAAM,CAACgB,OAAP,CAAeF,MAAf,EAAuBI,KAAvC,CAAf;AACD,OAFD,MAEO;AACLH,QAAAA,YAAY,GAAG,yBAAWF,KAAX,EAAkBb,MAAM,CAACgB,OAAP,CAAeF,MAAf,EAAuBI,KAAzC,CAAf;AACD;;AAEDH,MAAAA,YAAY,CAACH,OAAb,CAAqB,CAACO,IAAD,EAAOC,MAAP,KAAkB;AACrCb,QAAAA,SAAS,CAACa,MAAD,CAAT,CAAkBN,MAAlB,IAA4BK,IAA5B;AACD,OAFD;AAGD,KAZD;AAcA,WAAOZ,SAAP;AACD,GAxBkB,CAAnB;AA0BA,SAAOC,gBAAEa,OAAF,CAAUlB,UAAV,CAAP;AACD,C","sourcesContent":["import _ from 'lodash';\nimport wrapString from './wrapString';\nimport wrapWord from './wrapWord';\n\n/**\n * @param {Array} unmappedRows\n * @param {number[]} rowHeightIndex\n * @param {Object} config\n * @returns {Array}\n */\nexport default (unmappedRows, rowHeightIndex, config) => {\n const tableWidth = unmappedRows[0].length;\n\n const mappedRows = unmappedRows.map((cells, index0) => {\n const rowHeight = _.times(rowHeightIndex[index0], () => {\n return new Array(tableWidth).fill('');\n });\n\n // rowHeight\n // [{row index within rowSaw; index2}]\n // [{cell index within a virtual row; index1}]\n\n cells.forEach((value, index1) => {\n let chunkedValue;\n\n if (config.columns[index1].wrapWord) {\n chunkedValue = wrapWord(value, config.columns[index1].width);\n } else {\n chunkedValue = wrapString(value, config.columns[index1].width);\n }\n\n chunkedValue.forEach((part, index2) => {\n rowHeight[index2][index1] = part;\n });\n });\n\n return rowHeight;\n });\n\n return _.flatten(mappedRows);\n};\n"],"file":"mapDataUsingRowHeightIndex.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/padTableData.js b/tools/node_modules/eslint/node_modules/table/dist/padTableData.js index a78ce49bb1b624..81bd5f5d4ea03c 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/padTableData.js +++ b/tools/node_modules/eslint/node_modules/table/dist/padTableData.js @@ -1,20 +1,24 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; /** * @param {table~row[]} rows * @param {Object} config * @returns {table~row[]} */ -exports.default = (rows, config) => { +const padTableData = (rows, config) => { return rows.map(cells => { return cells.map((value, index1) => { const column = config.columns[index1]; - return ' '.repeat(column.paddingLeft) + value + ' '.repeat(column.paddingRight); }); }); -}; \ No newline at end of file +}; + +var _default = padTableData; +exports.default = _default; +//# sourceMappingURL=padTableData.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/padTableData.js.flow b/tools/node_modules/eslint/node_modules/table/dist/padTableData.js.flow new file mode 100644 index 00000000000000..f23dc021076099 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/padTableData.js.flow @@ -0,0 +1,14 @@ +/** + * @param {table~row[]} rows + * @param {Object} config + * @returns {table~row[]} + */ +export default (rows, config) => { + return rows.map((cells) => { + return cells.map((value, index1) => { + const column = config.columns[index1]; + + return ' '.repeat(column.paddingLeft) + value + ' '.repeat(column.paddingRight); + }); + }); +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/padTableData.js.map b/tools/node_modules/eslint/node_modules/table/dist/padTableData.js.map new file mode 100644 index 00000000000000..783f9cc2fb96da --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/padTableData.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/padTableData.js"],"names":["rows","config","map","cells","value","index1","column","columns","repeat","paddingLeft","paddingRight"],"mappings":";;;;;;;AAAA;;;;;sBAKgBA,I,EAAMC,M,KAAW;AAC/B,SAAOD,IAAI,CAACE,GAAL,CAAUC,KAAD,IAAW;AACzB,WAAOA,KAAK,CAACD,GAAN,CAAU,CAACE,KAAD,EAAQC,MAAR,KAAmB;AAClC,YAAMC,MAAM,GAAGL,MAAM,CAACM,OAAP,CAAeF,MAAf,CAAf;AAEA,aAAO,IAAIG,MAAJ,CAAWF,MAAM,CAACG,WAAlB,IAAiCL,KAAjC,GAAyC,IAAII,MAAJ,CAAWF,MAAM,CAACI,YAAlB,CAAhD;AACD,KAJM,CAAP;AAKD,GANM,CAAP;AAOD,C","sourcesContent":["/**\n * @param {table~row[]} rows\n * @param {Object} config\n * @returns {table~row[]}\n */\nexport default (rows, config) => {\n return rows.map((cells) => {\n return cells.map((value, index1) => {\n const column = config.columns[index1];\n\n return ' '.repeat(column.paddingLeft) + value + ' '.repeat(column.paddingRight);\n });\n });\n};\n"],"file":"padTableData.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/schemas/config.json b/tools/node_modules/eslint/node_modules/table/dist/schemas/config.json index 36074181494ce1..1a4a9981833029 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/schemas/config.json +++ b/tools/node_modules/eslint/node_modules/table/dist/schemas/config.json @@ -1,6 +1,6 @@ { "$id": "config.json", - "$schema": "http://json-schema.org/draft-06/schema#", + "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "border": { diff --git a/tools/node_modules/eslint/node_modules/table/dist/schemas/streamConfig.json b/tools/node_modules/eslint/node_modules/table/dist/schemas/streamConfig.json index d8402a6248e2bd..35199844fd433e 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/schemas/streamConfig.json +++ b/tools/node_modules/eslint/node_modules/table/dist/schemas/streamConfig.json @@ -1,6 +1,6 @@ { "$id": "streamConfig.json", - "$schema": "http://json-schema.org/draft-06/schema#", + "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "border": { diff --git a/tools/node_modules/eslint/node_modules/table/dist/stringifyTableData.js b/tools/node_modules/eslint/node_modules/table/dist/stringifyTableData.js index 46a8b94a397633..0217e3b7b1f376 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/stringifyTableData.js +++ b/tools/node_modules/eslint/node_modules/table/dist/stringifyTableData.js @@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; /** * Casts all cell values to a string. @@ -10,8 +11,12 @@ Object.defineProperty(exports, "__esModule", { * @param {table~row[]} rows * @returns {table~row[]} */ -exports.default = rows => { +const stringifyTableData = rows => { return rows.map(cells => { return cells.map(String); }); -}; \ No newline at end of file +}; + +var _default = stringifyTableData; +exports.default = _default; +//# sourceMappingURL=stringifyTableData.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/stringifyTableData.js.flow b/tools/node_modules/eslint/node_modules/table/dist/stringifyTableData.js.flow new file mode 100644 index 00000000000000..a4dffac13d9be6 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/stringifyTableData.js.flow @@ -0,0 +1,11 @@ +/** + * Casts all cell values to a string. + * + * @param {table~row[]} rows + * @returns {table~row[]} + */ +export default (rows) => { + return rows.map((cells) => { + return cells.map(String); + }); +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/stringifyTableData.js.map b/tools/node_modules/eslint/node_modules/table/dist/stringifyTableData.js.map new file mode 100644 index 00000000000000..6cbe5a71f3c427 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/stringifyTableData.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/stringifyTableData.js"],"names":["rows","map","cells","String"],"mappings":";;;;;;;AAAA;;;;;;2BAMgBA,I,IAAS;AACvB,SAAOA,IAAI,CAACC,GAAL,CAAUC,KAAD,IAAW;AACzB,WAAOA,KAAK,CAACD,GAAN,CAAUE,MAAV,CAAP;AACD,GAFM,CAAP;AAGD,C","sourcesContent":["/**\n * Casts all cell values to a string.\n *\n * @param {table~row[]} rows\n * @returns {table~row[]}\n */\nexport default (rows) => {\n return rows.map((cells) => {\n return cells.map(String);\n });\n};\n"],"file":"stringifyTableData.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/table.js b/tools/node_modules/eslint/node_modules/table/dist/table.js index fe8c3cfeb1b750..b4aac0167e3deb 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/table.js +++ b/tools/node_modules/eslint/node_modules/table/dist/table.js @@ -1,48 +1,29 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; -var _drawTable = require('./drawTable'); +var _drawTable = _interopRequireDefault(require("./drawTable")); -var _drawTable2 = _interopRequireDefault(_drawTable); +var _calculateCellWidthIndex = _interopRequireDefault(require("./calculateCellWidthIndex")); -var _calculateCellWidthIndex = require('./calculateCellWidthIndex'); +var _makeConfig = _interopRequireDefault(require("./makeConfig")); -var _calculateCellWidthIndex2 = _interopRequireDefault(_calculateCellWidthIndex); +var _calculateRowHeightIndex = _interopRequireDefault(require("./calculateRowHeightIndex")); -var _makeConfig = require('./makeConfig'); +var _mapDataUsingRowHeightIndex = _interopRequireDefault(require("./mapDataUsingRowHeightIndex")); -var _makeConfig2 = _interopRequireDefault(_makeConfig); +var _alignTableData = _interopRequireDefault(require("./alignTableData")); -var _calculateRowHeightIndex = require('./calculateRowHeightIndex'); +var _padTableData = _interopRequireDefault(require("./padTableData")); -var _calculateRowHeightIndex2 = _interopRequireDefault(_calculateRowHeightIndex); +var _validateTableData = _interopRequireDefault(require("./validateTableData")); -var _mapDataUsingRowHeightIndex = require('./mapDataUsingRowHeightIndex'); +var _stringifyTableData = _interopRequireDefault(require("./stringifyTableData")); -var _mapDataUsingRowHeightIndex2 = _interopRequireDefault(_mapDataUsingRowHeightIndex); - -var _alignTableData = require('./alignTableData'); - -var _alignTableData2 = _interopRequireDefault(_alignTableData); - -var _padTableData = require('./padTableData'); - -var _padTableData2 = _interopRequireDefault(_padTableData); - -var _validateTableData = require('./validateTableData'); - -var _validateTableData2 = _interopRequireDefault(_validateTableData); - -var _stringifyTableData = require('./stringifyTableData'); - -var _stringifyTableData2 = _interopRequireDefault(_stringifyTableData); - -var _truncateTableData = require('./truncateTableData'); - -var _truncateTableData2 = _interopRequireDefault(_truncateTableData); +var _truncateTableData = _interopRequireDefault(require("./truncateTableData")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -59,6 +40,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @property {string} alignment Cell content alignment (enum: left, center, right) (default: left). * @property {number} width Column width (default: auto). * @property {number} truncate Number of characters are which the content will be truncated (default: Infinity). + * @property {boolean} wrapWord When true the text is broken at the nearest space or one of the special characters * @property {number} paddingLeft Cell content padding width left (default: 1). * @property {number} paddingRight Cell content padding width right (default: 1). */ @@ -108,26 +90,20 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @param {table~config} userConfig * @returns {string} */ -exports.default = function (data) { - let userConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - +const table = (data, userConfig = {}) => { let rows; - - (0, _validateTableData2.default)(data); - - rows = (0, _stringifyTableData2.default)(data); - - const config = (0, _makeConfig2.default)(rows, userConfig); - - rows = (0, _truncateTableData2.default)(data, config); - - const rowHeightIndex = (0, _calculateRowHeightIndex2.default)(rows, config); - - rows = (0, _mapDataUsingRowHeightIndex2.default)(rows, rowHeightIndex, config); - rows = (0, _alignTableData2.default)(rows, config); - rows = (0, _padTableData2.default)(rows, config); - - const cellWidthIndex = (0, _calculateCellWidthIndex2.default)(rows[0]); - - return (0, _drawTable2.default)(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawHorizontalLine); -}; \ No newline at end of file + (0, _validateTableData.default)(data); + rows = (0, _stringifyTableData.default)(data); + const config = (0, _makeConfig.default)(rows, userConfig); + rows = (0, _truncateTableData.default)(data, config); + const rowHeightIndex = (0, _calculateRowHeightIndex.default)(rows, config); + rows = (0, _mapDataUsingRowHeightIndex.default)(rows, rowHeightIndex, config); + rows = (0, _alignTableData.default)(rows, config); + rows = (0, _padTableData.default)(rows, config); + const cellWidthIndex = (0, _calculateCellWidthIndex.default)(rows[0]); + return (0, _drawTable.default)(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawHorizontalLine); +}; + +var _default = table; +exports.default = _default; +//# sourceMappingURL=table.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/table.js.flow b/tools/node_modules/eslint/node_modules/table/dist/table.js.flow new file mode 100644 index 00000000000000..1b68a51a29488e --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/table.js.flow @@ -0,0 +1,95 @@ +import drawTable from './drawTable'; +import calculateCellWidthIndex from './calculateCellWidthIndex'; +import makeConfig from './makeConfig'; +import calculateRowHeightIndex from './calculateRowHeightIndex'; +import mapDataUsingRowHeightIndex from './mapDataUsingRowHeightIndex'; +import alignTableData from './alignTableData'; +import padTableData from './padTableData'; +import validateTableData from './validateTableData'; +import stringifyTableData from './stringifyTableData'; +import truncateTableData from './truncateTableData'; + +/** + * @typedef {string} table~cell + */ + +/** + * @typedef {table~cell[]} table~row + */ + +/** + * @typedef {Object} table~columns + * @property {string} alignment Cell content alignment (enum: left, center, right) (default: left). + * @property {number} width Column width (default: auto). + * @property {number} truncate Number of characters are which the content will be truncated (default: Infinity). + * @property {boolean} wrapWord When true the text is broken at the nearest space or one of the special characters + * @property {number} paddingLeft Cell content padding width left (default: 1). + * @property {number} paddingRight Cell content padding width right (default: 1). + */ + +/** + * @typedef {Object} table~border + * @property {string} topBody + * @property {string} topJoin + * @property {string} topLeft + * @property {string} topRight + * @property {string} bottomBody + * @property {string} bottomJoin + * @property {string} bottomLeft + * @property {string} bottomRight + * @property {string} bodyLeft + * @property {string} bodyRight + * @property {string} bodyJoin + * @property {string} joinBody + * @property {string} joinLeft + * @property {string} joinRight + * @property {string} joinJoin + */ + +/** + * Used to tell whether to draw a horizontal line. + * This callback is called for each non-content line of the table. + * The default behavior is to always return true. + * + * @typedef {Function} drawHorizontalLine + * @param {number} index + * @param {number} size + * @returns {boolean} + */ + +/** + * @typedef {Object} table~config + * @property {table~border} border + * @property {table~columns[]} columns Column specific configuration. + * @property {table~columns} columnDefault Default values for all columns. Column specific settings overwrite the default values. + * @property {table~drawHorizontalLine} drawHorizontalLine + */ + +/** + * Generates a text table. + * + * @param {table~row[]} data + * @param {table~config} userConfig + * @returns {string} + */ +export default (data, userConfig = {}) => { + let rows; + + validateTableData(data); + + rows = stringifyTableData(data); + + const config = makeConfig(rows, userConfig); + + rows = truncateTableData(data, config); + + const rowHeightIndex = calculateRowHeightIndex(rows, config); + + rows = mapDataUsingRowHeightIndex(rows, rowHeightIndex, config); + rows = alignTableData(rows, config); + rows = padTableData(rows, config); + + const cellWidthIndex = calculateCellWidthIndex(rows[0]); + + return drawTable(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawHorizontalLine); +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/table.js.map b/tools/node_modules/eslint/node_modules/table/dist/table.js.map new file mode 100644 index 00000000000000..5268d98da504b3 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/table.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/table.js"],"names":["data","userConfig","rows","config","rowHeightIndex","cellWidthIndex","border","drawHorizontalLine"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEA;;;;AAIA;;;;AAIA;;;;;;;;;;AAUA;;;;;;;;;;;;;;;;;;;AAmBA;;;;;;;;;;;AAWA;;;;;;;;AAQA;;;;;;;eAOgBA,I,EAAMC,UAAU,GAAG,E,KAAO;AACxC,MAAIC,IAAJ;AAEA,kCAAkBF,IAAlB;AAEAE,EAAAA,IAAI,GAAG,iCAAmBF,IAAnB,CAAP;AAEA,QAAMG,MAAM,GAAG,yBAAWD,IAAX,EAAiBD,UAAjB,CAAf;AAEAC,EAAAA,IAAI,GAAG,gCAAkBF,IAAlB,EAAwBG,MAAxB,CAAP;AAEA,QAAMC,cAAc,GAAG,sCAAwBF,IAAxB,EAA8BC,MAA9B,CAAvB;AAEAD,EAAAA,IAAI,GAAG,yCAA2BA,IAA3B,EAAiCE,cAAjC,EAAiDD,MAAjD,CAAP;AACAD,EAAAA,IAAI,GAAG,6BAAeA,IAAf,EAAqBC,MAArB,CAAP;AACAD,EAAAA,IAAI,GAAG,2BAAaA,IAAb,EAAmBC,MAAnB,CAAP;AAEA,QAAME,cAAc,GAAG,sCAAwBH,IAAI,CAAC,CAAD,CAA5B,CAAvB;AAEA,SAAO,wBAAUA,IAAV,EAAgBC,MAAM,CAACG,MAAvB,EAA+BD,cAA/B,EAA+CD,cAA/C,EAA+DD,MAAM,CAACI,kBAAtE,CAAP;AACD,C","sourcesContent":["import drawTable from './drawTable';\nimport calculateCellWidthIndex from './calculateCellWidthIndex';\nimport makeConfig from './makeConfig';\nimport calculateRowHeightIndex from './calculateRowHeightIndex';\nimport mapDataUsingRowHeightIndex from './mapDataUsingRowHeightIndex';\nimport alignTableData from './alignTableData';\nimport padTableData from './padTableData';\nimport validateTableData from './validateTableData';\nimport stringifyTableData from './stringifyTableData';\nimport truncateTableData from './truncateTableData';\n\n/**\n * @typedef {string} table~cell\n */\n\n/**\n * @typedef {table~cell[]} table~row\n */\n\n/**\n * @typedef {Object} table~columns\n * @property {string} alignment Cell content alignment (enum: left, center, right) (default: left).\n * @property {number} width Column width (default: auto).\n * @property {number} truncate Number of characters are which the content will be truncated (default: Infinity).\n * @property {boolean} wrapWord When true the text is broken at the nearest space or one of the special characters\n * @property {number} paddingLeft Cell content padding width left (default: 1).\n * @property {number} paddingRight Cell content padding width right (default: 1).\n */\n\n/**\n * @typedef {Object} table~border\n * @property {string} topBody\n * @property {string} topJoin\n * @property {string} topLeft\n * @property {string} topRight\n * @property {string} bottomBody\n * @property {string} bottomJoin\n * @property {string} bottomLeft\n * @property {string} bottomRight\n * @property {string} bodyLeft\n * @property {string} bodyRight\n * @property {string} bodyJoin\n * @property {string} joinBody\n * @property {string} joinLeft\n * @property {string} joinRight\n * @property {string} joinJoin\n */\n\n/**\n * Used to tell whether to draw a horizontal line.\n * This callback is called for each non-content line of the table.\n * The default behavior is to always return true.\n *\n * @typedef {Function} drawHorizontalLine\n * @param {number} index\n * @param {number} size\n * @returns {boolean}\n */\n\n/**\n * @typedef {Object} table~config\n * @property {table~border} border\n * @property {table~columns[]} columns Column specific configuration.\n * @property {table~columns} columnDefault Default values for all columns. Column specific settings overwrite the default values.\n * @property {table~drawHorizontalLine} drawHorizontalLine\n */\n\n/**\n * Generates a text table.\n *\n * @param {table~row[]} data\n * @param {table~config} userConfig\n * @returns {string}\n */\nexport default (data, userConfig = {}) => {\n let rows;\n\n validateTableData(data);\n\n rows = stringifyTableData(data);\n\n const config = makeConfig(rows, userConfig);\n\n rows = truncateTableData(data, config);\n\n const rowHeightIndex = calculateRowHeightIndex(rows, config);\n\n rows = mapDataUsingRowHeightIndex(rows, rowHeightIndex, config);\n rows = alignTableData(rows, config);\n rows = padTableData(rows, config);\n\n const cellWidthIndex = calculateCellWidthIndex(rows[0]);\n\n return drawTable(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawHorizontalLine);\n};\n"],"file":"table.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/truncateTableData.js b/tools/node_modules/eslint/node_modules/table/dist/truncateTableData.js index 748b41cca7be17..210a124bcbffe2 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/truncateTableData.js +++ b/tools/node_modules/eslint/node_modules/table/dist/truncateTableData.js @@ -1,12 +1,11 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; -var _lodash = require('lodash'); - -var _lodash2 = _interopRequireDefault(_lodash); +var _lodash = _interopRequireDefault(require("lodash")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -16,12 +15,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @param {Object} config * @returns {table~row[]} */ -exports.default = (rows, config) => { +const truncateTableData = (rows, config) => { return rows.map(cells => { return cells.map((content, index) => { - return _lodash2.default.truncate(content, { + return _lodash.default.truncate(content, { length: config.columns[index].truncate }); }); }); -}; \ No newline at end of file +}; + +var _default = truncateTableData; +exports.default = _default; +//# sourceMappingURL=truncateTableData.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/truncateTableData.js.flow b/tools/node_modules/eslint/node_modules/table/dist/truncateTableData.js.flow new file mode 100644 index 00000000000000..1052c92333033b --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/truncateTableData.js.flow @@ -0,0 +1,17 @@ +import _ from 'lodash'; + +/** + * @todo Make it work with ASCII content. + * @param {table~row[]} rows + * @param {Object} config + * @returns {table~row[]} + */ +export default (rows, config) => { + return rows.map((cells) => { + return cells.map((content, index) => { + return _.truncate(content, { + length: config.columns[index].truncate + }); + }); + }); +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/truncateTableData.js.map b/tools/node_modules/eslint/node_modules/table/dist/truncateTableData.js.map new file mode 100644 index 00000000000000..fbab35ea49bd14 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/truncateTableData.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/truncateTableData.js"],"names":["rows","config","map","cells","content","index","_","truncate","length","columns"],"mappings":";;;;;;;AAAA;;;;AAEA;;;;;;2BAMgBA,I,EAAMC,M,KAAW;AAC/B,SAAOD,IAAI,CAACE,GAAL,CAAUC,KAAD,IAAW;AACzB,WAAOA,KAAK,CAACD,GAAN,CAAU,CAACE,OAAD,EAAUC,KAAV,KAAoB;AACnC,aAAOC,gBAAEC,QAAF,CAAWH,OAAX,EAAoB;AACzBI,QAAAA,MAAM,EAAEP,MAAM,CAACQ,OAAP,CAAeJ,KAAf,EAAsBE;AADL,OAApB,CAAP;AAGD,KAJM,CAAP;AAKD,GANM,CAAP;AAOD,C","sourcesContent":["import _ from 'lodash';\n\n/**\n * @todo Make it work with ASCII content.\n * @param {table~row[]} rows\n * @param {Object} config\n * @returns {table~row[]}\n */\nexport default (rows, config) => {\n return rows.map((cells) => {\n return cells.map((content, index) => {\n return _.truncate(content, {\n length: config.columns[index].truncate\n });\n });\n });\n};\n"],"file":"truncateTableData.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/validateConfig.js b/tools/node_modules/eslint/node_modules/table/dist/validateConfig.js index 3ea3ddea8ff36d..40d812777b5017 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/validateConfig.js +++ b/tools/node_modules/eslint/node_modules/table/dist/validateConfig.js @@ -14,7 +14,7 @@ var validate = (function() { var errs__0 = errors; var valid1 = true; for (var key0 in data) { - var isAdditional0 = !(false || validate.schema.properties[key0]); + var isAdditional0 = !(false || validate.schema.properties.hasOwnProperty(key0)); if (isAdditional0) { valid1 = false; var err = { @@ -344,7 +344,7 @@ var validate = (function() { var errs__0 = errors; var valid1 = true; for (var key0 in data) { - var isAdditional0 = !(false || validate.schema.properties[key0]); + var isAdditional0 = !(false || key0 == 'alignment' || key0 == 'width' || key0 == 'wrapWord' || key0 == 'truncate' || key0 == 'paddingLeft' || key0 == 'paddingRight'); if (isAdditional0) { valid1 = false; var err = { @@ -385,8 +385,7 @@ var validate = (function() { if (equal(data1, schema1[i1])) { valid1 = true; break; - } - if (!valid1) { + } if (!valid1) { var err = { keyword: 'enum', dataPath: (dataPath || '') + '.alignment', @@ -641,7 +640,7 @@ var validate = (function() { })(); validate.schema = { "$id": "config.json", - "$schema": "http://json-schema.org/draft-06/schema#", + "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "border": { diff --git a/tools/node_modules/eslint/node_modules/table/dist/validateConfig.js.flow b/tools/node_modules/eslint/node_modules/table/dist/validateConfig.js.flow new file mode 100644 index 00000000000000..14b9710135a17a --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/validateConfig.js.flow @@ -0,0 +1,34 @@ +// eslint-disable-next-line import/default +import validateConfig from '../dist/validateConfig'; +// eslint-disable-next-line import/default +import validateStreamConfig from '../dist/validateStreamConfig'; + +const validate = { + 'config.json': validateConfig, + 'streamConfig.json': validateStreamConfig +}; + +/** + * @param {string} schemaId + * @param {formatData~config} config + * @returns {undefined} + */ +export default (schemaId, config = {}) => { + if (!validate[schemaId](config)) { + const errors = validate[schemaId].errors.map((error) => { + return { + dataPath: error.dataPath, + message: error.message, + params: error.params, + schemaPath: error.schemaPath + }; + }); + + /* eslint-disable no-console */ + console.log('config', config); + console.log('errors', errors); + /* eslint-enable no-console */ + + throw new Error('Invalid config.'); + } +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/validateConfig.js.map b/tools/node_modules/eslint/node_modules/table/dist/validateConfig.js.map new file mode 100644 index 00000000000000..43bebf7a69b1d1 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/validateConfig.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/validateConfig.js"],"names":["validate","validateConfig","validateStreamConfig","schemaId","config","errors","map","error","dataPath","message","params","schemaPath","console","log","Error"],"mappings":";;;;;;;AACA;;AAEA;;;;AAHA;AAEA;AAGA,MAAMA,QAAQ,GAAG;AACf,iBAAeC,uBADA;AAEf,uBAAqBC;AAFN,CAAjB;AAKA;;;;;;yBAKgBC,Q,EAAUC,MAAM,GAAG,E,KAAO;AACxC,MAAI,CAACJ,QAAQ,CAACG,QAAD,CAAR,CAAmBC,MAAnB,CAAL,EAAiC;AAC/B,UAAMC,MAAM,GAAGL,QAAQ,CAACG,QAAD,CAAR,CAAmBE,MAAnB,CAA0BC,GAA1B,CAA+BC,KAAD,IAAW;AACtD,aAAO;AACLC,QAAAA,QAAQ,EAAED,KAAK,CAACC,QADX;AAELC,QAAAA,OAAO,EAAEF,KAAK,CAACE,OAFV;AAGLC,QAAAA,MAAM,EAAEH,KAAK,CAACG,MAHT;AAILC,QAAAA,UAAU,EAAEJ,KAAK,CAACI;AAJb,OAAP;AAMD,KAPc,CAAf;AASA;;AACAC,IAAAA,OAAO,CAACC,GAAR,CAAY,QAAZ,EAAsBT,MAAtB;AACAQ,IAAAA,OAAO,CAACC,GAAR,CAAY,QAAZ,EAAsBR,MAAtB;AACA;;AAEA,UAAM,IAAIS,KAAJ,CAAU,iBAAV,CAAN;AACD;AACF,C","sourcesContent":["// eslint-disable-next-line import/default\nimport validateConfig from '../dist/validateConfig';\n// eslint-disable-next-line import/default\nimport validateStreamConfig from '../dist/validateStreamConfig';\n\nconst validate = {\n 'config.json': validateConfig,\n 'streamConfig.json': validateStreamConfig\n};\n\n/**\n * @param {string} schemaId\n * @param {formatData~config} config\n * @returns {undefined}\n */\nexport default (schemaId, config = {}) => {\n if (!validate[schemaId](config)) {\n const errors = validate[schemaId].errors.map((error) => {\n return {\n dataPath: error.dataPath,\n message: error.message,\n params: error.params,\n schemaPath: error.schemaPath\n };\n });\n\n /* eslint-disable no-console */\n console.log('config', config);\n console.log('errors', errors);\n /* eslint-enable no-console */\n\n throw new Error('Invalid config.');\n }\n};\n"],"file":"validateConfig.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/validateStreamConfig.js b/tools/node_modules/eslint/node_modules/table/dist/validateStreamConfig.js index 05c4b04c6bf835..ff10e5909ff4cd 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/validateStreamConfig.js +++ b/tools/node_modules/eslint/node_modules/table/dist/validateStreamConfig.js @@ -14,7 +14,7 @@ var validate = (function() { var errs__0 = errors; var valid1 = true; for (var key0 in data) { - var isAdditional0 = !(false || validate.schema.properties[key0]); + var isAdditional0 = !(false || validate.schema.properties.hasOwnProperty(key0)); if (isAdditional0) { valid1 = false; var err = { @@ -344,7 +344,7 @@ var validate = (function() { var errs__0 = errors; var valid1 = true; for (var key0 in data) { - var isAdditional0 = !(false || validate.schema.properties[key0]); + var isAdditional0 = !(false || key0 == 'alignment' || key0 == 'width' || key0 == 'wrapWord' || key0 == 'truncate' || key0 == 'paddingLeft' || key0 == 'paddingRight'); if (isAdditional0) { valid1 = false; var err = { @@ -385,8 +385,7 @@ var validate = (function() { if (equal(data1, schema1[i1])) { valid1 = true; break; - } - if (!valid1) { + } if (!valid1) { var err = { keyword: 'enum', dataPath: (dataPath || '') + '.alignment', @@ -628,7 +627,7 @@ var validate = (function() { })(); validate.schema = { "$id": "streamConfig.json", - "$schema": "http://json-schema.org/draft-06/schema#", + "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "border": { diff --git a/tools/node_modules/eslint/node_modules/table/dist/validateTableData.js b/tools/node_modules/eslint/node_modules/table/dist/validateTableData.js index b5e103ce409c4d..124335cbfe794c 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/validateTableData.js +++ b/tools/node_modules/eslint/node_modules/table/dist/validateTableData.js @@ -1,8 +1,9 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; /** * @typedef {string} cell @@ -16,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { * @param {column[]} rows * @returns {undefined} */ -exports.default = rows => { +const validateTableData = rows => { if (!Array.isArray(rows)) { throw new TypeError('Table data must be an array.'); } @@ -30,22 +31,68 @@ exports.default = rows => { } const columnNumber = rows[0].length; + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; - for (const cells of rows) { - if (!Array.isArray(cells)) { - throw new TypeError('Table row data must be an array.'); - } + try { + for (var _iterator = rows[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + const cells = _step.value; - if (cells.length !== columnNumber) { - throw new Error('Table must have a consistent number of cells.'); - } + if (!Array.isArray(cells)) { + throw new TypeError('Table row data must be an array.'); + } + + if (cells.length !== columnNumber) { + throw new Error('Table must have a consistent number of cells.'); + } // @todo Make an exception for newline characters. + // @see https://github.com/gajus/table/issues/9 + + + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; - // @todo Make an exception for newline characters. - // @see https://github.com/gajus/table/issues/9 - for (const cell of cells) { - if (/[\u0001-\u001A]/.test(cell)) { - throw new Error('Table data must not contain control characters.'); + try { + for (var _iterator2 = cells[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + const cell = _step2.value; + + // eslint-disable-next-line no-control-regex + if (/[\u0001-\u001A]/.test(cell)) { + throw new Error('Table data must not contain control characters.'); + } + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return != null) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return != null) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; } } } -}; \ No newline at end of file +}; + +var _default = validateTableData; +exports.default = _default; +//# sourceMappingURL=validateTableData.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/validateTableData.js.flow b/tools/node_modules/eslint/node_modules/table/dist/validateTableData.js.flow new file mode 100644 index 00000000000000..075eaf09249a45 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/validateTableData.js.flow @@ -0,0 +1,46 @@ +/** + * @typedef {string} cell + */ + +/** + * @typedef {cell[]} validateData~column + */ + +/** + * @param {column[]} rows + * @returns {undefined} + */ +export default (rows) => { + if (!Array.isArray(rows)) { + throw new TypeError('Table data must be an array.'); + } + + if (rows.length === 0) { + throw new Error('Table must define at least one row.'); + } + + if (rows[0].length === 0) { + throw new Error('Table must define at least one column.'); + } + + const columnNumber = rows[0].length; + + for (const cells of rows) { + if (!Array.isArray(cells)) { + throw new TypeError('Table row data must be an array.'); + } + + if (cells.length !== columnNumber) { + throw new Error('Table must have a consistent number of cells.'); + } + + // @todo Make an exception for newline characters. + // @see https://github.com/gajus/table/issues/9 + for (const cell of cells) { + // eslint-disable-next-line no-control-regex + if (/[\u0001-\u001A]/.test(cell)) { + throw new Error('Table data must not contain control characters.'); + } + } + } +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/validateTableData.js.map b/tools/node_modules/eslint/node_modules/table/dist/validateTableData.js.map new file mode 100644 index 00000000000000..bd892651ceb068 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/validateTableData.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/validateTableData.js"],"names":["rows","Array","isArray","TypeError","length","Error","columnNumber","cells","cell","test"],"mappings":";;;;;;;AAAA;;;;AAIA;;;;AAIA;;;;0BAIgBA,I,IAAS;AACvB,MAAI,CAACC,KAAK,CAACC,OAAN,CAAcF,IAAd,CAAL,EAA0B;AACxB,UAAM,IAAIG,SAAJ,CAAc,8BAAd,CAAN;AACD;;AAED,MAAIH,IAAI,CAACI,MAAL,KAAgB,CAApB,EAAuB;AACrB,UAAM,IAAIC,KAAJ,CAAU,qCAAV,CAAN;AACD;;AAED,MAAIL,IAAI,CAAC,CAAD,CAAJ,CAAQI,MAAR,KAAmB,CAAvB,EAA0B;AACxB,UAAM,IAAIC,KAAJ,CAAU,wCAAV,CAAN;AACD;;AAED,QAAMC,YAAY,GAAGN,IAAI,CAAC,CAAD,CAAJ,CAAQI,MAA7B;AAbuB;AAAA;AAAA;;AAAA;AAevB,yBAAoBJ,IAApB,8HAA0B;AAAA,YAAfO,KAAe;;AACxB,UAAI,CAACN,KAAK,CAACC,OAAN,CAAcK,KAAd,CAAL,EAA2B;AACzB,cAAM,IAAIJ,SAAJ,CAAc,kCAAd,CAAN;AACD;;AAED,UAAII,KAAK,CAACH,MAAN,KAAiBE,YAArB,EAAmC;AACjC,cAAM,IAAID,KAAJ,CAAU,+CAAV,CAAN;AACD,OAPuB,CASxB;AACA;;;AAVwB;AAAA;AAAA;;AAAA;AAWxB,8BAAmBE,KAAnB,mIAA0B;AAAA,gBAAfC,IAAe;;AACxB;AACA,cAAI,kBAAkBC,IAAlB,CAAuBD,IAAvB,CAAJ,EAAkC;AAChC,kBAAM,IAAIH,KAAJ,CAAU,iDAAV,CAAN;AACD;AACF;AAhBuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBzB;AAhCsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiCxB,C","sourcesContent":["/**\n * @typedef {string} cell\n */\n\n/**\n * @typedef {cell[]} validateData~column\n */\n\n/**\n * @param {column[]} rows\n * @returns {undefined}\n */\nexport default (rows) => {\n if (!Array.isArray(rows)) {\n throw new TypeError('Table data must be an array.');\n }\n\n if (rows.length === 0) {\n throw new Error('Table must define at least one row.');\n }\n\n if (rows[0].length === 0) {\n throw new Error('Table must define at least one column.');\n }\n\n const columnNumber = rows[0].length;\n\n for (const cells of rows) {\n if (!Array.isArray(cells)) {\n throw new TypeError('Table row data must be an array.');\n }\n\n if (cells.length !== columnNumber) {\n throw new Error('Table must have a consistent number of cells.');\n }\n\n // @todo Make an exception for newline characters.\n // @see https://github.com/gajus/table/issues/9\n for (const cell of cells) {\n // eslint-disable-next-line no-control-regex\n if (/[\\u0001-\\u001A]/.test(cell)) {\n throw new Error('Table data must not contain control characters.');\n }\n }\n }\n};\n"],"file":"validateTableData.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/wrapString.js b/tools/node_modules/eslint/node_modules/table/dist/wrapString.js index eae8ea051d95fc..c0dd8c8d6f7e12 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/wrapString.js +++ b/tools/node_modules/eslint/node_modules/table/dist/wrapString.js @@ -1,16 +1,13 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; -var _sliceAnsi = require('slice-ansi'); +var _sliceAnsi = _interopRequireDefault(require("slice-ansi")); -var _sliceAnsi2 = _interopRequireDefault(_sliceAnsi); - -var _stringWidth = require('string-width'); - -var _stringWidth2 = _interopRequireDefault(_stringWidth); +var _stringWidth = _interopRequireDefault(require("string-width")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -25,18 +22,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @param {number} size * @returns {Array} */ -exports.default = (subject, size) => { +const wrapString = (subject, size) => { let subjectSlice; - subjectSlice = subject; - const chunks = []; do { - chunks.push((0, _sliceAnsi2.default)(subjectSlice, 0, size)); - - subjectSlice = (0, _sliceAnsi2.default)(subjectSlice, size).trim(); - } while ((0, _stringWidth2.default)(subjectSlice)); + chunks.push((0, _sliceAnsi.default)(subjectSlice, 0, size)); + subjectSlice = (0, _sliceAnsi.default)(subjectSlice, size).trim(); + } while ((0, _stringWidth.default)(subjectSlice)); return chunks; -}; \ No newline at end of file +}; + +var _default = wrapString; +exports.default = _default; +//# sourceMappingURL=wrapString.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/wrapString.js.flow b/tools/node_modules/eslint/node_modules/table/dist/wrapString.js.flow new file mode 100644 index 00000000000000..bbb40721e34f99 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/wrapString.js.flow @@ -0,0 +1,29 @@ +import slice from 'slice-ansi'; +import stringWidth from 'string-width'; + +/** + * Creates an array of strings split into groups the length of size. + * This function works with strings that contain ASCII characters. + * + * wrapText is different from would-be "chunk" implementation + * in that whitespace characters that occur on a chunk size limit are trimmed. + * + * @param {string} subject + * @param {number} size + * @returns {Array} + */ +export default (subject, size) => { + let subjectSlice; + + subjectSlice = subject; + + const chunks = []; + + do { + chunks.push(slice(subjectSlice, 0, size)); + + subjectSlice = slice(subjectSlice, size).trim(); + } while (stringWidth(subjectSlice)); + + return chunks; +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/wrapString.js.map b/tools/node_modules/eslint/node_modules/table/dist/wrapString.js.map new file mode 100644 index 00000000000000..3d1d7b3c0825a7 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/wrapString.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/wrapString.js"],"names":["subject","size","subjectSlice","chunks","push","trim"],"mappings":";;;;;;;AAAA;;AACA;;;;AAEA;;;;;;;;;;;oBAWgBA,O,EAASC,I,KAAS;AAChC,MAAIC,YAAJ;AAEAA,EAAAA,YAAY,GAAGF,OAAf;AAEA,QAAMG,MAAM,GAAG,EAAf;;AAEA,KAAG;AACDA,IAAAA,MAAM,CAACC,IAAP,CAAY,wBAAMF,YAAN,EAAoB,CAApB,EAAuBD,IAAvB,CAAZ;AAEAC,IAAAA,YAAY,GAAG,wBAAMA,YAAN,EAAoBD,IAApB,EAA0BI,IAA1B,EAAf;AACD,GAJD,QAIS,0BAAYH,YAAZ,CAJT;;AAMA,SAAOC,MAAP;AACD,C","sourcesContent":["import slice from 'slice-ansi';\nimport stringWidth from 'string-width';\n\n/**\n * Creates an array of strings split into groups the length of size.\n * This function works with strings that contain ASCII characters.\n *\n * wrapText is different from would-be \"chunk\" implementation\n * in that whitespace characters that occur on a chunk size limit are trimmed.\n *\n * @param {string} subject\n * @param {number} size\n * @returns {Array}\n */\nexport default (subject, size) => {\n let subjectSlice;\n\n subjectSlice = subject;\n\n const chunks = [];\n\n do {\n chunks.push(slice(subjectSlice, 0, size));\n\n subjectSlice = slice(subjectSlice, size).trim();\n } while (stringWidth(subjectSlice));\n\n return chunks;\n};\n"],"file":"wrapString.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/wrapWord.js b/tools/node_modules/eslint/node_modules/table/dist/wrapWord.js index c0dd9df4b05d76..790b20bc00414a 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/wrapWord.js +++ b/tools/node_modules/eslint/node_modules/table/dist/wrapWord.js @@ -1,16 +1,13 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; -var _sliceAnsi = require('slice-ansi'); +var _sliceAnsi = _interopRequireDefault(require("slice-ansi")); -var _sliceAnsi2 = _interopRequireDefault(_sliceAnsi); - -var _stringWidth = require('string-width'); - -var _stringWidth2 = _interopRequireDefault(_stringWidth); +var _stringWidth = _interopRequireDefault(require("string-width")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -19,34 +16,32 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @param {number} size * @returns {Array} */ -exports.default = (input, size) => { +const wrapWord = (input, size) => { let subject; - subject = input; + const chunks = []; // https://regex101.com/r/gY5kZ1/1 - const chunks = []; - - // https://regex101.com/r/gY5kZ1/1 const re = new RegExp('(^.{1,' + size + '}(\\s+|$))|(^.{1,' + (size - 1) + '}(\\\\|/|_|\\.|,|;|-))'); do { let chunk; - chunk = subject.match(re); if (chunk) { chunk = chunk[0]; - - subject = (0, _sliceAnsi2.default)(subject, (0, _stringWidth2.default)(chunk)); - + subject = (0, _sliceAnsi.default)(subject, (0, _stringWidth.default)(chunk)); chunk = chunk.trim(); } else { - chunk = (0, _sliceAnsi2.default)(subject, 0, size); - subject = (0, _sliceAnsi2.default)(subject, size); + chunk = (0, _sliceAnsi.default)(subject, 0, size); + subject = (0, _sliceAnsi.default)(subject, size); } chunks.push(chunk); - } while ((0, _stringWidth2.default)(subject)); + } while ((0, _stringWidth.default)(subject)); return chunks; -}; \ No newline at end of file +}; + +var _default = wrapWord; +exports.default = _default; +//# sourceMappingURL=wrapWord.js.map \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/dist/wrapWord.js.flow b/tools/node_modules/eslint/node_modules/table/dist/wrapWord.js.flow new file mode 100644 index 00000000000000..02a8d45ea4c9bd --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/wrapWord.js.flow @@ -0,0 +1,39 @@ +import slice from 'slice-ansi'; +import stringWidth from 'string-width'; + +/** + * @param {string} input + * @param {number} size + * @returns {Array} + */ +export default (input, size) => { + let subject; + + subject = input; + + const chunks = []; + + // https://regex101.com/r/gY5kZ1/1 + const re = new RegExp('(^.{1,' + size + '}(\\s+|$))|(^.{1,' + (size - 1) + '}(\\\\|/|_|\\.|,|;|-))'); + + do { + let chunk; + + chunk = subject.match(re); + + if (chunk) { + chunk = chunk[0]; + + subject = slice(subject, stringWidth(chunk)); + + chunk = chunk.trim(); + } else { + chunk = slice(subject, 0, size); + subject = slice(subject, size); + } + + chunks.push(chunk); + } while (stringWidth(subject)); + + return chunks; +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/wrapWord.js.map b/tools/node_modules/eslint/node_modules/table/dist/wrapWord.js.map new file mode 100644 index 00000000000000..5e7aa9ccb73948 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/wrapWord.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/wrapWord.js"],"names":["input","size","subject","chunks","re","RegExp","chunk","match","trim","push"],"mappings":";;;;;;;AAAA;;AACA;;;;AAEA;;;;;kBAKgBA,K,EAAOC,I,KAAS;AAC9B,MAAIC,OAAJ;AAEAA,EAAAA,OAAO,GAAGF,KAAV;AAEA,QAAMG,MAAM,GAAG,EAAf,CAL8B,CAO9B;;AACA,QAAMC,EAAE,GAAG,IAAIC,MAAJ,CAAW,WAAWJ,IAAX,GAAkB,mBAAlB,IAAyCA,IAAI,GAAG,CAAhD,IAAqD,wBAAhE,CAAX;;AAEA,KAAG;AACD,QAAIK,KAAJ;AAEAA,IAAAA,KAAK,GAAGJ,OAAO,CAACK,KAAR,CAAcH,EAAd,CAAR;;AAEA,QAAIE,KAAJ,EAAW;AACTA,MAAAA,KAAK,GAAGA,KAAK,CAAC,CAAD,CAAb;AAEAJ,MAAAA,OAAO,GAAG,wBAAMA,OAAN,EAAe,0BAAYI,KAAZ,CAAf,CAAV;AAEAA,MAAAA,KAAK,GAAGA,KAAK,CAACE,IAAN,EAAR;AACD,KAND,MAMO;AACLF,MAAAA,KAAK,GAAG,wBAAMJ,OAAN,EAAe,CAAf,EAAkBD,IAAlB,CAAR;AACAC,MAAAA,OAAO,GAAG,wBAAMA,OAAN,EAAeD,IAAf,CAAV;AACD;;AAEDE,IAAAA,MAAM,CAACM,IAAP,CAAYH,KAAZ;AACD,GAjBD,QAiBS,0BAAYJ,OAAZ,CAjBT;;AAmBA,SAAOC,MAAP;AACD,C","sourcesContent":["import slice from 'slice-ansi';\nimport stringWidth from 'string-width';\n\n/**\n * @param {string} input\n * @param {number} size\n * @returns {Array}\n */\nexport default (input, size) => {\n let subject;\n\n subject = input;\n\n const chunks = [];\n\n // https://regex101.com/r/gY5kZ1/1\n const re = new RegExp('(^.{1,' + size + '}(\\\\s+|$))|(^.{1,' + (size - 1) + '}(\\\\\\\\|/|_|\\\\.|,|;|-))');\n\n do {\n let chunk;\n\n chunk = subject.match(re);\n\n if (chunk) {\n chunk = chunk[0];\n\n subject = slice(subject, stringWidth(chunk));\n\n chunk = chunk.trim();\n } else {\n chunk = slice(subject, 0, size);\n subject = slice(subject, size);\n }\n\n chunks.push(chunk);\n } while (stringWidth(subject));\n\n return chunks;\n};\n"],"file":"wrapWord.js"} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/package.json b/tools/node_modules/eslint/node_modules/table/package.json index a84ae5396b0236..3e6fcb12d1985a 100644 --- a/tools/node_modules/eslint/node_modules/table/package.json +++ b/tools/node_modules/eslint/node_modules/table/package.json @@ -9,36 +9,48 @@ }, "bundleDependencies": false, "dependencies": { - "ajv": "^6.0.1", - "ajv-keywords": "^3.0.0", - "chalk": "^2.1.0", - "lodash": "^4.17.4", + "ajv": "^6.5.3", + "lodash": "^4.17.10", "slice-ansi": "1.0.0", "string-width": "^2.1.1" }, "deprecated": false, "description": "Formats data into a string table.", "devDependencies": { + "@babel/cli": "^7.1.2", + "@babel/core": "^7.1.2", + "@babel/node": "^7.0.0", + "@babel/plugin-transform-flow-strip-types": "^7.0.0", + "@babel/preset-env": "^7.1.0", + "@babel/register": "^7.0.0", "ajv-cli": "^3.0.0", - "babel": "^6.23.0", - "babel-cli": "^6.26.0", - "babel-core": "^6.26.0", - "babel-plugin-istanbul": "^4.1.5", - "babel-preset-es2015-node4": "^2.1.1", - "babel-register": "^6.26.0", - "chai": "^4.1.2", - "eslint": "^4.7.2", - "eslint-config-canonical": "^9.3.1", - "gitdown": "^2.5.1", - "husky": "^0.14.3", - "mocha": "^5.0.0", - "nyc": "^11.2.1", - "sinon": "^4.0.0" + "ajv-keywords": "^3.2.0", + "babel-plugin-istanbul": "^5.1.0", + "babel-plugin-transform-export-default-name": "^2.0.4", + "chai": "^4.2.0", + "chalk": "^2.4.1", + "coveralls": "^3.0.2", + "eslint": "^5.6.1", + "eslint-config-canonical": "^13.0.0", + "flow-bin": "^0.81.0", + "flow-copy-source": "^2.0.2", + "gitdown": "^2.5.4", + "husky": "^1.0.1", + "mocha": "^5.2.0", + "nyc": "^13.1.0", + "semantic-release": "^15.9.16", + "sinon": "^6.3.4" }, "engines": { - "node": ">=4.0.0" + "node": ">=6.0.0" }, "homepage": "https://github.com/gajus/table#readme", + "husky": { + "hooks": { + "post-commit": "npm run create-readme && git add README.md && git commit -m 'docs: generate docs' --no-verify", + "pre-commit": "npm run lint && npm run test && npm run build" + } + }, "keywords": [ "ascii", "text", @@ -51,12 +63,14 @@ "name": "table", "nyc": { "include": [ - "src/*.js" + "src/**/*.js" ], "instrument": false, - "lines": 70, + "reporter": [ + "text-lcov" + ], "require": [ - "babel-register" + "@babel/register" ], "sourceMap": false }, @@ -65,13 +79,11 @@ "url": "git+https://github.com/gajus/table.git" }, "scripts": { - "build": "rm -fr ./dist && NODE_ENV=production babel --copy-files ./src --out-dir ./dist && npm run make-validators", - "lint": "npm run build && eslint ./src ./tests", - "make-readme": "gitdown ./.README/README.md --output-file ./README.md", - "make-validators": "ajv compile --all-errors --inline-refs=false -s src/schemas/config -c ajv-keywords/keywords/typeof -o dist/validateConfig.js && ajv compile --all-errors --inline-refs=false -s src/schemas/streamConfig -c ajv-keywords/keywords/typeof -o dist/validateStreamConfig.js", - "precommit": "npm run lint && npm run test", - "prepublish": "NODE_ENV=production npm run build", - "test": "npm run build && nyc --check-coverage mocha" + "build": "rm -fr ./dist && NODE_ENV=production babel ./src --out-dir ./dist --copy-files --source-maps && npm run create-validators && flow-copy-source src dist", + "create-readme": "gitdown ./.README/README.md --output-file ./README.md", + "create-validators": "ajv compile --all-errors --inline-refs=false -s src/schemas/config -c ajv-keywords/keywords/typeof -o dist/validateConfig.js && ajv compile --all-errors --inline-refs=false -s src/schemas/streamConfig -c ajv-keywords/keywords/typeof -o dist/validateStreamConfig.js", + "lint": "npm run build && eslint ./src ./test && flow", + "test": "mocha --require @babel/register" }, - "version": "4.0.3" + "version": "5.1.0" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/tslib/CopyrightNotice.txt b/tools/node_modules/eslint/node_modules/tslib/CopyrightNotice.txt index 4d8bc99e360ea5..0f6db1f75f714e 100644 --- a/tools/node_modules/eslint/node_modules/tslib/CopyrightNotice.txt +++ b/tools/node_modules/eslint/node_modules/tslib/CopyrightNotice.txt @@ -1,14 +1,15 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + diff --git a/tools/node_modules/eslint/node_modules/tslib/LICENSE.txt b/tools/node_modules/eslint/node_modules/tslib/LICENSE.txt index 2df8c87fda4e00..8746124b277914 100644 --- a/tools/node_modules/eslint/node_modules/tslib/LICENSE.txt +++ b/tools/node_modules/eslint/node_modules/tslib/LICENSE.txt @@ -1,55 +1,55 @@ -Apache License - -Version 2.0, January 2004 - -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. - -"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: - -You must give any other recipients of the Work or Derivative Works a copy of this License; and - -You must cause any modified files to carry prominent notices stating that You changed the files; and - -You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and - -If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and + +You must cause any modified files to carry prominent notices stating that You changed the files; and + +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/tools/node_modules/eslint/node_modules/tslib/README.md b/tools/node_modules/eslint/node_modules/tslib/README.md index c9819aa2cccd26..ae595fe2342253 100644 --- a/tools/node_modules/eslint/node_modules/tslib/README.md +++ b/tools/node_modules/eslint/node_modules/tslib/README.md @@ -1,134 +1,134 @@ -# tslib - -This is a runtime library for [TypeScript](http://www.typescriptlang.org/) that contains all of the TypeScript helper functions. - -This library is primarily used by the `--importHelpers` flag in TypeScript. -When using `--importHelpers`, a module that uses helper functions like `__extends` and `__assign` in the following emitted file: - -```ts -var __assign = (this && this.__assign) || Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; -}; -exports.x = {}; -exports.y = __assign({}, exports.x); - -``` - -will instead be emitted as something like the following: - -```ts -var tslib_1 = require("tslib"); -exports.x = {}; -exports.y = tslib_1.__assign({}, exports.x); -``` - -Because this can avoid duplicate declarations of things like `__extends`, `__assign`, etc., this means delivering users smaller files on average, as well as less runtime overhead. -For optimized bundles with TypeScript, you should absolutely consider using `tslib` and `--importHelpers`. - -# Installing - -For the latest stable version, run: - -## npm - -```sh -# TypeScript 2.3.3 or later -npm install --save tslib - -# TypeScript 2.3.2 or earlier -npm install --save tslib@1.6.1 -``` - -## bower - -```sh -# TypeScript 2.3.3 or later -bower install tslib - -# TypeScript 2.3.2 or earlier -bower install tslib@1.6.1 -``` - -## JSPM - -```sh -# TypeScript 2.3.3 or later -jspm install tslib - -# TypeScript 2.3.2 or earlier -jspm install tslib@1.6.1 -``` - -# Usage - -Set the `importHelpers` compiler option on the command line: - -``` -tsc --importHelpers file.ts -``` - -or in your tsconfig.json: - -```json -{ - "compilerOptions": { - "importHelpers": true - } -} -``` - -#### For bower and JSPM users - -You will need to add a `paths` mapping for `tslib`, e.g. For Bower users: - -```json -{ - "compilerOptions": { - "module": "amd", - "importHelpers": true, - "baseUrl": "./", - "paths": { - "tslib" : ["bower_components/tslib/tslib.d.ts"] - } - } -} -``` - -For JSPM users: - -```json -{ - "compilerOptions": { - "module": "system", - "importHelpers": true, - "baseUrl": "./", - "paths": { - "tslib" : ["jspm_packages/npm/tslib@1.9.3/tslib.d.ts"] - } - } -} -``` - - -# Contribute - -There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md) to TypeScript. - -* [Submit bugs](https://github.com/Microsoft/TypeScript/issues) and help us verify fixes as they are checked in. -* Review the [source code changes](https://github.com/Microsoft/TypeScript/pulls). -* Engage with other TypeScript users and developers on [StackOverflow](http://stackoverflow.com/questions/tagged/typescript). -* Join the [#typescript](http://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter. -* [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md). -* Read the language specification ([docx](http://go.microsoft.com/fwlink/?LinkId=267121), [pdf](http://go.microsoft.com/fwlink/?LinkId=267238)). - -# Documentation - -* [Quick tutorial](http://www.typescriptlang.org/Tutorial) -* [Programming handbook](http://www.typescriptlang.org/Handbook) -* [Language specification](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md) -* [Homepage](http://www.typescriptlang.org/) +# tslib + +This is a runtime library for [TypeScript](http://www.typescriptlang.org/) that contains all of the TypeScript helper functions. + +This library is primarily used by the `--importHelpers` flag in TypeScript. +When using `--importHelpers`, a module that uses helper functions like `__extends` and `__assign` in the following emitted file: + +```ts +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; +exports.x = {}; +exports.y = __assign({}, exports.x); + +``` + +will instead be emitted as something like the following: + +```ts +var tslib_1 = require("tslib"); +exports.x = {}; +exports.y = tslib_1.__assign({}, exports.x); +``` + +Because this can avoid duplicate declarations of things like `__extends`, `__assign`, etc., this means delivering users smaller files on average, as well as less runtime overhead. +For optimized bundles with TypeScript, you should absolutely consider using `tslib` and `--importHelpers`. + +# Installing + +For the latest stable version, run: + +## npm + +```sh +# TypeScript 2.3.3 or later +npm install --save tslib + +# TypeScript 2.3.2 or earlier +npm install --save tslib@1.6.1 +``` + +## bower + +```sh +# TypeScript 2.3.3 or later +bower install tslib + +# TypeScript 2.3.2 or earlier +bower install tslib@1.6.1 +``` + +## JSPM + +```sh +# TypeScript 2.3.3 or later +jspm install tslib + +# TypeScript 2.3.2 or earlier +jspm install tslib@1.6.1 +``` + +# Usage + +Set the `importHelpers` compiler option on the command line: + +``` +tsc --importHelpers file.ts +``` + +or in your tsconfig.json: + +```json +{ + "compilerOptions": { + "importHelpers": true + } +} +``` + +#### For bower and JSPM users + +You will need to add a `paths` mapping for `tslib`, e.g. For Bower users: + +```json +{ + "compilerOptions": { + "module": "amd", + "importHelpers": true, + "baseUrl": "./", + "paths": { + "tslib" : ["bower_components/tslib/tslib.d.ts"] + } + } +} +``` + +For JSPM users: + +```json +{ + "compilerOptions": { + "module": "system", + "importHelpers": true, + "baseUrl": "./", + "paths": { + "tslib" : ["jspm_packages/npm/tslib@1.9.3/tslib.d.ts"] + } + } +} +``` + + +# Contribute + +There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md) to TypeScript. + +* [Submit bugs](https://github.com/Microsoft/TypeScript/issues) and help us verify fixes as they are checked in. +* Review the [source code changes](https://github.com/Microsoft/TypeScript/pulls). +* Engage with other TypeScript users and developers on [StackOverflow](http://stackoverflow.com/questions/tagged/typescript). +* Join the [#typescript](http://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter. +* [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md). +* Read the language specification ([docx](http://go.microsoft.com/fwlink/?LinkId=267121), [pdf](http://go.microsoft.com/fwlink/?LinkId=267238)). + +# Documentation + +* [Quick tutorial](http://www.typescriptlang.org/Tutorial) +* [Programming handbook](http://www.typescriptlang.org/Handbook) +* [Language specification](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md) +* [Homepage](http://www.typescriptlang.org/) diff --git a/tools/node_modules/eslint/node_modules/tslib/tslib.d.ts b/tools/node_modules/eslint/node_modules/tslib/tslib.d.ts index 16be0f542deba9..c4a0e11584cd60 100644 --- a/tools/node_modules/eslint/node_modules/tslib/tslib.d.ts +++ b/tools/node_modules/eslint/node_modules/tslib/tslib.d.ts @@ -1,33 +1,33 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ -export declare function __extends(d: Function, b: Function): void; -export declare function __assign(t: any, ...sources: any[]): any; -export declare function __rest(t: any, propertyNames: (string | symbol)[]): any; -export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; -export declare function __param(paramIndex: number, decorator: Function): Function; -export declare function __metadata(metadataKey: any, metadataValue: any): Function; -export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; -export declare function __generator(thisArg: any, body: Function): any; -export declare function __exportStar(m: any, exports: any): void; -export declare function __values(o: any): any; -export declare function __read(o: any, n?: number): any[]; -export declare function __spread(...args: any[]): any[]; -export declare function __await(v: any): any; -export declare function __asyncGenerator(thisArg: any, _arguments: any, generator: Function): any; -export declare function __asyncDelegator(o: any): any; -export declare function __asyncValues(o: any): any; -export declare function __makeTemplateObject(cooked: string[], raw: string[]): TemplateStringsArray; -export declare function __importStar(mod: T): T; -export declare function __importDefault(mod: T): T | { default: T }; +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +export declare function __extends(d: Function, b: Function): void; +export declare function __assign(t: any, ...sources: any[]): any; +export declare function __rest(t: any, propertyNames: (string | symbol)[]): any; +export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; +export declare function __param(paramIndex: number, decorator: Function): Function; +export declare function __metadata(metadataKey: any, metadataValue: any): Function; +export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; +export declare function __generator(thisArg: any, body: Function): any; +export declare function __exportStar(m: any, exports: any): void; +export declare function __values(o: any): any; +export declare function __read(o: any, n?: number): any[]; +export declare function __spread(...args: any[]): any[]; +export declare function __await(v: any): any; +export declare function __asyncGenerator(thisArg: any, _arguments: any, generator: Function): any; +export declare function __asyncDelegator(o: any): any; +export declare function __asyncValues(o: any): any; +export declare function __makeTemplateObject(cooked: string[], raw: string[]): TemplateStringsArray; +export declare function __importStar(mod: T): T; +export declare function __importDefault(mod: T): T | { default: T }; diff --git a/tools/node_modules/eslint/node_modules/tslib/tslib.es6.js b/tools/node_modules/eslint/node_modules/tslib/tslib.es6.js index 45b35893ca4ca1..6da273e26024f1 100644 --- a/tools/node_modules/eslint/node_modules/tslib/tslib.es6.js +++ b/tools/node_modules/eslint/node_modules/tslib/tslib.es6.js @@ -1,186 +1,186 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ -/* global Reflect, Promise */ - -var extendStatics = function(d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); -}; - -export function __extends(d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -} - -export var __assign = function() { - __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - } - return __assign.apply(this, arguments); -} - -export function __rest(s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) - t[p[i]] = s[p[i]]; - return t; -} - -export function __decorate(decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -} - -export function __param(paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -} - -export function __metadata(metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); -} - -export function __awaiter(thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} - -export function __generator(thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -} - -export function __exportStar(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} - -export function __values(o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -} - -export function __read(o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -} - -export function __spread() { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; -} - -export function __await(v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); -} - -export function __asyncGenerator(thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } -} - -export function __asyncDelegator(o) { - var i, p; - return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } -} - -export function __asyncValues(o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); - function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } - function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } -} - -export function __makeTemplateObject(cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; - -export function __importStar(mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result.default = mod; - return result; -} - -export function __importDefault(mod) { - return (mod && mod.__esModule) ? mod : { default: mod }; -} +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +/* global Reflect, Promise */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +export function __extends(d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +export var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + } + return __assign.apply(this, arguments); +} + +export function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; +} + +export function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} + +export function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +} + +export function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); +} + +export function __awaiter(thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +export function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +export function __exportStar(m, exports) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} + +export function __values(o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +} + +export function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +export function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; +} + +export function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); +} + +export function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +} + +export function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } +} + +export function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +} + +export function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; + +export function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result.default = mod; + return result; +} + +export function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { default: mod }; +} diff --git a/tools/node_modules/eslint/node_modules/tslib/tslib.js b/tools/node_modules/eslint/node_modules/tslib/tslib.js index a74e93b05181c3..b0b1ff3ab8e776 100644 --- a/tools/node_modules/eslint/node_modules/tslib/tslib.js +++ b/tools/node_modules/eslint/node_modules/tslib/tslib.js @@ -1,243 +1,243 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ -/* global global, define, System, Reflect, Promise */ -var __extends; -var __assign; -var __rest; -var __decorate; -var __param; -var __metadata; -var __awaiter; -var __generator; -var __exportStar; -var __values; -var __read; -var __spread; -var __await; -var __asyncGenerator; -var __asyncDelegator; -var __asyncValues; -var __makeTemplateObject; -var __importStar; -var __importDefault; -(function (factory) { - var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; - if (typeof define === "function" && define.amd) { - define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); - } - else if (typeof module === "object" && typeof module.exports === "object") { - factory(createExporter(root, createExporter(module.exports))); - } - else { - factory(createExporter(root)); - } - function createExporter(exports, previous) { - if (exports !== root) { - if (typeof Object.create === "function") { - Object.defineProperty(exports, "__esModule", { value: true }); - } - else { - exports.__esModule = true; - } - } - return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; - } -}) -(function (exporter) { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - - __extends = function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - - __assign = Object.assign || function (t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - - __rest = function (s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) - t[p[i]] = s[p[i]]; - return t; - }; - - __decorate = function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; - }; - - __param = function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } - }; - - __metadata = function (metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); - }; - - __awaiter = function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; - - __generator = function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - }; - - __exportStar = function (m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; - }; - - __values = function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - }; - - __read = function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; - }; - - __spread = function () { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; - }; - - __await = function (v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); - }; - - __asyncGenerator = function (thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } - }; - - __asyncDelegator = function (o) { - var i, p; - return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } - }; - - __asyncValues = function (o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); - function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } - function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } - }; - - __makeTemplateObject = function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; - }; - - __importStar = function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; - }; - - __importDefault = function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - - exporter("__extends", __extends); - exporter("__assign", __assign); - exporter("__rest", __rest); - exporter("__decorate", __decorate); - exporter("__param", __param); - exporter("__metadata", __metadata); - exporter("__awaiter", __awaiter); - exporter("__generator", __generator); - exporter("__exportStar", __exportStar); - exporter("__values", __values); - exporter("__read", __read); - exporter("__spread", __spread); - exporter("__await", __await); - exporter("__asyncGenerator", __asyncGenerator); - exporter("__asyncDelegator", __asyncDelegator); - exporter("__asyncValues", __asyncValues); - exporter("__makeTemplateObject", __makeTemplateObject); - exporter("__importStar", __importStar); - exporter("__importDefault", __importDefault); -}); +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +/* global global, define, System, Reflect, Promise */ +var __extends; +var __assign; +var __rest; +var __decorate; +var __param; +var __metadata; +var __awaiter; +var __generator; +var __exportStar; +var __values; +var __read; +var __spread; +var __await; +var __asyncGenerator; +var __asyncDelegator; +var __asyncValues; +var __makeTemplateObject; +var __importStar; +var __importDefault; +(function (factory) { + var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; + if (typeof define === "function" && define.amd) { + define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); + } + else if (typeof module === "object" && typeof module.exports === "object") { + factory(createExporter(root, createExporter(module.exports))); + } + else { + factory(createExporter(root)); + } + function createExporter(exports, previous) { + if (exports !== root) { + if (typeof Object.create === "function") { + Object.defineProperty(exports, "__esModule", { value: true }); + } + else { + exports.__esModule = true; + } + } + return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; + } +}) +(function (exporter) { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + + __extends = function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + + __assign = Object.assign || function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + + __rest = function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; + }; + + __decorate = function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + + __param = function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } + }; + + __metadata = function (metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); + }; + + __awaiter = function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + + __generator = function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + }; + + __exportStar = function (m, exports) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + }; + + __values = function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + }; + + __read = function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; + }; + + __spread = function () { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; + }; + + __await = function (v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); + }; + + __asyncGenerator = function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } + }; + + __asyncDelegator = function (o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } + }; + + __asyncValues = function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } + }; + + __makeTemplateObject = function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; + }; + + __importStar = function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; + }; + + __importDefault = function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + + exporter("__extends", __extends); + exporter("__assign", __assign); + exporter("__rest", __rest); + exporter("__decorate", __decorate); + exporter("__param", __param); + exporter("__metadata", __metadata); + exporter("__awaiter", __awaiter); + exporter("__generator", __generator); + exporter("__exportStar", __exportStar); + exporter("__values", __values); + exporter("__read", __read); + exporter("__spread", __spread); + exporter("__await", __await); + exporter("__asyncGenerator", __asyncGenerator); + exporter("__asyncDelegator", __asyncDelegator); + exporter("__asyncValues", __asyncValues); + exporter("__makeTemplateObject", __makeTemplateObject); + exporter("__importStar", __importStar); + exporter("__importDefault", __importDefault); +}); diff --git a/tools/node_modules/eslint/package.json b/tools/node_modules/eslint/package.json index 09880a0388c598..12e5ab3d761bf5 100644 --- a/tools/node_modules/eslint/package.json +++ b/tools/node_modules/eslint/package.json @@ -43,12 +43,12 @@ "path-is-inside": "^1.0.2", "pluralize": "^7.0.0", "progress": "^2.0.0", - "regexpp": "^2.0.0", + "regexpp": "^2.0.1", "require-uncached": "^1.0.3", "semver": "^5.5.1", "strip-ansi": "^4.0.0", "strip-json-comments": "^2.0.1", - "table": "^4.0.3", + "table": "^5.0.2", "text-table": "^0.2.0" }, "deprecated": false, @@ -135,5 +135,5 @@ "release": "node Makefile.js release", "test": "node Makefile.js test" }, - "version": "5.6.1" + "version": "5.7.0" } \ No newline at end of file From 86a5690e385284be77a7b3b75cf4515bf5faa893 Mon Sep 17 00:00:00 2001 From: Diana Holland Date: Fri, 12 Oct 2018 11:36:17 -0700 Subject: [PATCH 083/328] crypto: move field initialization to class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23610 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Refael Ackermann Reviewed-By: Colin Ihrig Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Ujjwal Sharma --- src/node_crypto_clienthello-inl.h | 9 +-------- src/node_crypto_clienthello.h | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/node_crypto_clienthello-inl.h b/src/node_crypto_clienthello-inl.h index c5c595c7606cf9..9de8f2e5fcf731 100644 --- a/src/node_crypto_clienthello-inl.h +++ b/src/node_crypto_clienthello-inl.h @@ -34,14 +34,7 @@ inline ClientHelloParser::ClientHelloParser() : state_(kEnded), onhello_cb_(nullptr), onend_cb_(nullptr), - cb_arg_(nullptr), - session_size_(0), - session_id_(nullptr), - servername_size_(0), - servername_(nullptr), - ocsp_request_(0), - tls_ticket_size_(0), - tls_ticket_(nullptr) { + cb_arg_(nullptr) { Reset(); } diff --git a/src/node_crypto_clienthello.h b/src/node_crypto_clienthello.h index fd8756254ffc24..687e9589b6d932 100644 --- a/src/node_crypto_clienthello.h +++ b/src/node_crypto_clienthello.h @@ -108,16 +108,16 @@ class ClientHelloParser { OnHelloCb onhello_cb_; OnEndCb onend_cb_; void* cb_arg_; - size_t frame_len_; - size_t body_offset_; - size_t extension_offset_; - uint8_t session_size_; - const uint8_t* session_id_; - uint16_t servername_size_; - const uint8_t* servername_; - uint8_t ocsp_request_; - uint16_t tls_ticket_size_; - const uint8_t* tls_ticket_; + size_t frame_len_ = 0; + size_t body_offset_ = 0; + size_t extension_offset_ = 0; + uint8_t session_size_ = 0; + const uint8_t* session_id_ = nullptr; + uint16_t servername_size_ = 0; + const uint8_t* servername_ = nullptr; + uint8_t ocsp_request_ = 0; + uint16_t tls_ticket_size_ = -1; + const uint8_t* tls_ticket_ = nullptr; }; } // namespace crypto From 5ee0d90b6e1f4d8e3d851d637c1c0a72d9ad6eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Sun, 2 Sep 2018 13:49:02 +0300 Subject: [PATCH 084/328] doc: wrap links in <> This fixes links that were broken due to inclusion of the trailing dot. Also simplifies a pair of occurances of [](). PR-URL: https://github.com/nodejs/node/pull/23359 Reviewed-By: Rich Trott Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Colin Ihrig Reviewed-By: Vse Mozhet Byt Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: James M Snell --- doc/api/deprecations.md | 10 +++++----- doc/api/repl.md | 4 ++-- doc/api/tls.md | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 01e6afeeb261cd..22f40da01c4fe1 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -321,7 +321,7 @@ changes: Type: End-of-Life Calling an asynchronous function without a callback throws a `TypeError` -in Node.js 10.0.0 onwards. (See https://github.com/nodejs/node/pull/12562.) +in Node.js 10.0.0 onwards. (See .) ### DEP0014: fs.read legacy String interface @@ -1697,7 +1697,7 @@ changes: Type: End-of-Life The AsyncHooks Sensitive API was never documented and had various minor issues. -(See https://github.com/nodejs/node/issues/15572.) Use the `AsyncResource` +(See .) Use the `AsyncResource` API instead. @@ -1717,8 +1717,8 @@ changes: Type: End-of-Life `runInAsyncIdScope` doesn't emit the `'before'` or `'after'` event and can thus -cause a lot of issues. See https://github.com/nodejs/node/issues/14328 for more -details. +cause a lot of issues. See for +more details. ### DEP0089: require('assert') @@ -1875,7 +1875,7 @@ to unrecoverable errors. Use [`asyncResource.runInAsyncScope()`][] API instead which provides a much safer, and more convenient, alternative. See -https://github.com/nodejs/node/pull/18513 for more details. + for more details. ### DEP0099: async context-unaware node::MakeCallback C++ APIs diff --git a/doc/api/repl.md b/doc/api/repl.md index 98c3f66839da83..787e28a4a947b9 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -619,10 +619,10 @@ possible to connect to a long-running Node.js process without restarting it. For an example of running a "full-featured" (`terminal`) REPL over a `net.Server` and `net.Socket` instance, see: -[https://gist.github.com/TooTallNate/2209310](https://gist.github.com/TooTallNate/2209310). +. For an example of running a REPL instance over [curl(1)][], see: -[https://gist.github.com/TooTallNate/2053342](https://gist.github.com/TooTallNate/2053342). +. [`'uncaughtException'`]: process.html#process_event_uncaughtexception [`--experimental-repl-await`]: cli.html#cli_experimental_repl_await diff --git a/doc/api/tls.md b/doc/api/tls.md index 1f2b8906b5f4b2..364ec07e1729c2 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -566,7 +566,7 @@ field which always contains the value `'TLSv1/SSLv3'`. For example: `{ name: 'AES256-SHA', version: 'TLSv1/SSLv3' }`. See `SSL_CIPHER_get_name()` in -https://www.openssl.org/docs/man1.1.0/ssl/SSL_CIPHER_get_name.html for more + for more information. ### tlsSocket.getEphemeralKeyInfo() @@ -683,7 +683,7 @@ Example responses include: * `TLSv1.2` * `unknown` -See https://www.openssl.org/docs/man1.1.0/ssl/SSL_get_version.html for more +See for more information. ### tlsSocket.getSession() From 43d4977c96954ba317717401792b7f1ffed857c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Sun, 2 Sep 2018 14:37:12 +0300 Subject: [PATCH 085/328] doc: fix pr-url in repl.md Now it points to the actual pr, not to /compare/. PR-URL: https://github.com/nodejs/node/pull/23359 Reviewed-By: Rich Trott Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Colin Ihrig Reviewed-By: Vse Mozhet Byt Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: James M Snell --- doc/api/repl.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/repl.md b/doc/api/repl.md index 787e28a4a947b9..d010265327e5fa 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -453,7 +453,7 @@ Returns `true` if `keyword` is a valid keyword, otherwise `false`. added: v0.1.91 changes: - version: v10.0.0 - pr-url: https://github.com/nodejs/node/pull/v10.0.0 + pr-url: https://github.com/nodejs/node/pull/19187 description: The `REPL_MAGIC_MODE` `replMode` was removed. - version: v5.8.0 pr-url: https://github.com/nodejs/node/pull/5388 From 272d4faadfb1c2184ef91025e2098f512b20987d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Sun, 2 Sep 2018 15:45:53 +0300 Subject: [PATCH 086/328] doc: use reserved domains for examples in url.md Changes non-reserved domains to reserved ones in url.md. PR-URL: https://github.com/nodejs/node/pull/23359 Refs: https://www.iana.org/domains/reserved Reviewed-By: Rich Trott Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Colin Ihrig Reviewed-By: Vse Mozhet Byt Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: James M Snell --- doc/api/url.md | 96 +++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/doc/api/url.md b/doc/api/url.md index cd817bf304b19e..f299864d5c0f91 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -26,31 +26,31 @@ backwards compatibility with existing applications. New application code should use the WHATWG API. A comparison between the WHATWG and Legacy APIs is provided below. Above the URL -`'http://user:pass@sub.host.com:8080/p/a/t/h?query=string#hash'`, properties of -an object returned by the legacy `url.parse()` are shown. Below it are +`'http://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash'`, properties +of an object returned by the legacy `url.parse()` are shown. Below it are properties of a WHATWG `URL` object. WHATWG URL's `origin` property includes `protocol` and `host`, but not `username` or `password`. ```txt -┌─────────────────────────────────────────────────────────────────────────────────────────────┐ -│ href │ -├──────────┬──┬─────────────────────┬─────────────────────┬───────────────────────────┬───────┤ -│ protocol │ │ auth │ host │ path │ hash │ -│ │ │ ├──────────────┬──────┼──────────┬────────────────┤ │ -│ │ │ │ hostname │ port │ pathname │ search │ │ -│ │ │ │ │ │ ├─┬──────────────┤ │ -│ │ │ │ │ │ │ │ query │ │ -" https: // user : pass @ sub.host.com : 8080 /p/a/t/h ? query=string #hash " -│ │ │ │ │ hostname │ port │ │ │ │ -│ │ │ │ ├──────────────┴──────┤ │ │ │ -│ protocol │ │ username │ password │ host │ │ │ │ -├──────────┴──┼──────────┴──────────┼─────────────────────┤ │ │ │ -│ origin │ │ origin │ pathname │ search │ hash │ -├─────────────┴─────────────────────┴─────────────────────┴──────────┴────────────────┴───────┤ -│ href │ -└─────────────────────────────────────────────────────────────────────────────────────────────┘ +┌────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ href │ +├──────────┬──┬─────────────────────┬────────────────────────┬───────────────────────────┬───────┤ +│ protocol │ │ auth │ host │ path │ hash │ +│ │ │ ├─────────────────┬──────┼──────────┬────────────────┤ │ +│ │ │ │ hostname │ port │ pathname │ search │ │ +│ │ │ │ │ │ ├─┬──────────────┤ │ +│ │ │ │ │ │ │ │ query │ │ +" https: // user : pass @ sub.example.com : 8080 /p/a/t/h ? query=string #hash " +│ │ │ │ │ hostname │ port │ │ │ │ +│ │ │ │ ├─────────────────┴──────┤ │ │ │ +│ protocol │ │ username │ password │ host │ │ │ │ +├──────────┴──┼──────────┴──────────┼────────────────────────┤ │ │ │ +│ origin │ │ origin │ pathname │ search │ hash │ +├─────────────┴─────────────────────┴────────────────────────┴──────────┴────────────────┴───────┤ +│ href │ +└────────────────────────────────────────────────────────────────────────────────────────────────┘ (all spaces in the "" line should be ignored — they are purely for formatting) ``` @@ -58,7 +58,7 @@ Parsing the URL string using the WHATWG API: ```js const myURL = - new URL('https://user:pass@sub.host.com:8080/p/a/t/h?query=string#hash'); + new URL('https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash'); ``` Parsing the URL string using the Legacy API: @@ -66,7 +66,7 @@ Parsing the URL string using the Legacy API: ```js const url = require('url'); const myURL = - url.parse('https://user:pass@sub.host.com:8080/p/a/t/h?query=string#hash'); + url.parse('https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash'); ``` ## The WHATWG URL API @@ -120,8 +120,8 @@ Unicode characters appearing within the hostname of `input` will be automatically converted to ASCII using the [Punycode][] algorithm. ```js -const myURL = new URL('https://你好你好'); -// https://xn--6qqa088eba/ +const myURL = new URL('https://測試'); +// https://xn--g6w251d/ ``` This feature is only available if the `node` executable was compiled with @@ -132,23 +132,23 @@ and a `base` is provided, it is advised to validate that the `origin` of the `URL` object is what is expected. ```js -let myURL = new URL('http://anotherExample.org/', 'https://example.org/'); -// http://anotherexample.org/ +let myURL = new URL('http://Example.com/', 'https://example.org/'); +// http://example.com/ -myURL = new URL('https://anotherExample.org/', 'https://example.org/'); -// https://anotherexample.org/ +myURL = new URL('https://Example.com/', 'https://example.org/'); +// https://example.com/ -myURL = new URL('foo://anotherExample.org/', 'https://example.org/'); -// foo://anotherExample.org/ +myURL = new URL('foo://Example.com/', 'https://example.org/'); +// foo://Example.com/ -myURL = new URL('http:anotherExample.org/', 'https://example.org/'); -// http://anotherexample.org/ +myURL = new URL('http:Example.com/', 'https://example.org/'); +// http://example.com/ -myURL = new URL('https:anotherExample.org/', 'https://example.org/'); -// https://example.org/anotherExample.org/ +myURL = new URL('https:Example.com/', 'https://example.org/'); +// https://example.org/Example.com/ -myURL = new URL('foo:anotherExample.org/', 'https://example.org/'); -// foo:anotherExample.org/ +myURL = new URL('foo:Example.com/', 'https://example.org/'); +// foo:Example.com/ ``` #### url.hash @@ -249,12 +249,12 @@ console.log(myURL.origin); ``` ```js -const idnURL = new URL('https://你好你好'); +const idnURL = new URL('https://測試'); console.log(idnURL.origin); -// Prints https://xn--6qqa088eba +// Prints https://xn--g6w251d console.log(idnURL.hostname); -// Prints xn--6qqa088eba +// Prints xn--g6w251d ``` #### url.password @@ -929,16 +929,16 @@ any way. The `url.format(URL[, options])` method allows for basic customization of the output. ```js -const myURL = new URL('https://a:b@你好你好?abc#foo'); +const myURL = new URL('https://a:b@測試?abc#foo'); console.log(myURL.href); -// Prints https://a:b@xn--6qqa088eba/?abc#foo +// Prints https://a:b@xn--g6w251d/?abc#foo console.log(myURL.toString()); -// Prints https://a:b@xn--6qqa088eba/?abc#foo +// Prints https://a:b@xn--g6w251d/?abc#foo console.log(url.format(myURL, { fragment: false, unicode: true, auth: false })); -// Prints 'https://你好你好/?abc' +// Prints 'https://測試/?abc' ``` ### url.pathToFileURL(path) @@ -991,21 +991,21 @@ For example: `'#hash'`. The `host` property is the full lower-cased host portion of the URL, including the `port` if specified. -For example: `'sub.host.com:8080'`. +For example: `'sub.example.com:8080'`. #### urlObject.hostname The `hostname` property is the lower-cased host name portion of the `host` component *without* the `port` included. -For example: `'sub.host.com'`. +For example: `'sub.example.com'`. #### urlObject.href The `href` property is the full URL string that was parsed with both the `protocol` and `host` components converted to lower-case. -For example: `'http://user:pass@sub.host.com:8080/p/a/t/h?query=string#hash'`. +For example: `'http://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash'`. #### urlObject.path @@ -1265,11 +1265,11 @@ using the [Punycode][] algorithm. Note, however, that a hostname *may* contain *both* Punycode encoded and percent-encoded characters: ```js -const myURL = new URL('https://%CF%80.com/foo'); +const myURL = new URL('https://%CF%80.example.com/foo'); console.log(myURL.href); -// Prints https://xn--1xa.com/foo +// Prints https://xn--1xa.example.com/foo console.log(myURL.origin); -// Prints https://π.com +// Prints https://π.example.com ``` [`Error`]: errors.html#errors_class_error From 00c028fb1dd3f23ee8ea4166a94d45aab2146c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Wed, 10 Oct 2018 03:05:16 +0300 Subject: [PATCH 087/328] doc: fix url example to match behavior Fixes one WHATWG URL example to match the actual behavior. PR-URL: https://github.com/nodejs/node/pull/23359 Fixes: https://github.com/nodejs/node/issues/22653 Reviewed-By: Rich Trott Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Colin Ihrig Reviewed-By: Vse Mozhet Byt Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: James M Snell --- doc/api/url.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/url.md b/doc/api/url.md index f299864d5c0f91..84f9b3684ff0b2 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -1269,7 +1269,7 @@ const myURL = new URL('https://%CF%80.example.com/foo'); console.log(myURL.href); // Prints https://xn--1xa.example.com/foo console.log(myURL.origin); -// Prints https://π.example.com +// Prints https://xn--1xa.example.com ``` [`Error`]: errors.html#errors_class_error From ac0a03a278d61f7a30d814064c4520f15fb86514 Mon Sep 17 00:00:00 2001 From: Chris Nguyen Date: Fri, 12 Oct 2018 09:53:48 -0700 Subject: [PATCH 088/328] test: fix assertion order PR-URL: https://github.com/nodejs/node/pull/23533 Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil --- test/parallel/test-utf8-scripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-utf8-scripts.js b/test/parallel/test-utf8-scripts.js index a67f291f8931aa..24ee6455973ed1 100644 --- a/test/parallel/test-utf8-scripts.js +++ b/test/parallel/test-utf8-scripts.js @@ -27,4 +27,4 @@ const assert = require('assert'); console.log('Σὲ γνωρίζω ἀπὸ τὴν κόψη'); -assert.strictEqual(true, /Hellö Wörld/.test('Hellö Wörld')); +assert.strictEqual(/Hellö Wörld/.test('Hellö Wörld'), true); From 16175c1b89407e2f99a6eab3ea86725cabed5ec4 Mon Sep 17 00:00:00 2001 From: Carolina Pinzon Date: Fri, 12 Oct 2018 10:41:15 -0700 Subject: [PATCH 089/328] test: fix assertion order test-tls-server-verify PR-URL: https://github.com/nodejs/node/pull/23549 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-tls-server-verify.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-tls-server-verify.js b/test/parallel/test-tls-server-verify.js index 6039d13e8216c5..2fd815d627fdf7 100644 --- a/test/parallel/test-tls-server-verify.js +++ b/test/parallel/test-tls-server-verify.js @@ -226,14 +226,14 @@ function runClient(prefix, port, options, cb) { client.on('exit', function(code) { if (options.shouldReject) { assert.strictEqual( - true, rejected, + rejected, true, `${prefix}${options.name} NOT rejected, but should have been`); } else { assert.strictEqual( - false, rejected, + rejected, false, `${prefix}${options.name} rejected, but should NOT have been`); assert.strictEqual( - options.shouldAuth, authed, + authed, options.shouldAuth, `${prefix}${options.name} authed is ${authed} but should have been ${ options.shouldAuth}`); } From c634698d5c1bd4a17672e7ff50fc93986d3c69be Mon Sep 17 00:00:00 2001 From: Steven Scott Date: Fri, 12 Oct 2018 10:00:21 -0700 Subject: [PATCH 090/328] lib: switch to internalBinding for cjs loader Switch the cjs loader to use internalBinding instead of process.binding for reading command line options. PR-URL: https://github.com/nodejs/node/pull/23492 Reviewed-By: James M Snell Reviewed-By: Gus Caplan Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- lib/internal/modules/cjs/loader.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 3083cdbb8bce3f..4e48d549377081 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -40,9 +40,10 @@ const { stripBOM, stripShebang } = require('internal/modules/cjs/helpers'); -const preserveSymlinks = !!process.binding('config').preserveSymlinks; -const preserveSymlinksMain = !!process.binding('config').preserveSymlinksMain; -const experimentalModules = !!process.binding('config').experimentalModules; +const options = internalBinding('options'); +const preserveSymlinks = options.getOptions('--preserve-symlinks'); +const preserveSymlinksMain = options.getOptions('--preserve-symlinks-main'); +const experimentalModules = options.getOptions('--experimental-modules'); const { ERR_INVALID_ARG_TYPE, From 7e56801ddd2c3ac698437787a77c14669ebce3c5 Mon Sep 17 00:00:00 2001 From: Carl Richmond Date: Fri, 12 Oct 2018 10:03:58 -0700 Subject: [PATCH 091/328] test: fix assertion argument order PR-URL: https://github.com/nodejs/node/pull/23489 Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-http-set-cookies.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-http-set-cookies.js b/test/parallel/test-http-set-cookies.js index c307bda73a3515..7a57523b04af9c 100644 --- a/test/parallel/test-http-set-cookies.js +++ b/test/parallel/test-http-set-cookies.js @@ -47,8 +47,8 @@ server.on('listening', function() { http.get({ port: this.address().port, path: '/one' }, function(res) { // set-cookie headers are always return in an array. // even if there is only one. - assert.deepStrictEqual(['A'], res.headers['set-cookie']); - assert.strictEqual('text/plain', res.headers['content-type']); + assert.deepStrictEqual(res.headers['set-cookie'], ['A']); + assert.strictEqual(res.headers['content-type'], 'text/plain'); res.on('data', function(chunk) { console.log(chunk.toString()); @@ -62,8 +62,8 @@ server.on('listening', function() { // two set-cookie headers http.get({ port: this.address().port, path: '/two' }, function(res) { - assert.deepStrictEqual(['A', 'B'], res.headers['set-cookie']); - assert.strictEqual('text/plain', res.headers['content-type']); + assert.deepStrictEqual(res.headers['set-cookie'], ['A', 'B']); + assert.strictEqual(res.headers['content-type'], 'text/plain'); res.on('data', function(chunk) { console.log(chunk.toString()); From 58aaa613636368a722e9b6c1fb666c541bc3e7b7 Mon Sep 17 00:00:00 2001 From: Kayla Altepeter Date: Fri, 12 Oct 2018 09:49:09 -0700 Subject: [PATCH 092/328] test: rename process.argv[0] to process.execPath, rename ex to err PR-URL: https://github.com/nodejs/node/pull/23488 Reviewed-By: Colin Ihrig Reviewed-By: Bryan English Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-common.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-common.js b/test/parallel/test-common.js index 51e0302868cbe6..a133204437facb 100644 --- a/test/parallel/test-common.js +++ b/test/parallel/test-common.js @@ -29,8 +29,8 @@ const { execFile } = require('child_process'); // test for leaked global detection { const p = fixtures.path('leakedGlobal.js'); - execFile(process.argv[0], [p], common.mustCall((ex, stdout, stderr) => { - assert.notStrictEqual(ex.code, 0); + execFile(process.execPath, [p], common.mustCall((err, stdout, stderr) => { + assert.notStrictEqual(err.code, 0); assert.ok(/\bAssertionError\b.*\bUnexpected global\b.*\bgc\b/.test(stderr)); })); } @@ -85,8 +85,8 @@ const failFixtures = [ ]; for (const p of failFixtures) { const [file, expected] = p; - execFile(process.argv[0], [file], common.mustCall((ex, stdout, stderr) => { - assert.ok(ex); + execFile(process.execPath, [file], common.mustCall((err, stdout, stderr) => { + assert.ok(err); assert.strictEqual(stderr, ''); const firstLine = stdout.split('\n').shift(); assert.strictEqual(firstLine, expected); From 01d599cffe9d715a38278660e458615f439e9548 Mon Sep 17 00:00:00 2001 From: Felix Schlenkrich Date: Fri, 12 Oct 2018 09:33:41 -0700 Subject: [PATCH 093/328] test: fix strictEqual argument order PR-URL: https://github.com/nodejs/node/pull/23490 Reviewed-By: Anatoli Papirovski Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- test/parallel/test-http-status-message.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-http-status-message.js b/test/parallel/test-http-status-message.js index 10d17295814e84..29b31a35a5708a 100644 --- a/test/parallel/test-http-status-message.js +++ b/test/parallel/test-http-status-message.js @@ -33,18 +33,22 @@ const s = http.createServer(function(req, res) { s.listen(0, test); - function test() { const bufs = []; - const client = net.connect(this.address().port, function() { - client.write('GET / HTTP/1.1\r\nConnection: close\r\n\r\n'); - }); + const client = net.connect( + this.address().port, + function() { + client.write('GET / HTTP/1.1\r\nConnection: close\r\n\r\n'); + } + ); client.on('data', function(chunk) { bufs.push(chunk); }); client.on('end', function() { - const head = Buffer.concat(bufs).toString('latin1').split('\r\n')[0]; - assert.strictEqual('HTTP/1.1 200 Custom Message', head); + const head = Buffer.concat(bufs) + .toString('latin1') + .split('\r\n')[0]; + assert.strictEqual(head, 'HTTP/1.1 200 Custom Message'); console.log('ok'); s.close(); }); From e0a3e238bb0b94b93dda053c5f9dbb881bdab894 Mon Sep 17 00:00:00 2001 From: chrisforrette Date: Fri, 12 Oct 2018 10:08:45 -0700 Subject: [PATCH 094/328] test: modernizing test-dgram-listen-after-bind with arrow functions PR-URL: https://github.com/nodejs/node/pull/23500 Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-dgram-listen-after-bind.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-dgram-listen-after-bind.js b/test/parallel/test-dgram-listen-after-bind.js index 70a828f32cabe9..6a7e156e008a77 100644 --- a/test/parallel/test-dgram-listen-after-bind.js +++ b/test/parallel/test-dgram-listen-after-bind.js @@ -29,16 +29,16 @@ const socket = dgram.createSocket('udp4'); socket.bind(); let fired = false; -const timer = setTimeout(function() { +const timer = setTimeout(() => { socket.close(); }, 100); -socket.on('listening', function() { +socket.on('listening', () => { clearTimeout(timer); fired = true; socket.close(); }); -socket.on('close', function() { +socket.on('close', () => { assert(fired, 'listening should fire after bind'); }); From 13afb68e8a8b2dfec221c2a05e23f32151a1e8c6 Mon Sep 17 00:00:00 2001 From: "@CAYdenberg" <@CAYdenberg> Date: Fri, 12 Oct 2018 10:11:12 -0700 Subject: [PATCH 095/328] test: fix argument order in asserts PR-URL: https://github.com/nodejs/node/pull/23499 Reviewed-By: Guy Bedford Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- .../test-inspector-async-stack-traces-promise-then.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sequential/test-inspector-async-stack-traces-promise-then.js b/test/sequential/test-inspector-async-stack-traces-promise-then.js index 0acb603147b798..7590dacec8aeef 100644 --- a/test/sequential/test-inspector-async-stack-traces-promise-then.js +++ b/test/sequential/test-inspector-async-stack-traces-promise-then.js @@ -45,7 +45,7 @@ async function runTests() { 'break2', 'runTest:8'); await session.runToCompletion(); - assert.strictEqual(0, (await instance.expectShutdown()).exitCode); + assert.strictEqual((await instance.expectShutdown()).exitCode, 0); } function debuggerPausedAt(msg, functionName, previousTickLocation) { From 627e3ad241788270224f7877073cf91825cb5030 Mon Sep 17 00:00:00 2001 From: Jenna Zeigen Date: Fri, 12 Oct 2018 09:55:19 -0700 Subject: [PATCH 096/328] test: use arrow functions in test-exception-handler PR-URL: https://github.com/nodejs/node/pull/23498 Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-exception-handler.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-exception-handler.js b/test/parallel/test-exception-handler.js index 3ce9ad511ace4e..ca25ccd6effcaa 100644 --- a/test/parallel/test-exception-handler.js +++ b/test/parallel/test-exception-handler.js @@ -25,16 +25,16 @@ const assert = require('assert'); const MESSAGE = 'catch me if you can'; -process.on('uncaughtException', common.mustCall(function(e) { +process.on('uncaughtException', common.mustCall((e) => { console.log('uncaught exception! 1'); assert.strictEqual(MESSAGE, e.message); })); -process.on('uncaughtException', common.mustCall(function(e) { +process.on('uncaughtException', common.mustCall((e) => { console.log('uncaught exception! 2'); assert.strictEqual(MESSAGE, e.message); })); -setTimeout(function() { +setTimeout(() => { throw new Error(MESSAGE); }, 10); From 5a0b9faab8caa3299e5c2d70616dec14370aa7d2 Mon Sep 17 00:00:00 2001 From: Long Nguyen Date: Fri, 12 Oct 2018 09:40:51 -0700 Subject: [PATCH 097/328] lib: removed unused variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change removes a variable that is not being used in the file. PR-URL: https://github.com/nodejs/node/pull/23497 Reviewed-By: Anna Henningsen Reviewed-By: Tobias Nießen Reviewed-By: Colin Ihrig Reviewed-By: Guy Bedford Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- lib/internal/url.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/url.js b/lib/internal/url.js index 2afd2db9b72f16..2bad698883631e 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -458,7 +458,7 @@ Object.defineProperties(URL.prototype, { if (ctx.path.length > 0) { try { return (new URL(ctx.path[0])).origin; - } catch (err) { + } catch { // fall through... do nothing } } From f1fb2bea5e76d313a39deab032dc483810a992a6 Mon Sep 17 00:00:00 2001 From: Greg Goforth Date: Fri, 12 Oct 2018 10:12:42 -0700 Subject: [PATCH 098/328] test: modernized test to use arrow functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23496 Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Tobias Nießen Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat --- test/parallel/test-dgram-send-callback-multi-buffer.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-dgram-send-callback-multi-buffer.js b/test/parallel/test-dgram-send-callback-multi-buffer.js index f77b5618450095..09f01f6e8adccc 100644 --- a/test/parallel/test-dgram-send-callback-multi-buffer.js +++ b/test/parallel/test-dgram-send-callback-multi-buffer.js @@ -6,19 +6,19 @@ const dgram = require('dgram'); const client = dgram.createSocket('udp4'); -const messageSent = common.mustCall(function messageSent(err, bytes) { +const messageSent = common.mustCall((err, bytes) => { assert.strictEqual(bytes, buf1.length + buf2.length); }); const buf1 = Buffer.alloc(256, 'x'); const buf2 = Buffer.alloc(256, 'y'); -client.on('listening', function() { - const port = this.address().port; +client.on('listening', () => { + const port = client.address().port; client.send([buf1, buf2], port, common.localhostIPv4, messageSent); }); -client.on('message', common.mustCall(function onMessage(buf, info) { +client.on('message', common.mustCall((buf, info) => { const expected = Buffer.concat([buf1, buf2]); assert.ok(buf.equals(expected), 'message was received correctly'); client.close(); From e9f17464a836b648abafd48c67069cda99913624 Mon Sep 17 00:00:00 2001 From: scabhi Date: Fri, 12 Oct 2018 09:55:49 -0700 Subject: [PATCH 099/328] test: reversed arguments in strictqual to reflect documentation PR-URL: https://github.com/nodejs/node/pull/23494 Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/known_issues/test-inspector-cluster-port-clash.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/known_issues/test-inspector-cluster-port-clash.js b/test/known_issues/test-inspector-cluster-port-clash.js index 9fa2b483568c93..0333ffcb98751c 100644 --- a/test/known_issues/test-inspector-cluster-port-clash.js +++ b/test/known_issues/test-inspector-cluster-port-clash.js @@ -41,7 +41,7 @@ function serialFork() { if (code === 12) { return assert.fail(`worker ${worker.id} failed to bind port`); } - assert.strictEqual(0, code); + assert.strictEqual(code, 0); })); worker.on('disconnect', common.mustCall(res)); }); From fd5290e68cfa9571b0fa4b5beea7f36f7a81a186 Mon Sep 17 00:00:00 2001 From: Robert Monks Date: Fri, 12 Oct 2018 12:11:25 -0500 Subject: [PATCH 100/328] test: update function keywords to fat arrows Updated all the function keywords to fat arrow implementations in test/parallel/test-event-emitter-no-error-provided-to-error-event.js PR-URL: https://github.com/nodejs/node/pull/23493 Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- .../test-event-emitter-no-error-provided-to-error-event.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-event-emitter-no-error-provided-to-error-event.js b/test/parallel/test-event-emitter-no-error-provided-to-error-event.js index 1c56c7bc759215..5c30b54533133d 100644 --- a/test/parallel/test-event-emitter-no-error-provided-to-error-event.js +++ b/test/parallel/test-event-emitter-no-error-provided-to-error-event.js @@ -29,7 +29,7 @@ const domain = require('domain'); const e = new events.EventEmitter(); const d = domain.create(); d.add(e); - d.on('error', common.mustCall(function(er) { + d.on('error', common.mustCall((er) => { assert(er instanceof Error, 'error created'); })); e.emit('error'); @@ -39,7 +39,7 @@ for (const arg of [false, null, undefined]) { const e = new events.EventEmitter(); const d = domain.create(); d.add(e); - d.on('error', common.mustCall(function(er) { + d.on('error', common.mustCall((er) => { assert(er instanceof Error, 'error created'); })); e.emit('error', arg); @@ -49,7 +49,7 @@ for (const arg of [42, 'fortytwo', true]) { const e = new events.EventEmitter(); const d = domain.create(); d.add(e); - d.on('error', common.mustCall(function(er) { + d.on('error', common.mustCall((er) => { assert.strictEqual(er, arg); })); e.emit('error', arg); From d156d093ff713b2c2b69c9c82205ce8e37bfb4bf Mon Sep 17 00:00:00 2001 From: Andrew MacCuaig Date: Fri, 12 Oct 2018 10:02:17 -0700 Subject: [PATCH 101/328] test: fix ordering of assertion values --- test/addons-napi/test_general/testInstanceOf.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/addons-napi/test_general/testInstanceOf.js b/test/addons-napi/test_general/testInstanceOf.js index 3b37188ab4d20c..53455a0025a0e2 100644 --- a/test/addons-napi/test_general/testInstanceOf.js +++ b/test/addons-napi/test_general/testInstanceOf.js @@ -18,12 +18,12 @@ const v8TestsDirExists = fs.existsSync(v8TestsDir); // See for instance deps/v8/test/mjsunit/instanceof.js // eslint-disable-next-line no-unused-vars function assertTrue(assertion) { - return assert.strictEqual(true, assertion); + return assert.strictEqual(assertion, true); } // eslint-disable-next-line no-unused-vars function assertFalse(assertion) { - assert.strictEqual(false, assertion); + assert.strictEqual(assertion, false); } // eslint-disable-next-line no-unused-vars From 6f590be5396c4c69acbabcc239e90c8fa89e4d1e Mon Sep 17 00:00:00 2001 From: Alejandro Oviedo Garcia Date: Fri, 12 Oct 2018 14:17:01 -0300 Subject: [PATCH 102/328] test: fix strictEqual assertion arguments PR-URL: https://github.com/nodejs/node/pull/23508 Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-buffer-alloc.js | 104 ++++++++++++++--------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js index 023852b69a850a..6afcbf1b03b8e1 100644 --- a/test/parallel/test-buffer-alloc.js +++ b/test/parallel/test-buffer-alloc.js @@ -7,7 +7,7 @@ const SlowBuffer = require('buffer').SlowBuffer; const b = Buffer.allocUnsafe(1024); -assert.strictEqual(1024, b.length); +assert.strictEqual(b.length, 1024); b[0] = -1; assert.strictEqual(b[0], 255); @@ -21,17 +21,17 @@ for (let i = 0; i < 1024; i++) { } const c = Buffer.allocUnsafe(512); -assert.strictEqual(512, c.length); +assert.strictEqual(c.length, 512); const d = Buffer.from([]); -assert.strictEqual(0, d.length); +assert.strictEqual(d.length, 0); // Test offset properties { const b = Buffer.alloc(128); - assert.strictEqual(128, b.length); - assert.strictEqual(0, b.byteOffset); - assert.strictEqual(0, b.offset); + assert.strictEqual(b.length, 128); + assert.strictEqual(b.byteOffset, 0); + assert.strictEqual(b.offset, 0); } // Test creating a Buffer from a Uint32Array @@ -190,7 +190,7 @@ Buffer.alloc(1).write('', 1, 0); { const slice = b.slice(100, 150); - assert.strictEqual(50, slice.length); + assert.strictEqual(slice.length, 50); for (let i = 0; i < 50; i++) { assert.strictEqual(b[100 + i], slice[i]); } @@ -227,13 +227,13 @@ Buffer.alloc(1).write('', 1, 0); const a = Buffer.allocUnsafe(8); for (let i = 0; i < 8; i++) a[i] = i; const b = a.slice(4, 8); - assert.strictEqual(4, b[0]); - assert.strictEqual(5, b[1]); - assert.strictEqual(6, b[2]); - assert.strictEqual(7, b[3]); + assert.strictEqual(b[0], 4); + assert.strictEqual(b[1], 5); + assert.strictEqual(b[2], 6); + assert.strictEqual(b[3], 7); const c = b.slice(2, 4); - assert.strictEqual(6, c[0]); - assert.strictEqual(7, c[1]); + assert.strictEqual(c[0], 6); + assert.strictEqual(c[1], 7); } { @@ -301,7 +301,7 @@ Buffer.alloc(1).write('', 1, 0); // // Test toString('base64') // -assert.strictEqual('TWFu', (Buffer.from('Man')).toString('base64')); +assert.strictEqual((Buffer.from('Man')).toString('base64'), 'TWFu'); { // test that regular and URL-safe base64 both work @@ -501,7 +501,7 @@ assert.deepStrictEqual(Buffer.from(' YWJvcnVtLg', 'base64'), const b = Buffer.from(s); for (let i = 0; i < l; i++) { - assert.strictEqual('h'.charCodeAt(0), b[i]); + assert.strictEqual(b[i], 'h'.charCodeAt(0)); } const sb = b.toString(); @@ -571,16 +571,16 @@ function buildBuffer(data) { const x = buildBuffer([0x81, 0xa3, 0x66, 0x6f, 0x6f, 0xa3, 0x62, 0x61, 0x72]); -assert.strictEqual('', x.inspect()); +assert.strictEqual(x.inspect(), ''); { const z = x.slice(4); - assert.strictEqual(5, z.length); - assert.strictEqual(0x6f, z[0]); - assert.strictEqual(0xa3, z[1]); - assert.strictEqual(0x62, z[2]); - assert.strictEqual(0x61, z[3]); - assert.strictEqual(0x72, z[4]); + assert.strictEqual(z.length, 5); + assert.strictEqual(z[0], 0x6f); + assert.strictEqual(z[1], 0xa3); + assert.strictEqual(z[2], 0x62); + assert.strictEqual(z[3], 0x61); + assert.strictEqual(z[4], 0x72); } { @@ -590,27 +590,27 @@ assert.strictEqual('', x.inspect()); { const z = x.slice(0, 4); - assert.strictEqual(4, z.length); - assert.strictEqual(0x81, z[0]); - assert.strictEqual(0xa3, z[1]); + assert.strictEqual(z.length, 4); + assert.strictEqual(z[0], 0x81); + assert.strictEqual(z[1], 0xa3); } { const z = x.slice(0, 9); - assert.strictEqual(9, z.length); + assert.strictEqual(z.length, 9); } { const z = x.slice(1, 4); - assert.strictEqual(3, z.length); - assert.strictEqual(0xa3, z[0]); + assert.strictEqual(z.length, 3); + assert.strictEqual(z[0], 0xa3); } { const z = x.slice(2, 4); - assert.strictEqual(2, z.length); - assert.strictEqual(0x66, z[0]); - assert.strictEqual(0x6f, z[1]); + assert.strictEqual(z.length, 2); + assert.strictEqual(z[0], 0x66); + assert.strictEqual(z[1], 0x6f); } ['ucs2', 'ucs-2', 'utf16le', 'utf-16le'].forEach((encoding) => { @@ -630,16 +630,16 @@ assert.strictEqual('', x.inspect()); const b = Buffer.from([0xde, 0xad, 0xbe, 0xef]); let s = String.fromCharCode(0xffff); b.write(s, 0, 'latin1'); - assert.strictEqual(0xff, b[0]); - assert.strictEqual(0xad, b[1]); - assert.strictEqual(0xbe, b[2]); - assert.strictEqual(0xef, b[3]); + assert.strictEqual(b[0], 0xff); + assert.strictEqual(b[1], 0xad); + assert.strictEqual(b[2], 0xbe); + assert.strictEqual(b[3], 0xef); s = String.fromCharCode(0xaaee); b.write(s, 0, 'latin1'); - assert.strictEqual(0xee, b[0]); - assert.strictEqual(0xad, b[1]); - assert.strictEqual(0xbe, b[2]); - assert.strictEqual(0xef, b[3]); + assert.strictEqual(b[0], 0xee); + assert.strictEqual(b[1], 0xad); + assert.strictEqual(b[2], 0xbe); + assert.strictEqual(b[3], 0xef); } { @@ -647,16 +647,16 @@ assert.strictEqual('', x.inspect()); const b = Buffer.from([0xde, 0xad, 0xbe, 0xef]); let s = String.fromCharCode(0xffff); b.write(s, 0, 'latin1'); - assert.strictEqual(0xff, b[0]); - assert.strictEqual(0xad, b[1]); - assert.strictEqual(0xbe, b[2]); - assert.strictEqual(0xef, b[3]); + assert.strictEqual(b[0], 0xff); + assert.strictEqual(b[1], 0xad); + assert.strictEqual(b[2], 0xbe); + assert.strictEqual(b[3], 0xef); s = String.fromCharCode(0xaaee); b.write(s, 0, 'latin1'); - assert.strictEqual(0xee, b[0]); - assert.strictEqual(0xad, b[1]); - assert.strictEqual(0xbe, b[2]); - assert.strictEqual(0xef, b[3]); + assert.strictEqual(b[0], 0xee); + assert.strictEqual(b[1], 0xad); + assert.strictEqual(b[2], 0xbe); + assert.strictEqual(b[3], 0xef); } { @@ -729,11 +729,11 @@ assert.strictEqual('', x.inspect()); { // test offset returns are correct const b = Buffer.allocUnsafe(16); - assert.strictEqual(4, b.writeUInt32LE(0, 0)); - assert.strictEqual(6, b.writeUInt16LE(0, 4)); - assert.strictEqual(7, b.writeUInt8(0, 6)); - assert.strictEqual(8, b.writeInt8(0, 7)); - assert.strictEqual(16, b.writeDoubleLE(0, 8)); + assert.strictEqual(b.writeUInt32LE(0, 0), 4); + assert.strictEqual(b.writeUInt16LE(0, 4), 6); + assert.strictEqual(b.writeUInt8(0, 6), 7); + assert.strictEqual(b.writeInt8(0, 7), 8); + assert.strictEqual(b.writeDoubleLE(0, 8), 16); } { From 119fc3abdd8c4b6733542834aa3beb94d04b3b55 Mon Sep 17 00:00:00 2001 From: Milton Sosa Date: Fri, 12 Oct 2018 10:21:31 -0700 Subject: [PATCH 103/328] test: fix assertions args order in test/parallel/test-fs-chmod.js PR-URL: https://github.com/nodejs/node/pull/23507 Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-fs-chmod.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-fs-chmod.js b/test/parallel/test-fs-chmod.js index ed5919ce887bc8..c3b3dc2fc9c151 100644 --- a/test/parallel/test-fs-chmod.js +++ b/test/parallel/test-fs-chmod.js @@ -86,14 +86,14 @@ fs.chmod(file1, mode_async.toString(8), common.mustCall((err) => { if (common.isWindows) { assert.ok((fs.statSync(file1).mode & 0o777) & mode_async); } else { - assert.strictEqual(mode_async, fs.statSync(file1).mode & 0o777); + assert.strictEqual(fs.statSync(file1).mode & 0o777, mode_async); } fs.chmodSync(file1, mode_sync); if (common.isWindows) { assert.ok((fs.statSync(file1).mode & 0o777) & mode_sync); } else { - assert.strictEqual(mode_sync, fs.statSync(file1).mode & 0o777); + assert.strictEqual(fs.statSync(file1).mode & 0o777, mode_sync); } })); @@ -106,7 +106,7 @@ fs.open(file2, 'w', common.mustCall((err, fd) => { if (common.isWindows) { assert.ok((fs.fstatSync(fd).mode & 0o777) & mode_async); } else { - assert.strictEqual(mode_async, fs.fstatSync(fd).mode & 0o777); + assert.strictEqual(fs.fstatSync(fd).mode & 0o777, mode_async); } common.expectsError( @@ -123,7 +123,7 @@ fs.open(file2, 'w', common.mustCall((err, fd) => { if (common.isWindows) { assert.ok((fs.fstatSync(fd).mode & 0o777) & mode_sync); } else { - assert.strictEqual(mode_sync, fs.fstatSync(fd).mode & 0o777); + assert.strictEqual(fs.fstatSync(fd).mode & 0o777, mode_sync); } fs.close(fd, assert.ifError); @@ -139,10 +139,10 @@ if (fs.lchmod) { fs.lchmod(link, mode_async, common.mustCall((err) => { assert.ifError(err); - assert.strictEqual(mode_async, fs.lstatSync(link).mode & 0o777); + assert.strictEqual(fs.lstatSync(link).mode & 0o777, mode_async); fs.lchmodSync(link, mode_sync); - assert.strictEqual(mode_sync, fs.lstatSync(link).mode & 0o777); + assert.strictEqual(fs.lstatSync(link).mode & 0o777, mode_sync); })); } @@ -170,5 +170,5 @@ if (fs.lchmod) { }); process.on('exit', function() { - assert.strictEqual(0, openCount); + assert.strictEqual(openCount, 0); }); From d590aa858d733748baa556f9bf7492af2402be23 Mon Sep 17 00:00:00 2001 From: "Illescas, Ricardo" Date: Fri, 12 Oct 2018 11:19:56 -0600 Subject: [PATCH 104/328] test: fix argument order in assertions PR-URL: https://github.com/nodejs/node/pull/23506 Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater --- test/pummel/test-net-timeout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pummel/test-net-timeout.js b/test/pummel/test-net-timeout.js index 89190f8d282d50..e87cdc0b8edf51 100644 --- a/test/pummel/test-net-timeout.js +++ b/test/pummel/test-net-timeout.js @@ -66,7 +66,7 @@ echo_server.listen(common.PORT, function() { }); client.on('data', function(chunk) { - assert.strictEqual('hello\r\n', chunk); + assert.strictEqual(chunk, 'hello\r\n'); if (exchanges++ < 5) { setTimeout(function() { console.log('client write "hello"'); From 23d6932c6146b62f404f74ec93760627c41491a3 Mon Sep 17 00:00:00 2001 From: Jean-Francois Arseneau Date: Fri, 12 Oct 2018 09:53:32 -0700 Subject: [PATCH 105/328] test: put expected assert value in correct place The order of arguments in test-fs-readdir-ucs2 was the opposite of what is recommended in the documentation, which is that the first value should be the value being tested, and the second value is the expected value. This fixes the test to make it conform to the documentation. PR-URL: https://github.com/nodejs/node/pull/23505 Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-fs-readdir-ucs2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-fs-readdir-ucs2.js b/test/parallel/test-fs-readdir-ucs2.js index b17dc8d7292664..e5b85665932a7c 100644 --- a/test/parallel/test-fs-readdir-ucs2.js +++ b/test/parallel/test-fs-readdir-ucs2.js @@ -25,8 +25,8 @@ try { fs.readdir(tmpdir.path, 'ucs2', common.mustCall((err, list) => { assert.ifError(err); - assert.strictEqual(1, list.length); + assert.strictEqual(list.length, 1); const fn = list[0]; - assert.deepStrictEqual(filebuff, Buffer.from(fn, 'ucs2')); + assert.deepStrictEqual(Buffer.from(fn, 'ucs2'), filebuff); assert.strictEqual(fn, filename); })); From 28b6129a7b2c77a51686c9f90c82728662e622b8 Mon Sep 17 00:00:00 2001 From: Viacheslav Liakhov Date: Fri, 12 Oct 2018 10:20:32 -0700 Subject: [PATCH 106/328] test: modernize test-child-process-flush-stdio PR-URL: https://github.com/nodejs/node/pull/23504 Reviewed-By: Anatoli Papirovski Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-child-process-flush-stdio.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-child-process-flush-stdio.js b/test/parallel/test-child-process-flush-stdio.js index a2f0bb9f71f341..a7c1ea21be22a4 100644 --- a/test/parallel/test-child-process-flush-stdio.js +++ b/test/parallel/test-child-process-flush-stdio.js @@ -9,7 +9,7 @@ const opts = { shell: common.isWindows }; const p = cp.spawn('echo', [], opts); -p.on('close', common.mustCall(function(code, signal) { +p.on('close', common.mustCall((code, signal) => { assert.strictEqual(code, 0); assert.strictEqual(signal, null); spawnWithReadable(); @@ -17,17 +17,17 @@ p.on('close', common.mustCall(function(code, signal) { p.stdout.read(); -function spawnWithReadable() { +const spawnWithReadable = () => { const buffer = []; const p = cp.spawn('echo', ['123'], opts); - p.on('close', common.mustCall(function(code, signal) { + p.on('close', common.mustCall((code, signal) => { assert.strictEqual(code, 0); assert.strictEqual(signal, null); assert.strictEqual(Buffer.concat(buffer).toString().trim(), '123'); })); - p.stdout.on('readable', function() { + p.stdout.on('readable', () => { let buf; - while (buf = this.read()) + while (buf = p.stdout.read()) buffer.push(buf); }); -} +}; From 66c82adb0ecfcef0c669789b3d60452103397baa Mon Sep 17 00:00:00 2001 From: David Scott Date: Fri, 12 Oct 2018 09:43:36 -0700 Subject: [PATCH 107/328] test: properly order test assertion variables PR-URL: https://github.com/nodejs/node/pull/23503 Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater --- test/parallel/test-child-process-set-blocking.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-child-process-set-blocking.js b/test/parallel/test-child-process-set-blocking.js index bca886ed55cb16..51a079ef5fac73 100644 --- a/test/parallel/test-child-process-set-blocking.js +++ b/test/parallel/test-child-process-set-blocking.js @@ -31,5 +31,5 @@ const cp = ch.spawn('python', ['-c', `print ${SIZE} * "C"`], { }); cp.on('exit', common.mustCall(function(code) { - assert.strictEqual(0, code); + assert.strictEqual(code, 0); })); From f5fd8a21688376269a6694757be34e3d5aed36eb Mon Sep 17 00:00:00 2001 From: Daniyal Mokhammad Date: Fri, 12 Oct 2018 10:16:34 -0700 Subject: [PATCH 108/328] test: fixed incorrect variable order in assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/23502 Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-tracing-no-crash.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-tracing-no-crash.js b/test/parallel/test-tracing-no-crash.js index 816bd95df02e29..5b11522911e75d 100644 --- a/test/parallel/test-tracing-no-crash.js +++ b/test/parallel/test-tracing-no-crash.js @@ -4,8 +4,8 @@ const assert = require('assert'); const { spawn } = require('child_process'); function CheckNoSignalAndErrorCodeOne(code, signal) { - assert.strictEqual(null, signal); - assert.strictEqual(1, code); + assert.strictEqual(signal, null); + assert.strictEqual(code, 1); } const child = spawn(process.execPath, From ff5345cf5c4a36e469f0799c580669cc5ec52db7 Mon Sep 17 00:00:00 2001 From: Joshua Belcher Date: Fri, 12 Oct 2018 10:10:15 -0700 Subject: [PATCH 109/328] test: fix order of assert.strictEqual() args to actual, expected PR-URL: https://github.com/nodejs/node/pull/23501 Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater --- test/addons-napi/test_make_callback/test.js | 25 ++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/test/addons-napi/test_make_callback/test.js b/test/addons-napi/test_make_callback/test.js index 56e2b3f4e2b6c6..3f51acb6c07ac6 100644 --- a/test/addons-napi/test_make_callback/test.js +++ b/test/addons-napi/test_make_callback/test.js @@ -13,22 +13,21 @@ function myMultiArgFunc(arg1, arg2, arg3) { return 42; } -assert.strictEqual(42, makeCallback(process, common.mustCall(function() { +assert.strictEqual(makeCallback(process, common.mustCall(function() { assert.strictEqual(0, arguments.length); assert.strictEqual(this, process); return 42; -}))); +})), 42); -assert.strictEqual(42, makeCallback(process, common.mustCall(function(x) { - assert.strictEqual(1, arguments.length); +assert.strictEqual(makeCallback(process, common.mustCall(function(x) { + assert.strictEqual(arguments.length, 1); assert.strictEqual(this, process); assert.strictEqual(x, 1337); return 42; -}), 1337)); +}), 1337), 42); -assert.strictEqual(42, - makeCallback(this, - common.mustCall(myMultiArgFunc), 1, 2, 3)); +assert.strictEqual(makeCallback(this, + common.mustCall(myMultiArgFunc), 1, 2, 3), 42); // TODO(node-api): napi_make_callback needs to support // strings passed for the func argument @@ -47,12 +46,12 @@ const recv = { }), }; -assert.strictEqual(42, makeCallback(recv, 'one')); -assert.strictEqual(42, makeCallback(recv, 'two', 1337)); +assert.strictEqual(makeCallback(recv, 'one'), 42); +assert.strictEqual(makeCallback(recv, 'two', 1337), 42); // Check that callbacks on a receiver from a different context works. const foreignObject = vm.runInNewContext('({ fortytwo() { return 42; } })'); -assert.strictEqual(42, makeCallback(foreignObject, 'fortytwo')); +assert.strictEqual(makeCallback(foreignObject, 'fortytwo'), 42); */ // Check that the callback is made in the context of the receiver. @@ -63,7 +62,7 @@ const target = vm.runInNewContext(` return Object; }) `); -assert.notStrictEqual(Object, makeCallback(process, target, Object)); +assert.notStrictEqual(makeCallback(process, target, Object), Object); // Runs in inner context. const forward = vm.runInNewContext(` @@ -79,4 +78,4 @@ function endpoint($Object) { return Object; } -assert.strictEqual(Object, makeCallback(process, forward, endpoint)); +assert.strictEqual(makeCallback(process, forward, endpoint), Object); From 6eea5dc6e81b685dd34a383a97dc20be98b7be9c Mon Sep 17 00:00:00 2001 From: Jonny Kalambay Date: Fri, 12 Oct 2018 10:11:51 -0700 Subject: [PATCH 110/328] lib: migrate process.binding('config') to getOptions() PR-URL: https://github.com/nodejs/node/pull/23526 Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- lib/internal/modules/esm/default_resolve.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/internal/modules/esm/default_resolve.js b/lib/internal/modules/esm/default_resolve.js index 8f8efcb5360d63..7707262566c88a 100644 --- a/lib/internal/modules/esm/default_resolve.js +++ b/lib/internal/modules/esm/default_resolve.js @@ -6,8 +6,9 @@ const internalFS = require('internal/fs/utils'); const { NativeModule } = require('internal/bootstrap/loaders'); const { extname } = require('path'); const { realpathSync } = require('fs'); -const preserveSymlinks = !!process.binding('config').preserveSymlinks; -const preserveSymlinksMain = !!process.binding('config').preserveSymlinksMain; +const { getOptions } = internalBinding('options'); +const preserveSymlinks = getOptions('--preserve-symlinks'); +const preserveSymlinksMain = getOptions('--preserve-symlinks-main'); const { ERR_MISSING_MODULE, ERR_MODULE_RESOLUTION_LEGACY, From 4f116a7009acce8a7c98c8adf00b8938ae43f112 Mon Sep 17 00:00:00 2001 From: Pascal Lambert Date: Fri, 12 Oct 2018 11:27:46 -0600 Subject: [PATCH 111/328] test: swap assert argument order in test-vm-create-and-run-in-context.js PR-URL: https://github.com/nodejs/node/pull/23525 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-vm-create-and-run-in-context.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-vm-create-and-run-in-context.js b/test/parallel/test-vm-create-and-run-in-context.js index 09f643aa90df46..8f4ce72c50f246 100644 --- a/test/parallel/test-vm-create-and-run-in-context.js +++ b/test/parallel/test-vm-create-and-run-in-context.js @@ -33,13 +33,13 @@ assert.strictEqual('passed', result); // Create a new pre-populated context context = vm.createContext({ 'foo': 'bar', 'thing': 'lala' }); -assert.strictEqual('bar', context.foo); -assert.strictEqual('lala', context.thing); +assert.strictEqual(context.foo, 'bar'); +assert.strictEqual(context.thing, 'lala'); // Test updating context result = vm.runInContext('var foo = 3;', context); -assert.strictEqual(3, context.foo); -assert.strictEqual('lala', context.thing); +assert.strictEqual(context.foo, 3); +assert.strictEqual(context.thing, 'lala'); // https://github.com/nodejs/node/issues/5768 // Run in contextified sandbox without referencing the context From 9dc11e33544492d5404df1d1e986e1db73cb85c2 Mon Sep 17 00:00:00 2001 From: Arne Schramm Date: Fri, 12 Oct 2018 10:23:40 -0700 Subject: [PATCH 112/328] test: switch arguments of assert() The arguments of the assert were passed in the wrong order (expected, actual). This would have been confusing in case of an error. Changed it to be (actual, expected) PR-URL: https://github.com/nodejs/node/pull/23524 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/sequential/test-inspector-break-when-eval.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sequential/test-inspector-break-when-eval.js b/test/sequential/test-inspector-break-when-eval.js index e7529f786a9859..9952650252310e 100644 --- a/test/sequential/test-inspector-break-when-eval.js +++ b/test/sequential/test-inspector-break-when-eval.js @@ -63,7 +63,7 @@ async function runTests() { await breakOnLine(session); await stepOverConsoleStatement(session); await session.runToCompletion(); - assert.strictEqual(0, (await child.expectShutdown()).exitCode); + assert.strictEqual((await child.expectShutdown()).exitCode, 0); } runTests(); From b7d4404e872d9e8c2fee3410212cd0367371a617 Mon Sep 17 00:00:00 2001 From: Lee Gray Date: Fri, 12 Oct 2018 10:23:09 -0700 Subject: [PATCH 113/328] test: fix assert order in test-vm-context PR-URL: https://github.com/nodejs/node/pull/23523 Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-vm-context.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-vm-context.js b/test/parallel/test-vm-context.js index 31ed69da93fabc..e1cfd145f226ad 100644 --- a/test/parallel/test-vm-context.js +++ b/test/parallel/test-vm-context.js @@ -30,18 +30,18 @@ let script = new Script('"passed";'); // Run in a new empty context let context = vm.createContext(); let result = script.runInContext(context); -assert.strictEqual('passed', result); +assert.strictEqual(result, 'passed'); // Create a new pre-populated context context = vm.createContext({ 'foo': 'bar', 'thing': 'lala' }); -assert.strictEqual('bar', context.foo); -assert.strictEqual('lala', context.thing); +assert.strictEqual(context.foo, 'bar'); +assert.strictEqual(context.thing, 'lala'); // Test updating context script = new Script('foo = 3;'); result = script.runInContext(context); -assert.strictEqual(3, context.foo); -assert.strictEqual('lala', context.thing); +assert.strictEqual(context.foo, 3); +assert.strictEqual(context.thing, 'lala'); // Issue GH-227: common.expectsError(() => { From 100ed74216db22d02dba49b41efa420958271393 Mon Sep 17 00:00:00 2001 From: Randy Wressell Date: Fri, 12 Oct 2018 10:07:49 -0700 Subject: [PATCH 114/328] lib: migrate process.binding to getOptions PR-URL: https://github.com/nodejs/node/pull/23522 Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- lib/internal/modules/cjs/helpers.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/internal/modules/cjs/helpers.js b/lib/internal/modules/cjs/helpers.js index 5b5199c262ae3b..cda94987fad210 100644 --- a/lib/internal/modules/cjs/helpers.js +++ b/lib/internal/modules/cjs/helpers.js @@ -9,6 +9,8 @@ const { CHAR_HASH, } = require('internal/constants'); +const { getOptions } = internalBinding('options'); + // Invoke with makeRequireFunction(module) where |module| is the Module object // to use as the context for the require() function. function makeRequireFunction(mod) { @@ -105,7 +107,7 @@ const builtinLibs = [ 'v8', 'vm', 'zlib' ]; -if (process.binding('config').experimentalWorker) { +if (getOptions('--experimental-worker')) { builtinLibs.push('worker_threads'); builtinLibs.sort(); } From ad83caf7fa8fb343cd0deb757c831f1ef0ffd775 Mon Sep 17 00:00:00 2001 From: Tyler Vann-Campbell Date: Fri, 12 Oct 2018 10:03:45 -0700 Subject: [PATCH 115/328] test: use the correct parameter order on assert.strictEqual() The parameter order for assert.strictEqual() should be actual, expected rather than expected, actual which can make test failure messages confusing. This change reverses the order of the assertion to match the documented parameter order. PR-URL: https://github.com/nodejs/node/pull/23520 Reviewed-By: Guy Bedford Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater --- test/pummel/test-net-many-clients.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/pummel/test-net-many-clients.js b/test/pummel/test-net-many-clients.js index 657b03abdec205..db7da1ae041341 100644 --- a/test/pummel/test-net-many-clients.js +++ b/test/pummel/test-net-many-clients.js @@ -70,8 +70,8 @@ function runClient(callback) { client.on('close', function(had_error) { console.log('.'); - assert.strictEqual(false, had_error); - assert.strictEqual(bytes, client.recved.length); + assert.strictEqual(had_error, false); + assert.strictEqual(client.recved.length, bytes); if (client.fd) { console.log(client.fd); @@ -96,6 +96,6 @@ server.listen(common.PORT, function() { }); process.on('exit', function() { - assert.strictEqual(connections_per_client * concurrency, total_connections); + assert.strictEqual(total_connections, connections_per_client * concurrency); console.log('\nokay!'); }); From 9b89e9c2508b4f537a7d93bcb50b19ff093fa60c Mon Sep 17 00:00:00 2001 From: surreal8 Date: Fri, 12 Oct 2018 12:17:34 -0500 Subject: [PATCH 116/328] lib: migrate process.binding to internalBinding PR-URL: https://github.com/nodejs/node/pull/23517 Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Jeremiah Senkpiel Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- lib/internal/process/esm_loader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/process/esm_loader.js b/lib/internal/process/esm_loader.js index 23b98c620e64e5..d775e685d13ea7 100644 --- a/lib/internal/process/esm_loader.js +++ b/lib/internal/process/esm_loader.js @@ -48,7 +48,7 @@ exports.setup = function() { let ESMLoader = new Loader(); const loaderPromise = (async () => { - const userLoader = process.binding('config').userLoader; + const userLoader = internalBinding('options').getOptions('--loader'); if (userLoader) { const hooks = await ESMLoader.import( userLoader, pathToFileURL(`${process.cwd()}/`).href); From 161cbbb97ac3fa121a7714b2a14cc21baf8aed53 Mon Sep 17 00:00:00 2001 From: Takdeer Sodhan Date: Fri, 12 Oct 2018 10:27:36 -0700 Subject: [PATCH 117/328] test: fix assert.strictEqual arg order in test-tls-ecdh-multiple.js PR-URL: https://github.com/nodejs/node/pull/23516 Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-tls-ecdh-multiple.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-tls-ecdh-multiple.js b/test/parallel/test-tls-ecdh-multiple.js index 5dea61e20fbad4..d5f27a5e464437 100644 --- a/test/parallel/test-tls-ecdh-multiple.js +++ b/test/parallel/test-tls-ecdh-multiple.js @@ -48,7 +48,7 @@ server.listen(0, function() { }); client.on('exit', function(code) { - assert.strictEqual(0, code); + assert.strictEqual(code, 0); server.close(); }); From 0d6d6f63cda3782ba3f6ab49d98b27af36357844 Mon Sep 17 00:00:00 2001 From: Ben Schaaf Date: Fri, 12 Oct 2018 10:24:33 -0700 Subject: [PATCH 118/328] test: fix assert.strictEqual() argument order PR-URL: https://github.com/nodejs/node/pull/23515 Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- .../test-inspector-async-hook-setup-at-inspect-brk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sequential/test-inspector-async-hook-setup-at-inspect-brk.js b/test/sequential/test-inspector-async-hook-setup-at-inspect-brk.js index 9a2822e8f5740d..ffe3a979989d85 100644 --- a/test/sequential/test-inspector-async-hook-setup-at-inspect-brk.js +++ b/test/sequential/test-inspector-async-hook-setup-at-inspect-brk.js @@ -44,7 +44,7 @@ async function runTests() { await checkAsyncStackTrace(session); await session.runToCompletion(); - assert.strictEqual(55, (await instance.expectShutdown()).exitCode); + assert.strictEqual((await instance.expectShutdown()).exitCode, 55); } runTests(); From 608d5fa8f0b85008a70d29dc305a1c5a3eb4e319 Mon Sep 17 00:00:00 2001 From: David Ward Date: Fri, 12 Oct 2018 10:09:09 -0700 Subject: [PATCH 119/328] test: fix test-dgram-pingpong assertion arg order PR-URL: https://github.com/nodejs/node/pull/23514 Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Ruben Bridgewater --- test/sequential/test-dgram-pingpong.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sequential/test-dgram-pingpong.js b/test/sequential/test-dgram-pingpong.js index c97b7872dedf2c..33b01fbe22a9b9 100644 --- a/test/sequential/test-dgram-pingpong.js +++ b/test/sequential/test-dgram-pingpong.js @@ -6,7 +6,7 @@ const dgram = require('dgram'); function pingPongTest(port, host) { const server = dgram.createSocket('udp4', common.mustCall((msg, rinfo) => { - assert.strictEqual('PING', msg.toString('ascii')); + assert.strictEqual(msg.toString('ascii'), 'PING'); server.send('PONG', 0, 4, rinfo.port, rinfo.address); })); @@ -20,7 +20,7 @@ function pingPongTest(port, host) { const client = dgram.createSocket('udp4'); client.on('message', function(msg) { - assert.strictEqual('PONG', msg.toString('ascii')); + assert.strictEqual(msg.toString('ascii'), 'PONG'); client.close(); server.close(); From a0985281ee6b7660ff7659b1c8c04cfb983f0ce8 Mon Sep 17 00:00:00 2001 From: Elvis-Philip N Date: Fri, 12 Oct 2018 13:11:14 -0400 Subject: [PATCH 120/328] test: corret assertion arg order in test-regress-GH-892.js PR-URL: https://github.com/nodejs/node/pull/23513 Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater --- test/pummel/test-regress-GH-892.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/pummel/test-regress-GH-892.js b/test/pummel/test-regress-GH-892.js index 4021a53736421b..48201807e39e56 100644 --- a/test/pummel/test-regress-GH-892.js +++ b/test/pummel/test-regress-GH-892.js @@ -59,7 +59,7 @@ function makeRequest() { child.on('exit', function(code) { assert.ok(/DONE/.test(stderrBuffer)); - assert.strictEqual(0, code); + assert.strictEqual(code, 0); }); // The following two lines forward the stdio from the child @@ -95,7 +95,7 @@ const server = https.Server(serverOptions, function(req, res) { }); req.on('end', function() { - assert.strictEqual(bytesExpected, uploadCount); + assert.strictEqual(uploadCount, bytesExpected); res.writeHead(200, { 'content-type': 'text/plain' }); res.end('successful upload\n'); }); From 22a4ec1d70ce8787452613503cde789c0f9cd34a Mon Sep 17 00:00:00 2001 From: edgarzapeka Date: Fri, 12 Oct 2018 10:01:27 -0700 Subject: [PATCH 121/328] test: replaced functions with arrow functions PR-URL: https://github.com/nodejs/node/pull/23511 Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-domain-from-timer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-domain-from-timer.js b/test/parallel/test-domain-from-timer.js index ead0e1b8382fc5..3f8252543c9d2f 100644 --- a/test/parallel/test-domain-from-timer.js +++ b/test/parallel/test-domain-from-timer.js @@ -27,11 +27,11 @@ const assert = require('assert'); // timeouts call the callback directly from cc, so need to make sure the // domain will be used regardless -setTimeout(function() { +setTimeout(() => { const domain = require('domain'); const d = domain.create(); - d.run(function() { - process.nextTick(function() { + d.run(() => { + process.nextTick(() => { console.trace('in nexttick', process.domain === d); assert.strictEqual(process.domain, d); }); From 7cd9161ea40fa2af287ce30bd9b20f5ce3763512 Mon Sep 17 00:00:00 2001 From: Michael Chen Date: Fri, 12 Oct 2018 10:22:52 -0700 Subject: [PATCH 122/328] test: refactor functions to es6 PR-URL: https://github.com/nodejs/node/pull/23510 Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat --- .../parallel/test-cluster-setup-master-multiple.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-cluster-setup-master-multiple.js b/test/parallel/test-cluster-setup-master-multiple.js index 2a6341ea56c3c5..b33acccd411a0a 100644 --- a/test/parallel/test-cluster-setup-master-multiple.js +++ b/test/parallel/test-cluster-setup-master-multiple.js @@ -30,14 +30,12 @@ assert(cluster.isMaster); // makes that unnecessary. This is to make the test less fragile if the // implementation ever changes such that cluster.settings is mutated instead of // replaced. -function cheapClone(obj) { - return JSON.parse(JSON.stringify(obj)); -} +const cheapClone = (obj) => JSON.parse(JSON.stringify(obj)); const configs = []; // Capture changes -cluster.on('setup', function() { +cluster.on('setup', () => { console.log('"setup" emitted', cluster.settings); configs.push(cheapClone(cluster.settings)); }); @@ -48,7 +46,7 @@ const execs = [ 'node-next-3', ]; -process.on('exit', function assertTests() { +process.on('exit', () => { // Tests that "setup" is emitted for every call to setupMaster assert.strictEqual(configs.length, execs.length); @@ -58,14 +56,14 @@ process.on('exit', function assertTests() { }); // Make changes to cluster settings -execs.forEach(function(v, i) { - setTimeout(function() { +execs.forEach((v, i) => { + setTimeout(() => { cluster.setupMaster({ exec: v }); }, i * 100); }); // cluster emits 'setup' asynchronously, so we must stay alive long // enough for that to happen -setTimeout(function() { +setTimeout(() => { console.log('cluster setup complete'); }, (execs.length + 1) * 100); From de8ffbad803270da63a4a7a9a0c8e4fa782ec989 Mon Sep 17 00:00:00 2001 From: "garrik.leonardo@gmail.com" Date: Fri, 12 Oct 2018 12:34:28 -0500 Subject: [PATCH 123/328] test: updating assertion on test so it fits the new method signature One assertion on test-tls-connect-address-family.js was out fo date, here we are fixing it to match the signature of strictEqual method. PR-URL: https://github.com/nodejs/node/pull/23536 Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Ruben Bridgewater --- test/parallel/test-tls-connect-address-family.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-tls-connect-address-family.js b/test/parallel/test-tls-connect-address-family.js index 75416c397d7c75..569688ca8abd18 100644 --- a/test/parallel/test-tls-connect-address-family.js +++ b/test/parallel/test-tls-connect-address-family.js @@ -26,7 +26,7 @@ function runTest() { }; // Will fail with ECONNREFUSED if the address family is not honored. tls.connect(options).once('secureConnect', common.mustCall(function() { - assert.strictEqual('::1', this.remoteAddress); + assert.strictEqual(this.remoteAddress, '::1'); this.destroy(); })); })); From fa7d0ce4860cd96d900dd86ca6af294e61fcd229 Mon Sep 17 00:00:00 2001 From: MarianneDr Date: Fri, 12 Oct 2018 10:37:02 -0700 Subject: [PATCH 124/328] src: remove unused UVHandle methods PR-URL: https://github.com/nodejs/node/pull/23535 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- src/connection_wrap.h | 4 ---- src/tty_wrap.cc | 5 ----- src/tty_wrap.h | 2 -- src/udp_wrap.cc | 7 ------- src/udp_wrap.h | 2 -- 5 files changed, 20 deletions(-) diff --git a/src/connection_wrap.h b/src/connection_wrap.h index 72030a00901daf..5b114088760dad 100644 --- a/src/connection_wrap.h +++ b/src/connection_wrap.h @@ -12,10 +12,6 @@ namespace node { template class ConnectionWrap : public LibuvStreamWrap { public: - UVType* UVHandle() { - return &handle_; - } - static void OnConnection(uv_stream_t* handle, int status); static void AfterConnect(uv_connect_t* req, int status); diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc index 516fa1ec1ff4ed..9522dee95bbfb8 100644 --- a/src/tty_wrap.cc +++ b/src/tty_wrap.cc @@ -64,11 +64,6 @@ void TTYWrap::Initialize(Local target, } -uv_tty_t* TTYWrap::UVHandle() { - return &handle_; -} - - void TTYWrap::GuessHandleType(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); int fd; diff --git a/src/tty_wrap.h b/src/tty_wrap.h index ad5f364134e3e2..f794e2112fa1ee 100644 --- a/src/tty_wrap.h +++ b/src/tty_wrap.h @@ -36,8 +36,6 @@ class TTYWrap : public LibuvStreamWrap { v8::Local unused, v8::Local context); - uv_tty_t* UVHandle(); - SET_NO_MEMORY_INFO() SET_MEMORY_INFO_NAME(TTYWrap) SET_SELF_SIZE(TTYWrap) diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 28fa51f1c639d2..04d65c3635737e 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -27,8 +27,6 @@ #include "req_wrap-inl.h" #include "util-inl.h" - - namespace node { using v8::Array; @@ -512,11 +510,6 @@ Local UDPWrap::Instantiate(Environment* env, } -uv_udp_t* UDPWrap::UVHandle() { - return &handle_; -} - - } // namespace node NODE_BUILTIN_MODULE_CONTEXT_AWARE(udp_wrap, node::UDPWrap::Initialize) diff --git a/src/udp_wrap.h b/src/udp_wrap.h index c1261fdb3945e4..c7e1411c08659f 100644 --- a/src/udp_wrap.h +++ b/src/udp_wrap.h @@ -62,8 +62,6 @@ class UDPWrap: public HandleWrap { static v8::Local Instantiate(Environment* env, AsyncWrap* parent, SocketType type); - uv_udp_t* UVHandle(); - SET_NO_MEMORY_INFO() SET_MEMORY_INFO_NAME(UDPWrap) SET_SELF_SIZE(UDPWrap) From 474b401794b63614da12fe003273440dd5aefe43 Mon Sep 17 00:00:00 2001 From: Marcos Frony Date: Fri, 12 Oct 2018 10:15:11 -0700 Subject: [PATCH 125/328] test: reorder asserts arguments Revert arguments for assert and ensure that the first argument is always the actual value being tested. PR-URL: https://github.com/nodejs/node/pull/23534 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/pummel/test-net-pause.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/pummel/test-net-pause.js b/test/pummel/test-net-pause.js index c25f8a0bc1d49b..ea0e61264e32db 100644 --- a/test/pummel/test-net-pause.js +++ b/test/pummel/test-net-pause.js @@ -53,7 +53,7 @@ server.on('listening', function() { setTimeout(function() { chars_recved = recv.length; console.log(`pause at: ${chars_recved}`); - assert.strictEqual(true, chars_recved > 1); + assert.strictEqual(chars_recved > 1, true); client.pause(); setTimeout(function() { console.log(`resume at: ${chars_recved}`); @@ -86,6 +86,6 @@ server.on('listening', function() { server.listen(common.PORT); process.on('exit', function() { - assert.strictEqual(N, recv.length); + assert.strictEqual(recv.length, N); console.error('Exit'); }); From 90cbeae6d987c7db8567cde57bea52b0881f7f96 Mon Sep 17 00:00:00 2001 From: Andrew J D McCann Date: Fri, 12 Oct 2018 10:31:06 -0700 Subject: [PATCH 126/328] src: use default initializers over settings fields on the constructor PR-URL: https://github.com/nodejs/node/pull/23532 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- src/spawn_sync.cc | 4 +--- src/spawn_sync.h | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc index 46d895e38a7389..d57b4b03e23394 100644 --- a/src/spawn_sync.cc +++ b/src/spawn_sync.cc @@ -50,9 +50,7 @@ using v8::String; using v8::Value; -SyncProcessOutputBuffer::SyncProcessOutputBuffer() - : used_(0), - next_(nullptr) { +SyncProcessOutputBuffer::SyncProcessOutputBuffer() { } diff --git a/src/spawn_sync.h b/src/spawn_sync.h index adb2618cc5f404..397e62b9d2c0d9 100644 --- a/src/spawn_sync.h +++ b/src/spawn_sync.h @@ -56,9 +56,9 @@ class SyncProcessOutputBuffer { private: // Use unsigned int because that's what `uv_buf_init` takes. mutable char data_[kBufferSize]; - unsigned int used_; + unsigned int used_ = 0; - SyncProcessOutputBuffer* next_; + SyncProcessOutputBuffer* next_ = nullptr; }; From 0895576d10f971f8fd09460a29a59994d71a600c Mon Sep 17 00:00:00 2001 From: nofwayy Date: Fri, 12 Oct 2018 10:25:33 -0700 Subject: [PATCH 127/328] test: correct labelling of asserts errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23531 Reviewed-By: Сковорода Никита Андреевич Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Gireesh Punathil Reviewed-By: Ruben Bridgewater --- test/parallel/test-tls-over-http-tunnel.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-tls-over-http-tunnel.js b/test/parallel/test-tls-over-http-tunnel.js index f3f2bb3f2726ed..b26cf7872f6582 100644 --- a/test/parallel/test-tls-over-http-tunnel.js +++ b/test/parallel/test-tls-over-http-tunnel.js @@ -57,12 +57,12 @@ const proxy = net.createServer((clientSocket) => { clientSocket.on('data', (chunk) => { if (!serverSocket) { // Verify the CONNECT request - assert.strictEqual(`CONNECT localhost:${server.address().port} ` + + assert.strictEqual(chunk.toString(), + `CONNECT localhost:${server.address().port} ` + 'HTTP/1.1\r\n' + 'Proxy-Connections: keep-alive\r\n' + `Host: localhost:${proxy.address().port}\r\n` + - 'Connection: close\r\n\r\n', - chunk.toString()); + 'Connection: close\r\n\r\n'); console.log('PROXY: got CONNECT request'); console.log('PROXY: creating a tunnel'); @@ -126,7 +126,7 @@ proxy.listen(0, common.mustCall(() => { } function onConnect(res, socket, header) { - assert.strictEqual(200, res.statusCode); + assert.strictEqual(res.statusCode, 200); console.log('CLIENT: got CONNECT response'); // detach the socket @@ -149,10 +149,10 @@ proxy.listen(0, common.mustCall(() => { agent: false, rejectUnauthorized: false }, (res) => { - assert.strictEqual(200, res.statusCode); + assert.strictEqual(res.statusCode, 200); res.on('data', common.mustCall((chunk) => { - assert.strictEqual('hello world\n', chunk.toString()); + assert.strictEqual(chunk.toString(), 'hello world\n'); console.log('CLIENT: got HTTPS response'); gotRequest = true; })); From 93af93ae9f08da88a73ccf9f3625956c67b617fb Mon Sep 17 00:00:00 2001 From: jaxyz Date: Fri, 12 Oct 2018 10:33:15 -0700 Subject: [PATCH 128/328] test: fix strictEqual assertion argument in test-tls-ecdh-auto PR-URL: https://github.com/nodejs/node/pull/23530 Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Ruben Bridgewater --- test/parallel/test-tls-ecdh-auto.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-tls-ecdh-auto.js b/test/parallel/test-tls-ecdh-auto.js index 21aecad6cdc0d5..840063229a60b7 100644 --- a/test/parallel/test-tls-ecdh-auto.js +++ b/test/parallel/test-tls-ecdh-auto.js @@ -48,7 +48,7 @@ server.listen(0, function() { }); client.on('exit', function(code) { - assert.strictEqual(0, code); + assert.strictEqual(code, 0); server.close(); }); From 8e6989560370089935eb6a1faa55beb50bdb215a Mon Sep 17 00:00:00 2001 From: ssamuels0916 Date: Fri, 12 Oct 2018 10:21:44 -0700 Subject: [PATCH 129/328] test: fix assert.strictEqual() argument order PR-URL: https://github.com/nodejs/node/pull/23529 Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Ruben Bridgewater --- test/parallel/test-http-buffer-sanity.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-http-buffer-sanity.js b/test/parallel/test-http-buffer-sanity.js index 8dfccf7d5c688d..05c027fd482582 100644 --- a/test/parallel/test-http-buffer-sanity.js +++ b/test/parallel/test-http-buffer-sanity.js @@ -40,13 +40,13 @@ const server = http.Server(function(req, res) { req.on('data', (d) => { measuredSize += d.length; for (let j = 0; j < d.length; j++) { - assert.strictEqual(buffer[i], d[j]); + assert.strictEqual(d[j], buffer[i]); i++; } }); req.on('end', common.mustCall(() => { - assert.strictEqual(bufferSize, measuredSize); + assert.strictEqual(measuredSize, bufferSize); res.writeHead(200); res.write('thanks'); res.end(); @@ -64,7 +64,7 @@ server.listen(0, common.mustCall(() => { let data = ''; res.on('data', (chunk) => data += chunk); res.on('end', common.mustCall(() => { - assert.strictEqual('thanks', data); + assert.strictEqual(data, 'thanks'); })); })); req.end(buffer); From 5d7c15bc6d0fc5fc8b0f48e8d3fa1943c03f1bc2 Mon Sep 17 00:00:00 2001 From: Diana Lee Date: Fri, 12 Oct 2018 10:32:20 -0700 Subject: [PATCH 130/328] test: corrected the order of arguments in assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/23528 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/pummel/test-tls-securepair-client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/pummel/test-tls-securepair-client.js b/test/pummel/test-tls-securepair-client.js index 8e56e11fabd5ae..09006228c25564 100644 --- a/test/pummel/test-tls-securepair-client.js +++ b/test/pummel/test-tls-securepair-client.js @@ -171,8 +171,8 @@ function test(keyfn, certfn, check, next) { process.on('exit', function() { - assert.strictEqual(0, serverExitCode); - assert.strictEqual('WAIT-SERVER-CLOSE', state); + assert.strictEqual(serverExitCode, 0); + assert.strictEqual(state, 'WAIT-SERVER-CLOSE'); assert.ok(gotWriteCallback); }); } From efdbc2d846ba90c800773bdec1d4940d1134ccab Mon Sep 17 00:00:00 2001 From: Oktavianus Ludiro Date: Fri, 12 Oct 2018 10:19:49 -0700 Subject: [PATCH 131/328] test: use correct argument order for assert.strictEqual() The previous code did not pass correct argument order to assert.strictEqual(). Before: First argument provided is expected value Second argument provided is actual value After: First argument provided is actual value Second argument provided is expected value PR-URL: https://github.com/nodejs/node/pull/23527 Reviewed-By: Hitesh Kanwathirtha Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/pummel/test-fs-watch-file.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/pummel/test-fs-watch-file.js b/test/pummel/test-fs-watch-file.js index e9d208778faf3f..d8694418e9eea5 100644 --- a/test/pummel/test-fs-watch-file.js +++ b/test/pummel/test-fs-watch-file.js @@ -50,10 +50,10 @@ process.on('exit', function() { fs.unlinkSync(filepathTwoAbs); fs.unlinkSync(filenameThree); fs.unlinkSync(filenameFour); - assert.strictEqual(1, watchSeenOne); - assert.strictEqual(2, watchSeenTwo); - assert.strictEqual(1, watchSeenThree); - assert.strictEqual(1, watchSeenFour); + assert.strictEqual(watchSeenOne, 1); + assert.strictEqual(watchSeenTwo, 2); + assert.strictEqual(watchSeenThree, 1); + assert.strictEqual(watchSeenFour, 1); }); @@ -134,7 +134,7 @@ setTimeout(function() { { // Does not throw. function a() { ++watchSeenFour; - assert.strictEqual(1, watchSeenFour); + assert.strictEqual(watchSeenFour, 1); fs.unwatchFile(`.${path.sep}${filenameFour}`, a); } fs.watchFile(filenameFour, a); From 1e8ce06732c8a5e1742f91107533bb27e7f29870 Mon Sep 17 00:00:00 2001 From: Eli Itah Date: Fri, 12 Oct 2018 10:48:45 -0700 Subject: [PATCH 132/328] test: updating assertion and expect order in test-tls-client-verify.js PR-URL: https://github.com/nodejs/node/pull/23547 Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil --- test/parallel/test-tls-client-verify.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-tls-client-verify.js b/test/parallel/test-tls-client-verify.js index 3abcd3c16345ef..12d2514eed3a89 100644 --- a/test/parallel/test-tls-client-verify.js +++ b/test/parallel/test-tls-client-verify.js @@ -99,7 +99,7 @@ function testServers(index, servers, clientOptions, cb) { console.error(`expected: ${ok} authed: ${authorized}`); - assert.strictEqual(ok, authorized); + assert.strictEqual(authorized, ok); server.close(); })); @@ -108,7 +108,7 @@ function testServers(index, servers, clientOptions, cb) { }); client.on('end', common.mustCall(function() { - assert.strictEqual('hello world\n', b); + assert.strictEqual(b, 'hello world\n'); })); client.on('close', common.mustCall(function() { From 4c27cf0a4131e338216e8187d218525e1223692e Mon Sep 17 00:00:00 2001 From: Sean Healy Date: Fri, 12 Oct 2018 10:43:47 -0700 Subject: [PATCH 133/328] test: refactor callback functions to arrow functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor callback functions to modern arrow functions. Also, added `common.mustCall` to `online` callbacks. PR-URL: https://github.com/nodejs/node/pull/23546 Reviewed-By: James M Snell Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- .../test-cluster-worker-forced-exit.js | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-cluster-worker-forced-exit.js b/test/parallel/test-cluster-worker-forced-exit.js index 6a6046f23c4dd1..cc76b4ba3aff3a 100644 --- a/test/parallel/test-cluster-worker-forced-exit.js +++ b/test/parallel/test-cluster-worker-forced-exit.js @@ -37,10 +37,8 @@ const SENTINEL = 42; // 3 disconnect worker with child_process's disconnect, confirm // no sentinel value if (cluster.isWorker) { - process.on('disconnect', function(msg) { - setTimeout(function() { - process.exit(SENTINEL); - }, 10); + process.on('disconnect', (msg) => { + setTimeout(() => process.exit(SENTINEL), 10); }); return; } @@ -49,17 +47,17 @@ checkUnforced(); checkForced(); function checkUnforced() { - cluster.fork() - .on('online', function() { this.disconnect(); }) - .on('exit', common.mustCall(function(status) { + const worker = cluster.fork(); + worker + .on('online', common.mustCall(() => worker.disconnect())) + .on('exit', common.mustCall((status) => { assert.strictEqual(status, SENTINEL); })); } function checkForced() { - cluster.fork() - .on('online', function() { this.process.disconnect(); }) - .on('exit', common.mustCall(function(status) { - assert.strictEqual(status, 0); - })); + const worker = cluster.fork(); + worker + .on('online', common.mustCall(() => worker.process.disconnect())) + .on('exit', common.mustCall((status) => assert.strictEqual(status, 0))); } From 02b06880030d551173ca822077c7f5906b55ae33 Mon Sep 17 00:00:00 2001 From: Carl Richmond Date: Fri, 12 Oct 2018 10:40:59 -0700 Subject: [PATCH 134/328] test: fix assertion argument order PR-URL: https://github.com/nodejs/node/pull/23545 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat --- test/parallel/test-stream-pipe-cleanup.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-stream-pipe-cleanup.js b/test/parallel/test-stream-pipe-cleanup.js index b8ebc036bee24d..ac0a72a1da416b 100644 --- a/test/parallel/test-stream-pipe-cleanup.js +++ b/test/parallel/test-stream-pipe-cleanup.js @@ -65,8 +65,8 @@ for (i = 0; i < limit; i++) { r.pipe(w); r.emit('end'); } -assert.strictEqual(0, r.listeners('end').length); -assert.strictEqual(limit, w.endCalls); +assert.strictEqual(r.listeners('end').length, 0); +assert.strictEqual(w.endCalls, limit); w.endCalls = 0; @@ -75,8 +75,8 @@ for (i = 0; i < limit; i++) { r.pipe(w); r.emit('close'); } -assert.strictEqual(0, r.listeners('close').length); -assert.strictEqual(limit, w.endCalls); +assert.strictEqual(r.listeners('close').length, 0); +assert.strictEqual(w.endCalls, limit); w.endCalls = 0; @@ -87,7 +87,7 @@ for (i = 0; i < limit; i++) { r.pipe(w); w.emit('close'); } -assert.strictEqual(0, w.listeners('close').length); +assert.strictEqual(w.listeners('close').length, 0); r = new Readable(); w = new Writable(); From 6e5a5ff6540d3cdc75203a37bf90f631f5151e03 Mon Sep 17 00:00:00 2001 From: KelvinLawHF1 Date: Fri, 12 Oct 2018 10:26:11 -0700 Subject: [PATCH 135/328] test: fix assertions argument order PR-URL: https://github.com/nodejs/node/pull/23544 Reviewed-By: Anatoli Papirovski Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Ruben Bridgewater --- test/parallel/test-vm-static-this.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-vm-static-this.js b/test/parallel/test-vm-static-this.js index d4530604dc06f0..e9382d6c3b4c1a 100644 --- a/test/parallel/test-vm-static-this.js +++ b/test/parallel/test-vm-static-this.js @@ -26,7 +26,7 @@ const vm = require('vm'); // Run a string const result = vm.runInThisContext('\'passed\';'); -assert.strictEqual('passed', result); +assert.strictEqual(result, 'passed'); // thrown error assert.throws(function() { @@ -35,7 +35,7 @@ assert.throws(function() { global.hello = 5; vm.runInThisContext('hello = 2'); -assert.strictEqual(2, global.hello); +assert.strictEqual(global.hello, 2); // pass values @@ -48,14 +48,14 @@ global.obj = { foo: 0, baz: 3 }; /* eslint-disable no-unused-vars */ const baz = vm.runInThisContext(code); /* eslint-enable no-unused-vars */ -assert.strictEqual(0, global.obj.foo); -assert.strictEqual(2, global.bar); -assert.strictEqual(1, global.foo); +assert.strictEqual(global.obj.foo, 0); +assert.strictEqual(global.bar, 2); +assert.strictEqual(global.foo, 1); // call a function global.f = function() { global.foo = 100; }; vm.runInThisContext('f()'); -assert.strictEqual(100, global.foo); +assert.strictEqual(global.foo, 100); common.allowGlobals( global.hello, From b55fed075c2842a30c79a851fb0ea010528a736f Mon Sep 17 00:00:00 2001 From: Cody Hazelwood Date: Fri, 12 Oct 2018 10:40:49 -0700 Subject: [PATCH 136/328] src: use MallocedBuffer abstraction for buffers Drop `Free` and `std::unique_ptr` in favor of Node's `MallocedBuffer` for `char[]` buffer memory mangement. PR-URL: https://github.com/nodejs/node/pull/23543 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Franziska Hinkelmann --- src/stream_base.cc | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/stream_base.cc b/src/stream_base.cc index f44e188b5b818c..c6cce9c2d09ba9 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -8,6 +8,7 @@ #include "env-inl.h" #include "js_stream.h" #include "string_bytes.h" +#include "util.h" #include "util-inl.h" #include "v8.h" @@ -37,11 +38,6 @@ template int StreamBase::WriteString( const FunctionCallbackInfo& args); -struct Free { - void operator()(char* ptr) const { free(ptr); } -}; - - int StreamBase::ReadStartJS(const FunctionCallbackInfo& args) { return ReadStart(); } @@ -127,9 +123,9 @@ int StreamBase::Writev(const FunctionCallbackInfo& args) { } } - std::unique_ptr storage; + MallocedBuffer storage; if (storage_size > 0) - storage = std::unique_ptr(Malloc(storage_size)); + storage = MallocedBuffer(storage_size); offset = 0; if (!all_buffers) { @@ -145,7 +141,7 @@ int StreamBase::Writev(const FunctionCallbackInfo& args) { // Write string CHECK_LE(offset, storage_size); - char* str_storage = storage.get() + offset; + char* str_storage = storage.data + offset; size_t str_size = storage_size - offset; Local string = chunk->ToString(env->context()).ToLocalChecked(); @@ -164,7 +160,7 @@ int StreamBase::Writev(const FunctionCallbackInfo& args) { StreamWriteResult res = Write(*bufs, count, nullptr, req_wrap_obj); SetWriteResultPropertiesOnWrapObject(env, req_wrap_obj, res); - if (res.wrap != nullptr && storage) { + if (res.wrap != nullptr && storage_size > 0) { res.wrap->SetAllocatedStorage(storage.release(), storage_size); } return res.err; @@ -263,18 +259,18 @@ int StreamBase::WriteString(const FunctionCallbackInfo& args) { CHECK_EQ(count, 1); } - std::unique_ptr data; + MallocedBuffer data; if (try_write) { // Copy partial data - data = std::unique_ptr(Malloc(buf.len)); - memcpy(data.get(), buf.base, buf.len); + data = MallocedBuffer(buf.len); + memcpy(data.data, buf.base, buf.len); data_size = buf.len; } else { // Write it - data = std::unique_ptr(Malloc(storage_size)); + data = MallocedBuffer(storage_size); data_size = StringBytes::Write(env->isolate(), - data.get(), + data.data, storage_size, string, enc); @@ -282,7 +278,7 @@ int StreamBase::WriteString(const FunctionCallbackInfo& args) { CHECK_LE(data_size, storage_size); - buf = uv_buf_init(data.get(), data_size); + buf = uv_buf_init(data.data, data_size); uv_stream_t* send_handle = nullptr; From adc89e30cf4ffab59668fa2d106967603420823e Mon Sep 17 00:00:00 2001 From: Erin Bush Date: Fri, 12 Oct 2018 10:38:06 -0700 Subject: [PATCH 137/328] test: swap expected and actual arguments in assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/23542 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/pummel/test-net-pingpong-delay.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/pummel/test-net-pingpong-delay.js b/test/pummel/test-net-pingpong-delay.js index 25d610bf44a58b..392a6e0fed751e 100644 --- a/test/pummel/test-net-pingpong-delay.js +++ b/test/pummel/test-net-pingpong-delay.js @@ -35,11 +35,11 @@ function pingPongTest(port, host, on_complete) { socket.on('data', function(data) { console.log(data); - assert.strictEqual('PING', data); - assert.strictEqual('open', socket.readyState); - assert.strictEqual(true, count <= N); + assert.strictEqual(data, 'PING'); + assert.strictEqual(socket.readyState, 'open'); + assert.strictEqual(count <= N, true); setTimeout(function() { - assert.strictEqual('open', socket.readyState); + assert.strictEqual(socket.readyState, 'open'); socket.write('PONG'); }, DELAY); }); @@ -51,14 +51,14 @@ function pingPongTest(port, host, on_complete) { socket.on('end', function() { console.log('server-side socket EOF'); - assert.strictEqual('writeOnly', socket.readyState); + assert.strictEqual(socket.readyState, 'writeOnly'); socket.end(); }); socket.on('close', function(had_error) { console.log('server-side socket.end'); - assert.strictEqual(false, had_error); - assert.strictEqual('closed', socket.readyState); + assert.strictEqual(had_error, false); + assert.strictEqual(socket.readyState, 'closed'); socket.server.close(); }); }); @@ -69,17 +69,17 @@ function pingPongTest(port, host, on_complete) { client.setEncoding('utf8'); client.on('connect', function() { - assert.strictEqual('open', client.readyState); + assert.strictEqual(client.readyState, 'open'); client.write('PING'); }); client.on('data', function(data) { console.log(data); - assert.strictEqual('PONG', data); - assert.strictEqual('open', client.readyState); + assert.strictEqual(data, 'PONG'); + assert.strictEqual(client.readyState, 'open'); setTimeout(function() { - assert.strictEqual('open', client.readyState); + assert.strictEqual(client.readyState, 'open'); if (count++ < N) { client.write('PING'); } else { @@ -97,7 +97,7 @@ function pingPongTest(port, host, on_complete) { client.on('close', common.mustCall(function() { console.log('client.end'); - assert.strictEqual(N + 1, count); + assert.strictEqual(count, N + 1); assert.ok(client_ended); if (on_complete) on_complete(); })); From e5500f823d7a6055ffcd6b7403b1d2120b4a8a0a Mon Sep 17 00:00:00 2001 From: David Xue Date: Fri, 12 Oct 2018 10:42:25 -0700 Subject: [PATCH 138/328] test: added test for generateKeyPair MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23541 Reviewed-By: James M Snell Reviewed-By: Tobias Nießen Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-crypto-keygen.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/parallel/test-crypto-keygen.js b/test/parallel/test-crypto-keygen.js index af60c662f9340d..e9fe630dd72e84 100644 --- a/test/parallel/test-crypto-keygen.js +++ b/test/parallel/test-crypto-keygen.js @@ -358,6 +358,16 @@ function convertDERToPEM(label, der) { }); } +{ + // Test keygen without options object. + common.expectsError(() => generateKeyPair('rsa', common.mustNotCall()), { + type: TypeError, + code: 'ERR_INVALID_ARG_TYPE', + message: 'The "options" argument must be of ' + + 'type object. Received type undefined' + }); +} + { // Missing / invalid publicKeyEncoding. for (const enc of [undefined, null, 0, 'a', true]) { From 21a46ef1237001d80ae01b034b5b13cfb85e0c62 Mon Sep 17 00:00:00 2001 From: Allan Zheng Date: Fri, 12 Oct 2018 10:27:21 -0700 Subject: [PATCH 139/328] test: reverse the order of assertion statement arguments in pingpong test PR-URL: https://github.com/nodejs/node/pull/23540 Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Ruben Bridgewater --- test/pummel/test-net-pingpong.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js index 4db843afd3efc8..29ffd0bdf7261b 100644 --- a/test/pummel/test-net-pingpong.js +++ b/test/pummel/test-net-pingpong.js @@ -32,8 +32,8 @@ function pingPongTest(port, host, on_complete) { let sent_final_ping = false; const server = net.createServer({ allowHalfOpen: true }, function(socket) { - assert.strictEqual(true, socket.remoteAddress !== null); - assert.strictEqual(true, socket.remoteAddress !== undefined); + assert.strictEqual(socket.remoteAddress !== null, true); + assert.strictEqual(socket.remoteAddress !== undefined, true); const address = socket.remoteAddress; if (host === '127.0.0.1') { assert.strictEqual(address, '127.0.0.1'); @@ -50,21 +50,21 @@ function pingPongTest(port, host, on_complete) { socket.on('data', function(data) { console.log(`server got: ${JSON.stringify(data)}`); - assert.strictEqual('open', socket.readyState); - assert.strictEqual(true, count <= N); + assert.strictEqual(socket.readyState, 'open'); + assert.strictEqual(count <= N, true); if (/PING/.test(data)) { socket.write('PONG'); } }); socket.on('end', function() { - assert.strictEqual('writeOnly', socket.readyState); + assert.strictEqual(socket.readyState, 'writeOnly'); socket.end(); }); socket.on('close', function(had_error) { - assert.strictEqual(false, had_error); - assert.strictEqual('closed', socket.readyState); + assert.strictEqual(had_error, false); + assert.strictEqual(socket.readyState, 'closed'); socket.server.close(); }); }); @@ -75,21 +75,21 @@ function pingPongTest(port, host, on_complete) { client.setEncoding('utf8'); client.on('connect', function() { - assert.strictEqual('open', client.readyState); + assert.strictEqual(client.readyState, 'open'); client.write('PING'); }); client.on('data', function(data) { console.log(`client got: ${data}`); - assert.strictEqual('PONG', data); + assert.strictEqual(data, 'PONG'); count += 1; if (sent_final_ping) { - assert.strictEqual('readOnly', client.readyState); + assert.strictEqual(client.readyState, 'readOnly'); return; } else { - assert.strictEqual('open', client.readyState); + assert.strictEqual(client.readyState, 'open'); } if (count < N) { @@ -102,8 +102,8 @@ function pingPongTest(port, host, on_complete) { }); client.on('close', function() { - assert.strictEqual(N + 1, count); - assert.strictEqual(true, sent_final_ping); + assert.strictEqual(count, N + 1); + assert.strictEqual(sent_final_ping, true); if (on_complete) on_complete(); tests_run += 1; }); @@ -118,5 +118,5 @@ pingPongTest(common.PORT + 1, null); if (!common.isSunOS) pingPongTest(common.PORT + 2, '::1'); process.on('exit', function() { - assert.strictEqual(common.isSunOS ? 2 : 3, tests_run); + assert.strictEqual(tests_run, common.isSunOS ? 2 : 3); }); From 5bf919e818c09453afcf2469b79d337ff17db741 Mon Sep 17 00:00:00 2001 From: Ivan Lukasevych Date: Fri, 12 Oct 2018 10:39:25 -0700 Subject: [PATCH 140/328] test: fix assert.strictEqual() arguments order PR-URL: https://github.com/nodejs/node/pull/23539 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-tls-set-encoding.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-tls-set-encoding.js b/test/parallel/test-tls-set-encoding.js index b3aa52a22a73f3..77cb5763aeecca 100644 --- a/test/parallel/test-tls-set-encoding.js +++ b/test/parallel/test-tls-set-encoding.js @@ -64,15 +64,15 @@ server.listen(0, function() { // readyState is deprecated but we want to make // sure this isn't triggering an assert in lib/net.js // See https://github.com/nodejs/node-v0.x-archive/issues/1069. - assert.strictEqual('closed', client.readyState); + assert.strictEqual(client.readyState, 'closed'); // Confirming the buffer string is encoded in ASCII // and thus does NOT match the UTF8 string - assert.notStrictEqual(buffer, messageUtf8); + assert.notStrictEqual(messageUtf8, buffer); // Confirming the buffer string is encoded in ASCII // and thus does equal the ASCII string representation - assert.strictEqual(buffer, messageAscii); + assert.strictEqual(messageAscii, buffer); server.close(); }); From a4104889943903c97ada1ee3546843f2c5d646e4 Mon Sep 17 00:00:00 2001 From: Justin denBroeder Date: Fri, 12 Oct 2018 10:30:25 -0700 Subject: [PATCH 141/328] test: assert.strictEqual parameters ordered correctly The assert.strictEqual function should have the actual value first and the expected value second to enable easier debugging of AssertionErrors. PR-URL: https://github.com/nodejs/node/pull/23538 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-tls-securepair-server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-tls-securepair-server.js b/test/parallel/test-tls-securepair-server.js index 994e037c05a5e5..92234fb4108fc5 100644 --- a/test/parallel/test-tls-securepair-server.js +++ b/test/parallel/test-tls-securepair-server.js @@ -137,7 +137,7 @@ server.listen(0, common.mustCall(function() { client.stdout.pipe(process.stdout, { end: false }); client.on('exit', common.mustCall(function(code) { - assert.strictEqual(0, code); + assert.strictEqual(code, 0); server.close(); })); })); From 8d583a7b408e23656865e8d604a97db741ac6ac4 Mon Sep 17 00:00:00 2001 From: Chris Bautista Date: Fri, 12 Oct 2018 17:35:46 +0000 Subject: [PATCH 142/328] test: switch strictEqual parameters - actual first before expected PR-URL: https://github.com/nodejs/node/pull/23537 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/pummel/test-exec.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/pummel/test-exec.js b/test/pummel/test-exec.js index 92b5cb64ec67e3..7d631f87f2f74a 100644 --- a/test/pummel/test-exec.js +++ b/test/pummel/test-exec.js @@ -47,7 +47,7 @@ exec( console.log(`error!: ${err.code}`); console.log(`stdout: ${JSON.stringify(stdout)}`); console.log(`stderr: ${JSON.stringify(stderr)}`); - assert.strictEqual(false, err.killed); + assert.strictEqual(err.killed, false); } else { success_count++; console.dir(stdout); @@ -59,11 +59,11 @@ exec( exec('thisisnotavalidcommand', function(err, stdout, stderr) { if (err) { error_count++; - assert.strictEqual('', stdout); + assert.strictEqual(stdout, ''); assert.strictEqual(typeof err.code, 'number'); assert.notStrictEqual(err.code, 0); - assert.strictEqual(false, err.killed); - assert.strictEqual(null, err.signal); + assert.strictEqual(err.killed, false); + assert.strictEqual(err.signal, null); console.log(`error code: ${err.code}`); console.log(`stdout: ${JSON.stringify(stdout)}`); console.log(`stderr: ${JSON.stringify(stderr)}`); @@ -97,7 +97,7 @@ process.nextTick(function() { console.log(`kill pid ${killMeTwice.pid}`); // make sure there is no race condition in starting the process // the PID SHOULD exist directly following the exec() call. - assert.strictEqual('number', typeof killMeTwice._handle.pid); + assert.strictEqual(typeof killMeTwice._handle.pid, 'number'); // Kill the process killMeTwice.kill(); }); @@ -128,6 +128,6 @@ exec('python -c "print 200000*\'C\'"', { maxBuffer: 1000 }, process.on('exit', function() { - assert.strictEqual(1, success_count); - assert.strictEqual(1, error_count); + assert.strictEqual(success_count, 1); + assert.strictEqual(error_count, 1); }); From 77f210046904948ae249fdea015cf63caca0020f Mon Sep 17 00:00:00 2001 From: Joe Grosspietsch Date: Fri, 12 Oct 2018 10:57:10 -0700 Subject: [PATCH 143/328] test: fix strictEqual assertion order on readline tests PR-URL: https://github.com/nodejs/node/pull/23561 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil --- test/parallel/test-readline.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-readline.js b/test/parallel/test-readline.js index 82bf74549b2343..d464fdc440c58b 100644 --- a/test/parallel/test-readline.js +++ b/test/parallel/test-readline.js @@ -143,7 +143,7 @@ const assert = require('assert'); '' ].forEach(function(expectedLine) { rl.write.apply(rl, key.xterm.metad); - assert.strictEqual(0, rl.cursor); - assert.strictEqual(expectedLine, rl.line); + assert.strictEqual(rl.cursor, 0); + assert.strictEqual(rl.line, expectedLine); }); } From fc05ca56e7d7130474139998ab817d6d3abd0cb8 Mon Sep 17 00:00:00 2001 From: naris93 Date: Fri, 12 Oct 2018 10:47:42 -0700 Subject: [PATCH 144/328] test: modernize test-crypto-domain PR-URL: https://github.com/nodejs/node/pull/23559 Reviewed-By: Sam Ruby Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat --- test/parallel/test-crypto-domain.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-crypto-domain.js b/test/parallel/test-crypto-domain.js index 348b55b09d4e17..62e2be4c0f39c2 100644 --- a/test/parallel/test-crypto-domain.js +++ b/test/parallel/test-crypto-domain.js @@ -28,7 +28,7 @@ const assert = require('assert'); const crypto = require('crypto'); const domain = require('domain'); -function test(fn) { +const test = (fn) => { const ex = new Error('BAM'); const d = domain.create(); d.on('error', common.mustCall(function(err) { @@ -38,7 +38,7 @@ function test(fn) { throw ex; }); d.run(cb); -} +}; test(function(cb) { crypto.pbkdf2('password', 'salt', 1, 8, cb); From 0569bfeab16e3678ffcd1c1b33b5fc6a4dc6f6c4 Mon Sep 17 00:00:00 2001 From: Victor Poriazov Date: Fri, 12 Oct 2018 13:55:28 -0400 Subject: [PATCH 145/328] test: fix order of assert arguments in vm-new-script-this-context Fixes the order of assert.strictEqual arguments. PR-URL: https://github.com/nodejs/node/pull/23558 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat --- test/parallel/test-vm-new-script-this-context.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-vm-new-script-this-context.js b/test/parallel/test-vm-new-script-this-context.js index 2c0c21690e1821..18f39f9086ae2a 100644 --- a/test/parallel/test-vm-new-script-this-context.js +++ b/test/parallel/test-vm-new-script-this-context.js @@ -27,7 +27,7 @@ const Script = require('vm').Script; // Run a string let script = new Script('\'passed\';'); const result = script.runInThisContext(script); -assert.strictEqual('passed', result); +assert.strictEqual(result, 'passed'); // Thrown error script = new Script('throw new Error(\'test\');'); @@ -38,7 +38,7 @@ assert.throws(() => { global.hello = 5; script = new Script('hello = 2'); script.runInThisContext(script); -assert.strictEqual(2, global.hello); +assert.strictEqual(global.hello, 2); // Pass values @@ -49,15 +49,15 @@ global.foo = 2; global.obj = { foo: 0, baz: 3 }; script = new Script(global.code); script.runInThisContext(script); -assert.strictEqual(0, global.obj.foo); -assert.strictEqual(2, global.bar); -assert.strictEqual(1, global.foo); +assert.strictEqual(global.obj.foo, 0); +assert.strictEqual(global.bar, 2); +assert.strictEqual(global.foo, 1); // Call a function global.f = function() { global.foo = 100; }; script = new Script('f()'); script.runInThisContext(script); -assert.strictEqual(100, global.foo); +assert.strictEqual(global.foo, 100); common.allowGlobals( global.hello, From abf19da10fdc7698c08054be777f79079e04884a Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 12 Oct 2018 10:44:03 -0700 Subject: [PATCH 146/328] test: added async-hook benchmark Added a minimalist benchmark test for the async-hooks. PR-URL: https://github.com/nodejs/node/pull/23556 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Gabriel Schulhof Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat --- test/sequential/test-benchmark-async-hooks.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/sequential/test-benchmark-async-hooks.js diff --git a/test/sequential/test-benchmark-async-hooks.js b/test/sequential/test-benchmark-async-hooks.js new file mode 100644 index 00000000000000..4cb6f89a8c70e3 --- /dev/null +++ b/test/sequential/test-benchmark-async-hooks.js @@ -0,0 +1,18 @@ +'use strict'; + +const common = require('../common'); + +if (!common.hasCrypto) + common.skip('missing crypto'); + +if (!common.enoughTestMem) + common.skip('Insufficient memory for async_hooks benchmark test'); + +const runBenchmark = require('../common/benchmark'); + +runBenchmark('async_hooks', + [ + 'method=trackingDisabled', + 'n=10' + ], + {}); From fc2f104efeb6c08798d91a10cf180285fc07a76f Mon Sep 17 00:00:00 2001 From: Jackelin Herrera Date: Fri, 12 Oct 2018 10:14:18 -0700 Subject: [PATCH 147/328] test: reverse order of args in reconnect-error assert PR-URL: https://github.com/nodejs/node/pull/23555 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat --- test/sequential/test-net-reconnect-error.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/sequential/test-net-reconnect-error.js b/test/sequential/test-net-reconnect-error.js index 128feffc933ae3..e16d567c0ad1bb 100644 --- a/test/sequential/test-net-reconnect-error.js +++ b/test/sequential/test-net-reconnect-error.js @@ -33,7 +33,7 @@ c.on('connect', common.mustNotCall('client should not have connected')); c.on('error', common.mustCall((e) => { client_error_count++; - assert.strictEqual('ECONNREFUSED', e.code); + assert.strictEqual(e.code, 'ECONNREFUSED'); }, N + 1)); c.on('close', common.mustCall(() => { @@ -42,6 +42,6 @@ c.on('close', common.mustCall(() => { }, N + 1)); process.on('exit', function() { - assert.strictEqual(N + 1, disconnect_count); - assert.strictEqual(N + 1, client_error_count); + assert.strictEqual(disconnect_count, N + 1); + assert.strictEqual(client_error_count, N + 1); }); From 715768e1e175d5bc09ad6675132f8cb9cee423d2 Mon Sep 17 00:00:00 2001 From: Marcos Frony Date: Fri, 12 Oct 2018 10:48:13 -0700 Subject: [PATCH 148/328] build: add .DS_store to .gitgnore The following files were not being ignored: deps/npm/node_modules/node-gyp/gyp/tools/.DS_Store deps/npm/node_modules/node-gyp/gyp/tools/Xcode/.DS_Store PR-URL: https://github.com/nodejs/node/pull/23554 Reviewed-By: Hitesh Kanwathirtha Reviewed-By: Ruben Bridgewater Reviewed-By: Joyee Cheung Reviewed-By: Refael Ackermann --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f652a2c74c37d6..dad5a3efd8bcae 100644 --- a/.gitignore +++ b/.gitignore @@ -133,3 +133,5 @@ deps/uv/docs/src/guide/ deps/v8/gypfiles/Debug/ deps/v8/gypfiles/Release/ deps/v8/third_party/eu-strip/ + +.DS_Store From 042e97428fdc71117ff2a431cbfcd68cf3215838 Mon Sep 17 00:00:00 2001 From: Murtaza H <1850989+mhussa19@users.noreply.github.com> Date: Fri, 12 Oct 2018 09:55:48 -0700 Subject: [PATCH 149/328] test: removed unused error variable in try catch In test/parallel/test-fs-access.js PR-URL: https://github.com/nodejs/node/pull/23553 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat --- test/parallel/test-fs-access.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-fs-access.js b/test/parallel/test-fs-access.js index d053b9323bc275..abc8a2014f0ea8 100644 --- a/test/parallel/test-fs-access.js +++ b/test/parallel/test-fs-access.js @@ -53,7 +53,7 @@ if (!common.isWindows && process.getuid() === 0) { try { process.setuid('nobody'); hasWriteAccessForReadonlyFile = false; - } catch (err) { + } catch { } } From 04769c457318bbaee1d77f038cde03c6f53f9d14 Mon Sep 17 00:00:00 2001 From: Clinton Pahl Date: Fri, 12 Oct 2018 10:31:06 -0700 Subject: [PATCH 150/328] test: update strictEqual arguments order The argument order in the strictEqual check against stderr is in the wrong order. The first argument is now the actual value and the second argument is the expected value. PR-URL: https://github.com/nodejs/node/pull/23552 Reviewed-By: Gabriel Schulhof Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat --- test/parallel/test-stdin-from-file.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-stdin-from-file.js b/test/parallel/test-stdin-from-file.js index eda8e068fe37fe..f4fcb32edbfde5 100644 --- a/test/parallel/test-stdin-from-file.js +++ b/test/parallel/test-stdin-from-file.js @@ -36,5 +36,5 @@ childProcess.exec(cmd, common.mustCall(function(err, stdout, stderr) { assert.ifError(err); assert.strictEqual(stdout, `hello world\r\n${string}`); - assert.strictEqual('', stderr); + assert.strictEqual(stderr, ''); })); From 760b5715d9647fa8eda0a5609676d9545f30d9f0 Mon Sep 17 00:00:00 2001 From: Maki Toda Date: Fri, 12 Oct 2018 10:35:04 -0700 Subject: [PATCH 151/328] test: removed unused variable in fs-watch-file-slow PR-URL: https://github.com/nodejs/node/pull/23548 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat --- test/pummel/test-fs-watch-file-slow.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pummel/test-fs-watch-file-slow.js b/test/pummel/test-fs-watch-file-slow.js index cf7adc913db28c..94f2a263881427 100644 --- a/test/pummel/test-fs-watch-file-slow.js +++ b/test/pummel/test-fs-watch-file-slow.js @@ -34,7 +34,7 @@ let nevents = 0; try { fs.unlinkSync(FILENAME); -} catch (e) { +} catch { // swallow } From 9439e3e973b7e38bd6256a81e6da93f0fc7d23b6 Mon Sep 17 00:00:00 2001 From: Jason Nutter Date: Fri, 12 Oct 2018 11:25:42 -0700 Subject: [PATCH 152/328] test: fix order of parameters to assert.strictEqual Usage of assert.strictEqual in test-net-server-listen-remove-callback.js incorrectly passes the expected value as the first argument and actual value as the second argument. PR-URL: https://github.com/nodejs/node/pull/23590 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-net-server-listen-remove-callback.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-net-server-listen-remove-callback.js b/test/parallel/test-net-server-listen-remove-callback.js index 3989b229062304..a874099fb8c782 100644 --- a/test/parallel/test-net-server-listen-remove-callback.js +++ b/test/parallel/test-net-server-listen-remove-callback.js @@ -30,7 +30,7 @@ const server = net.createServer(); server.on('close', function() { const listeners = server.listeners('listening'); console.log('Closed, listeners:', listeners.length); - assert.strictEqual(0, listeners.length); + assert.strictEqual(listeners.length, 0); }); server.listen(0, function() { From 8b38c2e1c00a492bb241ae531cf26569395b25b0 Mon Sep 17 00:00:00 2001 From: "Illescas, Ricardo" Date: Fri, 12 Oct 2018 11:19:56 -0600 Subject: [PATCH 153/328] test: fix argument order in assertions PR-URL: https://github.com/nodejs/node/pull/23589 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Gireesh Punathil --- test/parallel/test-child-process-ipc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-child-process-ipc.js b/test/parallel/test-child-process-ipc.js index 36293cb73c1a7d..f1652a91e6968e 100644 --- a/test/parallel/test-child-process-ipc.js +++ b/test/parallel/test-child-process-ipc.js @@ -44,13 +44,13 @@ child.stdout.on('data', function(data) { console.log(`child said: ${JSON.stringify(data)}`); if (!gotHelloWorld) { console.error('testing for hello world'); - assert.strictEqual('hello world\r\n', data); + assert.strictEqual(data, 'hello world\r\n'); gotHelloWorld = true; console.error('writing echo me'); child.stdin.write('echo me\r\n'); } else { console.error('testing for echo me'); - assert.strictEqual('echo me\r\n', data); + assert.strictEqual(data, 'echo me\r\n'); gotEcho = true; child.stdin.end(); } From c9ba20aeca6136beb4dd0a4e5e9c9772c3645163 Mon Sep 17 00:00:00 2001 From: blakehall Date: Fri, 12 Oct 2018 11:22:53 -0700 Subject: [PATCH 154/328] test: fix assert.strictEqual() parameter order in test-path-maklong.js The argument order in the strictEqual check was in the wrong order. The first argument is now the actual value and the second argument is the expected value. PR-URL: https://github.com/nodejs/node/pull/23587 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-path-makelong.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/test/parallel/test-path-makelong.js b/test/parallel/test-path-makelong.js index f3b145729bd691..01c81b47502f4e 100644 --- a/test/parallel/test-path-makelong.js +++ b/test/parallel/test-path-makelong.js @@ -29,17 +29,18 @@ if (common.isWindows) { const file = fixtures.path('a.js'); const resolvedFile = path.resolve(file); - assert.strictEqual(`\\\\?\\${resolvedFile}`, - path.toNamespacedPath(file)); - assert.strictEqual(`\\\\?\\${resolvedFile}`, - path.toNamespacedPath(`\\\\?\\${file}`)); - assert.strictEqual('\\\\?\\UNC\\someserver\\someshare\\somefile', - path.toNamespacedPath( - '\\\\someserver\\someshare\\somefile')); - assert.strictEqual('\\\\?\\UNC\\someserver\\someshare\\somefile', path - .toNamespacedPath('\\\\?\\UNC\\someserver\\someshare\\somefile')); - assert.strictEqual('\\\\.\\pipe\\somepipe', - path.toNamespacedPath('\\\\.\\pipe\\somepipe')); + assert.strictEqual(path.toNamespacedPath(file), + `\\\\?\\${resolvedFile}`); + assert.strictEqual(path.toNamespacedPath(`\\\\?\\${file}`), + `\\\\?\\${resolvedFile}`); + assert.strictEqual(path.toNamespacedPath( + '\\\\someserver\\someshare\\somefile'), + '\\\\?\\UNC\\someserver\\someshare\\somefile'); + assert.strictEqual(path.toNamespacedPath( + '\\\\?\\UNC\\someserver\\someshare\\somefile'), + '\\\\?\\UNC\\someserver\\someshare\\somefile'); + assert.strictEqual(path.toNamespacedPath('\\\\.\\pipe\\somepipe'), + '\\\\.\\pipe\\somepipe'); } assert.strictEqual(path.toNamespacedPath(null), null); From 18ea8cfbddd26ac5de880ece134192fb855ba4f5 Mon Sep 17 00:00:00 2001 From: seantcoyote Date: Fri, 12 Oct 2018 11:14:50 -0700 Subject: [PATCH 155/328] test: fix assertion arguments order There's no issue for this PR, it's a task at the Node+JS Code-n-Learn. PR-URL: https://github.com/nodejs/node/pull/23584 Reviewed-By: Anatoli Papirovski Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-querystring.js | 65 +++++++++++++++---------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js index 7b77a42a167525..b5a4a599c3b59d 100644 --- a/test/parallel/test-querystring.js +++ b/test/parallel/test-querystring.js @@ -177,9 +177,8 @@ const qsUnescapeTestCases = [ ' !"#$%&\'()*+,-./01234567'] ]; -assert.strictEqual('918854443121279438895193', - qs.parse('id=918854443121279438895193').id); - +assert.strictEqual(qs.parse('id=918854443121279438895193').id, + '918854443121279438895193'); function check(actual, expected, input) { assert(!(actual instanceof Object)); @@ -221,7 +220,7 @@ qsWeirdObjects.forEach((testCase) => { }); qsNoMungeTestCases.forEach((testCase) => { - assert.deepStrictEqual(testCase[0], qs.stringify(testCase[1], '&', '=')); + assert.deepStrictEqual(qs.stringify(testCase[1], '&', '='), testCase[0]); }); // test the nested qs-in-qs case @@ -259,15 +258,15 @@ qsNoMungeTestCases.forEach((testCase) => { // basic qsTestCases.forEach((testCase) => { - assert.strictEqual(testCase[1], qs.stringify(testCase[2])); + assert.strictEqual(qs.stringify(testCase[2]), testCase[1]); }); qsColonTestCases.forEach((testCase) => { - assert.strictEqual(testCase[1], qs.stringify(testCase[2], ';', ':')); + assert.strictEqual(qs.stringify(testCase[2], ';', ':'), testCase[1]); }); qsWeirdObjects.forEach((testCase) => { - assert.strictEqual(testCase[1], qs.stringify(testCase[0])); + assert.strictEqual(qs.stringify(testCase[0]), testCase[1]); }); // invalid surrogate pair throws URIError @@ -281,12 +280,12 @@ common.expectsError( ); // coerce numbers to string -assert.strictEqual('foo=0', qs.stringify({ foo: 0 })); -assert.strictEqual('foo=0', qs.stringify({ foo: -0 })); -assert.strictEqual('foo=3', qs.stringify({ foo: 3 })); -assert.strictEqual('foo=-72.42', qs.stringify({ foo: -72.42 })); -assert.strictEqual('foo=', qs.stringify({ foo: NaN })); -assert.strictEqual('foo=', qs.stringify({ foo: Infinity })); +assert.strictEqual(qs.stringify({ foo: 0 }), 'foo=0'); +assert.strictEqual(qs.stringify({ foo: -0 }), 'foo=0'); +assert.strictEqual(qs.stringify({ foo: 3 }), 'foo=3'); +assert.strictEqual(qs.stringify({ foo: -72.42 }), 'foo=-72.42'); +assert.strictEqual(qs.stringify({ foo: NaN }), 'foo='); +assert.strictEqual(qs.stringify({ foo: Infinity }), 'foo='); // nested { @@ -360,26 +359,26 @@ assert.strictEqual( const b = qs.unescapeBuffer('%d3%f2Ug%1f6v%24%5e%98%cb' + '%0d%ac%a2%2f%9d%eb%d8%a2%e6'); // - assert.strictEqual(0xd3, b[0]); - assert.strictEqual(0xf2, b[1]); - assert.strictEqual(0x55, b[2]); - assert.strictEqual(0x67, b[3]); - assert.strictEqual(0x1f, b[4]); - assert.strictEqual(0x36, b[5]); - assert.strictEqual(0x76, b[6]); - assert.strictEqual(0x24, b[7]); - assert.strictEqual(0x5e, b[8]); - assert.strictEqual(0x98, b[9]); - assert.strictEqual(0xcb, b[10]); - assert.strictEqual(0x0d, b[11]); - assert.strictEqual(0xac, b[12]); - assert.strictEqual(0xa2, b[13]); - assert.strictEqual(0x2f, b[14]); - assert.strictEqual(0x9d, b[15]); - assert.strictEqual(0xeb, b[16]); - assert.strictEqual(0xd8, b[17]); - assert.strictEqual(0xa2, b[18]); - assert.strictEqual(0xe6, b[19]); + assert.strictEqual(b[0], 0xd3); + assert.strictEqual(b[1], 0xf2); + assert.strictEqual(b[2], 0x55); + assert.strictEqual(b[3], 0x67); + assert.strictEqual(b[4], 0x1f); + assert.strictEqual(b[5], 0x36); + assert.strictEqual(b[6], 0x76); + assert.strictEqual(b[7], 0x24); + assert.strictEqual(b[8], 0x5e); + assert.strictEqual(b[9], 0x98); + assert.strictEqual(b[10], 0xcb); + assert.strictEqual(b[11], 0x0d); + assert.strictEqual(b[12], 0xac); + assert.strictEqual(b[13], 0xa2); + assert.strictEqual(b[14], 0x2f); + assert.strictEqual(b[15], 0x9d); + assert.strictEqual(b[16], 0xeb); + assert.strictEqual(b[17], 0xd8); + assert.strictEqual(b[18], 0xa2); + assert.strictEqual(b[19], 0xe6); } assert.strictEqual(qs.unescapeBuffer('a+b', true).toString(), 'a b'); From 70ba0f97a07cd56884806877dafc5fe426fc14d5 Mon Sep 17 00:00:00 2001 From: Justin Lee Date: Fri, 12 Oct 2018 11:19:30 -0700 Subject: [PATCH 156/328] test: increased code coverage for proxySessionHandler PR-URL: https://github.com/nodejs/node/pull/23583 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-http2-socket-proxy.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/parallel/test-http2-socket-proxy.js b/test/parallel/test-http2-socket-proxy.js index 17f641835de696..600271fdeffc2e 100644 --- a/test/parallel/test-http2-socket-proxy.js +++ b/test/parallel/test-http2-socket-proxy.js @@ -92,6 +92,17 @@ server.on('stream', common.mustCall(function(stream, headers) { stream.end(); + // Setting socket properties sets the session properties correctly. + const fn = () => {}; + socket.setTimeout = fn; + assert.strictEqual(session.setTimeout, fn); + + socket.ref = fn; + assert.strictEqual(session.ref, fn); + + socket.unref = fn; + assert.strictEqual(session.unref, fn); + stream.session.on('close', common.mustCall(() => { assert.strictEqual(session.socket, undefined); })); From 6ec5b4a84d829bdd257b2cbefb886e40b4b9f78e Mon Sep 17 00:00:00 2001 From: Salman Shakeel Date: Fri, 12 Oct 2018 14:16:51 -0400 Subject: [PATCH 157/328] test: reversed actual and expected values for .strictEqual() Fixed strictEqual() parameters order according to the documentation for the assertion. PR-URL: https://github.com/nodejs/node/pull/23579 Reviewed-By: Anatoli Papirovski Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: Gireesh Punathil --- test/parallel/test-next-tick-ordering.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-next-tick-ordering.js b/test/parallel/test-next-tick-ordering.js index 76f43efa932fbf..9ae212cb7f3fbe 100644 --- a/test/parallel/test-next-tick-ordering.js +++ b/test/parallel/test-next-tick-ordering.js @@ -47,7 +47,7 @@ console.log('Running from main.'); process.on('exit', function() { - assert.strictEqual('nextTick', done[0]); + assert.strictEqual(done[0], 'nextTick'); /* Disabling this test. I don't think we can ensure the order for (i = 0; i < N; i += 1) { assert.strictEqual(i, done[i + 1]); From 2ea96196fe05df9a9e62d4446dd7c26725f4b50b Mon Sep 17 00:00:00 2001 From: Yitong Date: Fri, 12 Oct 2018 11:16:33 -0700 Subject: [PATCH 158/328] test: add crypto.scrypt test case with different encoding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23578 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Tobias Nießen Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater --- test/parallel/test-crypto-scrypt.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/parallel/test-crypto-scrypt.js b/test/parallel/test-crypto-scrypt.js index 982b0ac6d5b640..908179b46e3071 100644 --- a/test/parallel/test-crypto-scrypt.js +++ b/test/parallel/test-crypto-scrypt.js @@ -187,6 +187,24 @@ for (const options of toobig) { })); } +{ + const defaultEncoding = crypto.DEFAULT_ENCODING; + const defaults = { N: 16384, p: 1, r: 8 }; + const expected = crypto.scryptSync('pass', 'salt', 1, defaults); + + const testEncoding = 'latin1'; + crypto.DEFAULT_ENCODING = testEncoding; + const actual = crypto.scryptSync('pass', 'salt', 1); + assert.deepStrictEqual(actual, expected.toString(testEncoding)); + + crypto.scrypt('pass', 'salt', 1, common.mustCall((err, actual) => { + assert.ifError(err); + assert.deepStrictEqual(actual, expected.toString(testEncoding)); + })); + + crypto.DEFAULT_ENCODING = defaultEncoding; +} + for (const { args, expected } of badargs) { common.expectsError(() => crypto.scrypt(...args), expected); common.expectsError(() => crypto.scryptSync(...args), expected); From b68ee2238f0583931756bd10032b138ce39261f9 Mon Sep 17 00:00:00 2001 From: Ruy Adorno Date: Fri, 12 Oct 2018 10:48:12 -0700 Subject: [PATCH 159/328] test: fixed strictEqual arguments order Fixes usage of strictEqual arguments order in test/parallel/test-process-wrap.js Part of Node+JS Interactive 2018 Code & Learn PR-URL: https://github.com/nodejs/node/pull/23576 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-process-wrap.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-process-wrap.js b/test/parallel/test-process-wrap.js index b3cca47c463c19..0a0188154d7fb7 100644 --- a/test/parallel/test-process-wrap.js +++ b/test/parallel/test-process-wrap.js @@ -36,8 +36,8 @@ p.onexit = function(exitCode, signal) { p.close(); pipe.readStart(); - assert.strictEqual(0, exitCode); - assert.strictEqual('', signal); + assert.strictEqual(exitCode, 0); + assert.strictEqual(signal, ''); processExited = true; }; From 2a3ba01b08e9df590476c3067d8e5cc0bc085043 Mon Sep 17 00:00:00 2001 From: Liran Tal Date: Fri, 12 Oct 2018 10:46:35 -0700 Subject: [PATCH 160/328] test: fix arguments ordering for assertions to match the docs PR-URL: https://github.com/nodejs/node/pull/23575 Reviewed-By: Hitesh Kanwathirtha Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-require-resolve.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-require-resolve.js b/test/parallel/test-require-resolve.js index 2916f3709e3b15..2ffcc711854a87 100644 --- a/test/parallel/test-require-resolve.js +++ b/test/parallel/test-require-resolve.js @@ -25,15 +25,12 @@ const fixtures = require('../common/fixtures'); const assert = require('assert'); assert.strictEqual( - fixtures.path('a.js').toLowerCase(), - require.resolve(fixtures.path('a')).toLowerCase()); + require.resolve(fixtures.path('a')).toLowerCase(), + fixtures.path('a.js').toLowerCase()); assert.strictEqual( - fixtures.path('a.js').toLowerCase(), - require.resolve(fixtures.path('a')).toLowerCase()); -assert.strictEqual( - fixtures.path('nested-index', 'one', 'index.js').toLowerCase(), - require.resolve(fixtures.path('nested-index', 'one')).toLowerCase()); -assert.strictEqual('path', require.resolve('path')); + require.resolve(fixtures.path('nested-index', 'one')).toLowerCase(), + fixtures.path('nested-index', 'one', 'index.js').toLowerCase()); +assert.strictEqual(require.resolve('path'), 'path'); // Test configurable resolve() paths. require(fixtures.path('require-resolve.js')); From bcf24e7a4d8a58b8b9a3db537ece4faf5ef8ed3d Mon Sep 17 00:00:00 2001 From: Joe Shindelar Date: Fri, 12 Oct 2018 11:03:15 -0700 Subject: [PATCH 161/328] test: fix order of arguments passed to strictEqual The argument order in the strictEqual check was in the wrong order. The first argument is now the actual value and the second argument is the expected value. PR-URL: https://github.com/nodejs/node/pull/23571 Reviewed-By: Joyee Cheung Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-net-socket-local-address.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-net-socket-local-address.js b/test/parallel/test-net-socket-local-address.js index 1aa51e0c5c1d87..e80731bc78fb0a 100644 --- a/test/parallel/test-net-socket-local-address.js +++ b/test/parallel/test-net-socket-local-address.js @@ -18,8 +18,8 @@ const server = net.createServer((socket) => { server.on('close', common.mustCall(() => { // client and server should agree on the ports used - assert.deepStrictEqual(clientLocalPorts, serverRemotePorts); - assert.strictEqual(2, conns); + assert.deepStrictEqual(serverRemotePorts, clientLocalPorts); + assert.strictEqual(conns, 2); })); server.listen(0, common.localhostIPv4, connect); From 110606daa55c0bbb273f3ea40baa37a25a02da15 Mon Sep 17 00:00:00 2001 From: AlixAng Date: Fri, 12 Oct 2018 11:00:55 -0700 Subject: [PATCH 162/328] test: fix strictEqual input parameters order PR-URL: https://github.com/nodejs/node/pull/23570 Reviewed-By: Joyee Cheung Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-pipe-file-to-http.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-pipe-file-to-http.js b/test/parallel/test-pipe-file-to-http.js index 3cadec7a27237e..3d326a77a49bc7 100644 --- a/test/parallel/test-pipe-file-to-http.js +++ b/test/parallel/test-pipe-file-to-http.js @@ -34,7 +34,7 @@ let count = 0; const server = http.createServer(function(req, res) { let timeoutId; - assert.strictEqual('POST', req.method); + assert.strictEqual(req.method, 'POST'); req.pause(); setTimeout(function() { @@ -82,5 +82,5 @@ function makeRequest() { } process.on('exit', function() { - assert.strictEqual(1024 * 10240, count); + assert.strictEqual(count, 1024 * 10240); }); From 2cb4789a68e7073989fc2660efc0eaa3e5913450 Mon Sep 17 00:00:00 2001 From: francois Date: Fri, 12 Oct 2018 10:57:07 -0400 Subject: [PATCH 163/328] test: corrected assertion arguments order Fixed the order of expected arguments for assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/23569 Reviewed-By: Joyee Cheung Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil --- test/parallel/test-util.js | 139 +++++++++++++++++++------------------ 1 file changed, 73 insertions(+), 66 deletions(-) diff --git a/test/parallel/test-util.js b/test/parallel/test-util.js index 2f91417d106148..f0e2f642ea25d4 100644 --- a/test/parallel/test-util.js +++ b/test/parallel/test-util.js @@ -28,75 +28,75 @@ const errors = require('internal/errors'); const context = require('vm').runInNewContext; // isArray -assert.strictEqual(true, util.isArray([])); -assert.strictEqual(true, util.isArray(Array())); -assert.strictEqual(true, util.isArray(new Array())); -assert.strictEqual(true, util.isArray(new Array(5))); -assert.strictEqual(true, util.isArray(new Array('with', 'some', 'entries'))); -assert.strictEqual(true, util.isArray(context('Array')())); -assert.strictEqual(false, util.isArray({})); -assert.strictEqual(false, util.isArray({ push: function() {} })); -assert.strictEqual(false, util.isArray(/regexp/)); -assert.strictEqual(false, util.isArray(new Error())); -assert.strictEqual(false, util.isArray(Object.create(Array.prototype))); +assert.strictEqual(util.isArray([]), true); +assert.strictEqual(util.isArray(Array()), true); +assert.strictEqual(util.isArray(new Array()), true); +assert.strictEqual(util.isArray(new Array(5)), true); +assert.strictEqual(util.isArray(new Array('with', 'some', 'entries')), true); +assert.strictEqual(util.isArray(context('Array')()), true); +assert.strictEqual(util.isArray({}), false); +assert.strictEqual(util.isArray({ push: function() {} }), false); +assert.strictEqual(util.isArray(/regexp/), false); +assert.strictEqual(util.isArray(new Error()), false); +assert.strictEqual(util.isArray(Object.create(Array.prototype)), false); // isRegExp -assert.strictEqual(true, util.isRegExp(/regexp/)); -assert.strictEqual(true, util.isRegExp(RegExp(), 'foo')); -assert.strictEqual(true, util.isRegExp(new RegExp())); -assert.strictEqual(true, util.isRegExp(context('RegExp')())); -assert.strictEqual(false, util.isRegExp({})); -assert.strictEqual(false, util.isRegExp([])); -assert.strictEqual(false, util.isRegExp(new Date())); -assert.strictEqual(false, util.isRegExp(Object.create(RegExp.prototype))); +assert.strictEqual(util.isRegExp(/regexp/), true); +assert.strictEqual(util.isRegExp(RegExp(), 'foo'), true); +assert.strictEqual(util.isRegExp(new RegExp()), true); +assert.strictEqual(util.isRegExp(context('RegExp')()), true); +assert.strictEqual(util.isRegExp({}), false); +assert.strictEqual(util.isRegExp([]), false); +assert.strictEqual(util.isRegExp(new Date()), false); +assert.strictEqual(util.isRegExp(Object.create(RegExp.prototype)), false); // isDate -assert.strictEqual(true, util.isDate(new Date())); -assert.strictEqual(true, util.isDate(new Date(0), 'foo')); -assert.strictEqual(true, util.isDate(new (context('Date'))())); -assert.strictEqual(false, util.isDate(Date())); -assert.strictEqual(false, util.isDate({})); -assert.strictEqual(false, util.isDate([])); -assert.strictEqual(false, util.isDate(new Error())); -assert.strictEqual(false, util.isDate(Object.create(Date.prototype))); +assert.strictEqual(util.isDate(new Date()), true); +assert.strictEqual(util.isDate(new Date(0), 'foo'), true); +assert.strictEqual(util.isDate(new (context('Date'))()), true); +assert.strictEqual(util.isDate(Date()), false); +assert.strictEqual(util.isDate({}), false); +assert.strictEqual(util.isDate([]), false); +assert.strictEqual(util.isDate(new Error()), false); +assert.strictEqual(util.isDate(Object.create(Date.prototype)), false); // isError -assert.strictEqual(true, util.isError(new Error())); -assert.strictEqual(true, util.isError(new TypeError())); -assert.strictEqual(true, util.isError(new SyntaxError())); -assert.strictEqual(true, util.isError(new (context('Error'))())); -assert.strictEqual(true, util.isError(new (context('TypeError'))())); -assert.strictEqual(true, util.isError(new (context('SyntaxError'))())); -assert.strictEqual(false, util.isError({})); -assert.strictEqual(false, util.isError({ name: 'Error', message: '' })); -assert.strictEqual(false, util.isError([])); -assert.strictEqual(true, util.isError(Object.create(Error.prototype))); +assert.strictEqual(util.isError(new Error()), true); +assert.strictEqual(util.isError(new TypeError()), true); +assert.strictEqual(util.isError(new SyntaxError()), true); +assert.strictEqual(util.isError(new (context('Error'))()), true); +assert.strictEqual(util.isError(new (context('TypeError'))()), true); +assert.strictEqual(util.isError(new (context('SyntaxError'))()), true); +assert.strictEqual(util.isError({}), false); +assert.strictEqual(util.isError({ name: 'Error', message: '' }), false); +assert.strictEqual(util.isError([]), false); +assert.strictEqual(util.isError(Object.create(Error.prototype)), true); // isObject assert.ok(util.isObject({}) === true); // isPrimitive -assert.strictEqual(false, util.isPrimitive({})); -assert.strictEqual(false, util.isPrimitive(new Error())); -assert.strictEqual(false, util.isPrimitive(new Date())); -assert.strictEqual(false, util.isPrimitive([])); -assert.strictEqual(false, util.isPrimitive(/regexp/)); -assert.strictEqual(false, util.isPrimitive(function() {})); -assert.strictEqual(false, util.isPrimitive(new Number(1))); -assert.strictEqual(false, util.isPrimitive(new String('bla'))); -assert.strictEqual(false, util.isPrimitive(new Boolean(true))); -assert.strictEqual(true, util.isPrimitive(1)); -assert.strictEqual(true, util.isPrimitive('bla')); -assert.strictEqual(true, util.isPrimitive(true)); -assert.strictEqual(true, util.isPrimitive(undefined)); -assert.strictEqual(true, util.isPrimitive(null)); -assert.strictEqual(true, util.isPrimitive(Infinity)); -assert.strictEqual(true, util.isPrimitive(NaN)); -assert.strictEqual(true, util.isPrimitive(Symbol('symbol'))); +assert.strictEqual(util.isPrimitive({}), false); +assert.strictEqual(util.isPrimitive(new Error()), false); +assert.strictEqual(util.isPrimitive(new Date()), false); +assert.strictEqual(util.isPrimitive([]), false); +assert.strictEqual(util.isPrimitive(/regexp/), false); +assert.strictEqual(util.isPrimitive(function() {}), false); +assert.strictEqual(util.isPrimitive(new Number(1)), false); +assert.strictEqual(util.isPrimitive(new String('bla')), false); +assert.strictEqual(util.isPrimitive(new Boolean(true)), false); +assert.strictEqual(util.isPrimitive(1), true); +assert.strictEqual(util.isPrimitive('bla'), true); +assert.strictEqual(util.isPrimitive(true), true); +assert.strictEqual(util.isPrimitive(undefined), true); +assert.strictEqual(util.isPrimitive(null), true); +assert.strictEqual(util.isPrimitive(Infinity), true); +assert.strictEqual(util.isPrimitive(NaN), true); +assert.strictEqual(util.isPrimitive(Symbol('symbol')), true); // isBuffer -assert.strictEqual(false, util.isBuffer('foo')); -assert.strictEqual(true, util.isBuffer(Buffer.from('foo'))); +assert.strictEqual(util.isBuffer('foo'), false); +assert.strictEqual(util.isBuffer(Buffer.from('foo')), true); // _extend assert.deepStrictEqual(util._extend({ a: 1 }), { a: 1 }); @@ -160,18 +160,25 @@ util.error('test'); assert.strictEqual(util.types.isNativeError(new Error()), true); assert.strictEqual(util.types.isNativeError(new TypeError()), true); assert.strictEqual(util.types.isNativeError(new SyntaxError()), true); - assert.strictEqual(util.types.isNativeError(new (context('Error'))()), - true); - assert.strictEqual(util.types.isNativeError(new (context('TypeError'))()), - true); - assert.strictEqual(util.types.isNativeError(new (context('SyntaxError'))()), - true); + assert.strictEqual(util.types.isNativeError(new (context('Error'))()), true); + assert.strictEqual( + util.types.isNativeError(new (context('TypeError'))()), + true + ); + assert.strictEqual( + util.types.isNativeError(new (context('SyntaxError'))()), + true + ); assert.strictEqual(util.types.isNativeError({}), false); - assert.strictEqual(util.types.isNativeError({ name: 'Error', message: '' }), - false); + assert.strictEqual( + util.types.isNativeError({ name: 'Error', message: '' }), + false + ); assert.strictEqual(util.types.isNativeError([]), false); - assert.strictEqual(util.types.isNativeError(Object.create(Error.prototype)), - false); + assert.strictEqual( + util.types.isNativeError(Object.create(Error.prototype)), + false + ); assert.strictEqual( util.types.isNativeError(new errors.codes.ERR_IPC_CHANNEL_CLOSED()), true From ef2777db40c83fcae8350579bc2290ea5ab77f41 Mon Sep 17 00:00:00 2001 From: Saleh Abdel Motaal Date: Fri, 12 Oct 2018 11:06:25 -0700 Subject: [PATCH 164/328] test: fix strictEqual order for timers test PR-URL: https://github.com/nodejs/node/pull/23568 Reviewed-By: Joyee Cheung Reviewed-By: James M Snell Reviewed-By: Jeremiah Senkpiel Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-timers-linked-list.js | 32 ++++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/test/parallel/test-timers-linked-list.js b/test/parallel/test-timers-linked-list.js index 9cdb50e511bdaf..c7601462f65e31 100644 --- a/test/parallel/test-timers-linked-list.js +++ b/test/parallel/test-timers-linked-list.js @@ -41,47 +41,47 @@ L.init(C); L.init(D); assert.ok(L.isEmpty(list)); -assert.strictEqual(null, L.peek(list)); +assert.strictEqual(L.peek(list), null); L.append(list, A); // list -> A -assert.strictEqual(A, L.peek(list)); +assert.strictEqual(L.peek(list), A); L.append(list, B); // list -> A -> B -assert.strictEqual(A, L.peek(list)); +assert.strictEqual(L.peek(list), A); L.append(list, C); // list -> A -> B -> C -assert.strictEqual(A, L.peek(list)); +assert.strictEqual(L.peek(list), A); L.append(list, D); // list -> A -> B -> C -> D -assert.strictEqual(A, L.peek(list)); +assert.strictEqual(L.peek(list), A); L.remove(A); L.remove(B); // B is already removed, so removing it again shouldn't hurt. L.remove(B); // list -> C -> D -assert.strictEqual(C, L.peek(list)); +assert.strictEqual(L.peek(list), C); // Put B back on the list L.append(list, B); // list -> C -> D -> B -assert.strictEqual(C, L.peek(list)); +assert.strictEqual(L.peek(list), C); L.remove(C); // list -> D -> B -assert.strictEqual(D, L.peek(list)); +assert.strictEqual(L.peek(list), D); L.remove(B); // list -> D -assert.strictEqual(D, L.peek(list)); +assert.strictEqual(L.peek(list), D); L.remove(D); // list -assert.strictEqual(null, L.peek(list)); +assert.strictEqual(L.peek(list), null); assert.ok(L.isEmpty(list)); @@ -89,7 +89,7 @@ assert.ok(L.isEmpty(list)); L.append(list, D); // list -> D -assert.strictEqual(D, L.peek(list)); +assert.strictEqual(L.peek(list), D); L.append(list, C); L.append(list, B); @@ -100,8 +100,8 @@ L.append(list, A); L.append(list, C); // list -> D -> B -> A -> C -assert.strictEqual(D, L.peek(list)); -assert.strictEqual(B, L.peek(D)); -assert.strictEqual(A, L.peek(B)); -assert.strictEqual(C, L.peek(A)); -assert.strictEqual(list, L.peek(C)); +assert.strictEqual(L.peek(list), D); +assert.strictEqual(L.peek(D), B); +assert.strictEqual(L.peek(B), A); +assert.strictEqual(L.peek(A), C); +assert.strictEqual(L.peek(C), list); From db44a1a5a80861eda120e23bf35278dd70f19897 Mon Sep 17 00:00:00 2001 From: Richard Hoehn Date: Fri, 12 Oct 2018 11:07:52 -0700 Subject: [PATCH 165/328] src: add default initializer in tls_wrap PR-URL: https://github.com/nodejs/node/pull/23567 Reviewed-By: Joyee Cheung Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- src/tls_wrap.cc | 8 +------- src/tls_wrap.h | 12 ++++++------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 6577ffd3ec2080..b5eff3835856bb 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -59,13 +59,7 @@ TLSWrap::TLSWrap(Environment* env, AsyncWrap::PROVIDER_TLSWRAP), SSLWrap(env, sc, kind), StreamBase(env), - sc_(sc), - write_size_(0), - started_(false), - established_(false), - shutdown_(false), - cycle_depth_(0), - eof_(false) { + sc_(sc) { MakeWeak(); // sc comes from an Unwrap. Make sure it was assigned. diff --git a/src/tls_wrap.h b/src/tls_wrap.h index 0e265764822f29..4c47cd81197189 100644 --- a/src/tls_wrap.h +++ b/src/tls_wrap.h @@ -149,19 +149,19 @@ class TLSWrap : public AsyncWrap, BIO* enc_in_ = nullptr; BIO* enc_out_ = nullptr; std::vector pending_cleartext_input_; - size_t write_size_; + size_t write_size_ = 0; WriteWrap* current_write_ = nullptr; WriteWrap* current_empty_write_ = nullptr; bool write_callback_scheduled_ = false; - bool started_; - bool established_; - bool shutdown_; + bool started_ = false; + bool established_ = false; + bool shutdown_ = false; std::string error_; - int cycle_depth_; + int cycle_depth_ = 0; // If true - delivered EOF to the js-land, either after `close_notify`, or // after the `UV_EOF` on socket. - bool eof_; + bool eof_ = false; private: static void GetWriteQueueSize( From 7c7f8068bef63d7c2b1dab33535439d0b5a19093 Mon Sep 17 00:00:00 2001 From: Ethan Weber Date: Fri, 12 Oct 2018 10:52:38 -0700 Subject: [PATCH 166/328] test: fix assert value order Switched assertion values to match assert.strictEqual() documentation PR-URL: https://github.com/nodejs/node/pull/23566 Reviewed-By: Joyee Cheung Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil --- test/parallel/test-repl-require.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-repl-require.js b/test/parallel/test-repl-require.js index ecab4ba698911b..818fca7431fa94 100644 --- a/test/parallel/test-repl-require.js +++ b/test/parallel/test-repl-require.js @@ -32,7 +32,7 @@ server.listen(options, function() { }); process.on('exit', function() { - assert.strictEqual(false, /Cannot find module/.test(answer)); - assert.strictEqual(false, /Error/.test(answer)); + assert.strictEqual(/Cannot find module/.test(answer), false); + assert.strictEqual(/Error/.test(answer), false); assert.strictEqual(answer, '\'eye catcher\'\n\'perhaps I work\'\n'); }); From 0fcbe2c8ba4147dd1c0121aced4c7edb1699f430 Mon Sep 17 00:00:00 2001 From: Pete Lombardo Date: Fri, 12 Oct 2018 14:02:44 -0400 Subject: [PATCH 167/328] test: fix parameter order of assertions PR-URL: https://github.com/nodejs/node/pull/23565 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil --- test/pummel/test-net-throttle.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/pummel/test-net-throttle.js b/test/pummel/test-net-throttle.js index a08ed85ccd41bb..fb060c9d76d9d5 100644 --- a/test/pummel/test-net-throttle.js +++ b/test/pummel/test-net-throttle.js @@ -37,7 +37,7 @@ console.log(`start server on port ${common.PORT}`); const server = net.createServer(function(connection) { connection.write(body.slice(0, part_N)); connection.write(body.slice(part_N, 2 * part_N)); - assert.strictEqual(false, connection.write(body.slice(2 * part_N, N))); + assert.strictEqual(connection.write(body.slice(2 * part_N, N)), false); console.log(`bufferSize: ${connection.bufferSize}`, 'expecting', N); assert.ok(connection.bufferSize >= 0 && connection.writableLength <= N); @@ -58,7 +58,7 @@ server.listen(common.PORT, function() { console.log('pause'); const x = chars_recved; setTimeout(function() { - assert.strictEqual(chars_recved, x); + assert.strictEqual(x, chars_recved); client.resume(); console.log('resume'); paused = false; @@ -74,6 +74,6 @@ server.listen(common.PORT, function() { process.on('exit', function() { - assert.strictEqual(N, chars_recved); - assert.strictEqual(true, npauses > 2); + assert.strictEqual(chars_recved, N); + assert.strictEqual(npauses > 2, true); }); From e0b4dab58657e80c75950efcb31eedd1ed20e4a5 Mon Sep 17 00:00:00 2001 From: Savio Resende Date: Fri, 12 Oct 2018 10:47:37 -0700 Subject: [PATCH 168/328] test: fix assert.strictEqual() argument order PR-URL: https://github.com/nodejs/node/pull/23564 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Refael Ackermann Reviewed-By: Ruben Bridgewater Reviewed-By: Gireesh Punathil --- test/parallel/test-tcp-wrap-connect.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/parallel/test-tcp-wrap-connect.js b/test/parallel/test-tcp-wrap-connect.js index 36f87d1863ef36..6a118e32b1da73 100644 --- a/test/parallel/test-tcp-wrap-connect.js +++ b/test/parallel/test-tcp-wrap-connect.js @@ -13,19 +13,19 @@ function makeConnection() { assert.strictEqual(err, 0); req.oncomplete = function(status, client_, req_, readable, writable) { - assert.strictEqual(0, status); - assert.strictEqual(client, client_); - assert.strictEqual(req, req_); - assert.strictEqual(true, readable); - assert.strictEqual(true, writable); + assert.strictEqual(status, 0); + assert.strictEqual(client_, client); + assert.strictEqual(req_, req); + assert.strictEqual(readable, true); + assert.strictEqual(writable, true); const shutdownReq = new ShutdownWrap(); const err = client.shutdown(shutdownReq); assert.strictEqual(err, 0); shutdownReq.oncomplete = function(status, client_, error) { - assert.strictEqual(0, status); - assert.strictEqual(client, client_); + assert.strictEqual(status, 0); + assert.strictEqual(client_, client); assert.strictEqual(error, undefined); shutdownCount++; client.close(); @@ -50,7 +50,7 @@ const server = require('net').Server(function(s) { server.listen(0, makeConnection); process.on('exit', function() { - assert.strictEqual(1, shutdownCount); - assert.strictEqual(1, connectCount); - assert.strictEqual(1, endCount); + assert.strictEqual(shutdownCount, 1); + assert.strictEqual(connectCount, 1); + assert.strictEqual(endCount, 1); }); From 57b4fc16c3debc653986fa7251035d76414fec8f Mon Sep 17 00:00:00 2001 From: Mel Date: Fri, 12 Oct 2018 10:04:07 -0700 Subject: [PATCH 169/328] test: switch order of assertion arguments this updates the arguments in order to give the actual return value first and the given expected value second. PR-URL: https://github.com/nodejs/node/pull/23563 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil --- test/parallel/test-http-client-get-url.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http-client-get-url.js b/test/parallel/test-http-client-get-url.js index 7f6bfb8ecaa17b..a72eea56538c4d 100644 --- a/test/parallel/test-http-client-get-url.js +++ b/test/parallel/test-http-client-get-url.js @@ -28,8 +28,8 @@ const URL = url.URL; const testPath = '/foo?bar'; const server = http.createServer(common.mustCall((req, res) => { - assert.strictEqual('GET', req.method); - assert.strictEqual(testPath, req.url); + assert.strictEqual(req.method, 'GET'); + assert.strictEqual(req.url, testPath); res.writeHead(200, { 'Content-Type': 'text/plain' }); res.write('hello\n'); res.end(); From 4874ce2106830802828415a761c9aea489a5ca72 Mon Sep 17 00:00:00 2001 From: keeysnc Date: Fri, 12 Oct 2018 11:03:37 -0700 Subject: [PATCH 170/328] test: updated assert test values to doc standards PR-URL: https://github.com/nodejs/node/pull/23593 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Sakthipriyan Vairamani --- test/sequential/test-inspector-exception.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sequential/test-inspector-exception.js b/test/sequential/test-inspector-exception.js index 4a41e8826a50d1..1d60d524afe6e3 100644 --- a/test/sequential/test-inspector-exception.js +++ b/test/sequential/test-inspector-exception.js @@ -39,7 +39,7 @@ async function runTest() { const session = await child.connectInspectorSession(); await testBreakpointOnStart(session); await session.runToCompletion(); - assert.strictEqual(1, (await child.expectShutdown()).exitCode); + assert.strictEqual((await child.expectShutdown()).exitCode, 1); } runTest(); From 64268d005a9f9feb501195fe613bc713571e67cd Mon Sep 17 00:00:00 2001 From: erickwendel Date: Fri, 12 Oct 2018 14:12:00 -0700 Subject: [PATCH 171/328] test: fix assertion order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23626 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Ruben Bridgewater --- test/parallel/test-https-client-get-url.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-https-client-get-url.js b/test/parallel/test-https-client-get-url.js index 56a6fe6d18641a..5d520416fe22da 100644 --- a/test/parallel/test-https-client-get-url.js +++ b/test/parallel/test-https-client-get-url.js @@ -40,8 +40,8 @@ const options = { }; const server = https.createServer(options, common.mustCall((req, res) => { - assert.strictEqual('GET', req.method); - assert.strictEqual('/foo?bar', req.url); + assert.strictEqual(req.method, 'GET'); + assert.strictEqual(req.url, '/foo?bar'); res.writeHead(200, { 'Content-Type': 'text/plain' }); res.write('hello\n'); res.end(); From 4f8e4f065cb7dd05fd68c483c587aef4abce37d4 Mon Sep 17 00:00:00 2001 From: Martin Omander Date: Fri, 12 Oct 2018 11:44:56 -0700 Subject: [PATCH 172/328] module: removed unused variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variable problemChecking was not used. Removed it. PR-URL: https://github.com/nodejs/node/pull/23624 Reviewed-By: Anna Henningsen Reviewed-By: Сковорода Никита Андреевич Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Ruben Bridgewater --- lib/internal/modules/esm/default_resolve.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/modules/esm/default_resolve.js b/lib/internal/modules/esm/default_resolve.js index 7707262566c88a..7654ca91129325 100644 --- a/lib/internal/modules/esm/default_resolve.js +++ b/lib/internal/modules/esm/default_resolve.js @@ -37,7 +37,7 @@ function search(target, base) { new URL('./', questionedBase).pathname); const found = CJSmodule._resolveFilename(target, tmpMod); error = new ERR_MODULE_RESOLUTION_LEGACY(target, base, found); - } catch (problemChecking) { + } catch { // ignore } throw error; From 9fb6cf01f9c0cb6375a3f009cfb215846043bfed Mon Sep 17 00:00:00 2001 From: Jeff Marvin Date: Fri, 12 Oct 2018 11:47:03 -0700 Subject: [PATCH 173/328] test: correct assertion argument order This conforms assertions to follow the argument order of asserted then actual, and adds more explicit messages to describe assertion failures. PR-URL: https://github.com/nodejs/node/pull/23618 Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil --- test/sequential/test-inspector.js | 36 +++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/test/sequential/test-inspector.js b/test/sequential/test-inspector.js index 2a7a2ef4bf34ba..00fdb000e9e251 100644 --- a/test/sequential/test-inspector.js +++ b/test/sequential/test-inspector.js @@ -8,7 +8,12 @@ const assert = require('assert'); const { NodeInstance } = require('../common/inspector-helper.js'); function checkListResponse(response) { - assert.strictEqual(1, response.length); + const expectedLength = 1; + assert.strictEqual( + response.length, + expectedLength, + `Expected response length ${response.length} to be ${expectedLength}.` + ); assert.ok(response[0].devtoolsFrontendUrl); assert.ok( /ws:\/\/localhost:\d+\/[0-9A-Fa-f]{8}-/ @@ -41,7 +46,11 @@ function assertScopeValues({ result }, expected) { for (const actual of result) { const value = expected[actual.name]; if (value) { - assert.strictEqual(value, actual.value.value); + assert.strictEqual( + actual.value.value, + value, + `Expected scope values to be ${actual.value.value} instead of ${value}.` + ); unmatched.delete(actual.name); } } @@ -117,15 +126,24 @@ async function testBreakpoint(session) { 'generatePreview': true } }); - - assert.strictEqual(1002, result.value); + const expectedEvaluation = 1002; + assert.strictEqual( + result.value, + expectedEvaluation, + `Expected evaluation to be ${expectedEvaluation}, got ${result.value}.` + ); result = (await session.send({ 'method': 'Runtime.evaluate', 'params': { 'expression': '5 * 5' } })).result; - assert.strictEqual(25, result.value); + const expectedResult = 25; + assert.strictEqual( + result.value, + expectedResult, + `Expected Runtime.evaluate to be ${expectedResult}, got ${result.value}.` + ); } async function testI18NCharacters(session) { @@ -288,7 +306,13 @@ async function runTest() { await testI18NCharacters(session); await testCommandLineAPI(session); await session.runToCompletion(); - assert.strictEqual(55, (await child.expectShutdown()).exitCode); + const expectedExitCode = 55; + const { exitCode } = await child.expectShutdown(); + assert.strictEqual( + exitCode, + expectedExitCode, + `Expected exit code to be ${expectedExitCode} but got ${expectedExitCode}.` + ); } runTest(); From 202d38c48450e28bd094c3f6fb06e323edae73de Mon Sep 17 00:00:00 2001 From: vchoubey08 Date: Fri, 12 Oct 2018 11:43:02 -0700 Subject: [PATCH 174/328] test: reversed 1st and 2nd arguments for assert.strictEqual() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23617 Reviewed-By: Denys Otrishko Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Hitesh Kanwathirtha Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-memory-usage-emfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-memory-usage-emfile.js b/test/parallel/test-memory-usage-emfile.js index f8d1fc90da7aec..98496e17b099d2 100644 --- a/test/parallel/test-memory-usage-emfile.js +++ b/test/parallel/test-memory-usage-emfile.js @@ -10,4 +10,4 @@ while (files.length < 256) files.push(fs.openSync(__filename, 'r')); const r = process.memoryUsage(); -assert.strictEqual(true, r.rss > 0); +assert.strictEqual(r.rss > 0, true); From 6d80af31124aa1a4ad18d8d342169e5c7265caf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Vasseur?= Date: Fri, 12 Oct 2018 11:27:05 -0700 Subject: [PATCH 175/328] test: fix backward assertion arguments PR-URL: https://github.com/nodejs/node/pull/23616 Reviewed-By: Ruben Bridgewater Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-net-server-max-connections.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-net-server-max-connections.js b/test/parallel/test-net-server-max-connections.js index a711e5295be8bf..705c99b7b9737a 100644 --- a/test/parallel/test-net-server-max-connections.js +++ b/test/parallel/test-net-server-max-connections.js @@ -75,10 +75,10 @@ function makeConnection(index) { } if (index < server.maxConnections) { - assert.strictEqual(true, gotData, + assert.strictEqual(gotData, true, `${index} didn't get data, but should have`); } else { - assert.strictEqual(false, gotData, + assert.strictEqual(gotData, false, `${index} got data, but shouldn't have`); } }); @@ -103,5 +103,5 @@ function makeConnection(index) { process.on('exit', function() { - assert.strictEqual(N, closes); + assert.strictEqual(closes, N); }); From 4d9059b1df48e57edbef42ecc1169e5803027363 Mon Sep 17 00:00:00 2001 From: Sean Healy Date: Fri, 12 Oct 2018 11:42:58 -0700 Subject: [PATCH 176/328] test: update assertion parameter order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update assertions to be `value`, `expectedValue`. PR-URL: https://github.com/nodejs/node/pull/23614 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Anna Henningsen Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-http-proxy.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-http-proxy.js b/test/parallel/test-http-proxy.js index 8781679c0a45b8..6a986024af29be 100644 --- a/test/parallel/test-http-proxy.js +++ b/test/parallel/test-http-proxy.js @@ -50,9 +50,9 @@ const proxy = http.createServer(function(req, res) { console.error(`proxy res headers: ${JSON.stringify(proxy_res.headers)}`); - assert.strictEqual('world', proxy_res.headers.hello); - assert.strictEqual('text/plain', proxy_res.headers['content-type']); - assert.deepStrictEqual(cookies, proxy_res.headers['set-cookie']); + assert.strictEqual(proxy_res.headers.hello, 'world'); + assert.strictEqual(proxy_res.headers['content-type'], 'text/plain'); + assert.deepStrictEqual(proxy_res.headers['set-cookie'], cookies); res.writeHead(proxy_res.statusCode, proxy_res.headers); @@ -79,11 +79,11 @@ function startReq() { path: '/test' }, function(res) { console.error('got res'); - assert.strictEqual(200, res.statusCode); + assert.strictEqual(res.statusCode, 200); - assert.strictEqual('world', res.headers.hello); - assert.strictEqual('text/plain', res.headers['content-type']); - assert.deepStrictEqual(cookies, res.headers['set-cookie']); + assert.strictEqual(res.headers.hello, 'world'); + assert.strictEqual(res.headers['content-type'], 'text/plain'); + assert.deepStrictEqual(res.headers['set-cookie'], cookies); res.setEncoding('utf8'); res.on('data', function(chunk) { body += chunk; }); From d370c5e8c112e865d90c1b6abf837b641885e4ad Mon Sep 17 00:00:00 2001 From: Vsevolod Geraskin Date: Fri, 12 Oct 2018 11:39:59 -0700 Subject: [PATCH 177/328] test: reverse arguments in assert.strictEqual assert.strictEqual() had incorrect order of arguments with expected and actual values reversed. PR-URL: https://github.com/nodejs/node/pull/23613 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-http-keep-alive-close-on-header.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-http-keep-alive-close-on-header.js b/test/parallel/test-http-keep-alive-close-on-header.js index f5fb9466db1fa7..fd0c52037fa78c 100644 --- a/test/parallel/test-http-keep-alive-close-on-header.js +++ b/test/parallel/test-http-keep-alive-close-on-header.js @@ -46,7 +46,7 @@ server.listen(0, function() { port: this.address().port, agent: agent }, function(res) { - assert.strictEqual(1, agent.sockets[name].length); + assert.strictEqual(agent.sockets[name].length, 1); res.resume(); }); request.on('socket', function(s) { @@ -63,7 +63,7 @@ server.listen(0, function() { port: this.address().port, agent: agent }, function(res) { - assert.strictEqual(1, agent.sockets[name].length); + assert.strictEqual(agent.sockets[name].length, 1); res.resume(); }); request.on('socket', function(s) { @@ -80,7 +80,7 @@ server.listen(0, function() { agent: agent }, function(response) { response.on('end', function() { - assert.strictEqual(1, agent.sockets[name].length); + assert.strictEqual(agent.sockets[name].length, 1); server.close(); }); response.resume(); @@ -94,5 +94,5 @@ server.listen(0, function() { }); process.on('exit', function() { - assert.strictEqual(3, connectCount); + assert.strictEqual(connectCount, 3); }); From 0c9a8665417c6109ab769145e405236582cbdb94 Mon Sep 17 00:00:00 2001 From: Israel Ortiz Date: Fri, 12 Oct 2018 11:46:07 -0700 Subject: [PATCH 178/328] test: fix parameters in test-repl.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixed order of parameters in assert.strictEqual() assertion functions, first argument provided was the expected value and the second value was the actual value. this is backwards from the documentation for assertions like assert.strictEqual() where the first value being tested and the second value is the expected value PR-URL: https://github.com/nodejs/node/pull/23609 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-repl.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 49e718da0f0683..f8261dedd98974 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -784,8 +784,8 @@ function startTCPRepl() { client.setEncoding('utf8'); client.on('connect', common.mustCall(() => { - assert.strictEqual(true, client.readable); - assert.strictEqual(true, client.writable); + assert.strictEqual(client.readable, true); + assert.strictEqual(client.writable, true); resolveSocket(client); })); @@ -827,8 +827,8 @@ function startUnixRepl() { client.setEncoding('utf8'); client.on('connect', common.mustCall(() => { - assert.strictEqual(true, client.readable); - assert.strictEqual(true, client.writable); + assert.strictEqual(client.readable, true); + assert.strictEqual(client.writable, true); resolveSocket(client); })); From 37e1101a0fb869f58b5b0cd0636abd90967550ff Mon Sep 17 00:00:00 2001 From: Milton Sosa Date: Fri, 12 Oct 2018 11:46:14 -0700 Subject: [PATCH 179/328] test: fix assertions args order PR-URL: https://github.com/nodejs/node/pull/23608 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-http-chunk-problem.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http-chunk-problem.js b/test/parallel/test-http-chunk-problem.js index c2502a891d325c..4a2886da3f8e40 100644 --- a/test/parallel/test-http-chunk-problem.js +++ b/test/parallel/test-http-chunk-problem.js @@ -53,8 +53,8 @@ function executeRequest(cb) { 'shasum' ].join(' '), (err, stdout, stderr) => { assert.ifError(err); - assert.strictEqual('8c206a1a87599f532ce68675536f0b1546900d7a', - stdout.slice(0, 40)); + assert.strictEqual(stdout.slice(0, 40), + '8c206a1a87599f532ce68675536f0b1546900d7a'); cb(); } ); From 984fac4a532e0fd7427cc3650aaf7c97f2381bdd Mon Sep 17 00:00:00 2001 From: Paul Tichonczuk Date: Fri, 12 Oct 2018 11:38:16 -0700 Subject: [PATCH 180/328] test: re-order strictEqual paramater calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23607 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Denys Otrishko Reviewed-By: Anna Henningsen Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-net-reconnect.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-net-reconnect.js b/test/parallel/test-net-reconnect.js index c8b1503cea36e6..eb6b0728478a91 100644 --- a/test/parallel/test-net-reconnect.js +++ b/test/parallel/test-net-reconnect.js @@ -44,7 +44,7 @@ const server = net.createServer(function(socket) { socket.on('close', function(had_error) { console.log(`SERVER had_error: ${JSON.stringify(had_error)}`); - assert.strictEqual(false, had_error); + assert.strictEqual(had_error, false); }); }); @@ -61,7 +61,7 @@ server.listen(0, function() { client.on('data', function(chunk) { client_recv_count += 1; console.log(`client_recv_count ${client_recv_count}`); - assert.strictEqual('hello\r\n', chunk); + assert.strictEqual(chunk, 'hello\r\n'); console.error('CLIENT: calling end', client._writableState); client.end(); }); @@ -73,7 +73,7 @@ server.listen(0, function() { client.on('close', function(had_error) { console.log('CLIENT disconnect'); - assert.strictEqual(false, had_error); + assert.strictEqual(had_error, false); if (disconnect_count++ < N) client.connect(server.address().port); // reconnect else @@ -82,7 +82,7 @@ server.listen(0, function() { }); process.on('exit', function() { - assert.strictEqual(N + 1, disconnect_count); - assert.strictEqual(N + 1, client_recv_count); - assert.strictEqual(N + 1, client_end_count); + assert.strictEqual(disconnect_count, N + 1); + assert.strictEqual(client_recv_count, N + 1); + assert.strictEqual(client_end_count, N + 1); }); From af6528ab85b55474e6d1240b3696ac9c3705b755 Mon Sep 17 00:00:00 2001 From: Emily Kolar Date: Fri, 12 Oct 2018 11:38:17 -0700 Subject: [PATCH 181/328] test: fix order of assert args in client response domain test PR-URL: https://github.com/nodejs/node/pull/23604 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-http-client-response-domain.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http-client-response-domain.js b/test/parallel/test-http-client-response-domain.js index 0a32e929141e45..617dc729acb71f 100644 --- a/test/parallel/test-http-client-response-domain.js +++ b/test/parallel/test-http-client-response-domain.js @@ -44,8 +44,8 @@ server.listen(common.PIPE, function() { function test() { - d.on('error', common.mustCall(function(err) { - assert.strictEqual('should be caught by domain', err.message); + d.on('error', common.mustCall((err) => { + assert.strictEqual(err.message, 'should be caught by domain'); })); const req = http.get({ From dd91c1d20cabfd0f42263b6fcf2c17474d2fe6e0 Mon Sep 17 00:00:00 2001 From: Gino Notto Date: Fri, 12 Oct 2018 11:34:32 -0700 Subject: [PATCH 182/328] src: change macro to fn Change base64_encoded_size and unbase64 to inline functions. The base64_encoded_size is a constexpr to be used in function declarations. PR-URL: https://github.com/nodejs/node/pull/23603 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- src/base64.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/base64.h b/src/base64.h index a19d11f71c65f5..aedec375eba550 100644 --- a/src/base64.h +++ b/src/base64.h @@ -10,8 +10,9 @@ namespace node { //// Base 64 //// -#define base64_encoded_size(size) ((size + 2 - ((size + 2) % 3)) / 3 * 4) - +static inline constexpr size_t base64_encoded_size(size_t size) { + return ((size + 2 - ((size + 2) % 3)) / 3 * 4); +} // Doesn't check for padding at the end. Can be 1-2 bytes over. static inline size_t base64_decoded_size_fast(size_t size) { @@ -48,8 +49,9 @@ size_t base64_decoded_size(const TypeName* src, size_t size) { extern const int8_t unbase64_table[256]; -#define unbase64(x) \ - static_cast(unbase64_table[static_cast(x)]) +inline static int8_t unbase64(uint8_t x) { + return unbase64_table[x]; +} template From 8d39cf632323b5bb038d7a09bfa93ff26db09090 Mon Sep 17 00:00:00 2001 From: David Jiang Date: Fri, 12 Oct 2018 11:33:29 -0700 Subject: [PATCH 183/328] test: fix assert equal order of arguments PR-URL: https://github.com/nodejs/node/pull/23602 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-net-connect-handle-econnrefused.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-net-connect-handle-econnrefused.js b/test/parallel/test-net-connect-handle-econnrefused.js index 3c7310b4752d72..c1ccfc23384caf 100644 --- a/test/parallel/test-net-connect-handle-econnrefused.js +++ b/test/parallel/test-net-connect-handle-econnrefused.js @@ -31,6 +31,6 @@ server.close(common.mustCall(() => { const c = net.createConnection(port); c.on('connect', common.mustNotCall()); c.on('error', common.mustCall((e) => { - assert.strictEqual('ECONNREFUSED', e.code); + assert.strictEqual(e.code, 'ECONNREFUSED'); })); })); From e98d8f427c01ac70c0adbcf37fb13326b7d1b25c Mon Sep 17 00:00:00 2001 From: Chuck Theobald Date: Fri, 12 Oct 2018 11:06:31 -0700 Subject: [PATCH 184/328] test: change order of assert.strictEquals arguments Fix assert.strictEquals argument order. Arguments were actual first, expected second, contrary to the documentation. Now, actual value is first and expected value is second. PR-URL: https://github.com/nodejs/node/pull/23600 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-tcp-wrap-listen.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/parallel/test-tcp-wrap-listen.js b/test/parallel/test-tcp-wrap-listen.js index 8203a4771b861f..662cd63080e2df 100644 --- a/test/parallel/test-tcp-wrap-listen.js +++ b/test/parallel/test-tcp-wrap-listen.js @@ -8,7 +8,7 @@ const WriteWrap = process.binding('stream_wrap').WriteWrap; const server = new TCP(TCPConstants.SOCKET); const r = server.bind('0.0.0.0', 0); -assert.strictEqual(0, r); +assert.strictEqual(r, 0); let port = {}; server.getsockname(port); port = port.port; @@ -16,7 +16,7 @@ port = port.port; server.listen(128); server.onconnection = (err, client) => { - assert.strictEqual(0, client.writeQueueSize); + assert.strictEqual(client.writeQueueSize, 0); console.log('got connection'); const maybeCloseClient = () => { @@ -32,7 +32,7 @@ server.onconnection = (err, client) => { if (buffer) { assert.ok(buffer.length > 0); - assert.strictEqual(0, client.writeQueueSize); + assert.strictEqual(client.writeQueueSize, 0); const req = new WriteWrap(); req.async = false; @@ -42,7 +42,7 @@ server.onconnection = (err, client) => { console.log(`client.writeQueueSize: ${client.writeQueueSize}`); // 11 bytes should flush - assert.strictEqual(0, client.writeQueueSize); + assert.strictEqual(client.writeQueueSize, 0); if (req.async) req.oncomplete = common.mustCall(done); @@ -50,15 +50,15 @@ server.onconnection = (err, client) => { process.nextTick(done.bind(null, 0, client, req)); function done(status, client_, req_) { - assert.strictEqual(req, client.pendingWrites.shift()); + assert.strictEqual(client.pendingWrites.shift(), req); // Check parameters. - assert.strictEqual(0, status); - assert.strictEqual(client, client_); - assert.strictEqual(req, req_); + assert.strictEqual(status, 0); + assert.strictEqual(client_, client); + assert.strictEqual(req_, req); console.log(`client.writeQueueSize: ${client.writeQueueSize}`); - assert.strictEqual(0, client.writeQueueSize); + assert.strictEqual(client.writeQueueSize, 0); maybeCloseClient(); } @@ -80,7 +80,7 @@ c.on('connect', common.mustCall(() => { c.end('hello world'); })); c.setEncoding('utf8'); c.on('data', common.mustCall((d) => { - assert.strictEqual('hello world', d); + assert.strictEqual(d, 'hello world'); })); c.on('close', () => { From 25b166a5cbea18215699b6203d2c541abc637fe1 Mon Sep 17 00:00:00 2001 From: Ian Sutherland Date: Fri, 12 Oct 2018 11:33:54 -0700 Subject: [PATCH 185/328] test: fix assert parameter order in test-https-localaddress.js PR-URL: https://github.com/nodejs/node/pull/23599 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-https-localaddress.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-https-localaddress.js b/test/parallel/test-https-localaddress.js index bfa24457dac64e..470b59432533a1 100644 --- a/test/parallel/test-https-localaddress.js +++ b/test/parallel/test-https-localaddress.js @@ -38,7 +38,7 @@ const options = { const server = https.createServer(options, function(req, res) { console.log(`Connect from: ${req.connection.remoteAddress}`); - assert.strictEqual('127.0.0.2', req.connection.remoteAddress); + assert.strictEqual(req.connection.remoteAddress, '127.0.0.2'); req.on('end', function() { res.writeHead(200, { 'Content-Type': 'text/plain' }); From 3d703042c1b2881084e014558b948a0560880f62 Mon Sep 17 00:00:00 2001 From: Derek Date: Fri, 12 Oct 2018 11:29:32 -0700 Subject: [PATCH 186/328] test: fix assert.strictEqual() argument order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23598 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-https-eof-for-eom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-https-eof-for-eom.js b/test/parallel/test-https-eof-for-eom.js index 2e42680c7d6d5f..b2f178654f6de9 100644 --- a/test/parallel/test-https-eof-for-eom.js +++ b/test/parallel/test-https-eof-for-eom.js @@ -75,7 +75,7 @@ server.listen(0, common.mustCall(function() { server.close(); console.log('3) Client got response headers.'); - assert.strictEqual('gws', res.headers.server); + assert.strictEqual(res.headers.server, 'gws'); res.setEncoding('utf8'); res.on('data', function(s) { @@ -84,7 +84,7 @@ server.listen(0, common.mustCall(function() { res.on('end', common.mustCall(function() { console.log('5) Client got "end" event.'); - assert.strictEqual('hello world\nhello world\n', bodyBuffer); + assert.strictEqual(bodyBuffer, 'hello world\nhello world\n'); })); })); })); From 002c35cd42f38859c14f0effdc09ed3f0cd4d6ac Mon Sep 17 00:00:00 2001 From: Amanuel Ghebreweldi Date: Fri, 12 Oct 2018 11:19:09 -0700 Subject: [PATCH 187/328] test: assertions arguments match docs PR-URL: https://github.com/nodejs/node/pull/23594 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-pipe-head.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-pipe-head.js b/test/parallel/test-pipe-head.js index 1cfff9888d0d7f..cb3d183fcdff20 100644 --- a/test/parallel/test-pipe-head.js +++ b/test/parallel/test-pipe-head.js @@ -13,5 +13,5 @@ const cmd = `"${nodePath}" "${script}" | head -2`; exec(cmd, common.mustCall(function(err, stdout, stderr) { assert.ifError(err); const lines = stdout.split('\n'); - assert.strictEqual(3, lines.length); + assert.strictEqual(lines.length, 3); })); From e8ca33025a66c6e220115267645743466d721a85 Mon Sep 17 00:00:00 2001 From: Jared Haines Date: Fri, 12 Oct 2018 11:23:14 -0700 Subject: [PATCH 188/328] test: increased code coverage for slowCases Added test coverage for 4 un-covered if statements in slowCases PR-URL: https://github.com/nodejs/node/pull/23592 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat --- test/parallel/test-internal-util-normalizeencoding.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/parallel/test-internal-util-normalizeencoding.js b/test/parallel/test-internal-util-normalizeencoding.js index 1fe97156ee1758..d7a0259ac9c9fd 100644 --- a/test/parallel/test-internal-util-normalizeencoding.js +++ b/test/parallel/test-internal-util-normalizeencoding.js @@ -18,6 +18,7 @@ const tests = [ ['utF-8', 'utf8'], ['ucs2', 'utf16le'], ['UCS2', 'utf16le'], + ['UcS2', 'utf16le'], ['ucs-2', 'utf16le'], ['UCS-2', 'utf16le'], ['UcS-2', 'utf16le'], @@ -31,8 +32,11 @@ const tests = [ ['LaTiN1', 'latin1'], ['base64', 'base64'], ['BASE64', 'base64'], + ['Base64', 'base64'], ['hex', 'hex'], ['HEX', 'hex'], + ['ASCII', 'ascii'], + ['AsCii', 'ascii'], ['foo', undefined], [1, undefined], [false, undefined], From f82611a27eee5da0311213b6a44be47edb173883 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Thu, 11 Oct 2018 15:35:24 -0700 Subject: [PATCH 189/328] test: use smaller keys for a faster keygen test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On my machine, this brings test execution time down from about 2 seconds to 0.2 seconds. PR-URL: https://github.com/nodejs/node/pull/23430 Reviewed-By: Refael Ackermann Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Tobias Nießen Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig --- test/parallel/test-crypto-keygen.js | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/test/parallel/test-crypto-keygen.js b/test/parallel/test-crypto-keygen.js index e9fe630dd72e84..896deaf90b1bda 100644 --- a/test/parallel/test-crypto-keygen.js +++ b/test/parallel/test-crypto-keygen.js @@ -87,7 +87,7 @@ function convertDERToPEM(label, der) { // with a relatively small key. const ret = generateKeyPairSync('rsa', { publicExponent: 0x10001, - modulusLength: 1024, + modulusLength: 512, publicKeyEncoding: { type: 'pkcs1', format: 'pem' @@ -103,10 +103,10 @@ function convertDERToPEM(label, der) { assert.strictEqual(typeof publicKey, 'string'); assert(pkcs1PubExp.test(publicKey)); - assertApproximateSize(publicKey, 272); + assertApproximateSize(publicKey, 162); assert.strictEqual(typeof privateKey, 'string'); assert(pkcs8Exp.test(privateKey)); - assertApproximateSize(privateKey, 912); + assertApproximateSize(privateKey, 512); testEncryptDecrypt(publicKey, privateKey); testSignVerify(publicKey, privateKey); @@ -116,7 +116,7 @@ function convertDERToPEM(label, der) { // Test async RSA key generation. generateKeyPair('rsa', { publicExponent: 0x10001, - modulusLength: 4096, + modulusLength: 512, publicKeyEncoding: { type: 'pkcs1', format: 'der' @@ -132,11 +132,11 @@ function convertDERToPEM(label, der) { // will still need to convert it to PEM for testing. assert(Buffer.isBuffer(publicKeyDER)); const publicKey = convertDERToPEM('RSA PUBLIC KEY', publicKeyDER); - assertApproximateSize(publicKey, 720); + assertApproximateSize(publicKey, 180); assert.strictEqual(typeof privateKey, 'string'); assert(pkcs1PrivExp.test(privateKey)); - assertApproximateSize(privateKey, 3272); + assertApproximateSize(privateKey, 512); testEncryptDecrypt(publicKey, privateKey); testSignVerify(publicKey, privateKey); @@ -145,7 +145,7 @@ function convertDERToPEM(label, der) { // Now do the same with an encrypted private key. generateKeyPair('rsa', { publicExponent: 0x10001, - modulusLength: 4096, + modulusLength: 512, publicKeyEncoding: { type: 'pkcs1', format: 'der' @@ -163,7 +163,7 @@ function convertDERToPEM(label, der) { // will still need to convert it to PEM for testing. assert(Buffer.isBuffer(publicKeyDER)); const publicKey = convertDERToPEM('RSA PUBLIC KEY', publicKeyDER); - assertApproximateSize(publicKey, 720); + assertApproximateSize(publicKey, 180); assert.strictEqual(typeof privateKey, 'string'); assert(pkcs1EncExp('AES-256-CBC').test(privateKey)); @@ -182,7 +182,7 @@ function convertDERToPEM(label, der) { { // Test async DSA key generation. generateKeyPair('dsa', { - modulusLength: 2048, + modulusLength: 256, divisorLength: 256, publicKeyEncoding: { type: 'spki', @@ -203,8 +203,8 @@ function convertDERToPEM(label, der) { assert(Buffer.isBuffer(privateKeyDER)); const privateKey = convertDERToPEM('ENCRYPTED PRIVATE KEY', privateKeyDER); - assertApproximateSize(publicKey, 1194); - assertApproximateSize(privateKey, 1054); + assertApproximateSize(publicKey, 440); + assertApproximateSize(privateKey, 512); // Since the private key is encrypted, signing shouldn't work anymore. assert.throws(() => { @@ -279,7 +279,7 @@ function convertDERToPEM(label, der) { // Test async elliptic curve key generation, e.g. for ECDSA, with an encrypted // private key. generateKeyPair('ec', { - namedCurve: 'P-256', + namedCurve: 'P-192', paramEncoding: 'named', publicKeyEncoding: { type: 'spki', @@ -315,7 +315,7 @@ function convertDERToPEM(label, der) { // Test the util.promisified API with async RSA key generation. promisify(generateKeyPair)('rsa', { publicExponent: 0x10001, - modulusLength: 3072, + modulusLength: 512, publicKeyEncoding: { type: 'pkcs1', format: 'pem' @@ -328,15 +328,15 @@ function convertDERToPEM(label, der) { const { publicKey, privateKey } = keys; assert.strictEqual(typeof publicKey, 'string'); assert(pkcs1PubExp.test(publicKey)); - assertApproximateSize(publicKey, 600); + assertApproximateSize(publicKey, 180); assert.strictEqual(typeof privateKey, 'string'); assert(pkcs1PrivExp.test(privateKey)); - assertApproximateSize(privateKey, 2455); + assertApproximateSize(privateKey, 512); testEncryptDecrypt(publicKey, privateKey); testSignVerify(publicKey, privateKey); - })).catch(common.mustNotCall()); + })); } { @@ -545,7 +545,7 @@ function convertDERToPEM(label, der) { // Test invalid callbacks. for (const cb of [undefined, null, 0, {}]) { common.expectsError(() => generateKeyPair('rsa', { - modulusLength: 4096, + modulusLength: 512, publicKeyEncoding: { type: 'pkcs1', format: 'pem' }, privateKeyEncoding: { type: 'pkcs1', format: 'pem' } }, cb), { @@ -627,7 +627,7 @@ function convertDERToPEM(label, der) { // It should recognize both NIST and standard curve names. generateKeyPair('ec', { - namedCurve: 'P-256', + namedCurve: 'P-192', publicKeyEncoding: { type: 'spki', format: 'pem' }, privateKeyEncoding: { type: 'pkcs8', format: 'pem' } }, common.mustCall((err, publicKey, privateKey) => { From 642b1686be97ad66070a614bd685e8769fb9006c Mon Sep 17 00:00:00 2001 From: christian-bromann Date: Fri, 12 Oct 2018 11:54:37 -0700 Subject: [PATCH 190/328] test: add test coverage for fs.truncate Add test to check: - for `null` as len parameter - if error is propagated into callback if file doesn't exist - if an error is actually thrown if len is not a number PR-URL: https://github.com/nodejs/node/pull/23620 Reviewed-By: Refael Ackermann Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Denys Otrishko --- test/parallel/test-fs-truncate.js | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/parallel/test-fs-truncate.js b/test/parallel/test-fs-truncate.js index 735385f61c5249..a491ba5b7eaa20 100644 --- a/test/parallel/test-fs-truncate.js +++ b/test/parallel/test-fs-truncate.js @@ -249,6 +249,41 @@ function testFtruncate(cb) { })); } +{ + const file7 = path.resolve(tmp, 'truncate-file-7.txt'); + fs.writeFileSync(file7, 'Hi'); + fs.truncate(file7, undefined, common.mustCall(function(err) { + assert.ifError(err); + assert(fs.readFileSync(file7).equals(Buffer.from(''))); + })); +} + +{ + const file8 = path.resolve(tmp, 'non-existent-truncate-file.txt'); + const validateError = (err) => { + assert.strictEqual(file8, err.path); + assert.strictEqual( + err.message, + `ENOENT: no such file or directory, open '${file8}'`); + assert.strictEqual(err.code, 'ENOENT'); + assert.strictEqual(err.syscall, 'open'); + return true; + }; + fs.truncate(file8, 0, common.mustCall(validateError)); +} + +['', false, null, {}, []].forEach((input) => { + assert.throws( + () => fs.truncate('/foo/bar', input), + { + code: 'ERR_INVALID_ARG_TYPE', + name: 'TypeError [ERR_INVALID_ARG_TYPE]', + message: 'The "len" argument must be of type number. ' + + `Received type ${typeof input}` + } + ); +}); + ['', false, null, undefined, {}, []].forEach((input) => { ['ftruncate', 'ftruncateSync'].forEach((fnName) => { assert.throws( From 179d4c72696b44e7a6e30d2f6dd29a7f1f37e0a0 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 22 Sep 2018 14:09:52 +0200 Subject: [PATCH 191/328] zlib: refactor zlib internals Split out things that are specific to zlib as a specific compression library, vs. the interface that is common to most C compression libraries. This should pave the way for including support for e.g. brotli. PR-URL: https://github.com/nodejs/node/pull/23360 Reviewed-By: James M Snell Reviewed-By: Daniel Bevenius --- src/node_zlib.cc | 928 ++++++++++++++++------------ test/parallel/test-heapdump-zlib.js | 4 +- 2 files changed, 520 insertions(+), 412 deletions(-) diff --git a/src/node_zlib.cc b/src/node_zlib.cc index aef5e3e40ffa80..285742cd5ef94e 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -88,32 +88,75 @@ enum node_zlib_mode { #define GZIP_HEADER_ID1 0x1f #define GZIP_HEADER_ID2 0x8b -/** - * Deflate/Inflate - */ -class ZCtx : public AsyncWrap, public ThreadPoolWork { +struct CompressionError { + CompressionError(const char* message, const char* code, int err) + : message(message), code(code), err(err) {} + CompressionError() = default; + + const char* message = nullptr; + const char* code = nullptr; + int err = 0; + + inline bool IsError() const { return code != nullptr; } +}; + +class ZlibContext : public MemoryRetainer { + public: + ZlibContext() = default; + + // Streaming-related, should be available for all compression libraries: + void Close(); + void DoThreadPoolWork(); + void SetBuffers(char* in, uint32_t in_len, char* out, uint32_t out_len); + void SetFlush(int flush); + void GetAfterWriteOffsets(uint32_t* avail_in, uint32_t* avail_out) const; + CompressionError GetErrorInfo() const; + + // Zlib-specific: + CompressionError Init(int level, int window_bits, int mem_level, int strategy, + std::vector&& dictionary); + inline void SetMode(node_zlib_mode mode) { mode_ = mode; } + void SetAllocationFunctions(alloc_func alloc, free_func free, void* opaque); + CompressionError ResetStream(); + CompressionError SetParams(int level, int strategy); + + SET_MEMORY_INFO_NAME(ZlibContext) + SET_SELF_SIZE(ZlibContext) + + void MemoryInfo(MemoryTracker* tracker) const override { + tracker->TrackField("dictionary", dictionary_); + } + + private: + CompressionError ErrorForMessage(const char* message) const; + CompressionError SetDictionary(); + + int err_ = 0; + int flush_ = 0; + int level_ = 0; + int mem_level_ = 0; + node_zlib_mode mode_ = NONE; + int strategy_ = 0; + int window_bits_ = 0; + unsigned int gzip_id_bytes_read_ = 0; + std::vector dictionary_; + + z_stream strm_; + + DISALLOW_COPY_AND_ASSIGN(ZlibContext); +}; + +template +class CompressionStream : public AsyncWrap, public ThreadPoolWork { public: - ZCtx(Environment* env, Local wrap, node_zlib_mode mode) + CompressionStream(Environment* env, Local wrap) : AsyncWrap(env, wrap, AsyncWrap::PROVIDER_ZLIB), ThreadPoolWork(env), - err_(0), - flush_(0), - init_done_(false), - level_(0), - memLevel_(0), - mode_(mode), - strategy_(0), - windowBits_(0), - write_in_progress_(false), - pending_close_(false), - refs_(0), - gzip_id_bytes_read_(0), write_result_(nullptr) { MakeWeak(); } - - ~ZCtx() override { + ~CompressionStream() override { CHECK_EQ(false, write_in_progress_ && "write in progress"); Close(); CHECK_EQ(zlib_memory_, 0); @@ -127,27 +170,16 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { } pending_close_ = false; + closed_ = true; CHECK(init_done_ && "close before init"); - CHECK_LE(mode_, UNZIP); AllocScope alloc_scope(this); - int status = Z_OK; - if (mode_ == DEFLATE || mode_ == GZIP || mode_ == DEFLATERAW) { - status = deflateEnd(&strm_); - } else if (mode_ == INFLATE || mode_ == GUNZIP || mode_ == INFLATERAW || - mode_ == UNZIP) { - status = inflateEnd(&strm_); - } - - CHECK(status == Z_OK || status == Z_DATA_ERROR); - mode_ = NONE; - - dictionary_.clear(); + ctx_.Close(); } static void Close(const FunctionCallbackInfo& args) { - ZCtx* ctx; + CompressionStream* ctx; ASSIGN_OR_RETURN_UNWRAP(&ctx, args.Holder()); ctx->Close(); } @@ -198,7 +230,7 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { CHECK(Buffer::IsWithinBounds(out_off, out_len, Buffer::Length(out_buf))); out = Buffer::Data(out_buf) + out_off; - ZCtx* ctx; + CompressionStream* ctx; ASSIGN_OR_RETURN_UNWRAP(&ctx, args.Holder()); ctx->Write(flush, in, in_len, out, out_len); @@ -211,26 +243,22 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { AllocScope alloc_scope(this); CHECK(init_done_ && "write before init"); - CHECK(mode_ != NONE && "already finalized"); + CHECK(!closed_ && "already finalized"); CHECK_EQ(false, write_in_progress_); CHECK_EQ(false, pending_close_); write_in_progress_ = true; Ref(); - strm_.avail_in = in_len; - strm_.next_in = reinterpret_cast(in); - strm_.avail_out = out_len; - strm_.next_out = reinterpret_cast(out); - flush_ = flush; + ctx_.SetBuffers(in, in_len, out, out_len); + ctx_.SetFlush(flush); if (!async) { // sync version env()->PrintSyncTrace(); DoThreadPoolWork(); if (CheckError()) { - write_result_[0] = strm_.avail_out; - write_result_[1] = strm_.avail_in; + UpdateWriteResult(); write_in_progress_ = false; } Unref(); @@ -241,142 +269,24 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { ScheduleWork(); } + void UpdateWriteResult() { + ctx_.GetAfterWriteOffsets(&write_result_[1], &write_result_[0]); + } + // thread pool! // This function may be called multiple times on the uv_work pool // for a single write() call, until all of the input bytes have // been consumed. void DoThreadPoolWork() override { - const Bytef* next_expected_header_byte = nullptr; - - // If the avail_out is left at 0, then it means that it ran out - // of room. If there was avail_out left over, then it means - // that all of the input was consumed. - switch (mode_) { - case DEFLATE: - case GZIP: - case DEFLATERAW: - err_ = deflate(&strm_, flush_); - break; - case UNZIP: - if (strm_.avail_in > 0) { - next_expected_header_byte = strm_.next_in; - } - - switch (gzip_id_bytes_read_) { - case 0: - if (next_expected_header_byte == nullptr) { - break; - } - - if (*next_expected_header_byte == GZIP_HEADER_ID1) { - gzip_id_bytes_read_ = 1; - next_expected_header_byte++; - - if (strm_.avail_in == 1) { - // The only available byte was already read. - break; - } - } else { - mode_ = INFLATE; - break; - } - - // fallthrough - case 1: - if (next_expected_header_byte == nullptr) { - break; - } - - if (*next_expected_header_byte == GZIP_HEADER_ID2) { - gzip_id_bytes_read_ = 2; - mode_ = GUNZIP; - } else { - // There is no actual difference between INFLATE and INFLATERAW - // (after initialization). - mode_ = INFLATE; - } - - break; - default: - CHECK(0 && "invalid number of gzip magic number bytes read"); - } - - // fallthrough - case INFLATE: - case GUNZIP: - case INFLATERAW: - err_ = inflate(&strm_, flush_); - - // If data was encoded with dictionary (INFLATERAW will have it set in - // SetDictionary, don't repeat that here) - if (mode_ != INFLATERAW && - err_ == Z_NEED_DICT && - !dictionary_.empty()) { - // Load it - err_ = inflateSetDictionary(&strm_, - dictionary_.data(), - dictionary_.size()); - if (err_ == Z_OK) { - // And try to decode again - err_ = inflate(&strm_, flush_); - } else if (err_ == Z_DATA_ERROR) { - // Both inflateSetDictionary() and inflate() return Z_DATA_ERROR. - // Make it possible for After() to tell a bad dictionary from bad - // input. - err_ = Z_NEED_DICT; - } - } - - while (strm_.avail_in > 0 && - mode_ == GUNZIP && - err_ == Z_STREAM_END && - strm_.next_in[0] != 0x00) { - // Bytes remain in input buffer. Perhaps this is another compressed - // member in the same archive, or just trailing garbage. - // Trailing zero bytes are okay, though, since they are frequently - // used for padding. - - Reset(); - err_ = inflate(&strm_, flush_); - } - break; - default: - UNREACHABLE(); - } - - // pass any errors back to the main thread to deal with. - - // now After will emit the output, and - // either schedule another call to Process, - // or shift the queue and call Process. + ctx_.DoThreadPoolWork(); } bool CheckError() { - // Acceptable error states depend on the type of zlib stream. - switch (err_) { - case Z_OK: - case Z_BUF_ERROR: - if (strm_.avail_out != 0 && flush_ == Z_FINISH) { - Error("unexpected end of file"); - return false; - } - case Z_STREAM_END: - // normal statuses, not fatal - break; - case Z_NEED_DICT: - if (dictionary_.empty()) - Error("Missing dictionary"); - else - Error("Bad dictionary"); - return false; - default: - // something else. - Error("Zlib error"); - return false; - } - - return true; + const CompressionError err = ctx_.GetErrorInfo(); + if (!err.IsError()) return true; + EmitError(err); + return false; } @@ -400,8 +310,7 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { if (!CheckError()) return; - write_result_[0] = strm_.avail_out; - write_result_[1] = strm_.avail_in; + UpdateWriteResult(); // call the write() cb Local cb = PersistentToLocal(env()->isolate(), @@ -413,19 +322,15 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { } // TODO(addaleax): Switch to modern error system (node_errors.h). - void Error(const char* message) { + void EmitError(const CompressionError& err) { // If you hit this assertion, you forgot to enter the v8::Context first. CHECK_EQ(env()->context(), env()->isolate()->GetCurrentContext()); - if (strm_.msg != nullptr) { - message = strm_.msg; - } - HandleScope scope(env()->isolate()); Local args[3] = { - OneByteString(env()->isolate(), message), - Integer::New(env()->isolate(), err_), - OneByteString(env()->isolate(), ZlibStrerror(err_)) + OneByteString(env()->isolate(), err.message), + Integer::New(env()->isolate(), err.err), + OneByteString(env()->isolate(), err.code) }; MakeCallback(env()->onerror_string(), arraysize(args), args); @@ -435,12 +340,107 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { Close(); } + void MemoryInfo(MemoryTracker* tracker) const override { + tracker->TrackField("compression context", ctx_); + tracker->TrackFieldWithSize("zlib_memory", + zlib_memory_ + unreported_allocations_); + } + + protected: + CompressionContext* context() { return &ctx_; } + + void InitStream(uint32_t* write_result, Local write_js_callback) { + write_result_ = write_result; + write_js_callback_.Reset(env()->isolate(), write_js_callback); + init_done_ = true; + } + + // Allocation functions provided to zlib itself. We store the real size of + // the allocated memory chunk just before the "payload" memory we return + // to zlib. + // Because we use zlib off the thread pool, we can not report memory directly + // to V8; rather, we first store it as "unreported" memory in a separate + // field and later report it back from the main thread. + static void* AllocForZlib(void* data, uInt items, uInt size) { + CompressionStream* ctx = static_cast(data); + size_t real_size = + MultiplyWithOverflowCheck(static_cast(items), + static_cast(size)) + sizeof(size_t); + char* memory = UncheckedMalloc(real_size); + if (UNLIKELY(memory == nullptr)) return nullptr; + *reinterpret_cast(memory) = real_size; + ctx->unreported_allocations_.fetch_add(real_size, + std::memory_order_relaxed); + return memory + sizeof(size_t); + } + + static void FreeForZlib(void* data, void* pointer) { + if (UNLIKELY(pointer == nullptr)) return; + CompressionStream* ctx = static_cast(data); + char* real_pointer = static_cast(pointer) - sizeof(size_t); + size_t real_size = *reinterpret_cast(real_pointer); + ctx->unreported_allocations_.fetch_sub(real_size, + std::memory_order_relaxed); + free(real_pointer); + } + + // This is called on the main thread after zlib may have allocated something + // in order to report it back to V8. + void AdjustAmountOfExternalAllocatedMemory() { + ssize_t report = + unreported_allocations_.exchange(0, std::memory_order_relaxed); + if (report == 0) return; + CHECK_IMPLIES(report < 0, zlib_memory_ >= static_cast(-report)); + zlib_memory_ += report; + env()->isolate()->AdjustAmountOfExternalAllocatedMemory(report); + } + + struct AllocScope { + explicit AllocScope(CompressionStream* stream) : stream(stream) {} + ~AllocScope() { stream->AdjustAmountOfExternalAllocatedMemory(); } + CompressionStream* stream; + }; + + private: + void Ref() { + if (++refs_ == 1) { + ClearWeak(); + } + } + + void Unref() { + CHECK_GT(refs_, 0); + if (--refs_ == 0) { + MakeWeak(); + } + } + + bool init_done_ = false; + bool write_in_progress_ = false; + bool pending_close_ = false; + bool closed_ = false; + unsigned int refs_ = 0; + uint32_t* write_result_ = nullptr; + Persistent write_js_callback_; + std::atomic unreported_allocations_{0}; + size_t zlib_memory_ = 0; + + CompressionContext ctx_; +}; + +class ZlibStream : public CompressionStream { + public: + ZlibStream(Environment* env, Local wrap, node_zlib_mode mode) + : CompressionStream(env, wrap) { + context()->SetMode(mode); + } + static void New(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsInt32()); node_zlib_mode mode = static_cast(args[0].As()->Value()); - new ZCtx(env, args.This(), mode); + new ZlibStream(env, args.This(), mode); } // just pull the ints out of the args and call the other Init @@ -459,42 +459,25 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { "init(windowBits, level, memLevel, strategy, writeResult, writeCallback," " dictionary)"); - ZCtx* ctx; - ASSIGN_OR_RETURN_UNWRAP(&ctx, args.Holder()); + ZlibStream* wrap; + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); Local context = args.GetIsolate()->GetCurrentContext(); // windowBits is special. On the compression side, 0 is an invalid value. // But on the decompression side, a value of 0 for windowBits tells zlib // to use the window size in the zlib header of the compressed stream. - uint32_t windowBits; - if (!args[0]->Uint32Value(context).To(&windowBits)) return; - - if (!((windowBits == 0) && - (ctx->mode_ == INFLATE || - ctx->mode_ == GUNZIP || - ctx->mode_ == UNZIP))) { - CHECK( - (windowBits >= Z_MIN_WINDOWBITS && windowBits <= Z_MAX_WINDOWBITS) && - "invalid windowBits"); - } + uint32_t window_bits; + if (!args[0]->Uint32Value(context).To(&window_bits)) return; - int level; + int32_t level; if (!args[1]->Int32Value(context).To(&level)) return; - CHECK((level >= Z_MIN_LEVEL && level <= Z_MAX_LEVEL) && - "invalid compression level"); - uint32_t memLevel; - if (!args[2]->Uint32Value(context).To(&memLevel)) return; - CHECK((memLevel >= Z_MIN_MEMLEVEL && memLevel <= Z_MAX_MEMLEVEL) && - "invalid memlevel"); + uint32_t mem_level; + if (!args[2]->Uint32Value(context).To(&mem_level)) return; uint32_t strategy; if (!args[3]->Uint32Value(context).To(&strategy)) return; - CHECK((strategy == Z_FILTERED || strategy == Z_HUFFMAN_ONLY || - strategy == Z_RLE || strategy == Z_FIXED || - strategy == Z_DEFAULT_STRATEGY) && - "invalid strategy"); CHECK(args[4]->IsUint32Array()); Local array = args[4].As(); @@ -512,261 +495,385 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { data + Buffer::Length(args[6])); } - bool ret = ctx->Init(level, windowBits, memLevel, strategy, write_result, - write_js_callback, std::move(dictionary)); - if (ret) - ctx->SetDictionary(); + wrap->InitStream(write_result, write_js_callback); + + AllocScope alloc_scope(wrap); + wrap->context()->SetAllocationFunctions( + AllocForZlib, FreeForZlib, static_cast(wrap)); + const CompressionError err = + wrap->context()->Init(level, window_bits, mem_level, strategy, + std::move(dictionary)); + if (err.IsError()) + wrap->EmitError(err); - return args.GetReturnValue().Set(ret); + return args.GetReturnValue().Set(!err.IsError()); } static void Params(const FunctionCallbackInfo& args) { CHECK(args.Length() == 2 && "params(level, strategy)"); - ZCtx* ctx; - ASSIGN_OR_RETURN_UNWRAP(&ctx, args.Holder()); - Environment* env = ctx->env(); + ZlibStream* wrap; + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + Local context = args.GetIsolate()->GetCurrentContext(); int level; - if (!args[0]->Int32Value(env->context()).To(&level)) return; + if (!args[0]->Int32Value(context).To(&level)) return; int strategy; - if (!args[1]->Int32Value(env->context()).To(&strategy)) return; - ctx->Params(level, strategy); + if (!args[1]->Int32Value(context).To(&strategy)) return; + + AllocScope alloc_scope(wrap); + const CompressionError err = wrap->context()->SetParams(level, strategy); + if (err.IsError()) + wrap->EmitError(err); } static void Reset(const FunctionCallbackInfo &args) { - ZCtx* ctx; - ASSIGN_OR_RETURN_UNWRAP(&ctx, args.Holder()); - ctx->Reset(); - ctx->SetDictionary(); + ZlibStream* wrap; + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + + AllocScope alloc_scope(wrap); + const CompressionError err = wrap->context()->ResetStream(); + if (err.IsError()) + wrap->EmitError(err); } - bool Init(int level, int windowBits, int memLevel, - int strategy, uint32_t* write_result, - Local write_js_callback, - std::vector&& dictionary) { - AllocScope alloc_scope(this); - level_ = level; - windowBits_ = windowBits; - memLevel_ = memLevel; - strategy_ = strategy; + SET_MEMORY_INFO_NAME(ZlibStream) + SET_SELF_SIZE(ZlibStream) +}; - strm_.zalloc = AllocForZlib; - strm_.zfree = FreeForZlib; - strm_.opaque = static_cast(this); - flush_ = Z_NO_FLUSH; +void ZlibContext::Close() { + CHECK_LE(mode_, UNZIP); - err_ = Z_OK; + int status = Z_OK; + if (mode_ == DEFLATE || mode_ == GZIP || mode_ == DEFLATERAW) { + status = deflateEnd(&strm_); + } else if (mode_ == INFLATE || mode_ == GUNZIP || mode_ == INFLATERAW || + mode_ == UNZIP) { + status = inflateEnd(&strm_); + } - if (mode_ == GZIP || mode_ == GUNZIP) { - windowBits_ += 16; - } + CHECK(status == Z_OK || status == Z_DATA_ERROR); + mode_ = NONE; - if (mode_ == UNZIP) { - windowBits_ += 32; - } + dictionary_.clear(); +} - if (mode_ == DEFLATERAW || mode_ == INFLATERAW) { - windowBits_ *= -1; - } - switch (mode_) { - case DEFLATE: - case GZIP: - case DEFLATERAW: - err_ = deflateInit2(&strm_, - level_, - Z_DEFLATED, - windowBits_, - memLevel_, - strategy_); - break; - case INFLATE: - case GUNZIP: - case INFLATERAW: - case UNZIP: - err_ = inflateInit2(&strm_, windowBits_); - break; - default: - UNREACHABLE(); - } +void ZlibContext::DoThreadPoolWork() { + const Bytef* next_expected_header_byte = nullptr; + + // If the avail_out is left at 0, then it means that it ran out + // of room. If there was avail_out left over, then it means + // that all of the input was consumed. + switch (mode_) { + case DEFLATE: + case GZIP: + case DEFLATERAW: + err_ = deflate(&strm_, flush_); + break; + case UNZIP: + if (strm_.avail_in > 0) { + next_expected_header_byte = strm_.next_in; + } - dictionary_ = std::move(dictionary); + switch (gzip_id_bytes_read_) { + case 0: + if (next_expected_header_byte == nullptr) { + break; + } - write_in_progress_ = false; - init_done_ = true; + if (*next_expected_header_byte == GZIP_HEADER_ID1) { + gzip_id_bytes_read_ = 1; + next_expected_header_byte++; - if (err_ != Z_OK) { - dictionary_.clear(); - mode_ = NONE; - return false; - } + if (strm_.avail_in == 1) { + // The only available byte was already read. + break; + } + } else { + mode_ = INFLATE; + break; + } - write_result_ = write_result; - write_js_callback_.Reset(env()->isolate(), write_js_callback); - return true; - } + // fallthrough + case 1: + if (next_expected_header_byte == nullptr) { + break; + } - void SetDictionary() { - if (dictionary_.empty()) - return; + if (*next_expected_header_byte == GZIP_HEADER_ID2) { + gzip_id_bytes_read_ = 2; + mode_ = GUNZIP; + } else { + // There is no actual difference between INFLATE and INFLATERAW + // (after initialization). + mode_ = INFLATE; + } - err_ = Z_OK; + break; + default: + CHECK(0 && "invalid number of gzip magic number bytes read"); + } - switch (mode_) { - case DEFLATE: - case DEFLATERAW: - err_ = deflateSetDictionary(&strm_, - dictionary_.data(), - dictionary_.size()); - break; - case INFLATERAW: - // The other inflate cases will have the dictionary set when inflate() - // returns Z_NEED_DICT in Process() + // fallthrough + case INFLATE: + case GUNZIP: + case INFLATERAW: + err_ = inflate(&strm_, flush_); + + // If data was encoded with dictionary (INFLATERAW will have it set in + // SetDictionary, don't repeat that here) + if (mode_ != INFLATERAW && + err_ == Z_NEED_DICT && + !dictionary_.empty()) { + // Load it err_ = inflateSetDictionary(&strm_, dictionary_.data(), dictionary_.size()); - break; - default: - break; - } + if (err_ == Z_OK) { + // And try to decode again + err_ = inflate(&strm_, flush_); + } else if (err_ == Z_DATA_ERROR) { + // Both inflateSetDictionary() and inflate() return Z_DATA_ERROR. + // Make it possible for After() to tell a bad dictionary from bad + // input. + err_ = Z_NEED_DICT; + } + } - if (err_ != Z_OK) { - Error("Failed to set dictionary"); - } + while (strm_.avail_in > 0 && + mode_ == GUNZIP && + err_ == Z_STREAM_END && + strm_.next_in[0] != 0x00) { + // Bytes remain in input buffer. Perhaps this is another compressed + // member in the same archive, or just trailing garbage. + // Trailing zero bytes are okay, though, since they are frequently + // used for padding. + + ResetStream(); + err_ = inflate(&strm_, flush_); + } + break; + default: + UNREACHABLE(); } +} - void Params(int level, int strategy) { - AllocScope alloc_scope(this); - err_ = Z_OK; +void ZlibContext::SetBuffers(char* in, uint32_t in_len, + char* out, uint32_t out_len) { + strm_.avail_in = in_len; + strm_.next_in = reinterpret_cast(in); + strm_.avail_out = out_len; + strm_.next_out = reinterpret_cast(out); +} + + +void ZlibContext::SetFlush(int flush) { + flush_ = flush; +} - switch (mode_) { - case DEFLATE: - case DEFLATERAW: - err_ = deflateParams(&strm_, level, strategy); - break; - default: - break; - } - if (err_ != Z_OK && err_ != Z_BUF_ERROR) { - Error("Failed to set parameters"); +void ZlibContext::GetAfterWriteOffsets(uint32_t* avail_in, + uint32_t* avail_out) const { + *avail_in = strm_.avail_in; + *avail_out = strm_.avail_out; +} + + +CompressionError ZlibContext::ErrorForMessage(const char* message) const { + if (strm_.msg != nullptr) + message = strm_.msg; + + return CompressionError { message, ZlibStrerror(err_), err_ }; +} + + +CompressionError ZlibContext::GetErrorInfo() const { + // Acceptable error states depend on the type of zlib stream. + switch (err_) { + case Z_OK: + case Z_BUF_ERROR: + if (strm_.avail_out != 0 && flush_ == Z_FINISH) { + return ErrorForMessage("unexpected end of file"); } + case Z_STREAM_END: + // normal statuses, not fatal + break; + case Z_NEED_DICT: + if (dictionary_.empty()) + return ErrorForMessage("Missing dictionary"); + else + return ErrorForMessage("Bad dictionary"); + default: + // something else. + return ErrorForMessage("Zlib error"); } - void Reset() { - AllocScope alloc_scope(this); + return CompressionError {}; +} - err_ = Z_OK; - - switch (mode_) { - case DEFLATE: - case DEFLATERAW: - case GZIP: - err_ = deflateReset(&strm_); - break; - case INFLATE: - case INFLATERAW: - case GUNZIP: - err_ = inflateReset(&strm_); - break; - default: - break; - } - if (err_ != Z_OK) { - Error("Failed to reset stream"); - } +CompressionError ZlibContext::ResetStream() { + err_ = Z_OK; + + switch (mode_) { + case DEFLATE: + case DEFLATERAW: + case GZIP: + err_ = deflateReset(&strm_); + break; + case INFLATE: + case INFLATERAW: + case GUNZIP: + err_ = inflateReset(&strm_); + break; + default: + break; } - void MemoryInfo(MemoryTracker* tracker) const override { - tracker->TrackField("dictionary", dictionary_); - tracker->TrackFieldWithSize("zlib_memory", - zlib_memory_ + unreported_allocations_); + if (err_ != Z_OK) + return ErrorForMessage("Failed to reset stream"); + + return SetDictionary(); +} + + +void ZlibContext::SetAllocationFunctions(alloc_func alloc, + free_func free, + void* opaque) { + strm_.zalloc = alloc; + strm_.zfree = free; + strm_.opaque = opaque; +} + + +CompressionError ZlibContext::Init( + int level, int window_bits, int mem_level, int strategy, + std::vector&& dictionary) { + if (!((window_bits == 0) && + (mode_ == INFLATE || + mode_ == GUNZIP || + mode_ == UNZIP))) { + CHECK( + (window_bits >= Z_MIN_WINDOWBITS && window_bits <= Z_MAX_WINDOWBITS) && + "invalid windowBits"); } - SET_MEMORY_INFO_NAME(ZCtx) - SET_SELF_SIZE(ZCtx) + CHECK((level >= Z_MIN_LEVEL && level <= Z_MAX_LEVEL) && + "invalid compression level"); - private: - void Ref() { - if (++refs_ == 1) { - ClearWeak(); - } + CHECK((mem_level >= Z_MIN_MEMLEVEL && mem_level <= Z_MAX_MEMLEVEL) && + "invalid memlevel"); + + CHECK((strategy == Z_FILTERED || strategy == Z_HUFFMAN_ONLY || + strategy == Z_RLE || strategy == Z_FIXED || + strategy == Z_DEFAULT_STRATEGY) && + "invalid strategy"); + + level_ = level; + window_bits_ = window_bits; + mem_level_ = mem_level; + strategy_ = strategy; + + flush_ = Z_NO_FLUSH; + + err_ = Z_OK; + + if (mode_ == GZIP || mode_ == GUNZIP) { + window_bits_ += 16; } - void Unref() { - CHECK_GT(refs_, 0); - if (--refs_ == 0) { - MakeWeak(); - } + if (mode_ == UNZIP) { + window_bits_ += 32; } - // Allocation functions provided to zlib itself. We store the real size of - // the allocated memory chunk just before the "payload" memory we return - // to zlib. - // Because we use zlib off the thread pool, we can not report memory directly - // to V8; rather, we first store it as "unreported" memory in a separate - // field and later report it back from the main thread. - static void* AllocForZlib(void* data, uInt items, uInt size) { - ZCtx* ctx = static_cast(data); - size_t real_size = - MultiplyWithOverflowCheck(static_cast(items), - static_cast(size)) + sizeof(size_t); - char* memory = UncheckedMalloc(real_size); - if (UNLIKELY(memory == nullptr)) return nullptr; - *reinterpret_cast(memory) = real_size; - ctx->unreported_allocations_.fetch_add(real_size, - std::memory_order_relaxed); - return memory + sizeof(size_t); + if (mode_ == DEFLATERAW || mode_ == INFLATERAW) { + window_bits_ *= -1; } - static void FreeForZlib(void* data, void* pointer) { - if (UNLIKELY(pointer == nullptr)) return; - ZCtx* ctx = static_cast(data); - char* real_pointer = static_cast(pointer) - sizeof(size_t); - size_t real_size = *reinterpret_cast(real_pointer); - ctx->unreported_allocations_.fetch_sub(real_size, - std::memory_order_relaxed); - free(real_pointer); + switch (mode_) { + case DEFLATE: + case GZIP: + case DEFLATERAW: + err_ = deflateInit2(&strm_, + level_, + Z_DEFLATED, + window_bits_, + mem_level_, + strategy_); + break; + case INFLATE: + case GUNZIP: + case INFLATERAW: + case UNZIP: + err_ = inflateInit2(&strm_, window_bits_); + break; + default: + UNREACHABLE(); } - // This is called on the main thread after zlib may have allocated something - // in order to report it back to V8. - void AdjustAmountOfExternalAllocatedMemory() { - ssize_t report = - unreported_allocations_.exchange(0, std::memory_order_relaxed); - if (report == 0) return; - CHECK_IMPLIES(report < 0, zlib_memory_ >= static_cast(-report)); - zlib_memory_ += report; - env()->isolate()->AdjustAmountOfExternalAllocatedMemory(report); + dictionary_ = std::move(dictionary); + + if (err_ != Z_OK) { + dictionary_.clear(); + mode_ = NONE; + return ErrorForMessage(nullptr); } - struct AllocScope { - explicit AllocScope(ZCtx* ctx) : ctx(ctx) {} - ~AllocScope() { ctx->AdjustAmountOfExternalAllocatedMemory(); } - ZCtx* ctx; - }; + return SetDictionary(); +} - std::vector dictionary_; - int err_; - int flush_; - bool init_done_; - int level_; - int memLevel_; - node_zlib_mode mode_; - int strategy_; - z_stream strm_; - int windowBits_; - bool write_in_progress_; - bool pending_close_; - unsigned int refs_; - unsigned int gzip_id_bytes_read_; - uint32_t* write_result_; - Persistent write_js_callback_; - std::atomic unreported_allocations_{0}; - size_t zlib_memory_ = 0; -}; + +CompressionError ZlibContext::SetDictionary() { + if (dictionary_.empty()) + return CompressionError {}; + + err_ = Z_OK; + + switch (mode_) { + case DEFLATE: + case DEFLATERAW: + err_ = deflateSetDictionary(&strm_, + dictionary_.data(), + dictionary_.size()); + break; + case INFLATERAW: + // The other inflate cases will have the dictionary set when inflate() + // returns Z_NEED_DICT in Process() + err_ = inflateSetDictionary(&strm_, + dictionary_.data(), + dictionary_.size()); + break; + default: + break; + } + + if (err_ != Z_OK) { + return ErrorForMessage("Failed to set dictionary"); + } + + return CompressionError {}; +} + + +CompressionError ZlibContext::SetParams(int level, int strategy) { + err_ = Z_OK; + + switch (mode_) { + case DEFLATE: + case DEFLATERAW: + err_ = deflateParams(&strm_, level, strategy); + break; + default: + break; + } + + if (err_ != Z_OK && err_ != Z_BUF_ERROR) { + return ErrorForMessage("Failed to set parameters"); + } + + return CompressionError {}; +} void Initialize(Local target, @@ -774,17 +881,18 @@ void Initialize(Local target, Local context, void* priv) { Environment* env = Environment::GetCurrent(context); - Local z = env->NewFunctionTemplate(ZCtx::New); + Local z = env->NewFunctionTemplate(ZlibStream::New); z->InstanceTemplate()->SetInternalFieldCount(1); z->Inherit(AsyncWrap::GetConstructorTemplate(env)); - env->SetProtoMethod(z, "write", ZCtx::Write); - env->SetProtoMethod(z, "writeSync", ZCtx::Write); - env->SetProtoMethod(z, "init", ZCtx::Init); - env->SetProtoMethod(z, "close", ZCtx::Close); - env->SetProtoMethod(z, "params", ZCtx::Params); - env->SetProtoMethod(z, "reset", ZCtx::Reset); + env->SetProtoMethod(z, "write", ZlibStream::Write); + env->SetProtoMethod(z, "writeSync", ZlibStream::Write); + env->SetProtoMethod(z, "close", ZlibStream::Close); + + env->SetProtoMethod(z, "init", ZlibStream::Init); + env->SetProtoMethod(z, "params", ZlibStream::Params); + env->SetProtoMethod(z, "reset", ZlibStream::Reset); Local zlibString = FIXED_ONE_BYTE_STRING(env->isolate(), "Zlib"); z->SetClassName(zlibString); diff --git a/test/parallel/test-heapdump-zlib.js b/test/parallel/test-heapdump-zlib.js index f79e345821ea50..0f86576bd1f2fa 100644 --- a/test/parallel/test-heapdump-zlib.js +++ b/test/parallel/test-heapdump-zlib.js @@ -4,10 +4,10 @@ require('../common'); const { validateSnapshotNodes } = require('../common/heap'); const zlib = require('zlib'); -validateSnapshotNodes('Node / ZCtx', []); +validateSnapshotNodes('Node / ZlibStream', []); // eslint-disable-next-line no-unused-vars const gunzip = zlib.createGunzip(); -validateSnapshotNodes('Node / ZCtx', [ +validateSnapshotNodes('Node / ZlibStream', [ { children: [ { node_name: 'Zlib', edge_name: 'wrapped' }, From 79d7733c59b9808e33e0cdb4bd174e28e2a2aef9 Mon Sep 17 00:00:00 2001 From: Jonathan Samines Date: Fri, 12 Oct 2018 10:47:28 -0600 Subject: [PATCH 192/328] test: fix strictEqual arguments order Fix strictEqual assertion arguments order to conform to the function signature in buffer tests PR-URL: https://github.com/nodejs/node/pull/23486 Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-buffer-readuint.js | 36 +++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/test/parallel/test-buffer-readuint.js b/test/parallel/test-buffer-readuint.js index 8ffcbab850d5fb..ff66bc7ea16a09 100644 --- a/test/parallel/test-buffer-readuint.js +++ b/test/parallel/test-buffer-readuint.js @@ -47,37 +47,37 @@ const assert = require('assert'); // Test 8 bit unsigned integers { const data = Buffer.from([0xff, 0x2a, 0x2a, 0x2a]); - assert.strictEqual(255, data.readUInt8(0)); - assert.strictEqual(42, data.readUInt8(1)); - assert.strictEqual(42, data.readUInt8(2)); - assert.strictEqual(42, data.readUInt8(3)); + assert.strictEqual(data.readUInt8(0), 255); + assert.strictEqual(data.readUInt8(1), 42); + assert.strictEqual(data.readUInt8(2), 42); + assert.strictEqual(data.readUInt8(3), 42); } // Test 16 bit unsigned integers { const data = Buffer.from([0x00, 0x2a, 0x42, 0x3f]); - assert.strictEqual(0x2a, data.readUInt16BE(0)); - assert.strictEqual(0x2a42, data.readUInt16BE(1)); - assert.strictEqual(0x423f, data.readUInt16BE(2)); - assert.strictEqual(0x2a00, data.readUInt16LE(0)); - assert.strictEqual(0x422a, data.readUInt16LE(1)); - assert.strictEqual(0x3f42, data.readUInt16LE(2)); + assert.strictEqual(data.readUInt16BE(0), 0x2a); + assert.strictEqual(data.readUInt16BE(1), 0x2a42); + assert.strictEqual(data.readUInt16BE(2), 0x423f); + assert.strictEqual(data.readUInt16LE(0), 0x2a00); + assert.strictEqual(data.readUInt16LE(1), 0x422a); + assert.strictEqual(data.readUInt16LE(2), 0x3f42); data[0] = 0xfe; data[1] = 0xfe; - assert.strictEqual(0xfefe, data.readUInt16BE(0)); - assert.strictEqual(0xfefe, data.readUInt16LE(0)); + assert.strictEqual(data.readUInt16BE(0), 0xfefe); + assert.strictEqual(data.readUInt16LE(0), 0xfefe); } // Test 32 bit unsigned integers { const data = Buffer.from([0x32, 0x65, 0x42, 0x56, 0x23, 0xff]); - assert.strictEqual(0x32654256, data.readUInt32BE(0)); - assert.strictEqual(0x65425623, data.readUInt32BE(1)); - assert.strictEqual(0x425623ff, data.readUInt32BE(2)); - assert.strictEqual(0x56426532, data.readUInt32LE(0)); - assert.strictEqual(0x23564265, data.readUInt32LE(1)); - assert.strictEqual(0xff235642, data.readUInt32LE(2)); + assert.strictEqual(data.readUInt32BE(0), 0x32654256); + assert.strictEqual(data.readUInt32BE(1), 0x65425623); + assert.strictEqual(data.readUInt32BE(2), 0x425623ff); + assert.strictEqual(data.readUInt32LE(0), 0x56426532); + assert.strictEqual(data.readUInt32LE(1), 0x23564265); + assert.strictEqual(data.readUInt32LE(2), 0xff235642); } // Test UInt From 148ae30fd77def2883d16a80ab554e9accb2a2d7 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Wed, 3 Oct 2018 18:50:21 -0400 Subject: [PATCH 193/328] tools,test: cleanup and dedup code * Hoist common code to base class (`GetTestStatus`, and the `section` property to `TestConfiguration`) * Replace ListSet with the built in set * Remove ClassifiedTest * Inline PrintReport * How cases_to_run are filtered PR-URL: https://github.com/nodejs/node/pull/23251 Reviewed-By: Rich Trott --- test/message/testcfg.py | 11 +-- test/pseudo-tty/testcfg.py | 11 +-- test/testpy/__init__.py | 10 +-- tools/test.py | 150 +++++++++++++------------------------ 4 files changed, 58 insertions(+), 124 deletions(-) diff --git a/test/message/testcfg.py b/test/message/testcfg.py index 819dfa12c5b631..7e8d73bb39acd7 100644 --- a/test/message/testcfg.py +++ b/test/message/testcfg.py @@ -108,10 +108,6 @@ def GetSource(self): class MessageTestConfiguration(test.TestConfiguration): - - def __init__(self, context, root): - super(MessageTestConfiguration, self).__init__(context, root) - def Ls(self, path): if isdir(path): return [f for f in os.listdir(path) @@ -135,11 +131,6 @@ def ListTests(self, current_path, path, arch, mode): def GetBuildRequirements(self): return ['sample', 'sample=shell'] - def GetTestStatus(self, sections, defs): - status_file = join(self.root, 'message.status') - if exists(status_file): - test.ReadConfigurationInto(status_file, sections, defs) - def GetConfiguration(context, root): - return MessageTestConfiguration(context, root) + return MessageTestConfiguration(context, root, 'message') diff --git a/test/pseudo-tty/testcfg.py b/test/pseudo-tty/testcfg.py index 920789844583de..a5b7917bc05a46 100644 --- a/test/pseudo-tty/testcfg.py +++ b/test/pseudo-tty/testcfg.py @@ -122,10 +122,6 @@ def RunCommand(self, command, env): class TTYTestConfiguration(test.TestConfiguration): - - def __init__(self, context, root): - super(TTYTestConfiguration, self).__init__(context, root) - def Ls(self, path): if isdir(path): return [f[:-3] for f in os.listdir(path) if f.endswith('.js')] @@ -155,11 +151,6 @@ def ListTests(self, current_path, path, arch, mode): def GetBuildRequirements(self): return ['sample', 'sample=shell'] - def GetTestStatus(self, sections, defs): - status_file = join(self.root, 'pseudo-tty.status') - if exists(status_file): - test.ReadConfigurationInto(status_file, sections, defs) - def GetConfiguration(context, root): - return TTYTestConfiguration(context, root) + return TTYTestConfiguration(context, root, 'pseudo-tty') diff --git a/test/testpy/__init__.py b/test/testpy/__init__.py index 8b5b2f6b48f09f..27d7124bf2ed16 100644 --- a/test/testpy/__init__.py +++ b/test/testpy/__init__.py @@ -95,11 +95,10 @@ def GetCommand(self): def GetSource(self): return open(self.file).read() -class SimpleTestConfiguration(test.TestConfiguration): +class SimpleTestConfiguration(test.TestConfiguration): def __init__(self, context, root, section, additional=None): - super(SimpleTestConfiguration, self).__init__(context, root) - self.section = section + super(SimpleTestConfiguration, self).__init__(context, root, section) if additional is not None: self.additional_flags = additional else: @@ -122,11 +121,6 @@ def ListTests(self, current_path, path, arch, mode): def GetBuildRequirements(self): return ['sample', 'sample=shell'] - def GetTestStatus(self, sections, defs): - status_file = join(self.root, '%s.status' % (self.section)) - if exists(status_file): - test.ReadConfigurationInto(status_file, sections, defs) - class ParallelTestConfiguration(SimpleTestConfiguration): def __init__(self, context, root, section, additional=None): super(ParallelTestConfiguration, self).__init__(context, root, section, diff --git a/tools/test.py b/tools/test.py index c5c9fb53c07626..3d62eedd1631e2 100755 --- a/tools/test.py +++ b/tools/test.py @@ -131,7 +131,7 @@ def RunSingle(self, parallel, thread_id): test = self.sequential_queue.get_nowait() except Empty: return - case = test.case + case = test case.thread_id = thread_id self.lock.acquire() self.AboutToRun(case) @@ -780,10 +780,10 @@ def CarCdr(path): class TestConfiguration(object): - - def __init__(self, context, root): + def __init__(self, context, root, section): self.context = context self.root = root + self.section = section def Contains(self, path, file): if len(path) > len(file): @@ -794,7 +794,9 @@ def Contains(self, path, file): return True def GetTestStatus(self, sections, defs): - pass + status_file = join(self.root, '%s.status' % self.section) + if exists(status_file): + ReadConfigurationInto(status_file, sections, defs) class TestSuite(object): @@ -934,6 +936,7 @@ def RunTestCases(cases_to_run, progress, tasks, flaky_tests_mode): # ------------------------------------------- +RUN = 'run' SKIP = 'skip' FAIL = 'fail' PASS = 'pass' @@ -963,8 +966,8 @@ def __init__(self, name): self.name = name def GetOutcomes(self, env, defs): - if self.name in env: return ListSet([env[self.name]]) - else: return Nothing() + if self.name in env: return set([env[self.name]]) + else: return set() class Outcome(Expression): @@ -976,45 +979,7 @@ def GetOutcomes(self, env, defs): if self.name in defs: return defs[self.name].GetOutcomes(env, defs) else: - return ListSet([self.name]) - - -class Set(object): - pass - - -class ListSet(Set): - - def __init__(self, elms): - self.elms = elms - - def __str__(self): - return "ListSet%s" % str(self.elms) - - def Intersect(self, that): - if not isinstance(that, ListSet): - return that.Intersect(self) - return ListSet([ x for x in self.elms if x in that.elms ]) - - def Union(self, that): - if not isinstance(that, ListSet): - return that.Union(self) - return ListSet(self.elms + [ x for x in that.elms if x not in self.elms ]) - - def IsEmpty(self): - return len(self.elms) == 0 - - -class Nothing(Set): - - def Intersect(self, that): - return self - - def Union(self, that): - return that - - def IsEmpty(self): - return True + return set([self.name]) class Operation(Expression): @@ -1030,21 +995,23 @@ def Evaluate(self, env, defs): elif self.op == 'if': return False elif self.op == '==': - inter = self.left.GetOutcomes(env, defs).Intersect(self.right.GetOutcomes(env, defs)) - return not inter.IsEmpty() + inter = self.left.GetOutcomes(env, defs) & self.right.GetOutcomes(env, defs) + return bool(inter) else: assert self.op == '&&' return self.left.Evaluate(env, defs) and self.right.Evaluate(env, defs) def GetOutcomes(self, env, defs): if self.op == '||' or self.op == ',': - return self.left.GetOutcomes(env, defs).Union(self.right.GetOutcomes(env, defs)) + return self.left.GetOutcomes(env, defs) | self.right.GetOutcomes(env, defs) elif self.op == 'if': - if self.right.Evaluate(env, defs): return self.left.GetOutcomes(env, defs) - else: return Nothing() + if self.right.Evaluate(env, defs): + return self.left.GetOutcomes(env, defs) + else: + return set() else: assert self.op == '&&' - return self.left.GetOutcomes(env, defs).Intersect(self.right.GetOutcomes(env, defs)) + return self.left.GetOutcomes(env, defs) & self.right.GetOutcomes(env, defs) def IsAlpha(str): @@ -1223,15 +1190,6 @@ def ParseCondition(expr): return ast -class ClassifiedTest(object): - - def __init__(self, case, outcomes): - self.case = case - self.outcomes = outcomes - self.parallel = self.case.parallel - self.disable_core_files = self.case.disable_core_files - - class Configuration(object): """The parsed contents of a configuration file""" @@ -1281,9 +1239,7 @@ def __init__(self, raw_path, path, value): self.value = value def GetOutcomes(self, env, defs): - set = self.value.GetOutcomes(env, defs) - assert isinstance(set, ListSet) - return set.elms + return self.value.GetOutcomes(env, defs) def Contains(self, path): if len(self.path) > len(path): @@ -1428,6 +1384,7 @@ def ProcessOptions(options): options.mode = options.mode.split(',') options.run = options.run.split(',') options.skip_tests = options.skip_tests.split(',') + options.skip_tests.remove("") if options.run == [""]: options.run = None elif len(options.run) != 2: @@ -1450,7 +1407,7 @@ def ProcessOptions(options): # tends to exaggerate the number of available cpus/cores. cores = os.environ.get('JOBS') options.j = int(cores) if cores is not None else multiprocessing.cpu_count() - if options.flaky_tests not in ["run", "skip", "dontcare"]: + if options.flaky_tests not in [RUN, SKIP, DONTCARE]: print "Unknown flaky-tests mode %s" % options.flaky_tests return False return True @@ -1464,18 +1421,6 @@ def ProcessOptions(options): * %(fail)4d tests are expected to fail that we should fix\ """ -def PrintReport(cases): - def IsFailOk(o): - return (len(o) == 2) and (FAIL in o) and (OKAY in o) - unskipped = [c for c in cases if not SKIP in c.outcomes] - print REPORT_TEMPLATE % { - 'total': len(cases), - 'skipped': len(cases) - len(unskipped), - 'pass': len([t for t in unskipped if list(t.outcomes) == [PASS]]), - 'fail_ok': len([t for t in unskipped if IsFailOk(t.outcomes)]), - 'fail': len([t for t in unskipped if list(t.outcomes) == [FAIL]]) - } - class Pattern(object): @@ -1534,6 +1479,14 @@ def FormatTime(d): return time.strftime("%M:%S.", time.gmtime(d)) + ("%03i" % millis) +def FormatTimedelta(td): + if hasattr(td.total, 'total_seconds'): + d = td.total_seconds() + else: # python2.6 compat + d = td.seconds + (td.microseconds / 10.0**6) + return FormatTime(d) + + def PrintCrashed(code): if utils.IsWindows(): return "CRASHED" @@ -1713,25 +1666,32 @@ def Main(): print "Could not create the temporary directory", options.temp_dir sys.exit(1) - if options.report: - PrintReport(all_cases) - - result = None - def DoSkip(case): - # A list of tests that should be skipped can be provided. This is - # useful for tests that fail in some environments, e.g., under coverage. - if options.skip_tests != [""]: - if [ st for st in options.skip_tests if st in case.case.file ]: - return True - if SKIP in case.outcomes or SLOW in case.outcomes: + def should_keep(case): + if any((s in case.file) for s in options.skip_tests): + return False + elif SKIP in case.outcomes: + return False + elif (options.flaky_tests == SKIP) and (set([FLAKY]) & case.outcomes): + return False + else: return True - return FLAKY in case.outcomes and options.flaky_tests == SKIP - cases_to_run = [ c for c in all_cases if not DoSkip(c) ] + + cases_to_run = filter(should_keep, all_cases) + + if options.report: + print(REPORT_TEMPLATE % { + 'total': len(all_cases), + 'skipped': len(all_cases) - len(cases_to_run), + 'pass': len([t for t in cases_to_run if PASS in t.outcomes]), + 'fail_ok': len([t for t in cases_to_run if t.outcomes == set([FAIL, OKAY])]), + 'fail': len([t for t in cases_to_run if t.outcomes == set([FAIL])]) + }) + if options.run is not None: # Must ensure the list of tests is sorted before selecting, to avoid # silent errors if this file is changed to list the tests in a way that # can be different in different machines - cases_to_run.sort(key=lambda c: (c.case.arch, c.case.mode, c.case.file)) + cases_to_run.sort(key=lambda c: (c.arch, c.mode, c.file)) cases_to_run = [ cases_to_run[i] for i in xrange(options.run[0], len(cases_to_run), @@ -1756,13 +1716,11 @@ def DoSkip(case): # test output. print sys.stderr.write("--- Total time: %s ---\n" % FormatTime(duration)) - timed_tests = [ t.case for t in cases_to_run if not t.case.duration is None ] + timed_tests = [ t for t in cases_to_run if not t.duration is None ] timed_tests.sort(lambda a, b: a.CompareTime(b)) - index = 1 - for entry in timed_tests[:20]: - t = FormatTime(entry.duration.total_seconds()) - sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel())) - index += 1 + for i, entry in enumerate(timed_tests[:20], start=1): + t = FormatTimedelta(entry.duration) + sys.stderr.write("%4i (%s) %s\n" % (i, t, entry.GetLabel())) return result From 9e03393ff26c27199f49b26608e06194ab23cfbc Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Wed, 10 Oct 2018 13:22:55 -0400 Subject: [PATCH 194/328] tools,test: add list of slow tests they will be skipped if run with `--flaky-tests=skip` PR-URL: https://github.com/nodejs/node/pull/23251 Reviewed-By: Rich Trott --- test/root.status | 190 +++++++++++++++++++++++++++++++++++++++++++++++ tools/test.py | 45 ++++++----- 2 files changed, 211 insertions(+), 24 deletions(-) create mode 100644 test/root.status diff --git a/test/root.status b/test/root.status new file mode 100644 index 00000000000000..9ed9004c2169d0 --- /dev/null +++ b/test/root.status @@ -0,0 +1,190 @@ +[$mode==debug] +async-hooks/test-callback-error: SLOW +async-hooks/test-callback-error: SLOW +async-hooks/test-emit-init: SLOW +async-hooks/test-emit-init: SLOW +async-hooks/test-querywrap: SLOW +async-hooks/test-querywrap: SLOW +async-hooks/test-tlswrap: SLOW +async-hooks/test-tlswrap: SLOW +message/eval_messages: SLOW +message/stdin_messages: SLOW +parallel/test-benchmark-assert: SLOW +parallel/test-benchmark-cluster: SLOW +parallel/test-benchmark-crypto: SLOW +parallel/test-benchmark-dns: SLOW +parallel/test-benchmark-domain: SLOW +parallel/test-benchmark-es: SLOW +parallel/test-benchmark-events: SLOW +parallel/test-benchmark-fs: SLOW +parallel/test-benchmark-misc: SLOW +parallel/test-benchmark-module: SLOW +parallel/test-benchmark-os: SLOW +parallel/test-benchmark-process: SLOW +parallel/test-benchmark-querystring: SLOW +parallel/test-benchmark-streams: SLOW +parallel/test-benchmark-string_decoder: SLOW +parallel/test-benchmark-timers: SLOW +parallel/test-benchmark-url: SLOW +parallel/test-benchmark-util: SLOW +parallel/test-benchmark-v8: SLOW +parallel/test-benchmark-vm: SLOW +parallel/test-benchmark-zlib: SLOW +parallel/test-buffer-constructor-node-modules-paths: SLOW +parallel/test-buffer-indexof: SLOW +parallel/test-child-process-spawnsync-input: SLOW +parallel/test-child-process-windows-hide: SLOW +parallel/test-cli-eval: SLOW +parallel/test-cli-eval-event: SLOW +parallel/test-cli-node-options: SLOW +parallel/test-cli-node-options-disallowed: SLOW +parallel/test-cli-node-print-help: SLOW +parallel/test-cli-syntax: SLOW +parallel/test-cluster-basic: SLOW +parallel/test-cluster-bind-privileged-port: SLOW +parallel/test-cluster-bind-twice: SLOW +parallel/test-cluster-disconnect: SLOW +parallel/test-cluster-disconnect-idle-worker: SLOW +parallel/test-crypto-fips: SLOW +parallel/test-domain-abort-on-uncaught: SLOW +parallel/test-domain-uncaught-exception: SLOW +parallel/test-domain-with-abort-on-uncaught-exception: SLOW +parallel/test-env-var-no-warnings: SLOW +parallel/test-error-reporting: SLOW +parallel/test-eslint-alphabetize-errors: SLOW +parallel/test-eslint-buffer-constructor: SLOW +parallel/test-eslint-crypto-check: SLOW +parallel/test-eslint-documented-errors: SLOW +parallel/test-eslint-duplicate-requires: SLOW +parallel/test-eslint-eslint-check: SLOW +parallel/test-eslint-inspector-check: SLOW +parallel/test-eslint-lowercase-name-for-primitive: SLOW +parallel/test-eslint-no-let-in-for-declaration: SLOW +parallel/test-eslint-no-unescaped-regexp-dot: SLOW +parallel/test-eslint-number-isnan: SLOW +parallel/test-eslint-prefer-assert-iferror: SLOW +parallel/test-eslint-prefer-assert-methods: SLOW +parallel/test-eslint-prefer-common-expectserror: SLOW +parallel/test-eslint-prefer-common-mustnotcall: SLOW +parallel/test-eslint-prefer-util-format-errors: SLOW +parallel/test-eslint-require-buffer: SLOW +parallel/test-eslint-required-modules: SLOW +parallel/test-fs-read-stream-concurrent-reads: SLOW +parallel/test-gc-tls-external-memory: SLOW +parallel/test-heapdump-dns: SLOW +parallel/test-heapdump-fs-promise: SLOW +parallel/test-heapdump-http2: SLOW +parallel/test-heapdump-inspector: SLOW +parallel/test-heapdump-tls: SLOW +parallel/test-heapdump-worker: SLOW +parallel/test-heapdump-zlib: SLOW +parallel/test-http-client-timeout-option-with-agent: SLOW +parallel/test-http-pipeline-flood: SLOW +parallel/test-http-pipeline-requests-connection-leak: SLOW +parallel/test-http2-forget-closed-streams: SLOW +parallel/test-http2-multiplex: SLOW +parallel/test-inspector-tracing-domain: SLOW +parallel/test-listen-fd-cluster: SLOW +parallel/test-module-loading-globalpaths: SLOW +parallel/test-module-main-fail: SLOW +parallel/test-module-main-preserve-symlinks-fail: SLOW +parallel/test-net-pingpong: SLOW +parallel/test-next-tick-fixed-queue-regression: SLOW +parallel/test-npm-install: SLOW +parallel/test-preload: SLOW +parallel/test-repl: SLOW +parallel/test-repl-tab-complete: SLOW +parallel/test-repl-top-level-await: SLOW +parallel/test-stdio-pipe-access: SLOW +parallel/test-stream-pipeline: SLOW +parallel/test-stream2-read-sync-stack: SLOW +parallel/test-stringbytes-external: SLOW +parallel/test-sync-io-option: SLOW +parallel/test-tick-processor-arguments: SLOW +parallel/test-tls-env-bad-extra-ca: SLOW +parallel/test-tls-env-extra-ca: SLOW +parallel/test-tls-handshake-exception: SLOW +parallel/test-tls-securepair-leak: SLOW +parallel/test-tls-server-verify: SLOW +parallel/test-tls-session-cache: SLOW +parallel/test-tls-ticket-cluster: SLOW +parallel/test-tls-timeout-server: SLOW +parallel/test-tls-timeout-server-2: SLOW +parallel/test-tls-tlswrap-segfault: SLOW +parallel/test-trace-events-all: SLOW +parallel/test-trace-events-api: SLOW +parallel/test-trace-events-async-hooks: SLOW +parallel/test-trace-events-binding: SLOW +parallel/test-trace-events-bootstrap: SLOW +parallel/test-trace-events-category-used: SLOW +parallel/test-trace-events-file-pattern: SLOW +parallel/test-trace-events-fs-sync: SLOW +parallel/test-trace-events-metadata: SLOW +parallel/test-trace-events-none: SLOW +parallel/test-trace-events-perf: SLOW +parallel/test-trace-events-process-exit: SLOW +parallel/test-trace-events-promises: SLOW +parallel/test-trace-events-v8: SLOW +parallel/test-trace-events-vm: SLOW +parallel/test-trace-events-worker-metadata: SLOW +parallel/test-tracing-no-crash: SLOW +parallel/test-url-relative: SLOW +parallel/test-util-callbackify: SLOW +parallel/test-util-inspect: SLOW +parallel/test-util-inspect-long-running: SLOW +parallel/test-util-types: SLOW +parallel/test-v8-coverage: SLOW +parallel/test-vm-api-handles-getter-errors: SLOW +parallel/test-vm-basic: SLOW +parallel/test-vm-cached-data: SLOW +parallel/test-vm-sigint: SLOW +parallel/test-vm-sigint-existing-handler: SLOW +parallel/test-vm-symbols: SLOW +parallel/test-vm-syntax-error-message: SLOW +parallel/test-vm-syntax-error-stderr: SLOW +parallel/test-worker: SLOW +parallel/test-worker-cleanup-handles: SLOW +parallel/test-worker-debug: SLOW +parallel/test-worker-esmodule: SLOW +parallel/test-worker-exit-code: SLOW +parallel/test-worker-memory: SLOW +parallel/test-worker-message-channel: SLOW +parallel/test-worker-message-channel-sharedarraybuffer: SLOW +parallel/test-worker-nexttick-terminate: SLOW +parallel/test-worker-onmessage: SLOW +parallel/test-worker-onmessage-not-a-function: SLOW +parallel/test-worker-parent-port-ref: SLOW +parallel/test-worker-relative-path: SLOW +parallel/test-worker-relative-path-double-dot: SLOW +parallel/test-worker-stdio: SLOW +parallel/test-worker-syntax-error: SLOW +parallel/test-worker-syntax-error-file: SLOW +parallel/test-worker-uncaught-exception: SLOW +parallel/test-worker-uncaught-exception-async: SLOW +parallel/test-worker-unsupported-things: SLOW +parallel/test-worker-workerdata-sharedarraybuffer: SLOW +parallel/test-zlib-bytes-read: SLOW +parallel/test-zlib-convenience-methods: SLOW +sequential/test-benchmark-buffer: SLOW +sequential/test-benchmark-child-process: SLOW +sequential/test-benchmark-dgram: SLOW +sequential/test-benchmark-http: SLOW +sequential/test-benchmark-net: SLOW +sequential/test-benchmark-path: SLOW +sequential/test-benchmark-tls: SLOW +sequential/test-child-process-execsync: SLOW +sequential/test-child-process-exit: SLOW +sequential/test-child-process-pass-fd: SLOW +sequential/test-fs-readfile-tostring-fail: SLOW +sequential/test-fs-watch-system-limit: SLOW +sequential/test-gc-http-client: SLOW +sequential/test-gc-http-client-connaborted: SLOW +sequential/test-gc-http-client-onerror: SLOW +sequential/test-gc-http-client-timeout: SLOW +sequential/test-gc-net-timeout: SLOW +sequential/test-http2-ping-flood: SLOW +sequential/test-http2-settings-flood: SLOW +sequential/test-inspector-port-cluster: SLOW +sequential/test-net-bytes-per-incoming-chunk-overhead: SLOW +sequential/test-pipe: SLOW +sequential/test-util-debug: SLOW diff --git a/tools/test.py b/tools/test.py index 3d62eedd1631e2..0571f3394bcc38 100755 --- a/tools/test.py +++ b/tools/test.py @@ -850,15 +850,15 @@ def GetTestStatus(self, context, sections, defs): class LiteralTestSuite(TestSuite): - - def __init__(self, tests): + def __init__(self, tests_repos, test_root): super(LiteralTestSuite, self).__init__('root') - self.tests = tests + self.tests_repos = tests_repos + self.test_root = test_root def GetBuildRequirements(self, path, context): (name, rest) = CarCdr(path) result = [ ] - for test in self.tests: + for test in self.tests_repos: if not name or name.match(test.GetName()): result += test.GetBuildRequirements(rest, context) return result @@ -866,7 +866,7 @@ def GetBuildRequirements(self, path, context): def ListTests(self, current_path, path, context, arch, mode): (name, rest) = CarCdr(path) result = [ ] - for test in self.tests: + for test in self.tests_repos: test_name = test.GetName() if not name or name.match(test_name): full_path = current_path + [test_name] @@ -875,8 +875,11 @@ def ListTests(self, current_path, path, context, arch, mode): return result def GetTestStatus(self, context, sections, defs): - for test in self.tests: - test.GetTestStatus(context, sections, defs) + # Just read the test configuration from root_path/root.status. + root = TestConfiguration(context, self.test_root, 'root') + root.GetTestStatus(sections, defs) + for tests_repos in self.tests_repos: + tests_repos.GetTestStatus(context, sections, defs) TIMEOUT_SCALEFACTOR = { @@ -1198,23 +1201,18 @@ def __init__(self, sections, defs): self.defs = defs def ClassifyTests(self, cases, env): - sections = [s for s in self.sections if s.condition.Evaluate(env, self.defs)] + sections = [ s for s in self.sections if s.condition.Evaluate(env, self.defs) ] all_rules = reduce(list.__add__, [s.rules for s in sections], []) unused_rules = set(all_rules) - result = [ ] - all_outcomes = set([]) + result = [] for case in cases: matches = [ r for r in all_rules if r.Contains(case.path) ] - outcomes = set([]) - for rule in matches: - outcomes = outcomes.union(rule.GetOutcomes(env, self.defs)) - unused_rules.discard(rule) - if not outcomes: - outcomes = [PASS] - case.outcomes = outcomes - all_outcomes = all_outcomes.union(outcomes) - result.append(ClassifiedTest(case, outcomes)) - return (result, list(unused_rules), all_outcomes) + outcomes_list = [ r.GetOutcomes(env, self.defs) for r in matches ] + outcomes = reduce(set.union, outcomes_list, set()) + unused_rules.difference_update(matches) + case.outcomes = set(outcomes) or set([PASS]) + result.append(case) + return result, unused_rules class Section(object): @@ -1552,7 +1550,7 @@ def Main(): repositories = [TestRepository(join(workspace, 'test', name)) for name in suites] repositories += [TestRepository(a) for a in options.suite] - root = LiteralTestSuite(repositories) + root = LiteralTestSuite(repositories, test_root) paths = ArgsToTestPaths(test_root, args, suites) # Check for --valgrind option. If enabled, we overwrite the special @@ -1623,8 +1621,7 @@ def Main(): } test_list = root.ListTests([], path, context, arch, mode) unclassified_tests += test_list - (cases, unused_rules, _) = ( - config.ClassifyTests(test_list, env)) + cases, unused_rules = config.ClassifyTests(test_list, env) if globally_unused_rules is None: globally_unused_rules = set(unused_rules) else: @@ -1671,7 +1668,7 @@ def should_keep(case): return False elif SKIP in case.outcomes: return False - elif (options.flaky_tests == SKIP) and (set([FLAKY]) & case.outcomes): + elif (options.flaky_tests == SKIP) and (set([SLOW, FLAKY]) & case.outcomes): return False else: return True From ea9c44d6f81db9db30fd5ba36a7355783af434fd Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Sun, 14 Oct 2018 22:23:01 -0700 Subject: [PATCH 195/328] src: remove OCB support ifdef OPENSSL_NO_OCB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Electron uses BoringSSL which does not support OCB . It is also possible to build OpenSSL without support for OCB for Node.js. This commit disables OCB if OPENSSL_NO_OCB is defined. PR-URL: https://github.com/nodejs/node/pull/23635 Reviewed-By: Tobias Nießen Reviewed-By: Anna Henningsen --- src/node_crypto.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 2ab682cc2257c0..3af5446427f349 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -84,6 +84,11 @@ using v8::Uint32; using v8::Undefined; using v8::Value; +#ifdef OPENSSL_NO_OCB +# define IS_OCB_MODE(mode) false +#else +# define IS_OCB_MODE(mode) ((mode) == EVP_CIPH_OCB_MODE) +#endif struct StackOfX509Deleter { void operator()(STACK_OF(X509)* p) const { sk_X509_pop_free(p, X509_free); } @@ -2540,7 +2545,7 @@ int VerifyCallback(int preverify_ok, X509_STORE_CTX* ctx) { static bool IsSupportedAuthenticatedMode(int mode) { return mode == EVP_CIPH_CCM_MODE || mode == EVP_CIPH_GCM_MODE || - mode == EVP_CIPH_OCB_MODE; + IS_OCB_MODE(mode); } void CipherBase::Initialize(Environment* env, Local target) { @@ -2765,7 +2770,7 @@ bool CipherBase::InitAuthenticated(const char* cipher_type, int iv_len, } const int mode = EVP_CIPHER_CTX_mode(ctx_.get()); - if (mode == EVP_CIPH_CCM_MODE || mode == EVP_CIPH_OCB_MODE) { + if (mode == EVP_CIPH_CCM_MODE || IS_OCB_MODE(mode)) { if (auth_tag_len == kNoAuthTagLength) { char msg[128]; snprintf(msg, sizeof(msg), "authTagLength required for %s", cipher_type); @@ -2893,7 +2898,7 @@ void CipherBase::SetAuthTag(const FunctionCallbackInfo& args) { } else if (mode == EVP_CIPH_OCB_MODE) { // At this point, the tag length is already known and must match the // length of the given authentication tag. - CHECK(mode == EVP_CIPH_CCM_MODE || mode == EVP_CIPH_OCB_MODE); + CHECK(mode == EVP_CIPH_CCM_MODE || IS_OCB_MODE(mode)); CHECK_NE(cipher->auth_tag_len_, kNoAuthTagLength); if (cipher->auth_tag_len_ != tag_len) { char msg[50]; From 3e4032a3337635138c0c9e617e6eccf675c7a3aa Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Sat, 13 Oct 2018 21:06:41 -0400 Subject: [PATCH 196/328] doc: cleanup and references in C++ guide PR-URL: https://github.com/nodejs/node/pull/23650 Reviewed-By: Anna Henningsen Reviewed-By: Joyee Cheung --- CPP_STYLE_GUIDE.md | 57 +++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/CPP_STYLE_GUIDE.md b/CPP_STYLE_GUIDE.md index c717ca31724e5f..36c3538f418a55 100644 --- a/CPP_STYLE_GUIDE.md +++ b/CPP_STYLE_GUIDE.md @@ -192,40 +192,39 @@ class FancyContainer { ### Use `nullptr` instead of `NULL` or `0` -What it says in the title. +Further reading in the [C++ Core Guidelines][ES.47]. ### Ownership and Smart Pointers -"Smart" pointers are classes that act like pointers, e.g. -by overloading the `*` and `->` operators. Some smart pointer types can be -used to automate ownership bookkeeping, to ensure these responsibilities are -met. `std::unique_ptr` is a smart pointer type introduced in C++11, which -expresses exclusive ownership of a dynamically allocated object; the object -is deleted when the `std::unique_ptr` goes out of scope. It cannot be -copied, but can be moved to represent ownership transfer. -`std::shared_ptr` is a smart pointer type that expresses shared ownership of a -dynamically allocated object. `std::shared_ptr`s can be copied; ownership -of the object is shared among all copies, and the object -is deleted when the last `std::shared_ptr` is destroyed. - -Prefer to use `std::unique_ptr` to make ownership -transfer explicit. For example: +* [R.20]: Use `std::unique_ptr` or `std::shared_ptr` to represent ownership +* [R.21]: Prefer `unique_ptr` over `shared_ptr` unless you need to share + ownership + +Use `std::unique_ptr` to make ownership transfer explicit. For example: ```cpp std::unique_ptr FooFactory(); void FooConsumer(std::unique_ptr ptr); ``` -Never use `std::auto_ptr`. Instead, use `std::unique_ptr`. +Since `std::unique_ptr` has only move semantics, passing one by value transfers +ownership to the callee and invalidates the caller's instance. + +Don't use `std::auto_ptr`, it is deprecated ([Reference][cppref_auto_ptr]). ## Others ### Type casting -- Always avoid C-style casts (`(type)value`) -- `dynamic_cast` does not work because RTTI is not enabled -- Use `static_cast` for casting whenever it works -- `reinterpret_cast` is okay if `static_cast` is not appropriate +- Use `static_cast` if casting is required, and it is valid +- Use `reinterpret_cast` only when it is necessary +- Avoid C-style casts (`(type)value`) +- `dynamic_cast` does not work because Node.js is built without + [Run Time Type Information][] + +Further reading: +* [ES.48]: Avoid casts +* [ES.49]: If you must use a cast, use a named cast ### Using `auto` @@ -316,13 +315,25 @@ exports.foo = function(str) { #### Avoid throwing JavaScript errors in nested C++ methods -When you have to throw the errors from C++, try to do it at the top level and -not inside of nested calls. +When you need to throw a JavaScript exception from C++ (i.e. +`isolate()->ThrowException()`) prefer to do it as close to the return to JS as +possible, and not inside of nested C++ calls. Since this changes the JS +execution state doing it closest to where it is consumed reduces the chances of +side effects. -Using C++ `throw` is not allowed. +Node.js is built [without C++ exception handling][], so code using `throw` or +even `try` and `catch` **will** break. [C++ Core Guidelines]: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines [Google C++ Style Guide]: https://google.github.io/styleguide/cppguide.html [Google’s `cpplint`]: https://github.com/google/styleguide [errors]: https://github.com/nodejs/node/blob/master/doc/guides/using-internal-errors.md +[ES.47]: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-nullptr +[ES.48]: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-casts +[ES.49]: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-casts-named +[R.20]: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rr-owner +[R.21]: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rr-unique +[Run Time Type Information]: https://en.wikipedia.org/wiki/Run-time_type_information +[cppref_auto_ptr]: https://en.cppreference.com/w/cpp/memory/auto_ptr +[without C++ exception handling]: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_exceptions.html#intro.using.exception.no From f5cadf6c1201dc95c416bca7c0cdb98bb1a0787e Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 14 Oct 2018 18:20:40 -0400 Subject: [PATCH 197/328] src: update v8::Object::GetPropertyNames() usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the non-deprecated version of GetPropertyNames(). PR-URL: https://github.com/nodejs/node/pull/23660 Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso Reviewed-By: Gus Caplan Reviewed-By: Sakthipriyan Vairamani Reviewed-By: James M Snell --- src/node_contextify.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 9c09bbb5fff3d1..c99f6c7ea5aef5 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -504,7 +504,12 @@ void ContextifyContext::PropertyEnumeratorCallback( if (ctx->context_.IsEmpty()) return; - args.GetReturnValue().Set(ctx->sandbox()->GetPropertyNames()); + Local properties; + + if (!ctx->sandbox()->GetPropertyNames(ctx->context()).ToLocal(&properties)) + return; + + args.GetReturnValue().Set(properties); } // static From 4ba897750d5ecd89e24d2cc4935064a985fcc9c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sat, 13 Oct 2018 19:23:07 +0200 Subject: [PATCH 198/328] crypto: simplify error handling in ECDH::New The type of the argument is being checked within JS which makes the type checking in C++ unnecessary. PR-URL: https://github.com/nodejs/node/pull/23647 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen --- src/node_crypto.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 3af5446427f349..3e4bdbb1128196 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -4352,7 +4352,7 @@ void ECDH::New(const FunctionCallbackInfo& args) { MarkPopErrorOnReturn mark_pop_error_on_return; // TODO(indutny): Support raw curves? - THROW_AND_RETURN_IF_NOT_STRING(env, args[0], "ECDH curve name"); + CHECK(args[0]->IsString()); node::Utf8Value curve(env->isolate(), args[0]); int nid = OBJ_sn2nid(*curve); From 3ca41dce5cdbaacb679ef86f2bd69688aad5bbc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sat, 13 Oct 2018 23:08:24 +0200 Subject: [PATCH 199/328] crypto: simplify internal state handling Uninitialized instances are not exposed to users, so this condition should always be true. PR-URL: https://github.com/nodejs/node/pull/23648 Reviewed-By: Refael Ackermann Reviewed-By: Colin Ihrig Reviewed-By: Ben Noordhuis --- src/node_crypto.cc | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 3e4bdbb1128196..5f69e4f87ef005 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -4115,10 +4115,7 @@ void DiffieHellman::GenerateKeys(const FunctionCallbackInfo& args) { DiffieHellman* diffieHellman; ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.Holder()); - - if (!diffieHellman->initialised_) { - return ThrowCryptoError(env, ERR_get_error(), "Not initialized"); - } + CHECK(diffieHellman->initialised_); if (!DH_generate_key(diffieHellman->dh_.get())) { return ThrowCryptoError(env, ERR_get_error(), "Key generation failed"); @@ -4140,7 +4137,7 @@ void DiffieHellman::GetField(const FunctionCallbackInfo& args, DiffieHellman* dh; ASSIGN_OR_RETURN_UNWRAP(&dh, args.Holder()); - if (!dh->initialised_) return env->ThrowError("Not initialized"); + CHECK(dh->initialised_); const BIGNUM* num = get_field(dh->dh_.get()); if (num == nullptr) return env->ThrowError(err_if_null); @@ -4192,10 +4189,7 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo& args) { DiffieHellman* diffieHellman; ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.Holder()); - - if (!diffieHellman->initialised_) { - return ThrowCryptoError(env, ERR_get_error(), "Not initialized"); - } + CHECK(diffieHellman->initialised_); ClearErrorOnReturn clear_error_on_return; @@ -4263,7 +4257,7 @@ void DiffieHellman::SetKey(const v8::FunctionCallbackInfo& args, DiffieHellman* dh; ASSIGN_OR_RETURN_UNWRAP(&dh, args.Holder()); - if (!dh->initialised_) return env->ThrowError("Not initialized"); + CHECK(dh->initialised_); char errmsg[64]; @@ -4309,10 +4303,7 @@ void DiffieHellman::VerifyErrorGetter(const FunctionCallbackInfo& args) { DiffieHellman* diffieHellman; ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.Holder()); - - if (!diffieHellman->initialised_) - return ThrowCryptoError(diffieHellman->env(), ERR_get_error(), - "Not initialized"); + CHECK(diffieHellman->initialised_); args.GetReturnValue().Set(diffieHellman->verifyError_); } From 81dc2419f459e949b52c0d626c43342dcc71d1ec Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sat, 13 Oct 2018 00:59:35 -0400 Subject: [PATCH 200/328] tls: prevent multiple connection errors onConnectEnd(), which is called by TLSSocket, has a guard to prevent being called multiple times, but it does not prevent the OpenSSL error handler from being called, leading to multiple error events. This commit adds that piece of missing logic. PR-URL: https://github.com/nodejs/node/pull/23636 Fixes: https://github.com/nodejs/node/issues/23631 Reviewed-By: Anna Henningsen Reviewed-By: Wyatt Preul Reviewed-By: James M Snell --- lib/_tls_wrap.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index d6f1480040bd3b..9049a830f805e4 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -250,9 +250,11 @@ function onocspresponse(resp) { function onerror(err) { const owner = this[owner_symbol]; - if (owner._writableState.errorEmitted) + if (owner._hadError) return; + owner._hadError = true; + // Destroy socket if error happened before handshake's finish if (!owner._secureEstablished) { // When handshake fails control is not yet released, @@ -267,8 +269,6 @@ function onerror(err) { // Throw error owner._emitTLSError(err); } - - owner._writableState.errorEmitted = true; } function initRead(tls, wrapped) { From 850b54f4fdd477e7edfff024dc243b9fb5720329 Mon Sep 17 00:00:00 2001 From: Steven Auger Date: Fri, 12 Oct 2018 14:25:42 -0400 Subject: [PATCH 201/328] src: changed stdio_pipes_ to std::vector PR-URL: https://github.com/nodejs/node/pull/23615 Reviewed-By: Sam Ruby Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Refael Ackermann --- src/spawn_sync.cc | 26 ++++++++++++-------------- src/spawn_sync.h | 2 +- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc index d57b4b03e23394..7d4f2ee8a15d4e 100644 --- a/src/spawn_sync.cc +++ b/src/spawn_sync.cc @@ -390,7 +390,6 @@ SyncProcessRunner::SyncProcessRunner(Environment* env) stdio_count_(0), uv_stdio_containers_(nullptr), - stdio_pipes_(nullptr), stdio_pipes_initialized_(false), uv_process_options_(), @@ -421,7 +420,7 @@ SyncProcessRunner::SyncProcessRunner(Environment* env) SyncProcessRunner::~SyncProcessRunner() { CHECK_EQ(lifecycle_, kHandlesClosed); - stdio_pipes_.reset(); + stdio_pipes_.clear(); delete[] file_buffer_; delete[] args_buffer_; delete[] cwd_buffer_; @@ -500,10 +499,9 @@ Maybe SyncProcessRunner::TryInitializeAndRunLoop(Local options) { } uv_process_.data = this; - for (uint32_t i = 0; i < stdio_count_; i++) { - SyncProcessStdioPipe* h = stdio_pipes_[i].get(); - if (h != nullptr) { - r = h->Start(); + for (const auto& pipe : stdio_pipes_) { + if (pipe != nullptr) { + r = pipe->Start(); if (r < 0) { SetPipeError(r); return Just(false); @@ -563,12 +561,12 @@ void SyncProcessRunner::CloseStdioPipes() { CHECK_LT(lifecycle_, kHandlesClosed); if (stdio_pipes_initialized_) { - CHECK(stdio_pipes_); + CHECK(!stdio_pipes_.empty()); CHECK_NOT_NULL(uv_loop_); - for (uint32_t i = 0; i < stdio_count_; i++) { - if (stdio_pipes_[i]) - stdio_pipes_[i]->Close(); + for (const auto& pipe : stdio_pipes_) { + if (pipe) + pipe->Close(); } stdio_pipes_initialized_ = false; @@ -723,13 +721,13 @@ Local SyncProcessRunner::BuildResultObject() { Local SyncProcessRunner::BuildOutputArray() { CHECK_GE(lifecycle_, kInitialized); - CHECK(stdio_pipes_); + CHECK(!stdio_pipes_.empty()); EscapableHandleScope scope(env()->isolate()); Local context = env()->context(); Local js_output = Array::New(env()->isolate(), stdio_count_); - for (uint32_t i = 0; i < stdio_count_; i++) { + for (uint32_t i = 0; i < stdio_pipes_.size(); i++) { SyncProcessStdioPipe* h = stdio_pipes_[i].get(); if (h != nullptr && h->writable()) js_output->Set(context, i, h->GetOutputAsBuffer(env())).FromJust(); @@ -857,8 +855,8 @@ int SyncProcessRunner::ParseStdioOptions(Local js_value) { stdio_count_ = js_stdio_options->Length(); uv_stdio_containers_ = new uv_stdio_container_t[stdio_count_]; - stdio_pipes_.reset( - new std::unique_ptr[stdio_count_]()); + stdio_pipes_.clear(); + stdio_pipes_.resize(stdio_count_); stdio_pipes_initialized_ = true; for (uint32_t i = 0; i < stdio_count_; i++) { diff --git a/src/spawn_sync.h b/src/spawn_sync.h index 397e62b9d2c0d9..5b04d94b47b30e 100644 --- a/src/spawn_sync.h +++ b/src/spawn_sync.h @@ -203,7 +203,7 @@ class SyncProcessRunner { uint32_t stdio_count_; uv_stdio_container_t* uv_stdio_containers_; - std::unique_ptr[]> stdio_pipes_; + std::vector> stdio_pipes_; bool stdio_pipes_initialized_; uv_process_options_t uv_process_options_; From 11eabba0fb347aa78d7472618e08ab9a99f219ca Mon Sep 17 00:00:00 2001 From: Nancy Truong Date: Fri, 12 Oct 2018 10:23:36 -0700 Subject: [PATCH 202/328] test: check codes of thrown errors PR-URL: https://github.com/nodejs/node/pull/23519 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: George Adams --- test/parallel/test-buffer-alloc.js | 16 ++++++++++------ test/parallel/test-buffer-arraybuffer.js | 7 ++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js index 6afcbf1b03b8e1..feca44881192f6 100644 --- a/test/parallel/test-buffer-alloc.js +++ b/test/parallel/test-buffer-alloc.js @@ -967,12 +967,16 @@ common.expectsError( message: 'argument must be a buffer' }); -const regErrorMsg = - new RegExp('The first argument must be one of type string, Buffer, ' + - 'ArrayBuffer, Array, or Array-like Object\\.'); - -assert.throws(() => Buffer.from(), regErrorMsg); -assert.throws(() => Buffer.from(null), regErrorMsg); +assert.throws(() => Buffer.from(), { + name: 'TypeError [ERR_INVALID_ARG_TYPE]', + message: 'The first argument must be one of type string, Buffer, ' + + 'ArrayBuffer, Array, or Array-like Object. Received type undefined' +}); +assert.throws(() => Buffer.from(null), { + name: 'TypeError [ERR_INVALID_ARG_TYPE]', + message: 'The first argument must be one of type string, Buffer, ' + + 'ArrayBuffer, Array, or Array-like Object. Received type object' +}); // Test prototype getters don't throw assert.strictEqual(Buffer.prototype.parent, undefined); diff --git a/test/parallel/test-buffer-arraybuffer.js b/test/parallel/test-buffer-arraybuffer.js index 8d26f983f2b4dd..2a1ce141079279 100644 --- a/test/parallel/test-buffer-arraybuffer.js +++ b/test/parallel/test-buffer-arraybuffer.js @@ -40,7 +40,12 @@ assert.throws(function() { Object.setPrototypeOf(AB, ArrayBuffer); Object.setPrototypeOf(AB.prototype, ArrayBuffer.prototype); Buffer.from(new AB()); -}, TypeError); +}, { + code: 'ERR_INVALID_ARG_TYPE', + name: 'TypeError [ERR_INVALID_ARG_TYPE]', + message: 'The first argument must be one of type string, Buffer,' + + ' ArrayBuffer, Array, or Array-like Object. Received type object' +}); // Test the byteOffset and length arguments { From e856fa2155a8e2719fc38c40c7812315b3ad54da Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 15 Oct 2018 22:25:28 -0700 Subject: [PATCH 203/328] doc: simplify security reporting text Edit security-reporting text in the README to keep it concise and straightforward. The removed text may discourage reporting. Nothing like it appears in similar security-reporting text that I have reviewed. See, for example, the Linux kernel docs on security reporting: https://www.kernel.org/doc/html/v4.11/admin-guide/security-bugs.html PR-URL: https://github.com/nodejs/node/pull/23686 Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater --- README.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ae2f28b2daf551..00cbd58d532325 100644 --- a/README.md +++ b/README.md @@ -166,15 +166,10 @@ team has addressed the vulnerability. The security team will acknowledge your email within 24 hours. You will receive a more detailed response within 48 hours. -There are no hard and fast rules to determine if a bug is worth reporting as -a security issue. The general rule is an issue worth reporting should allow an -attacker to compromise the confidentiality, integrity, or availability of the -Node.js application or its system for which the attacker does not already have -the capability. - -To illustrate the point, here are some examples of past issues and what the -Security Response Team thinks of them. When in doubt, however, please do send -us a report nonetheless. +There are no hard and fast rules to determine if a bug is worth reporting as a +security issue. Here are some examples of past issues and what the Security +Response Team thinks of them. When in doubt, please do send us a report +nonetheless. ### Public disclosure preferred From abd46ee1b5a909f49033d51135fc40ab66f02554 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 14 Oct 2018 19:07:15 +0200 Subject: [PATCH 204/328] build: fix `./configure --enable-d8` Add SHARED_INTERMEDIATE_DIR to the include path because that is where Torque-generated files live. d8.cc includes files from deps/v8/src that depend on those generated files. PR-URL: https://github.com/nodejs/node/pull/23656 Reviewed-By: Colin Ihrig Reviewed-By: Richard Lau Reviewed-By: Anna Henningsen Reviewed-By: Refael Ackermann Reviewed-By: Gus Caplan --- deps/v8/gypfiles/d8.gyp | 1 + 1 file changed, 1 insertion(+) diff --git a/deps/v8/gypfiles/d8.gyp b/deps/v8/gypfiles/d8.gyp index f593a2b044ee4a..9611dfccf8aff0 100644 --- a/deps/v8/gypfiles/d8.gyp +++ b/deps/v8/gypfiles/d8.gyp @@ -23,6 +23,7 @@ 'include_dirs+': [ '..', '<(DEPTH)', + '<(SHARED_INTERMEDIATE_DIR)', ], 'sources': [ '../src/d8.h', From ac83a147146c9f4c73d7b81a2338f90076ae23d4 Mon Sep 17 00:00:00 2001 From: "Sakthipriyan Vairamani (thefourtheye)" Date: Thu, 18 Oct 2018 10:29:07 +0530 Subject: [PATCH 205/328] tools: prefer filter to remove empty strings Ref: https://github.com/nodejs/node/pull/23585#issuecomment-430585490 Python's `list.remove` will throw if the element is not found and also it removes only the first occurrence. This patch replaces the use of `list.remove` with a `filter` which solves both of the above mentioned problems. PR-URL: https://github.com/nodejs/node/pull/23727 Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca Reviewed-By: Rod Vagg Reviewed-By: Refael Ackermann Reviewed-By: Matheus Marchini Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- tools/test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/test.py b/tools/test.py index 0571f3394bcc38..3d0ba43beca8b5 100755 --- a/tools/test.py +++ b/tools/test.py @@ -1381,8 +1381,8 @@ def ProcessOptions(options): options.arch = options.arch.split(',') options.mode = options.mode.split(',') options.run = options.run.split(',') - options.skip_tests = options.skip_tests.split(',') - options.skip_tests.remove("") + # Split at commas and filter out all the empty strings. + options.skip_tests = filter(bool, options.skip_tests.split(',')) if options.run == [""]: options.run = None elif len(options.run) != 2: From 28599e896a4d23da246935561dc7e98fc7c69953 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 17 Oct 2018 19:17:06 -0700 Subject: [PATCH 206/328] tools: do not lint commit message if var undefined Check that $TRAVIS_COMMIT_RANGE is set before trying to lint commit messages in Travis CI. Refs: https://github.com/nodejs/node/pull/23572#issuecomment-430850382 Refs: https://github.com/nodejs/node/pull/22842#issuecomment-430850049 PR-URL: https://github.com/nodejs/node/pull/23725 Reviewed-By: Anatoli Papirovski Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Matheus Marchini --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fad2e7f0c77509..156d28298b4e58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ matrix: script: - make lint # Lint the first commit in the PR. - - git log $TRAVIS_COMMIT_RANGE --pretty=format:'%h' --no-merges | tail -1 | xargs npx core-validate-commit --no-validate-metadata + - \[ -z "$TRAVIS_COMMIT_RANGE" \] || git log $TRAVIS_COMMIT_RANGE --pretty=format:'%h' --no-merges | tail -1 | xargs npx core-validate-commit --no-validate-metadata - name: "Test Suite" install: - ./configure From 8cd83c50b8f727b3ecfb8fa66cdd9294ad9436c3 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 16 Oct 2018 21:29:02 -0700 Subject: [PATCH 207/328] doc: improve README.md Make text more concise and remove some use of passive voice. PR-URL: https://github.com/nodejs/node/pull/23705 Reviewed-By: Vse Mozhet Byt Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Matheus Marchini Reviewed-By: Refael Ackermann --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 00cbd58d532325..5c5848313acf77 100644 --- a/README.md +++ b/README.md @@ -208,9 +208,7 @@ When in doubt, please do send us a report. ## Current Project Team Members -The Node.js project team comprises a group of core collaborators and a sub-group -that forms the _Technical Steering Committee_ (TSC) which governs the project. -For more information about the governance of the Node.js project, see +For information about the governance of the Node.js project, see [GOVERNANCE.md](./GOVERNANCE.md). ### TSC (Technical Steering Committee) @@ -587,7 +585,7 @@ Node.js releases are signed with one of the following GPG keys: * **Rod Vagg** <rod@vagg.org> `DD8F2338BAE7501E3DD5AC78C273792F7D83545D` -The full set of trusted release keys can be imported by running: +To import the full set of trusted release keys: ```shell gpg --keyserver pool.sks-keyservers.net --recv-keys 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 @@ -603,7 +601,7 @@ gpg --keyserver pool.sks-keyservers.net --recv-keys DD8F2338BAE7501E3DD5AC78C273 See the section above on [Verifying Binaries](#verifying-binaries) for how to use these keys to verify a downloaded file. -Previous releases may also have been signed with one of the following GPG keys: +Other keys used to sign some previous releases: * **Chris Dickinson** <christopher.s.dickinson@gmail.com> `9554F04D7259F04124DE6B476D5A82AC7E37093B` From 703f40a035e76e14642e16758699ca4e1bcc6081 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 18 Oct 2018 16:09:14 -0700 Subject: [PATCH 208/328] tools: clarify commit message linting Clarify in Travis results that the commit message linting is for the commit message and not something else. PR-URL: https://github.com/nodejs/node/pull/23742 Reviewed-By: Richard Lau Reviewed-By: Vladimir de Turckheim Reviewed-By: Refael Ackermann Reviewed-By: Sakthipriyan Vairamani --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 156d28298b4e58..004c6ab4cf7236 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ matrix: script: - make lint # Lint the first commit in the PR. - - \[ -z "$TRAVIS_COMMIT_RANGE" \] || git log $TRAVIS_COMMIT_RANGE --pretty=format:'%h' --no-merges | tail -1 | xargs npx core-validate-commit --no-validate-metadata + - \[ -z "$TRAVIS_COMMIT_RANGE" \] || (echo -e '\nLinting the commit message according to the guidelines at https://goo.gl/p2fr5Q\n' && git log $TRAVIS_COMMIT_RANGE --pretty=format:'%h' --no-merges | tail -1 | xargs npx -q core-validate-commit --no-validate-metadata) - name: "Test Suite" install: - ./configure From 44279e03fc05b27eb7bad9d94470cac35545b488 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 15 Oct 2018 23:55:12 -0400 Subject: [PATCH 209/328] deps: add missing ares_android.h file This file was left out of the c-ares 1.14.0 update. PR-URL: https://github.com/nodejs/node/pull/23682 Fixes: https://github.com/nodejs/node/issues/23681 Reviewed-By: Anna Henningsen Reviewed-By: Denys Otrishko Reviewed-By: Ruben Bridgewater Reviewed-By: Refael Ackermann Reviewed-By: James M Snell --- deps/cares/src/ares_android.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 deps/cares/src/ares_android.h diff --git a/deps/cares/src/ares_android.h b/deps/cares/src/ares_android.h new file mode 100644 index 00000000000000..ff520f96e8eacc --- /dev/null +++ b/deps/cares/src/ares_android.h @@ -0,0 +1,26 @@ +/* Copyright (C) 2017 by John Schember + * + * Permission to use, copy, modify, and distribute this + * software and its documentation for any purpose and without + * fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting + * documentation, and that the name of M.I.T. not be used in + * advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" + * without express or implied warranty. + */ + +#ifndef __ARES_ANDROID_H__ +#define __ARES_ANDROID_H__ + +#if defined(ANDROID) || defined(__ANDROID__) + +char **ares_get_android_server_list(size_t max_servers, size_t *num_servers); +void ares_library_cleanup_android(void); + +#endif + +#endif /* __ARES_ANDROID_H__ */ From 8ec2c51bc9c1212fb30ab256b7923455b1d1e581 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Thu, 18 Oct 2018 17:45:47 -0700 Subject: [PATCH 210/328] meta: clarify fast-track approval Refs: https://github.com/nodejs/node/pull/23725#issuecomment-431202936 PR-URL: https://github.com/nodejs/node/pull/23744 Reviewed-By: Refael Ackermann Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: Matheus Marchini Reviewed-By: Vse Mozhet Byt Reviewed-By: Ruben Bridgewater --- COLLABORATOR_GUIDE.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/COLLABORATOR_GUIDE.md b/COLLABORATOR_GUIDE.md index 7dba23dc74e566..7cfc6388c549b5 100644 --- a/COLLABORATOR_GUIDE.md +++ b/COLLABORATOR_GUIDE.md @@ -187,7 +187,9 @@ Collaborators that previously approved the pull request. If someone disagrees with the fast-tracking request, remove the label and leave a comment indicating why the pull request should not be fast-tracked. The pull request can be landed once two or more Collaborators approve both the pull request and the -fast-tracking request, and the necessary CI testing is done. +fast-tracking request, and the necessary CI testing is done. A request to +fast-track a PR made by a different Collaborator than the pull-request author +counts as a fast-track approval. ### Testing and CI From d862f1e89446cdb0f5a0604d07bf11bcdca49573 Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Tue, 16 Oct 2018 13:03:34 -0700 Subject: [PATCH 211/328] doc: add Backport-PR-URL info in backport guide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23701 Reviewed-By: Michaël Zasso Reviewed-By: Matheus Marchini Reviewed-By: Michael Dawson Reviewed-By: James M Snell Reviewed-By: Refael Ackermann Reviewed-By: Shelley Vohr Reviewed-By: Joyee Cheung Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Luigi Pinca Reviewed-By: George Adams Reviewed-By: Trivikram Kamat --- doc/guides/backporting-to-release-lines.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/guides/backporting-to-release-lines.md b/doc/guides/backporting-to-release-lines.md index 7dee8b0e640eed..150a1248b146b9 100644 --- a/doc/guides/backporting-to-release-lines.md +++ b/doc/guides/backporting-to-release-lines.md @@ -68,17 +68,20 @@ hint: and commit the result with 'git commit' using `git add`, and then commit the changes. That can be done with `git cherry-pick --continue`. 6. Leave the commit message as is. If you think it should be modified, comment - in the Pull Request. + in the Pull Request. The `Backport-PR-URL` metadata does need to be added to + the commit, but this will be done later. 7. Make sure `make -j4 test` passes. 8. Push the changes to your fork 9. Open a pull request: 1. Be sure to target the `v8.x-staging` branch in the pull request. - 2. Include the backport target in the pull request title in the following + 1. Include the backport target in the pull request title in the following format — `[v8.x backport] `. Example: `[v8.x backport] process: improve performance of nextTick` - 3. Check the checkbox labeled "Allow edits from maintainers". - 4. In the description add a reference to the original PR - 5. Run a [`node-test-pull-request`][] CI job (with `REBASE_ONTO` set to the + 1. Check the checkbox labeled "Allow edits from maintainers". + 1. In the description add a reference to the original PR. + 1. Amend the commit message and include a `Backport-PR-URL:` metadata and + re-push the change to your fork. + 1. Run a [`node-test-pull-request`][] CI job (with `REBASE_ONTO` set to the default ``) 10. If during the review process conflicts arise, use the following to rebase: `git pull --rebase upstream v8.x-staging` From ff9232db35eae3ece525af6c20b270093fb378a7 Mon Sep 17 00:00:00 2001 From: James Irwin Date: Fri, 12 Oct 2018 12:28:12 -0500 Subject: [PATCH 212/328] test: correct order of args in buffer compare PR-URL: https://github.com/nodejs/node/pull/23521 Reviewed-By: James M Snell Reviewed-By: Hitesh Kanwathirtha Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-buffer-compare-offset.js | 40 ++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/test/parallel/test-buffer-compare-offset.js b/test/parallel/test-buffer-compare-offset.js index 7f3121bef17ab5..7de1c783d0c1c4 100644 --- a/test/parallel/test-buffer-compare-offset.js +++ b/test/parallel/test-buffer-compare-offset.js @@ -6,56 +6,56 @@ const assert = require('assert'); const a = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]); const b = Buffer.from([5, 6, 7, 8, 9, 0, 1, 2, 3, 4]); -assert.strictEqual(-1, a.compare(b)); +assert.strictEqual(a.compare(b), -1); // Equivalent to a.compare(b). -assert.strictEqual(-1, a.compare(b, 0)); -assert.strictEqual(-1, a.compare(b, '0')); -assert.strictEqual(-1, a.compare(b, undefined)); +assert.strictEqual(a.compare(b, 0), -1); +assert.strictEqual(a.compare(b, '0'), -1); +assert.strictEqual(a.compare(b, undefined), -1); // Equivalent to a.compare(b). -assert.strictEqual(-1, a.compare(b, 0, undefined, 0)); +assert.strictEqual(a.compare(b, 0, undefined, 0), -1); // Zero-length target, return 1 -assert.strictEqual(1, a.compare(b, 0, 0, 0)); -assert.strictEqual(1, a.compare(b, '0', '0', '0')); +assert.strictEqual(a.compare(b, 0, 0, 0), 1); +assert.strictEqual(a.compare(b, '0', '0', '0'), 1); // Equivalent to Buffer.compare(a, b.slice(6, 10)) -assert.strictEqual(1, a.compare(b, 6, 10)); +assert.strictEqual(a.compare(b, 6, 10), 1); // Zero-length source, return -1 -assert.strictEqual(-1, a.compare(b, 6, 10, 0, 0)); +assert.strictEqual(a.compare(b, 6, 10, 0, 0), -1); // Zero-length source and target, return 0 -assert.strictEqual(0, a.compare(b, 0, 0, 0, 0)); -assert.strictEqual(0, a.compare(b, 1, 1, 2, 2)); +assert.strictEqual(a.compare(b, 0, 0, 0, 0), 0); +assert.strictEqual(a.compare(b, 1, 1, 2, 2), 0); // Equivalent to Buffer.compare(a.slice(4), b.slice(0, 5)) -assert.strictEqual(1, a.compare(b, 0, 5, 4)); +assert.strictEqual(a.compare(b, 0, 5, 4), 1); // Equivalent to Buffer.compare(a.slice(1), b.slice(5)) -assert.strictEqual(1, a.compare(b, 5, undefined, 1)); +assert.strictEqual(a.compare(b, 5, undefined, 1), 1); // Equivalent to Buffer.compare(a.slice(2), b.slice(2, 4)) -assert.strictEqual(-1, a.compare(b, 2, 4, 2)); +assert.strictEqual(a.compare(b, 2, 4, 2), -1); // Equivalent to Buffer.compare(a.slice(4), b.slice(0, 7)) -assert.strictEqual(-1, a.compare(b, 0, 7, 4)); +assert.strictEqual(a.compare(b, 0, 7, 4), -1); // Equivalent to Buffer.compare(a.slice(4, 6), b.slice(0, 7)); -assert.strictEqual(-1, a.compare(b, 0, 7, 4, 6)); +assert.strictEqual(a.compare(b, 0, 7, 4, 6), -1); // zero length target -assert.strictEqual(1, a.compare(b, 0, null)); +assert.strictEqual(a.compare(b, 0, null), 1); // coerces to targetEnd == 5 -assert.strictEqual(-1, a.compare(b, 0, { valueOf: () => 5 })); +assert.strictEqual(a.compare(b, 0, { valueOf: () => 5 }), -1); // zero length target -assert.strictEqual(1, a.compare(b, Infinity, -Infinity)); +assert.strictEqual(a.compare(b, Infinity, -Infinity), 1); // zero length target because default for targetEnd <= targetSource -assert.strictEqual(1, a.compare(b, '0xff')); +assert.strictEqual(a.compare(b, '0xff'), 1); const oor = common.expectsError({ code: 'ERR_INDEX_OUT_OF_RANGE' }, 7); From f318d163a52159acbf52f155726560dc3539d54e Mon Sep 17 00:00:00 2001 From: James M Snell Date: Thu, 18 Oct 2018 18:22:46 -0700 Subject: [PATCH 213/328] doc: document use of buffer.swap16() for utf16be Fixes: https://github.com/nodejs/node/issues/12813 PR-URL: https://github.com/nodejs/node/pull/23747 Reviewed-By: Luigi Pinca Reviewed-By: Vse Mozhet Byt Reviewed-By: Ruben Bridgewater --- doc/api/buffer.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 56999a1955d0a1..897512ae000805 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -1933,6 +1933,14 @@ buf2.swap16(); // Throws ERR_INVALID_BUFFER_SIZE ``` +One convenient use of `buf.swap16()` is to perform a fast in-place conversion +between UTF-16 little-endian and UTF-16 big-endian: + +```js +const buf = Buffer.from('This is little-endian UTF-16', 'utf16le'); +buf.swap16(); // Convert to big-endian UTF-16 text. +``` + ### buf.swap32() +> Stability: 0 - Deprecated + The default encoding to use for functions that can take either strings or [buffers][`Buffer`]. The default value is `'buffer'`, which makes methods default to [`Buffer`][] objects. @@ -1315,6 +1317,8 @@ added: v6.0.0 deprecated: v10.0.0 --> +> Stability: 0 - Deprecated + Property for checking and controlling whether a FIPS compliant crypto provider is currently in use. Setting to true requires a FIPS build of Node.js. From d13bb2c2eb6831d041af200b603573a8ac68fb33 Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Wed, 17 Oct 2018 14:27:54 -0700 Subject: [PATCH 215/328] benchmark: coerce PORT to number Without this fix net/tcp-raw-c2s.js aborts in environments where PORT is defined. TCPWrap::Connect expects the third arg to be a UInt32. PR-URL: https://github.com/nodejs/node/pull/23721 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat --- benchmark/_http-benchmarkers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/_http-benchmarkers.js b/benchmark/_http-benchmarkers.js index 76e02504b27ec1..9079dff3ff83cc 100644 --- a/benchmark/_http-benchmarkers.js +++ b/benchmark/_http-benchmarkers.js @@ -8,7 +8,7 @@ const requirementsURL = 'https://github.com/nodejs/node/blob/master/doc/guides/writing-and-running-benchmarks.md#http-benchmark-requirements'; // The port used by servers and wrk -exports.PORT = process.env.PORT || 12346; +exports.PORT = Number(process.env.PORT) || 12346; class AutocannonBenchmarker { constructor() { From f216699ab42c19050f3278e93b657548ffa6d05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Wed, 17 Oct 2018 19:01:15 +0200 Subject: [PATCH 216/328] crypto: remove DiffieHellman.initialised_ As pointed out by Ben Noordhuis, this internal field can be removed since all instances are initialized when exposed to users. PR-URL: https://github.com/nodejs/node/pull/23717 Refs: https://github.com/nodejs/node/pull/23648 Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater --- src/node_crypto.cc | 23 +++-------------------- src/node_crypto.h | 2 -- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 5f69e4f87ef005..7d9294d65a53b6 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -4001,11 +4001,7 @@ bool DiffieHellman::Init(int primeLength, int g) { dh_.reset(DH_new()); if (!DH_generate_parameters_ex(dh_.get(), primeLength, g, 0)) return false; - bool result = VerifyContext(); - if (!result) - return false; - initialised_ = true; - return true; + return VerifyContext(); } @@ -4020,11 +4016,7 @@ bool DiffieHellman::Init(const char* p, int p_len, int g) { BN_free(bn_g); return false; } - bool result = VerifyContext(); - if (!result) - return false; - initialised_ = true; - return true; + return VerifyContext(); } @@ -4037,11 +4029,7 @@ bool DiffieHellman::Init(const char* p, int p_len, const char* g, int g_len) { BN_free(bn_g); return false; } - bool result = VerifyContext(); - if (!result) - return false; - initialised_ = true; - return true; + return VerifyContext(); } @@ -4115,7 +4103,6 @@ void DiffieHellman::GenerateKeys(const FunctionCallbackInfo& args) { DiffieHellman* diffieHellman; ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.Holder()); - CHECK(diffieHellman->initialised_); if (!DH_generate_key(diffieHellman->dh_.get())) { return ThrowCryptoError(env, ERR_get_error(), "Key generation failed"); @@ -4137,7 +4124,6 @@ void DiffieHellman::GetField(const FunctionCallbackInfo& args, DiffieHellman* dh; ASSIGN_OR_RETURN_UNWRAP(&dh, args.Holder()); - CHECK(dh->initialised_); const BIGNUM* num = get_field(dh->dh_.get()); if (num == nullptr) return env->ThrowError(err_if_null); @@ -4189,7 +4175,6 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo& args) { DiffieHellman* diffieHellman; ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.Holder()); - CHECK(diffieHellman->initialised_); ClearErrorOnReturn clear_error_on_return; @@ -4257,7 +4242,6 @@ void DiffieHellman::SetKey(const v8::FunctionCallbackInfo& args, DiffieHellman* dh; ASSIGN_OR_RETURN_UNWRAP(&dh, args.Holder()); - CHECK(dh->initialised_); char errmsg[64]; @@ -4303,7 +4287,6 @@ void DiffieHellman::VerifyErrorGetter(const FunctionCallbackInfo& args) { DiffieHellman* diffieHellman; ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.Holder()); - CHECK(diffieHellman->initialised_); args.GetReturnValue().Set(diffieHellman->verifyError_); } diff --git a/src/node_crypto.h b/src/node_crypto.h index f4afd2fdaf5758..fd865e909d773f 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -615,7 +615,6 @@ class DiffieHellman : public BaseObject { DiffieHellman(Environment* env, v8::Local wrap) : BaseObject(env, wrap), - initialised_(false), verifyError_(0) { MakeWeak(); } @@ -633,7 +632,6 @@ class DiffieHellman : public BaseObject { int (*set_field)(DH*, BIGNUM*), const char* what); bool VerifyContext(); - bool initialised_; int verifyError_; DHPointer dh_; }; From 4e019f05bce322833826f8adb7372fbfd5229f35 Mon Sep 17 00:00:00 2001 From: Dusan Radovanovic Date: Fri, 12 Oct 2018 11:28:00 -0700 Subject: [PATCH 217/328] test: reversed params in assert.strictEqual() Reversed parameters of assert.strictEqual() in test-promises-unhandled-rejections.js so that first one is actual and second one is expected value. PR-URL: https://github.com/nodejs/node/pull/23591 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Sakthipriyan Vairamani --- .../test-promises-unhandled-rejections.js | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/test/parallel/test-promises-unhandled-rejections.js b/test/parallel/test-promises-unhandled-rejections.js index 92b6d7a96147a1..d336630f7cf8ce 100644 --- a/test/parallel/test-promises-unhandled-rejections.js +++ b/test/parallel/test-promises-unhandled-rejections.js @@ -112,7 +112,7 @@ asyncTest('synchronously rejected promise should trigger' + ' unhandledRejection', function(done) { const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(e, reason); + assert.strictEqual(reason, e); }); Promise.reject(e); }); @@ -121,7 +121,7 @@ asyncTest('synchronously rejected promise should trigger' + ' unhandledRejection', function(done) { const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(e, reason); + assert.strictEqual(reason, e); }); new Promise(function(_, reject) { reject(e); @@ -132,7 +132,7 @@ asyncTest('Promise rejected after setImmediate should trigger' + ' unhandledRejection', function(done) { const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(e, reason); + assert.strictEqual(reason, e); }); new Promise(function(_, reject) { setImmediate(function() { @@ -145,7 +145,7 @@ asyncTest('Promise rejected after setTimeout(,1) should trigger' + ' unhandled rejection', function(done) { const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(e, reason); + assert.strictEqual(reason, e); }); new Promise(function(_, reject) { setTimeout(function() { @@ -158,7 +158,7 @@ asyncTest('Catching a promise rejection after setImmediate is not' + ' soon enough to stop unhandledRejection', function(done) { const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(e, reason); + assert.strictEqual(reason, e); }); let _reject; const promise = new Promise(function(_, reject) { @@ -175,11 +175,11 @@ asyncTest('When re-throwing new errors in a promise catch, only the' + const e = new Error(); const e2 = new Error(); onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(e2, reason); - assert.strictEqual(promise2, promise); + assert.strictEqual(reason, e2); + assert.strictEqual(promise, promise2); }); const promise2 = Promise.reject(e).then(assert.fail, function(reason) { - assert.strictEqual(e, reason); + assert.strictEqual(reason, e); throw e2; }); }); @@ -188,7 +188,7 @@ asyncTest('Test params of unhandledRejection for a synchronously-rejected ' + 'promise', function(done) { const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(e, reason); + assert.strictEqual(reason, e); assert.strictEqual(promise, promise); }); Promise.reject(e); @@ -200,15 +200,15 @@ asyncTest('When re-throwing new errors in a promise catch, only the ' + const e = new Error(); const e2 = new Error(); onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(e2, reason); - assert.strictEqual(promise2, promise); + assert.strictEqual(reason, e2); + assert.strictEqual(promise, promise2); }); const promise2 = new Promise(function(_, reject) { setTimeout(function() { reject(e); }, 1); }).then(assert.fail, function(reason) { - assert.strictEqual(e, reason); + assert.strictEqual(reason, e); throw e2; }); }); @@ -219,15 +219,15 @@ asyncTest('When re-throwing new errors in a promise catch, only the re-thrown' + const e = new Error(); const e2 = new Error(); onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(e2, reason); - assert.strictEqual(promise2, promise); + assert.strictEqual(reason, e2); + assert.strictEqual(promise, promise2); }); const promise = new Promise(function(_, reject) { setTimeout(function() { reject(e); process.nextTick(function() { promise2 = promise.then(assert.fail, function(reason) { - assert.strictEqual(e, reason); + assert.strictEqual(reason, e); throw e2; }); }); @@ -308,7 +308,7 @@ asyncTest('catching a promise which is asynchronously rejected (via ' + }, 1); }); }).then(assert.fail, function(reason) { - assert.strictEqual(e, reason); + assert.strictEqual(reason, e); }); }); @@ -319,7 +319,7 @@ asyncTest('Catching a rejected promise derived from throwing in a' + Promise.resolve().then(function() { throw e; }).then(assert.fail, function(reason) { - assert.strictEqual(e, reason); + assert.strictEqual(reason, e); }); }); @@ -331,7 +331,7 @@ asyncTest('Catching a rejected promise derived from returning a' + Promise.resolve().then(function() { return Promise.reject(e); }).then(assert.fail, function(reason) { - assert.strictEqual(e, reason); + assert.strictEqual(reason, e); }); }); @@ -340,8 +340,8 @@ asyncTest('A rejected promise derived from returning an' + ' does trigger unhandledRejection', function(done) { const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(e, reason); - assert.strictEqual(_promise, promise); + assert.strictEqual(reason, e); + assert.strictEqual(promise, _promise); }); const _promise = Promise.resolve().then(function() { return new Promise(function(_, reject) { @@ -356,8 +356,8 @@ asyncTest('A rejected promise derived from throwing in a fulfillment handler' + ' does trigger unhandledRejection', function(done) { const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(e, reason); - assert.strictEqual(_promise, promise); + assert.strictEqual(reason, e); + assert.strictEqual(promise, _promise); }); const _promise = Promise.resolve().then(function() { throw e; @@ -370,8 +370,8 @@ asyncTest( function(done) { const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(e, reason); - assert.strictEqual(_promise, promise); + assert.strictEqual(reason, e); + assert.strictEqual(promise, _promise); }); const _promise = Promise.resolve().then(function() { return Promise.reject(e); @@ -410,8 +410,8 @@ asyncTest('Failing to catch the Promise.all() of a collection that includes' + ' promise, not the passed promise', function(done) { const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(e, reason); - assert.strictEqual(p, promise); + assert.strictEqual(reason, e); + assert.strictEqual(promise, p); }); const p = Promise.all([Promise.reject(e)]); }); @@ -422,13 +422,13 @@ asyncTest('Waiting setTimeout(, 10) to catch a promise causes an' + const unhandledPromises = []; const e = new Error(); process.on('unhandledRejection', function(reason, promise) { - assert.strictEqual(e, reason); + assert.strictEqual(reason, e); unhandledPromises.push(promise); }); process.on('rejectionHandled', function(promise) { - assert.strictEqual(1, unhandledPromises.length); + assert.strictEqual(unhandledPromises.length, 1); assert.strictEqual(unhandledPromises[0], promise); - assert.strictEqual(thePromise, promise); + assert.strictEqual(promise, thePromise); done(); }); @@ -437,7 +437,7 @@ asyncTest('Waiting setTimeout(, 10) to catch a promise causes an' + }); setTimeout(function() { thePromise.then(assert.fail, function(reason) { - assert.strictEqual(e, reason); + assert.strictEqual(reason, e); }); }, 10); }); @@ -568,8 +568,8 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' + ' (setImmediate before promise creation/rejection)', function(done) { const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(e, reason); - assert.strictEqual(p, promise); + assert.strictEqual(reason, e); + assert.strictEqual(promise, p); }); const p = Promise.reject(e); setImmediate(function() { @@ -583,8 +583,8 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' + ' handler; unhandledRejection will be triggered in that case' + ' (setImmediate before promise creation/rejection)', function(done) { onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(undefined, reason); - assert.strictEqual(p, promise); + assert.strictEqual(reason, undefined); + assert.strictEqual(promise, p); }); setImmediate(function() { Promise.resolve().then(function() { @@ -604,8 +604,8 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' + ' handler; unhandledRejection will be triggered in that case' + ' (setImmediate after promise creation/rejection)', function(done) { onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(undefined, reason); - assert.strictEqual(p, promise); + assert.strictEqual(reason, undefined); + assert.strictEqual(promise, p); }); const p = Promise.reject(); setImmediate(function() { @@ -634,8 +634,8 @@ asyncTest( const e = new Error('error'); const domainError = new Error('domain error'); onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(reason, e); - assert.strictEqual(domainReceivedError, domainError); + assert.strictEqual(e, reason); + assert.strictEqual(domainError, domainReceivedError); }); Promise.reject(e); process.nextTick(function() { @@ -670,7 +670,7 @@ asyncTest('Throwing an error inside a rejectionHandled handler goes to' + const e = new Error(); const e2 = new Error(); const tearDownException = setupException(function(err) { - assert.strictEqual(e2, err); + assert.strictEqual(err, e2); tearDownException(); done(); }); From 0b7aa275a91757a30c1af2b7ac5dfaf486088da5 Mon Sep 17 00:00:00 2001 From: "Illescas, Ricardo" Date: Fri, 12 Oct 2018 12:15:43 -0600 Subject: [PATCH 218/328] test: fix argument order in assertion Change the order of assert parameters so the first argument is the value and the second one the expected value. PR-URL: https://github.com/nodejs/node/pull/23581 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani --- test/known_issues/test-http-path-contains-unicode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/known_issues/test-http-path-contains-unicode.js b/test/known_issues/test-http-path-contains-unicode.js index 4d50c8865ba542..a51b07210214b9 100644 --- a/test/known_issues/test-http-path-contains-unicode.js +++ b/test/known_issues/test-http-path-contains-unicode.js @@ -10,7 +10,7 @@ const http = require('http'); const expected = '/café🐶'; -assert.strictEqual('/caf\u{e9}\u{1f436}', expected); +assert.strictEqual(expected, '/caf\u{e9}\u{1f436}'); const server = http.createServer(common.mustCall(function(req, res) { assert.strictEqual(req.url, expected); From 8e7a12f4500c702731313591d64726031ab8c4d2 Mon Sep 17 00:00:00 2001 From: "garrik.leonardo@gmail.com" Date: Fri, 12 Oct 2018 13:30:40 -0500 Subject: [PATCH 219/328] test: improve test coverage for fs module Covering the case when fs-read get invalid argument for file handle PR-URL: https://github.com/nodejs/node/pull/23601 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Gireesh Punathil --- test/parallel/test-fs-read.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/parallel/test-fs-read.js b/test/parallel/test-fs-read.js index 864876537c22c6..715c7b6aebd98d 100644 --- a/test/parallel/test-fs-read.js +++ b/test/parallel/test-fs-read.js @@ -68,3 +68,11 @@ test(new Uint8Array(expected.length), assert.strictEqual(nRead, 0); })); } + +assert.throws( + () => fs.read(null, Buffer.alloc(1), 0, 1, 0), + { + message: 'The "fd" argument must be of type number. Received type object', + code: 'ERR_INVALID_ARG_TYPE', + } +); From 523db5f5a978fe48be56a0c9c944833814e9cfd3 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Tue, 30 Oct 2018 11:49:50 -0400 Subject: [PATCH 220/328] doc: fix headings for CHANGELOG_v10.md The LTS bit flip did not include the new title heading for LTS in the changelog. This commit fixes that. PR-URL: https://github.com/nodejs/node/pull/23973 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat --- doc/changelogs/CHANGELOG_V10.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/changelogs/CHANGELOG_V10.md b/doc/changelogs/CHANGELOG_V10.md index 244247586955b2..153f6eb46c9382 100644 --- a/doc/changelogs/CHANGELOG_V10.md +++ b/doc/changelogs/CHANGELOG_V10.md @@ -5,11 +5,14 @@ - + + - +
CurrentLTS 'Dubnium'Current
+ 10.13.0
+
10.12.0
10.11.0
10.10.0
From 8345a8227d3b73f6bc538602dbaf416771a0d71c Mon Sep 17 00:00:00 2001 From: Bastian Krol Date: Mon, 1 Oct 2018 17:11:25 +0200 Subject: [PATCH 221/328] async_hooks: add missing async_hooks destroys in AsyncReset This adds missing async_hooks destroy calls for sockets (in _http_agent.js) and HTTP parsers. We need to emit a destroy in AsyncWrap#AsyncReset before assigning a new async_id when the instance has already been in use and is being recycled, because in that case, we have already emitted an init for the "old" async_id. This also removes a duplicated init call for HTTP parser: Each time a new parser was created, AsyncReset was being called via the C++ Parser class constructor (super constructor AsyncWrap) and also via Parser::Reinitialize. Backport-PR-URL: https://github.com/nodejs/node/pull/23404 PR-URL: https://github.com/nodejs/node/pull/23272 Fixes: https://github.com/nodejs/node/issues/19859 Reviewed-By: Matteo Collina Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- benchmark/http/bench-parser.js | 2 +- benchmark/misc/freelist.js | 2 +- lib/_http_agent.js | 2 +- lib/_http_client.js | 3 +- lib/_http_common.js | 2 +- lib/_http_server.js | 3 +- lib/internal/freelist.js | 21 ++++- src/async_wrap.cc | 9 ++ src/node_http_parser.cc | 10 ++- test/async-hooks/test-graph.http.js | 13 +-- .../test-async-hooks-http-agent-destroy.js | 84 +++++++++++++++++++ .../test-async-hooks-http-parser-destroy.js | 61 ++++++++++++++ test/parallel/test-freelist.js | 25 +++--- test/parallel/test-http-parser.js | 4 +- test/parallel/test-internal-modules-expose.js | 2 +- test/sequential/test-http-regr-gh-2928.js | 4 +- 16 files changed, 207 insertions(+), 40 deletions(-) create mode 100644 test/parallel/test-async-hooks-http-agent-destroy.js create mode 100644 test/parallel/test-async-hooks-http-parser-destroy.js diff --git a/benchmark/http/bench-parser.js b/benchmark/http/bench-parser.js index d629fe67e59e76..fdf4ec0d1eda14 100644 --- a/benchmark/http/bench-parser.js +++ b/benchmark/http/bench-parser.js @@ -31,7 +31,7 @@ function processHeader(header, n) { bench.start(); for (var i = 0; i < n; i++) { parser.execute(header, 0, header.length); - parser.reinitialize(REQUEST); + parser.reinitialize(REQUEST, i > 0); } bench.end(n); } diff --git a/benchmark/misc/freelist.js b/benchmark/misc/freelist.js index 8c3281cc407363..7fa9af4f3ddb7f 100644 --- a/benchmark/misc/freelist.js +++ b/benchmark/misc/freelist.js @@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, { }); function main({ n }) { - const FreeList = require('internal/freelist'); + const { FreeList } = require('internal/freelist'); const poolSize = 1000; const list = new FreeList('test', poolSize, Object); var j; diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 1a2920cf098298..97c5ab604ff821 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -167,7 +167,7 @@ Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */, var socket = this.freeSockets[name].shift(); // Guard against an uninitialized or user supplied Socket. if (socket._handle && typeof socket._handle.asyncReset === 'function') { - // Assign the handle a new asyncId and run any init() hooks. + // Assign the handle a new asyncId and run any destroy()/init() hooks. socket._handle.asyncReset(); socket[async_id_symbol] = socket._handle.getAsyncId(); } diff --git a/lib/_http_client.js b/lib/_http_client.js index c8c671ccfc418e..075787ba9f8f33 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -48,6 +48,7 @@ const { ERR_UNESCAPED_CHARACTERS } = require('internal/errors').codes; const { validateTimerDuration } = require('internal/timers'); +const is_reused_symbol = require('internal/freelist').symbols.is_reused_symbol; const INVALID_PATH_REGEX = /[^\u0021-\u00ff]/; @@ -625,7 +626,7 @@ function tickOnSocket(req, socket) { var parser = parsers.alloc(); req.socket = socket; req.connection = socket; - parser.reinitialize(HTTPParser.RESPONSE); + parser.reinitialize(HTTPParser.RESPONSE, parser[is_reused_symbol]); parser.socket = socket; parser.outgoing = req; req.parser = parser; diff --git a/lib/_http_common.js b/lib/_http_common.js index 10e8b63bfed75d..8b68d0c81500a8 100644 --- a/lib/_http_common.js +++ b/lib/_http_common.js @@ -23,7 +23,7 @@ const { methods, HTTPParser } = internalBinding('http_parser'); -const FreeList = require('internal/freelist'); +const { FreeList } = require('internal/freelist'); const { ondrain } = require('internal/http'); const incoming = require('_http_incoming'); const { diff --git a/lib/_http_server.js b/lib/_http_server.js index 19783012c436fa..e80765a0d3f6f8 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -42,6 +42,7 @@ const { defaultTriggerAsyncIdScope, getOrSetAsyncId } = require('internal/async_hooks'); +const is_reused_symbol = require('internal/freelist').symbols.is_reused_symbol; const { IncomingMessage } = require('_http_incoming'); const { ERR_HTTP_HEADERS_SENT, @@ -339,7 +340,7 @@ function connectionListenerInternal(server, socket) { socket.on('timeout', socketOnTimeout); var parser = parsers.alloc(); - parser.reinitialize(HTTPParser.REQUEST); + parser.reinitialize(HTTPParser.REQUEST, parser[is_reused_symbol]); parser.socket = socket; socket.parser = parser; diff --git a/lib/internal/freelist.js b/lib/internal/freelist.js index 7e9cef9528ab75..04d684e8334ff5 100644 --- a/lib/internal/freelist.js +++ b/lib/internal/freelist.js @@ -1,5 +1,7 @@ 'use strict'; +const is_reused_symbol = Symbol('isReused'); + class FreeList { constructor(name, max, ctor) { this.name = name; @@ -9,9 +11,15 @@ class FreeList { } alloc() { - return this.list.length ? - this.list.pop() : - this.ctor.apply(this, arguments); + let item; + if (this.list.length > 0) { + item = this.list.pop(); + item[is_reused_symbol] = true; + } else { + item = this.ctor.apply(this, arguments); + item[is_reused_symbol] = false; + } + return item; } free(obj) { @@ -23,4 +31,9 @@ class FreeList { } } -module.exports = FreeList; +module.exports = { + FreeList, + symbols: { + is_reused_symbol + } +}; diff --git a/src/async_wrap.cc b/src/async_wrap.cc index 0cfe0202ccf675..bf751f9b661cee 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -562,6 +562,7 @@ AsyncWrap::AsyncWrap(Environment* env, CHECK_NE(provider, PROVIDER_NONE); CHECK_GE(object->InternalFieldCount(), 1); + async_id_ = -1; // Use AsyncReset() call to execute the init() callbacks. AsyncReset(execution_async_id, silent); } @@ -605,6 +606,14 @@ void AsyncWrap::EmitDestroy(Environment* env, double async_id) { // and reused over their lifetime. This way a new uid can be assigned when // the resource is pulled out of the pool and put back into use. void AsyncWrap::AsyncReset(double execution_async_id, bool silent) { + if (async_id_ != -1) { + // This instance was in use before, we have already emitted an init with + // its previous async_id and need to emit a matching destroy for that + // before generating a new async_id. + EmitDestroy(env(), async_id_); + } + + // Now we can assign a new async_id_ to this instance. async_id_ = execution_async_id == -1 ? env()->new_async_id() : execution_async_id; trigger_async_id_ = env()->get_default_trigger_async_id(); diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 771189d0904359..58bae3323c0484 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -465,6 +465,8 @@ class Parser : public AsyncWrap, public StreamListener { Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsInt32()); + CHECK(args[1]->IsBoolean()); + bool isReused = args[1]->IsTrue(); http_parser_type type = static_cast(args[0].As()->Value()); @@ -473,8 +475,12 @@ class Parser : public AsyncWrap, public StreamListener { ASSIGN_OR_RETURN_UNWRAP(&parser, args.Holder()); // Should always be called from the same context. CHECK_EQ(env, parser->env()); - // The parser is being reused. Reset the async id and call init() callbacks. - parser->AsyncReset(); + // This parser has either just been created or it is being reused. + // We must only call AsyncReset for the latter case, because AsyncReset has + // already been called via the constructor for the former case. + if (isReused) { + parser->AsyncReset(); + } parser->Init(type); } diff --git a/test/async-hooks/test-graph.http.js b/test/async-hooks/test-graph.http.js index eea72ca3bac72c..4f787d43e8231f 100644 --- a/test/async-hooks/test-graph.http.js +++ b/test/async-hooks/test-graph.http.js @@ -38,24 +38,15 @@ process.on('exit', function() { { type: 'HTTPPARSER', id: 'httpparser:1', triggerAsyncId: 'tcpserver:1' }, - { type: 'HTTPPARSER', - id: 'httpparser:2', - triggerAsyncId: 'tcpserver:1' }, { type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' }, { type: 'Timeout', id: 'timeout:1', triggerAsyncId: 'tcp:2' }, { type: 'TIMERWRAP', id: 'timer:1', triggerAsyncId: 'tcp:2' }, { type: 'HTTPPARSER', - id: 'httpparser:3', - triggerAsyncId: 'tcp:2' }, - { type: 'HTTPPARSER', - id: 'httpparser:4', + id: 'httpparser:2', triggerAsyncId: 'tcp:2' }, { type: 'Timeout', id: 'timeout:2', - triggerAsyncId: 'httpparser:4' }, - { type: 'TIMERWRAP', - id: 'timer:2', - triggerAsyncId: 'httpparser:4' }, + triggerAsyncId: 'httpparser:2' }, { type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'tcp:2' } ] diff --git a/test/parallel/test-async-hooks-http-agent-destroy.js b/test/parallel/test-async-hooks-http-agent-destroy.js new file mode 100644 index 00000000000000..637f2c511410e7 --- /dev/null +++ b/test/parallel/test-async-hooks-http-agent-destroy.js @@ -0,0 +1,84 @@ +'use strict'; +// Flags: --expose-internals +const common = require('../common'); +const assert = require('assert'); +const { async_id_symbol } = require('internal/async_hooks').symbols; +const async_hooks = require('async_hooks'); +const http = require('http'); + +// Regression test for https://github.com/nodejs/node/issues/19859 +// Checks that an http.Agent emits a destroy for the old asyncId before calling +// asyncReset()s when reusing a socket handle. The setup is nearly identical to +// parallel/test-async-hooks-http-agent (which focuses on the assertion that +// a fresh asyncId is assigned to the net.Socket instance). + +const destroyedIds = new Set(); +async_hooks.createHook({ + destroy: common.mustCallAtLeast((asyncId) => { + destroyedIds.add(asyncId); + }, 1) +}).enable(); + +// Make sure a single socket is transparently reused for 2 requests. +const agent = new http.Agent({ + keepAlive: true, + keepAliveMsecs: Infinity, + maxSockets: 1 +}); + +const server = http.createServer(common.mustCall((req, res) => { + req.once('data', common.mustCallAtLeast(() => { + res.writeHead(200, { 'Content-Type': 'text/plain' }); + res.write('foo'); + })); + req.on('end', common.mustCall(() => { + res.end('bar'); + })); +}, 2)).listen(0, common.mustCall(() => { + const port = server.address().port; + const payload = 'hello world'; + + // First request. This is useless except for adding a socket to the + // agent’s pool for reuse. + const r1 = http.request({ + agent, port, method: 'POST' + }, common.mustCall((res) => { + // Remember which socket we used. + const socket = res.socket; + const asyncIdAtFirstRequest = socket[async_id_symbol]; + assert.ok(asyncIdAtFirstRequest > 0, `${asyncIdAtFirstRequest} > 0`); + // Check that request and response share their socket. + assert.strictEqual(r1.socket, socket); + + res.on('data', common.mustCallAtLeast(() => {})); + res.on('end', common.mustCall(() => { + // setImmediate() to give the agent time to register the freed socket. + setImmediate(common.mustCall(() => { + // The socket is free for reuse now. + assert.strictEqual(socket[async_id_symbol], -1); + + // second request: + const r2 = http.request({ + agent, port, method: 'POST' + }, common.mustCall((res) => { + assert.ok(destroyedIds.has(asyncIdAtFirstRequest)); + + // Empty payload, to hit the “right” code path. + r2.end(''); + + res.on('data', common.mustCallAtLeast(() => {})); + res.on('end', common.mustCall(() => { + // Clean up to let the event loop stop. + server.close(); + agent.destroy(); + })); + })); + + // Schedule a payload to be written immediately, but do not end the + // request just yet. + r2.write(payload); + })); + })); + })); + r1.end(payload); +})); diff --git a/test/parallel/test-async-hooks-http-parser-destroy.js b/test/parallel/test-async-hooks-http-parser-destroy.js new file mode 100644 index 00000000000000..aeb805702d89e9 --- /dev/null +++ b/test/parallel/test-async-hooks-http-parser-destroy.js @@ -0,0 +1,61 @@ +'use strict'; +const common = require('../common'); +const Countdown = require('../common/countdown'); +const assert = require('assert'); +const async_hooks = require('async_hooks'); +const http = require('http'); + +// Regression test for https://github.com/nodejs/node/issues/19859. +// Checks that matching destroys are emitted when creating new/reusing old http +// parser instances. + +const N = 50; +const KEEP_ALIVE = 100; + +const createdIds = []; +const destroyedIds = []; +async_hooks.createHook({ + init: common.mustCallAtLeast((asyncId, type) => { + if (type === 'HTTPPARSER') { + createdIds.push(asyncId); + } + }, N), + destroy: (asyncId) => { + destroyedIds.push(asyncId); + } +}).enable(); + +const server = http.createServer(function(req, res) { + res.end('Hello'); +}); + +const keepAliveAgent = new http.Agent({ + keepAlive: true, + keepAliveMsecs: KEEP_ALIVE, +}); + +const countdown = new Countdown(N, () => { + server.close(() => { + // give the server sockets time to close (which will also free their + // associated parser objects) after the server has been closed. + setTimeout(() => { + createdIds.forEach((createdAsyncId) => { + assert.ok(destroyedIds.indexOf(createdAsyncId) >= 0); + }); + }, KEEP_ALIVE * 2); + }); +}); + +server.listen(0, function() { + for (let i = 0; i < N; ++i) { + (function makeRequest() { + http.get({ + port: server.address().port, + agent: keepAliveAgent + }, function(res) { + countdown.dec(); + res.resume(); + }); + })(); + } +}); diff --git a/test/parallel/test-freelist.js b/test/parallel/test-freelist.js index d1f7d888c03868..03946dfda257c2 100644 --- a/test/parallel/test-freelist.js +++ b/test/parallel/test-freelist.js @@ -4,28 +4,27 @@ require('../common'); const assert = require('assert'); -const FreeList = require('internal/freelist'); +const { FreeList } = require('internal/freelist'); assert.strictEqual(typeof FreeList, 'function'); -const flist1 = new FreeList('flist1', 3, String); +const flist1 = new FreeList('flist1', 3, Object); // Allocating when empty, should not change the list size -const result = flist1.alloc('test'); -assert.strictEqual(typeof result, 'string'); -assert.strictEqual(result, 'test'); +const result = flist1.alloc(); +assert.strictEqual(typeof result, 'object'); assert.strictEqual(flist1.list.length, 0); // Exhaust the free list -assert(flist1.free('test1')); -assert(flist1.free('test2')); -assert(flist1.free('test3')); +assert(flist1.free({ id: 'test1' })); +assert(flist1.free({ id: 'test2' })); +assert(flist1.free({ id: 'test3' })); // Now it should not return 'true', as max length is exceeded -assert.strictEqual(flist1.free('test4'), false); -assert.strictEqual(flist1.free('test5'), false); +assert.strictEqual(flist1.free({ id: 'test4' }), false); +assert.strictEqual(flist1.free({ id: 'test5' }), false); // At this point 'alloc' should just return the stored values -assert.strictEqual(flist1.alloc(), 'test3'); -assert.strictEqual(flist1.alloc(), 'test2'); -assert.strictEqual(flist1.alloc(), 'test1'); +assert.strictEqual(flist1.alloc().id, 'test3'); +assert.strictEqual(flist1.alloc().id, 'test2'); +assert.strictEqual(flist1.alloc().id, 'test1'); diff --git a/test/parallel/test-http-parser.js b/test/parallel/test-http-parser.js index bc9c6920bc36a2..d555af867105cc 100644 --- a/test/parallel/test-http-parser.js +++ b/test/parallel/test-http-parser.js @@ -95,7 +95,7 @@ function expectBody(expected) { throw new Error('hello world'); }; - parser.reinitialize(HTTPParser.REQUEST); + parser.reinitialize(HTTPParser.REQUEST, true); assert.throws( () => { parser.execute(request, 0, request.length); }, @@ -555,7 +555,7 @@ function expectBody(expected) { parser[kOnBody] = expectBody('ping'); parser.execute(req1, 0, req1.length); - parser.reinitialize(REQUEST); + parser.reinitialize(REQUEST, true); parser[kOnBody] = expectBody('pong'); parser[kOnHeadersComplete] = onHeadersComplete2; parser.execute(req2, 0, req2.length); diff --git a/test/parallel/test-internal-modules-expose.js b/test/parallel/test-internal-modules-expose.js index a3fd6f63ffe399..ab48e36881268c 100644 --- a/test/parallel/test-internal-modules-expose.js +++ b/test/parallel/test-internal-modules-expose.js @@ -7,5 +7,5 @@ const config = process.binding('config'); console.log(config, process.argv); -assert.strictEqual(typeof require('internal/freelist'), 'function'); +assert.strictEqual(typeof require('internal/freelist').FreeList, 'function'); assert.strictEqual(config.exposeInternals, true); diff --git a/test/sequential/test-http-regr-gh-2928.js b/test/sequential/test-http-regr-gh-2928.js index 55e3a93bc98eaa..77fea620779766 100644 --- a/test/sequential/test-http-regr-gh-2928.js +++ b/test/sequential/test-http-regr-gh-2928.js @@ -1,11 +1,13 @@ // This test is designed to fail with a segmentation fault in Node.js 4.1.0 and // execute without issues in Node.js 4.1.1 and up. +// Flags: --expose-internals 'use strict'; const common = require('../common'); const assert = require('assert'); const httpCommon = require('_http_common'); const HTTPParser = process.binding('http_parser').HTTPParser; +const is_reused_symbol = require('internal/freelist').symbols.is_reused_symbol; const net = require('net'); const COUNT = httpCommon.parsers.max + 1; @@ -23,7 +25,7 @@ function execAndClose() { process.stdout.write('.'); const parser = parsers.pop(); - parser.reinitialize(HTTPParser.RESPONSE); + parser.reinitialize(HTTPParser.RESPONSE, parser[is_reused_symbol]); const socket = net.connect(common.PORT); socket.on('error', (e) => { From e9a291582d145a00df27aaaa54b66e42c725d89e Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Wed, 31 Oct 2018 09:41:10 -0500 Subject: [PATCH 222/328] win: clarify Boxstarter behavior on install tools Clarify the behavior of what Boxstarter may do when it runs on a box to install all the necessary tools so that there are no surprises to the end user when the script is run. Currently there is no interface that warns the user that Boxstarter will reboot the machine possibly multiple times depending on how many dependencies need to be installed and doesn't mention a need to disable UAC. For folks who see what may look like a reboot loop, we feel it is necessary to make them aware that UAC will be disabled and they will need to take action to re-enable UAC manually if they interfere/stop the script from finishing. PR-URL: https://github.com/nodejs/node/pull/23987 Fixes: https://github.com/nodejs/Release/issues/369 Reviewed-By: John-David Dalton Reviewed-By: Refael Ackermann Reviewed-By: Richard Lau --- tools/msvs/install_tools/install_tools.bat | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/msvs/install_tools/install_tools.bat b/tools/msvs/install_tools/install_tools.bat index db10cf1f46049e..1585b5b7c96e04 100644 --- a/tools/msvs/install_tools/install_tools.bat +++ b/tools/msvs/install_tools/install_tools.bat @@ -47,7 +47,23 @@ echo script is at your own risk. Please read the Chocolatey's legal terms of use echo and the Boxstarter project license as well as how the community repository echo for Chocolatey.org is maintained. echo. -echo You can close this window to stop now. +pause + +cls +echo !!!!!WARNING!!!!! +echo ----------------- +echo Use of Boxstarter may reboot your computer automatically multiple times. +echo When performing a reboot, Boxstarter will need to disable User Account +echo Control (UAC) to allow the script to run immediately after the reboot. When +echo the scripts have completed, Boxstarter will re-enable UAC. If you prematurely +echo stop the process, UAC will need to be re-enabled manually. +echo. +echo Sometimes the scripts may install all necessary Windows Updates which +echo could cause a high number of reboots that appear to be a reboot loop when +echo in fact it is just a normal Windows Updates reboot cycle. +echo. +echo If this is not what you would like to occur, you can close this window +echo to stop now. pause "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command Start-Process '%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe' -ArgumentList '-NoProfile -InputFormat None -ExecutionPolicy Bypass -Command iex ((New-Object System.Net.WebClient).DownloadString(''https://boxstarter.org/bootstrapper.ps1'')); get-boxstarter -Force; Install-BoxstarterPackage -PackageName ''%~dp0\install_tools.txt''; Read-Host ''Type ENTER to exit'' ' -Verb RunAs From 257a5e9c389b648aca08b02aae9e19f142ce0493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Wed, 31 Oct 2018 00:52:35 +0000 Subject: [PATCH 223/328] win: add prompt to tools installation script Fixes: https://github.com/nodejs/Release/issues/369 PR-URL: https://github.com/nodejs/node/pull/23987 Reviewed-By: John-David Dalton Reviewed-By: Refael Ackermann Reviewed-By: Richard Lau --- tools/msvs/install_tools/install_tools.bat | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/msvs/install_tools/install_tools.bat b/tools/msvs/install_tools/install_tools.bat index 1585b5b7c96e04..36456fa6f656a9 100644 --- a/tools/msvs/install_tools/install_tools.bat +++ b/tools/msvs/install_tools/install_tools.bat @@ -1,5 +1,7 @@ @echo off +setlocal + cls echo ==================================================== echo Tools for Node.js Native Modules Installation Script @@ -61,9 +63,14 @@ echo. echo Sometimes the scripts may install all necessary Windows Updates which echo could cause a high number of reboots that appear to be a reboot loop when echo in fact it is just a normal Windows Updates reboot cycle. +:acceptretry echo. -echo If this is not what you would like to occur, you can close this window -echo to stop now. -pause +echo Your computer may REBOOT SEVERAL TIMES WITHOUT FURTHER WARNING. +echo Please type YES followed by enter to confirm that you have saved all your +set /p "ACCEPT_PROMPT=work and closed all open programs: " +if /i not "%ACCEPT_PROMPT%"=="yes" ( + echo Please type YES to confirm, or close the window to exit. + goto acceptretry +) "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command Start-Process '%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe' -ArgumentList '-NoProfile -InputFormat None -ExecutionPolicy Bypass -Command iex ((New-Object System.Net.WebClient).DownloadString(''https://boxstarter.org/bootstrapper.ps1'')); get-boxstarter -Force; Install-BoxstarterPackage -PackageName ''%~dp0\install_tools.txt''; Read-Host ''Type ENTER to exit'' ' -Verb RunAs From d1102f81dc49eb38b3ceb756e2d21eb3ca325cb0 Mon Sep 17 00:00:00 2001 From: Suresh Srinivas Date: Fri, 23 Mar 2018 12:16:48 -0700 Subject: [PATCH 224/328] src: initial large page (2M) support Backport-PR-URL: https://github.com/nodejs/node/pull/23861 PR-URL: https://github.com/nodejs/node/pull/22079 Reviewed-By: Gireesh Punathil Reviewed-By: Denys Otrishko Reviewed-By: Refael Ackermann --- configure.py | 24 +++ node.gyp | 9 + node.gypi | 10 ++ src/large_pages/ld.implicit.script | 8 + src/large_pages/node_large_page.cc | 276 +++++++++++++++++++++++++++++ src/large_pages/node_large_page.h | 35 ++++ src/node.cc | 12 ++ 7 files changed, 374 insertions(+) create mode 100644 src/large_pages/ld.implicit.script create mode 100644 src/large_pages/node_large_page.cc create mode 100644 src/large_pages/node_large_page.h diff --git a/configure.py b/configure.py index bfed05d495a957..841f6c7902c193 100755 --- a/configure.py +++ b/configure.py @@ -388,6 +388,12 @@ dest='with_etw', help='build with ETW (default is true on Windows)') +parser.add_option('--use-largepages', + action='store_true', + dest='node_use_large_pages', + help='build with Large Pages support. This feature is supported only on Linux kernel' + + '>= 2.6.38 with Transparent Huge pages enabled') + intl_optgroup.add_option('--with-intl', action='store', dest='with_intl', @@ -1008,6 +1014,24 @@ def configure_node(o): else: o['variables']['node_use_dtrace'] = 'false' + if options.node_use_large_pages and flavor != 'linux': + raise Exception( + 'Large pages are supported only on Linux Systems.') + if options.node_use_large_pages and flavor == 'linux': + if options.shared or options.enable_static: + raise Exception( + 'Large pages are supported only while creating node executable.') + if target_arch!="x64": + raise Exception( + 'Large pages are supported only x64 platform.') + # Example full version string: 2.6.32-696.28.1.el6.x86_64 + FULL_KERNEL_VERSION=os.uname()[2] + KERNEL_VERSION=FULL_KERNEL_VERSION.split('-')[0] + if KERNEL_VERSION < "2.6.38": + raise Exception( + 'Large pages need Linux kernel version >= 2.6.38') + o['variables']['node_use_large_pages'] = b(options.node_use_large_pages) + if options.no_ifaddrs: o['defines'] += ['SUNOS_NO_IFADDRS'] diff --git a/node.gyp b/node.gyp index 910489d3ad5ce5..31fd9ac90c5b75 100644 --- a/node.gyp +++ b/node.gyp @@ -604,6 +604,15 @@ 'src/tls_wrap.h' ], }], + [ 'node_use_large_pages=="true" and OS=="linux"', { + 'defines': [ 'NODE_ENABLE_LARGE_CODE_PAGES=1' ], + # The current implementation of Large Pages is under Linux. + # Other implementations are possible but not currently supported. + 'sources': [ + 'src/large_pages/node_large_page.cc', + 'src/large_pages/node_large_page.h' + ], + }], [ 'use_openssl_def==1', { # TODO(bnoordhuis) Make all platforms export the same list of symbols. # Teach mkssldef.py to generate linker maps that UNIX linkers understand. diff --git a/node.gypi b/node.gypi index ae56249ae3ad76..ab2df8645e4e0e 100644 --- a/node.gypi +++ b/node.gypi @@ -289,6 +289,16 @@ 'ldflags': [ '-Wl,-M,/usr/lib/ld/map.noexstk' ], }], + [ 'OS in "freebsd linux"', { + 'ldflags': [ '-Wl,-z,relro', + '-Wl,-z,now' ] + }], + [ 'OS=="linux" and target_arch=="x64" and node_use_large_pages=="true"', { + 'ldflags': [ + '-Wl,-T', + ' +#include // _O_RDWR +#include // PATH_MAX +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // readlink + +// The functions in this file map the text segment of node into 2M pages. +// The algorithm is simple +// Find the text region of node binary in memory +// 1: Examine the /proc/self/maps to determine the currently mapped text +// region and obtain the start and end +// Modify the start to point to the very beginning of node text segment +// (from variable nodetext setup in ld.script) +// Align the address of start and end to Large Page Boundaries +// +// 2: Move the text region to large pages +// Map a new area and copy the original code there +// Use mmap using the start address with MAP_FIXED so we get exactly the +// same virtual address +// Use madvise with MADV_HUGE_PAGE to use Anonymous 2M Pages +// If successful copy the code there and unmap the original region. + +extern char __nodetext; + +namespace node { + +struct text_region { + char* from; + char* to; + int total_hugepages; + bool found_text_region; +}; + +static const size_t hps = 2L * 1024 * 1024; + +static void PrintSystemError(int error) { + fprintf(stderr, "Hugepages WARNING: %s\n", strerror(error)); + return; +} + +inline int64_t hugepage_align_up(int64_t addr) { + return (((addr) + (hps) - 1) & ~((hps) - 1)); +} + +inline int64_t hugepage_align_down(int64_t addr) { + return ((addr) & ~((hps) - 1)); +} + +// The format of the maps file is the following +// address perms offset dev inode pathname +// 00400000-00452000 r-xp 00000000 08:02 173521 /usr/bin/dbus-daemon +// This is also handling the case where the first line is not the binary + +static struct text_region FindNodeTextRegion() { + std::ifstream ifs; + std::string map_line; + std::string permission; + std::string dev; + char dash; + int64_t start, end, offset, inode; + struct text_region nregion; + + nregion.found_text_region = false; + + ifs.open("/proc/self/maps"); + if (!ifs) { + fprintf(stderr, "Could not open /proc/self/maps\n"); + return nregion; + } + + std::string exename; + { + char selfexe[PATH_MAX]; + ssize_t count = readlink("/proc/self/exe", selfexe, PATH_MAX); + exename = std::string(selfexe, count); + } + + while (std::getline(ifs, map_line)) { + std::istringstream iss(map_line); + iss >> std::hex >> start; + iss >> dash; + iss >> std::hex >> end; + iss >> permission; + iss >> offset; + iss >> dev; + iss >> inode; + if (inode != 0) { + std::string pathname; + iss >> pathname; + if (pathname == exename && permission == "r-xp") { + start = reinterpret_cast(&__nodetext); + char* from = reinterpret_cast(hugepage_align_up(start)); + char* to = reinterpret_cast(hugepage_align_down(end)); + + if (from < to) { + size_t size = to - from; + nregion.found_text_region = true; + nregion.from = from; + nregion.to = to; + nregion.total_hugepages = size / hps; + } + break; + } + } + } + + ifs.close(); + return nregion; +} + +static bool IsTransparentHugePagesEnabled() { + std::ifstream ifs; + + ifs.open("/sys/kernel/mm/transparent_hugepage/enabled"); + if (!ifs) { + fprintf(stderr, "Could not open file: " \ + "/sys/kernel/mm/transparent_hugepage/enabled\n"); + return false; + } + + std::string always, madvise, never; + if (ifs.is_open()) { + while (ifs >> always >> madvise >> never) {} + } + + int ret_status = false; + + if (always.compare("[always]") == 0) + ret_status = true; + else if (madvise.compare("[madvise]") == 0) + ret_status = true; + else if (never.compare("[never]") == 0) + ret_status = false; + + ifs.close(); + return ret_status; +} + +// Moving the text region to large pages. We need to be very careful. +// 1: This function itself should not be moved. +// We use a gcc attributes +// (__section__) to put it outside the ".text" section +// (__aligned__) to align it at 2M boundary +// (__noline__) to not inline this function +// 2: This function should not call any function(s) that might be moved. +// a. map a new area and copy the original code there +// b. mmap using the start address with MAP_FIXED so we get exactly +// the same virtual address +// c. madvise with MADV_HUGE_PAGE +// d. If successful copy the code there and unmap the original region +int +__attribute__((__section__(".lpstub"))) +__attribute__((__aligned__(hps))) +__attribute__((__noinline__)) +MoveTextRegionToLargePages(const text_region& r) { + void* nmem = nullptr; + void* tmem = nullptr; + int ret = 0; + + size_t size = r.to - r.from; + void* start = r.from; + + // Allocate temporary region preparing for copy + nmem = mmap(nullptr, size, + PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (nmem == MAP_FAILED) { + PrintSystemError(errno); + return -1; + } + + memcpy(nmem, r.from, size); + +// We already know the original page is r-xp +// (PROT_READ, PROT_EXEC, MAP_PRIVATE) +// We want PROT_WRITE because we are writing into it. +// We want it at the fixed address and we use MAP_FIXED. + tmem = mmap(start, size, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1 , 0); + if (tmem == MAP_FAILED) { + PrintSystemError(errno); + munmap(nmem, size); + return -1; + } + + ret = madvise(tmem, size, MADV_HUGEPAGE); + if (ret == -1) { + PrintSystemError(errno); + ret = munmap(tmem, size); + if (ret == -1) { + PrintSystemError(errno); + } + ret = munmap(nmem, size); + if (ret == -1) { + PrintSystemError(errno); + } + + return -1; + } + + memcpy(start, nmem, size); + ret = mprotect(start, size, PROT_READ | PROT_EXEC); + if (ret == -1) { + PrintSystemError(errno); + ret = munmap(tmem, size); + if (ret == -1) { + PrintSystemError(errno); + } + ret = munmap(nmem, size); + if (ret == -1) { + PrintSystemError(errno); + } + return -1; + } + + // Release the old/temporary mapped region + ret = munmap(nmem, size); + if (ret == -1) { + PrintSystemError(errno); + } + + return ret; +} + +// This is the primary API called from main +int MapStaticCodeToLargePages() { + struct text_region r = FindNodeTextRegion(); + if (r.found_text_region == false) { + fprintf(stderr, "Hugepages WARNING: failed to find text region\n"); + return -1; + } + + if (r.from > reinterpret_cast(&MoveTextRegionToLargePages)) + return MoveTextRegionToLargePages(r); + + return -1; +} + +bool IsLargePagesEnabled() { + return IsTransparentHugePagesEnabled(); +} + +} // namespace node diff --git a/src/large_pages/node_large_page.h b/src/large_pages/node_large_page.h new file mode 100644 index 00000000000000..bce505585cf0d0 --- /dev/null +++ b/src/large_pages/node_large_page.h @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Intel Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom +// the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES +// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +// OR OTHER DEALINGS IN THE SOFTWARE. +// +// SPDX-License-Identifier: MIT + +#ifndef SRC_LARGE_PAGES_NODE_LARGE_PAGE_H_ +#define SRC_LARGE_PAGES_NODE_LARGE_PAGE_H_ + +#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + + +namespace node { +bool IsLargePagesEnabled(); +int MapStaticCodeToLargePages(); +} // namespace node + +#endif // NODE_WANT_INTERNALS +#endif // SRC_LARGE_PAGES_NODE_LARGE_PAGE_H_ diff --git a/src/node.cc b/src/node.cc index 7e8738080b3c5e..d9f297cc29a92b 100644 --- a/src/node.cc +++ b/src/node.cc @@ -73,6 +73,10 @@ #include "../deps/v8/src/third_party/vtune/v8-vtune.h" #endif +#ifdef NODE_ENABLE_LARGE_CODE_PAGES +#include "large_pages/node_large_page.h" +#endif + #include #include // _O_RDWR #include // PATH_MAX @@ -2985,6 +2989,14 @@ int Start(int argc, char** argv) { CHECK_GT(argc, 0); +#ifdef NODE_ENABLE_LARGE_CODE_PAGES + if (node::IsLargePagesEnabled()) { + if (node::MapStaticCodeToLargePages() != 0) { + fprintf(stderr, "Reverting to default page size\n"); + } + } +#endif + // Hack around with the argv pointer. Used for process.title = "blah". argv = uv_setup_args(argc, argv); From 8552bb406544baaed74203d0b9baf04e09466803 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Tue, 16 Oct 2018 13:28:52 -0400 Subject: [PATCH 225/328] test: enable trace-events tests for workers Use the `cwd` option for `child_process` instead of `process.chdir()` to enable the trace events tests to run on workers. Conflicts: test/parallel/test-trace-events-binding.js test/parallel/test-trace-events-category-used.js Backport-PR-URL: https://github.com/nodejs/node/pull/23882 PR-URL: https://github.com/nodejs/node/pull/23698 Refs: https://github.com/nodejs/node/pull/23674#discussion_r225335819 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- test/parallel/test-trace-events-all.js | 10 ++++------ test/parallel/test-trace-events-api.js | 3 +-- test/parallel/test-trace-events-async-hooks.js | 10 ++++------ test/parallel/test-trace-events-binding.js | 10 ++++------ test/parallel/test-trace-events-bootstrap.js | 7 ++----- test/parallel/test-trace-events-category-used.js | 10 ++++------ test/parallel/test-trace-events-file-pattern.js | 10 ++++------ test/parallel/test-trace-events-fs-sync.js | 9 +++------ test/parallel/test-trace-events-metadata.js | 10 ++++------ test/parallel/test-trace-events-none.js | 10 ++++------ test/parallel/test-trace-events-perf.js | 7 ++----- test/parallel/test-trace-events-process-exit.js | 12 ++++-------- test/parallel/test-trace-events-promises.js | 7 ++----- test/parallel/test-trace-events-v8.js | 10 ++++------ test/parallel/test-trace-events-vm.js | 7 ++----- 15 files changed, 48 insertions(+), 84 deletions(-) diff --git a/test/parallel/test-trace-events-all.js b/test/parallel/test-trace-events-all.js index f3d38cb4286b13..01e869f4abe9c8 100644 --- a/test/parallel/test-trace-events-all.js +++ b/test/parallel/test-trace-events-all.js @@ -3,20 +3,18 @@ const common = require('../common'); const assert = require('assert'); const cp = require('child_process'); const fs = require('fs'); - -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); +const path = require('path'); const CODE = 'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)'; -const FILE_NAME = 'node_trace.1.log'; const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -process.chdir(tmpdir.path); +const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log'); const proc = cp.spawn(process.execPath, - [ '--trace-events-enabled', '-e', CODE ]); + [ '--trace-events-enabled', '-e', CODE ], + { cwd: tmpdir.path }); proc.once('exit', common.mustCall(() => { assert(fs.existsSync(FILE_NAME)); diff --git a/test/parallel/test-trace-events-api.js b/test/parallel/test-trace-events-api.js index f7d7ec35b022f6..2810ac0dd0f6d7 100644 --- a/test/parallel/test-trace-events-api.js +++ b/test/parallel/test-trace-events-api.js @@ -5,8 +5,7 @@ const common = require('../common'); if (!process.binding('config').hasTracing) common.skip('missing trace events'); -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); +common.skipIfWorker(); // https://github.com/nodejs/node/issues/22767 const assert = require('assert'); const cp = require('child_process'); diff --git a/test/parallel/test-trace-events-async-hooks.js b/test/parallel/test-trace-events-async-hooks.js index 8374b6546a6e79..0ec00da78d0c21 100644 --- a/test/parallel/test-trace-events-async-hooks.js +++ b/test/parallel/test-trace-events-async-hooks.js @@ -3,22 +3,20 @@ const common = require('../common'); const assert = require('assert'); const cp = require('child_process'); const fs = require('fs'); +const path = require('path'); const util = require('util'); -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); - const CODE = 'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)'; -const FILE_NAME = 'node_trace.1.log'; const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -process.chdir(tmpdir.path); +const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log'); const proc = cp.spawn(process.execPath, [ '--trace-event-categories', 'node.async_hooks', - '-e', CODE ]); + '-e', CODE ], + { cwd: tmpdir.path }); proc.once('exit', common.mustCall(() => { assert(fs.existsSync(FILE_NAME)); diff --git a/test/parallel/test-trace-events-binding.js b/test/parallel/test-trace-events-binding.js index 7ce75ace330990..b8491e5e1bb103 100644 --- a/test/parallel/test-trace-events-binding.js +++ b/test/parallel/test-trace-events-binding.js @@ -3,9 +3,7 @@ const common = require('../common'); const assert = require('assert'); const cp = require('child_process'); const fs = require('fs'); - -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); +const path = require('path'); const CODE = ` process.binding("trace_events").emit( @@ -21,15 +19,15 @@ const CODE = ` 'b'.charCodeAt(0), 'missing', 'type-value', 10, 'extra-value', 20); `; -const FILE_NAME = 'node_trace.1.log'; const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -process.chdir(tmpdir.path); +const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log'); const proc = cp.spawn(process.execPath, [ '--trace-event-categories', 'custom', - '-e', CODE ]); + '-e', CODE ], + { cwd: tmpdir.path }); proc.once('exit', common.mustCall(() => { assert(fs.existsSync(FILE_NAME)); diff --git a/test/parallel/test-trace-events-bootstrap.js b/test/parallel/test-trace-events-bootstrap.js index 8d5e00f00f8b0c..087fbd2f182a61 100644 --- a/test/parallel/test-trace-events-bootstrap.js +++ b/test/parallel/test-trace-events-bootstrap.js @@ -2,13 +2,10 @@ const common = require('../common'); const assert = require('assert'); const cp = require('child_process'); -const path = require('path'); const fs = require('fs'); +const path = require('path'); const tmpdir = require('../common/tmpdir'); -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); - const names = [ 'environment', 'nodeStart', @@ -30,10 +27,10 @@ if (process.argv[2] === 'child') { 1 + 1; } else { tmpdir.refresh(); - process.chdir(tmpdir.path); const proc = cp.fork(__filename, [ 'child' ], { + cwd: tmpdir.path, execArgv: [ '--trace-event-categories', 'node.bootstrap' diff --git a/test/parallel/test-trace-events-category-used.js b/test/parallel/test-trace-events-category-used.js index d5aff4e1361ce6..971a8ef832ce1d 100644 --- a/test/parallel/test-trace-events-category-used.js +++ b/test/parallel/test-trace-events-category-used.js @@ -3,20 +3,17 @@ const common = require('../common'); const assert = require('assert'); const cp = require('child_process'); -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); - const CODE = `console.log( process.binding("trace_events").categoryGroupEnabled("custom") );`; const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -process.chdir(tmpdir.path); const procEnabled = cp.spawn( process.execPath, - [ '--trace-event-categories', 'custom', '-e', CODE ] + [ '--trace-event-categories', 'custom', '-e', CODE ], + { cwd: tmpdir.path } ); let procEnabledOutput = ''; @@ -28,7 +25,8 @@ procEnabled.once('exit', common.mustCall(() => { const procDisabled = cp.spawn( process.execPath, - [ '--trace-event-categories', 'other', '-e', CODE ] + [ '--trace-event-categories', 'other', '-e', CODE ], + { cwd: tmpdir.path } ); let procDisabledOutput = ''; diff --git a/test/parallel/test-trace-events-file-pattern.js b/test/parallel/test-trace-events-file-pattern.js index 60a3296c642994..a60559b7f91b2b 100644 --- a/test/parallel/test-trace-events-file-pattern.js +++ b/test/parallel/test-trace-events-file-pattern.js @@ -4,12 +4,9 @@ const tmpdir = require('../common/tmpdir'); const assert = require('assert'); const cp = require('child_process'); const fs = require('fs'); - -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); +const path = require('path'); tmpdir.refresh(); -process.chdir(tmpdir.path); const CODE = 'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)'; @@ -20,10 +17,11 @@ const proc = cp.spawn(process.execPath, [ // eslint-disable-next-line no-template-curly-in-string '${pid}-${rotation}-${pid}-${rotation}.tracing.log', '-e', CODE -]); +], { cwd: tmpdir.path }); proc.once('exit', common.mustCall(() => { - const expectedFilename = `${proc.pid}-1-${proc.pid}-1.tracing.log`; + const expectedFilename = path.join(tmpdir.path, + `${proc.pid}-1-${proc.pid}-1.tracing.log`); assert(fs.existsSync(expectedFilename)); fs.readFile(expectedFilename, common.mustCall((err, data) => { diff --git a/test/parallel/test-trace-events-fs-sync.js b/test/parallel/test-trace-events-fs-sync.js index 54222bcb333f51..d8e9ca30a8ebd3 100644 --- a/test/parallel/test-trace-events-fs-sync.js +++ b/test/parallel/test-trace-events-fs-sync.js @@ -3,13 +3,10 @@ const common = require('../common'); const assert = require('assert'); const cp = require('child_process'); const fs = require('fs'); +const path = require('path'); const util = require('util'); -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); - const tests = new Array(); -const traceFile = 'node_trace.1.log'; let gid = 1; let uid = 1; @@ -119,14 +116,14 @@ if (common.canCreateSymLink()) { const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -process.chdir(tmpdir.path); +const traceFile = path.join(tmpdir.path, 'node_trace.1.log'); for (const tr in tests) { const proc = cp.spawnSync(process.execPath, [ '--trace-events-enabled', '--trace-event-categories', 'node.fs.sync', '-e', tests[tr] ], - { encoding: 'utf8' }); + { cwd: tmpdir.path, encoding: 'utf8' }); // Some AIX versions don't support futimes or utimes, so skip. if (common.isAIX && proc.status !== 0 && tr === 'fs.sync.futimes') { continue; diff --git a/test/parallel/test-trace-events-metadata.js b/test/parallel/test-trace-events-metadata.js index aeb605beb0cbf3..d3afbcaef5d53e 100644 --- a/test/parallel/test-trace-events-metadata.js +++ b/test/parallel/test-trace-events-metadata.js @@ -3,23 +3,21 @@ const common = require('../common'); const assert = require('assert'); const cp = require('child_process'); const fs = require('fs'); - -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); +const path = require('path'); const CODE = 'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1);' + 'process.title = "foo"'; -const FILE_NAME = 'node_trace.1.log'; const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -process.chdir(tmpdir.path); +const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log'); const proc = cp.spawn(process.execPath, [ '--trace-event-categories', 'node.perf.usertiming', '--title=bar', - '-e', CODE ]); + '-e', CODE ], + { cwd: tmpdir.path }); proc.once('exit', common.mustCall(() => { assert(fs.existsSync(FILE_NAME)); fs.readFile(FILE_NAME, common.mustCall((err, data) => { diff --git a/test/parallel/test-trace-events-none.js b/test/parallel/test-trace-events-none.js index 4c2fe0ca216104..dfe77e4b39369f 100644 --- a/test/parallel/test-trace-events-none.js +++ b/test/parallel/test-trace-events-none.js @@ -3,21 +3,19 @@ const common = require('../common'); const assert = require('assert'); const cp = require('child_process'); const fs = require('fs'); - -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); +const path = require('path'); const CODE = 'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)'; -const FILE_NAME = 'node_trace.1.log'; const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -process.chdir(tmpdir.path); +const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log'); const proc_no_categories = cp.spawn( process.execPath, - [ '--trace-event-categories', '""', '-e', CODE ] + [ '--trace-event-categories', '""', '-e', CODE ], + { cwd: tmpdir.path } ); proc_no_categories.once('exit', common.mustCall(() => { diff --git a/test/parallel/test-trace-events-perf.js b/test/parallel/test-trace-events-perf.js index 27eef28fb12325..2403a8078a47fd 100644 --- a/test/parallel/test-trace-events-perf.js +++ b/test/parallel/test-trace-events-perf.js @@ -2,13 +2,10 @@ const common = require('../common'); const assert = require('assert'); const cp = require('child_process'); -const path = require('path'); const fs = require('fs'); +const path = require('path'); const tmpdir = require('../common/tmpdir'); -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); - if (process.argv[2] === 'child') { const { performance } = require('perf_hooks'); @@ -25,7 +22,6 @@ if (process.argv[2] === 'child') { ff(); // Will emit a timerify trace event } else { tmpdir.refresh(); - process.chdir(tmpdir.path); const expectedMarks = ['A', 'B']; const expectedBegins = [ @@ -41,6 +37,7 @@ if (process.argv[2] === 'child') { [ 'child' ], { + cwd: tmpdir.path, execArgv: [ '--trace-event-categories', 'node.perf' diff --git a/test/parallel/test-trace-events-process-exit.js b/test/parallel/test-trace-events-process-exit.js index 254963c2d3a751..1a39b889a3c809 100644 --- a/test/parallel/test-trace-events-process-exit.js +++ b/test/parallel/test-trace-events-process-exit.js @@ -3,20 +3,16 @@ const common = require('../common'); const assert = require('assert'); const cp = require('child_process'); const fs = require('fs'); - -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); +const path = require('path'); const tmpdir = require('../common/tmpdir'); - -const FILE_NAME = 'node_trace.1.log'; - tmpdir.refresh(); -process.chdir(tmpdir.path); +const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log'); const proc = cp.spawn(process.execPath, [ '--trace-events-enabled', - '-e', 'process.exit()' ]); + '-e', 'process.exit()' ], + { cwd: tmpdir.path }); proc.once('exit', common.mustCall(() => { assert(fs.existsSync(FILE_NAME)); diff --git a/test/parallel/test-trace-events-promises.js b/test/parallel/test-trace-events-promises.js index 3088be52960095..0dd4fddc6d75ba 100644 --- a/test/parallel/test-trace-events-promises.js +++ b/test/parallel/test-trace-events-promises.js @@ -2,15 +2,12 @@ const common = require('../common'); const assert = require('assert'); const cp = require('child_process'); -const path = require('path'); const fs = require('fs'); +const path = require('path'); const tmpdir = require('../common/tmpdir'); common.disableCrashOnUnhandledRejection(); -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); - if (process.argv[2] === 'child') { const p = Promise.reject(1); // Handled later Promise.reject(2); // Unhandled @@ -19,10 +16,10 @@ if (process.argv[2] === 'child') { }); } else { tmpdir.refresh(); - process.chdir(tmpdir.path); const proc = cp.fork(__filename, [ 'child' ], { + cwd: tmpdir.path, execArgv: [ '--no-warnings', '--trace-event-categories', diff --git a/test/parallel/test-trace-events-v8.js b/test/parallel/test-trace-events-v8.js index 183a8382a4e575..f7984dcd0ce475 100644 --- a/test/parallel/test-trace-events-v8.js +++ b/test/parallel/test-trace-events-v8.js @@ -3,22 +3,20 @@ const common = require('../common'); const assert = require('assert'); const cp = require('child_process'); const fs = require('fs'); - -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); +const path = require('path'); const CODE = 'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)'; -const FILE_NAME = 'node_trace.1.log'; const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -process.chdir(tmpdir.path); +const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log'); const proc = cp.spawn(process.execPath, [ '--trace-events-enabled', '--trace-event-categories', 'v8', - '-e', CODE ]); + '-e', CODE ], + { cwd: tmpdir.path }); proc.once('exit', common.mustCall(() => { assert(fs.existsSync(FILE_NAME)); diff --git a/test/parallel/test-trace-events-vm.js b/test/parallel/test-trace-events-vm.js index 758de3e964f7b2..3e5d32b6c3f82c 100644 --- a/test/parallel/test-trace-events-vm.js +++ b/test/parallel/test-trace-events-vm.js @@ -2,13 +2,10 @@ const common = require('../common'); const assert = require('assert'); const cp = require('child_process'); -const path = require('path'); const fs = require('fs'); +const path = require('path'); const tmpdir = require('../common/tmpdir'); -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); - const names = [ 'ContextifyScript::New', 'RunInThisContext', @@ -20,10 +17,10 @@ if (process.argv[2] === 'child') { vm.runInNewContext('1 + 1'); } else { tmpdir.refresh(); - process.chdir(tmpdir.path); const proc = cp.fork(__filename, [ 'child' ], { + cwd: tmpdir.path, execArgv: [ '--trace-event-categories', 'node.vm.script' From 2290c315a2b812e35706cb55d1003cc10e17087a Mon Sep 17 00:00:00 2001 From: Peter Marshall Date: Tue, 6 Nov 2018 18:18:09 +0100 Subject: [PATCH 226/328] deps: partially revert 'increase V8 deprecation levels' PR-URL: https://github.com/nodejs/node/pull/24195 Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau Reviewed-By: Refael Ackermann --- common.gypi | 2 +- deps/v8/include/v8.h | 44 ++++++++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/common.gypi b/common.gypi index 14c6b5ae9f8463..d1492ac9f996c9 100644 --- a/common.gypi +++ b/common.gypi @@ -33,7 +33,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.36', + 'v8_embedder_string': '-node.37', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 55ad7c8cf220cc..a5aaf2d6842dde 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -1019,9 +1019,9 @@ class V8_EXPORT PrimitiveArray { public: static Local New(Isolate* isolate, int length); int Length() const; - V8_DEPRECATED("Use Isolate* version", + V8_DEPRECATE_SOON("Use Isolate* version", void Set(int index, Local item)); - V8_DEPRECATED("Use Isolate* version", + V8_DEPRECATE_SOON("Use Isolate* version", Local Get(int index)); void Set(Isolate* isolate, int index, Local item); Local Get(Isolate* isolate, int index); @@ -1739,8 +1739,8 @@ class V8_EXPORT StackTrace { /** * Returns a StackFrame at a particular index. */ - V8_DEPRECATED("Use Isolate version", - Local GetFrame(uint32_t index) const); + V8_DEPRECATE_SOON("Use Isolate version", + Local GetFrame(uint32_t index) const); Local GetFrame(Isolate* isolate, uint32_t index) const; /** @@ -2451,7 +2451,7 @@ class V8_EXPORT Value : public Data { inline V8_DEPRECATED("Use maybe version", Local ToBoolean() const); - inline V8_DEPRECATED("Use maybe version", Local ToString() const); + inline V8_DEPRECATE_SOON("Use maybe version", Local ToString() const); inline V8_DEPRECATED("Use maybe version", Local ToObject() const); inline V8_DEPRECATED("Use maybe version", Local ToInteger() const); @@ -2471,7 +2471,7 @@ class V8_EXPORT Value : public Data { Local context) const; V8_WARN_UNUSED_RESULT Maybe Int32Value(Local context) const; - V8_DEPRECATED("Use maybe version", bool BooleanValue() const); + V8_DEPRECATE_SOON("Use maybe version", bool BooleanValue() const); V8_DEPRECATED("Use maybe version", double NumberValue() const); V8_DEPRECATED("Use maybe version", int64_t IntegerValue() const); V8_DEPRECATED("Use maybe version", uint32_t Uint32Value() const); @@ -2584,7 +2584,7 @@ class V8_EXPORT String : public Name { * Returns the number of bytes in the UTF-8 encoded * representation of this string. */ - V8_DEPRECATED("Use Isolate version instead", int Utf8Length() const); + V8_DEPRECATE_SOON("Use Isolate version instead", int Utf8Length() const); int Utf8Length(Isolate* isolate) const; @@ -2642,23 +2642,23 @@ class V8_EXPORT String : public Name { // 16-bit character codes. int Write(Isolate* isolate, uint16_t* buffer, int start = 0, int length = -1, int options = NO_OPTIONS) const; - V8_DEPRECATED("Use Isolate* version", - int Write(uint16_t* buffer, int start = 0, int length = -1, - int options = NO_OPTIONS) const); + V8_DEPRECATE_SOON("Use Isolate* version", + int Write(uint16_t* buffer, int start = 0, int length = -1, + int options = NO_OPTIONS) const); // One byte characters. int WriteOneByte(Isolate* isolate, uint8_t* buffer, int start = 0, int length = -1, int options = NO_OPTIONS) const; - V8_DEPRECATED("Use Isolate* version", - int WriteOneByte(uint8_t* buffer, int start = 0, - int length = -1, int options = NO_OPTIONS) + V8_DEPRECATE_SOON("Use Isolate* version", + int WriteOneByte(uint8_t* buffer, int start = 0, + int length = -1, int options = NO_OPTIONS) const); // UTF-8 encoded characters. int WriteUtf8(Isolate* isolate, char* buffer, int length = -1, int* nchars_ref = NULL, int options = NO_OPTIONS) const; - V8_DEPRECATED("Use Isolate* version", - int WriteUtf8(char* buffer, int length = -1, - int* nchars_ref = NULL, - int options = NO_OPTIONS) const); + V8_DEPRECATE_SOON("Use Isolate* version", + int WriteUtf8(char* buffer, int length = -1, + int* nchars_ref = NULL, + int options = NO_OPTIONS) const); /** * A zero length string. @@ -2822,9 +2822,9 @@ class V8_EXPORT String : public Name { */ static Local Concat(Isolate* isolate, Local left, Local right); - static V8_DEPRECATED("Use Isolate* version", - Local Concat(Local left, - Local right)); + static V8_DEPRECATE_SOON("Use Isolate* version", + Local Concat(Local left, + Local right)); /** * Creates a new external string using the data defined in the given @@ -5049,8 +5049,8 @@ class V8_EXPORT BooleanObject : public Object { class V8_EXPORT StringObject : public Object { public: static Local New(Isolate* isolate, Local value); - V8_DEPRECATED("Use Isolate* version", - static Local New(Local value)); + V8_DEPRECATE_SOON("Use Isolate* version", + static Local New(Local value)); Local ValueOf() const; From 1e9b4a2a09ad7a4f31ce85bee5af30b81b6e1980 Mon Sep 17 00:00:00 2001 From: Peter Marshall Date: Mon, 22 Oct 2018 11:26:35 +0200 Subject: [PATCH 227/328] deps: backport 525b396195 from upstream V8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message: [cpu-profiler] Fix a leak caused by re-logging existing functions. Don't re-log all existing functions during StartProcessorIfNotStarted(). They will already be in the CodeMap attached to the ProfileGenerator and re-logging them causes leaks. See the linked bug for more details. Bug: v8:8253 Change-Id: Ibb1a1ab2431c588e8c3a3a9ff714767cdf61a88e Reviewed-on: https://chromium-review.googlesource.com/1256763 Commit-Queue: Peter Marshall Reviewed-by: Yang Guo Cr-Commit-Position: refs/heads/master@{#56336} PR-URL: https://github.com/nodejs/node/pull/23827 Reviewed-By: Michaël Zasso Reviewed-By: Matheus Marchini Reviewed-By: James M Snell Reviewed-By: Refael Ackermann --- common.gypi | 2 +- deps/v8/src/profiler/cpu-profiler.cc | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/common.gypi b/common.gypi index d1492ac9f996c9..da85dc58fd4825 100644 --- a/common.gypi +++ b/common.gypi @@ -33,7 +33,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.37', + 'v8_embedder_string': '-node.38', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/src/profiler/cpu-profiler.cc b/deps/v8/src/profiler/cpu-profiler.cc index 79606dc812ebda..ff510c040e86cf 100644 --- a/deps/v8/src/profiler/cpu-profiler.cc +++ b/deps/v8/src/profiler/cpu-profiler.cc @@ -368,8 +368,11 @@ void CpuProfiler::StartProcessorIfNotStarted() { // Disable logging when using the new implementation. saved_is_logging_ = logger->is_logging_; logger->is_logging_ = false; + + bool codemap_needs_initialization = false; if (!generator_) { generator_.reset(new ProfileGenerator(profiles_.get())); + codemap_needs_initialization = true; CreateEntriesForRuntimeCallStats(); } processor_.reset(new ProfilerEventsProcessor(isolate_, generator_.get(), @@ -382,12 +385,14 @@ void CpuProfiler::StartProcessorIfNotStarted() { isolate_->set_is_profiling(true); // Enumerate stuff we already have in the heap. DCHECK(isolate_->heap()->HasBeenSetUp()); - if (!FLAG_prof_browser_mode) { - logger->LogCodeObjects(); + if (codemap_needs_initialization) { + if (!FLAG_prof_browser_mode) { + logger->LogCodeObjects(); + } + logger->LogCompiledFunctions(); + logger->LogAccessorCallbacks(); + LogBuiltins(); } - logger->LogCompiledFunctions(); - logger->LogAccessorCallbacks(); - LogBuiltins(); // Enable stack sampling. processor_->AddCurrentStack(isolate_); processor_->StartSynchronously(); From 3df083c5fb3f1ca4c69765b64a647555c89bc486 Mon Sep 17 00:00:00 2001 From: Anto Aravinth Date: Mon, 15 Oct 2018 06:51:15 +0530 Subject: [PATCH 228/328] util: handle null prototype on inspect This makes sure the prototype is always detected properly. Backport-PR-URL: https://github.com/nodejs/node/pull/23655 PR-URL: https://github.com/nodejs/node/pull/22331 Fixes: https://github.com/nodejs/node/issues/22141 Reviewed-By: Ruben Bridgewater Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: John-David Dalton --- lib/internal/util/inspect.js | 87 ++++++++++++++++++++------- test/parallel/test-util-inspect.js | 96 ++++++++++++++++++++++++------ 2 files changed, 141 insertions(+), 42 deletions(-) diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 5642d7e798dd69..6cec84355211d4 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -286,6 +286,7 @@ function getEmptyFormatArray() { } function getConstructorName(obj) { + let firstProto; while (obj) { const descriptor = Object.getOwnPropertyDescriptor(obj, 'constructor'); if (descriptor !== undefined && @@ -295,12 +296,28 @@ function getConstructorName(obj) { } obj = Object.getPrototypeOf(obj); + if (firstProto === undefined) { + firstProto = obj; + } + } + + if (firstProto === null) { + return null; } + // TODO(BridgeAR): Improve prototype inspection. + // We could use inspect on the prototype itself to improve the output. return ''; } function getPrefix(constructor, tag, fallback) { + if (constructor === null) { + if (tag !== '') { + return `[${fallback}: null prototype] [${tag}] `; + } + return `[${fallback}: null prototype] `; + } + if (constructor !== '') { if (tag !== '' && constructor !== tag) { return `${constructor} [${tag}] `; @@ -308,12 +325,6 @@ function getPrefix(constructor, tag, fallback) { return `${constructor} `; } - if (tag !== '') - return `[${tag}] `; - - if (fallback !== undefined) - return `${fallback} `; - return ''; } @@ -387,21 +398,49 @@ function findTypedConstructor(value) { } } +let lazyNullPrototypeCache; +// Creates a subclass and name +// the constructor as `${clazz} : null prototype` +function clazzWithNullPrototype(clazz, name) { + if (lazyNullPrototypeCache === undefined) { + lazyNullPrototypeCache = new Map(); + } else { + const cachedClass = lazyNullPrototypeCache.get(clazz); + if (cachedClass !== undefined) { + return cachedClass; + } + } + class NullPrototype extends clazz { + get [Symbol.toStringTag]() { + return ''; + } + } + Object.defineProperty(NullPrototype.prototype.constructor, 'name', + { value: `[${name}: null prototype]` }); + lazyNullPrototypeCache.set(clazz, NullPrototype); + return NullPrototype; +} + function noPrototypeIterator(ctx, value, recurseTimes) { let newVal; - // TODO: Create a Subclass in case there's no prototype and show - // `null-prototype`. if (isSet(value)) { - const clazz = Object.getPrototypeOf(value) || Set; + const clazz = Object.getPrototypeOf(value) || + clazzWithNullPrototype(Set, 'Set'); newVal = new clazz(setValues(value)); } else if (isMap(value)) { - const clazz = Object.getPrototypeOf(value) || Map; + const clazz = Object.getPrototypeOf(value) || + clazzWithNullPrototype(Map, 'Map'); newVal = new clazz(mapEntries(value)); } else if (Array.isArray(value)) { - const clazz = Object.getPrototypeOf(value) || Array; + const clazz = Object.getPrototypeOf(value) || + clazzWithNullPrototype(Array, 'Array'); newVal = new clazz(value.length || 0); } else if (isTypedArray(value)) { - const clazz = findTypedConstructor(value) || Uint8Array; + let clazz = Object.getPrototypeOf(value); + if (!clazz) { + const constructor = findTypedConstructor(value); + clazz = clazzWithNullPrototype(constructor, constructor.name); + } newVal = new clazz(value); } if (newVal) { @@ -492,7 +531,7 @@ function formatRaw(ctx, value, recurseTimes) { if (Array.isArray(value)) { keys = getOwnNonIndexProperties(value, filter); // Only set the constructor for non ordinary ("Array [...]") arrays. - const prefix = getPrefix(constructor, tag); + const prefix = getPrefix(constructor, tag, 'Array'); braces = [`${prefix === 'Array ' ? '' : prefix}[`, ']']; if (value.length === 0 && keys.length === 0) return `${braces[0]}]`; @@ -500,21 +539,24 @@ function formatRaw(ctx, value, recurseTimes) { formatter = formatArray; } else if (isSet(value)) { keys = getKeys(value, ctx.showHidden); - const prefix = getPrefix(constructor, tag); + const prefix = getPrefix(constructor, tag, 'Set'); if (value.size === 0 && keys.length === 0) return `${prefix}{}`; braces = [`${prefix}{`, '}']; formatter = formatSet; } else if (isMap(value)) { keys = getKeys(value, ctx.showHidden); - const prefix = getPrefix(constructor, tag); + const prefix = getPrefix(constructor, tag, 'Map'); if (value.size === 0 && keys.length === 0) return `${prefix}{}`; braces = [`${prefix}{`, '}']; formatter = formatMap; } else if (isTypedArray(value)) { keys = getOwnNonIndexProperties(value, filter); - braces = [`${getPrefix(constructor, tag)}[`, ']']; + const prefix = constructor !== null ? + getPrefix(constructor, tag) : + getPrefix(constructor, tag, findTypedConstructor(value).name); + braces = [`${prefix}[`, ']']; if (value.length === 0 && keys.length === 0 && !ctx.showHidden) return `${braces[0]}]`; formatter = formatTypedArray; @@ -540,7 +582,7 @@ function formatRaw(ctx, value, recurseTimes) { return '[Arguments] {}'; braces[0] = '[Arguments] {'; } else if (tag !== '') { - braces[0] = `${getPrefix(constructor, tag)}{`; + braces[0] = `${getPrefix(constructor, tag, 'Object')}{`; if (keys.length === 0) { return `${braces[0]}}`; } @@ -587,13 +629,12 @@ function formatRaw(ctx, value, recurseTimes) { base = `[${base.slice(0, stackStart)}]`; } } else if (isAnyArrayBuffer(value)) { - let prefix = getPrefix(constructor, tag); - if (prefix === '') { - prefix = isArrayBuffer(value) ? 'ArrayBuffer ' : 'SharedArrayBuffer '; - } // Fast path for ArrayBuffer and SharedArrayBuffer. // Can't do the same for DataView because it has a non-primitive // .buffer property that we need to recurse for. + const arrayType = isArrayBuffer(value) ? 'ArrayBuffer' : + 'SharedArrayBuffer'; + const prefix = getPrefix(constructor, tag, arrayType); if (keys.length === 0) return prefix + `{ byteLength: ${formatNumber(ctx.stylize, value.byteLength)} }`; @@ -658,9 +699,9 @@ function formatRaw(ctx, value, recurseTimes) { } else if (keys.length === 0) { if (isExternal(value)) return ctx.stylize('[External]', 'special'); - return `${getPrefix(constructor, tag)}{}`; + return `${getPrefix(constructor, tag, 'Object')}{}`; } else { - braces[0] = `${getPrefix(constructor, tag)}{`; + braces[0] = `${getPrefix(constructor, tag, 'Object')}{`; } } } diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index a6e6c2f1bf9737..f12b49c073b840 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -258,7 +258,7 @@ assert.strictEqual( name: { value: 'Tim', enumerable: true }, hidden: { value: 'secret' } }), { showHidden: true }), - "{ name: 'Tim', [hidden]: 'secret' }" + "[Object: null prototype] { name: 'Tim', [hidden]: 'secret' }" ); assert.strictEqual( @@ -266,7 +266,7 @@ assert.strictEqual( name: { value: 'Tim', enumerable: true }, hidden: { value: 'secret' } })), - "{ name: 'Tim' }" + "[Object: null prototype] { name: 'Tim' }" ); // Dynamic properties. @@ -502,11 +502,17 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324'); set: function() {} } }); - assert.strictEqual(util.inspect(getter, true), '{ [a]: [Getter] }'); - assert.strictEqual(util.inspect(setter, true), '{ [b]: [Setter] }'); + assert.strictEqual( + util.inspect(getter, true), + '[Object: null prototype] { [a]: [Getter] }' + ); + assert.strictEqual( + util.inspect(setter, true), + '[Object: null prototype] { [b]: [Setter] }' + ); assert.strictEqual( util.inspect(getterAndSetter, true), - '{ [c]: [Getter/Setter] }' + '[Object: null prototype] { [c]: [Getter/Setter] }' ); } @@ -1134,7 +1140,7 @@ if (typeof Symbol !== 'undefined') { { const x = Object.create(null); - assert.strictEqual(util.inspect(x), '{}'); + assert.strictEqual(util.inspect(x), '[Object: null prototype] {}'); } { @@ -1274,7 +1280,7 @@ util.inspect(process); assert.strictEqual(util.inspect( Object.create(null, { [Symbol.toStringTag]: { value: 'foo' } })), - '[foo] {}'); + '[Object: null prototype] [foo] {}'); assert.strictEqual(util.inspect(new Foo()), "Foo [bar] { foo: 'bar' }"); @@ -1618,20 +1624,12 @@ util.inspect(process); 'prematurely. Maximum call stack size exceeded.]')); } -// Verify the output in case the value has no prototype. -// Sadly, these cases can not be fully inspected :( -[ - [/a/, '/undefined/undefined'], - [new DataView(new ArrayBuffer(2)), - 'DataView {\n byteLength: undefined,\n byteOffset: undefined,\n ' + - 'buffer: undefined }'], - [new SharedArrayBuffer(2), 'SharedArrayBuffer { byteLength: undefined }'] -].forEach(([value, expected]) => { +{ assert.strictEqual( - util.inspect(Object.setPrototypeOf(value, null)), - expected + util.inspect(Object.setPrototypeOf(/a/, null)), + '/undefined/undefined' ); -}); +} // Verify that throwing in valueOf and having no prototype still produces nice // results. @@ -1667,6 +1665,39 @@ util.inspect(process); } }); assert.strictEqual(util.inspect(value), expected); + value.foo = 'bar'; + assert.notStrictEqual(util.inspect(value), expected); + delete value.foo; + value[Symbol('foo')] = 'yeah'; + assert.notStrictEqual(util.inspect(value), expected); +}); + +[ + [[1, 3, 4], '[Array: null prototype] [ 1, 3, 4 ]'], + [new Set([1, 2]), '[Set: null prototype] { 1, 2 }'], + [new Map([[1, 2]]), '[Map: null prototype] { 1 => 2 }'], + [new Promise((resolve) => setTimeout(resolve, 10)), + '[Promise: null prototype] { }'], + [new WeakSet(), '[WeakSet: null prototype] { [items unknown] }'], + [new WeakMap(), '[WeakMap: null prototype] { [items unknown] }'], + [new Uint8Array(2), '[Uint8Array: null prototype] [ 0, 0 ]'], + [new Uint16Array(2), '[Uint16Array: null prototype] [ 0, 0 ]'], + [new Uint32Array(2), '[Uint32Array: null prototype] [ 0, 0 ]'], + [new Int8Array(2), '[Int8Array: null prototype] [ 0, 0 ]'], + [new Int16Array(2), '[Int16Array: null prototype] [ 0, 0 ]'], + [new Int32Array(2), '[Int32Array: null prototype] [ 0, 0 ]'], + [new Float32Array(2), '[Float32Array: null prototype] [ 0, 0 ]'], + [new Float64Array(2), '[Float64Array: null prototype] [ 0, 0 ]'], + [new BigInt64Array(2), '[BigInt64Array: null prototype] [ 0, 0 ]'], + [new BigUint64Array(2), '[BigUint64Array: null prototype] [ 0, 0 ]'], + [new ArrayBuffer(16), '[ArrayBuffer: null prototype] ' + + '{ byteLength: undefined }'], + [new DataView(new ArrayBuffer(16)), + '[DataView: null prototype] {\n byteLength: undefined,\n ' + + 'byteOffset: undefined,\n buffer: undefined }'], + [new SharedArrayBuffer(2), '[SharedArrayBuffer: null prototype] ' + + '{ byteLength: undefined }'] +].forEach(([value, expected]) => { assert.strictEqual( util.inspect(Object.setPrototypeOf(value, null)), expected @@ -1748,3 +1779,30 @@ assert.strictEqual( '[ 3, 2, 1, [Symbol(a)]: false, [Symbol(b)]: true, a: 1, b: 2, c: 3 ]' ); } + +// Manipulate the prototype to one that we can not handle. +{ + let obj = { a: true }; + let value = (function() { return function() {}; })(); + Object.setPrototypeOf(value, null); + Object.setPrototypeOf(obj, value); + assert.strictEqual(util.inspect(obj), '{ a: true }'); + + obj = { a: true }; + value = []; + Object.setPrototypeOf(value, null); + Object.setPrototypeOf(obj, value); + assert.strictEqual(util.inspect(obj), '{ a: true }'); +} + +// Check that the fallback always works. +{ + const obj = new Set([1, 2]); + const iterator = obj[Symbol.iterator]; + Object.setPrototypeOf(obj, null); + Object.defineProperty(obj, Symbol.iterator, { + value: iterator, + configurable: true + }); + assert.strictEqual(util.inspect(obj), '[Set: null prototype] { 1, 2 }'); +} From de2340dccd4c483c1b6fdae4e7426915c86938d5 Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Thu, 11 Oct 2018 06:33:25 -0700 Subject: [PATCH 229/328] src: trace_event: secondary storage for metadata Metadata trace-events should be held in secondary storage so that they can be periodically reemitted. This change establishes the secondary storage and ensures that events are reemitted on each flush. Backport-PR-URL: https://github.com/nodejs/node/pull/23700 PR-URL: https://github.com/nodejs/node/pull/20900 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Backport-PR-URL: https://github.com/nodejs/node/pull/23700 --- src/node.cc | 4 +- src/node_platform.cc | 2 +- src/node_platform.h | 9 +++-- src/tracing/agent.cc | 27 +++++++++++++ src/tracing/agent.h | 15 +++++++ src/tracing/trace_event.cc | 14 ++++--- src/tracing/trace_event.h | 40 +++++++++++++------ test/cctest/node_test_fixture.cc | 2 +- test/cctest/node_test_fixture.h | 12 +++--- .../test-trace-events-dynamic-enable.js | 10 ++--- 10 files changed, 98 insertions(+), 37 deletions(-) diff --git a/src/node.cc b/src/node.cc index d9f297cc29a92b..a6728b7fb0fd5a 100644 --- a/src/node.cc +++ b/src/node.cc @@ -279,9 +279,9 @@ static struct { #if NODE_USE_V8_PLATFORM void Initialize(int thread_pool_size) { tracing_agent_.reset(new tracing::Agent()); + node::tracing::TraceEventHelper::SetAgent(tracing_agent_.get()); auto controller = tracing_agent_->GetTracingController(); controller->AddTraceStateObserver(new NodeTraceStateObserver(controller)); - tracing::TraceEventHelper::SetTracingController(controller); StartTracingAgent(); // Tracing must be initialized before platform threads are created. platform_ = new NodePlatform(thread_pool_size, controller); @@ -2805,7 +2805,7 @@ MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform() { MultiIsolatePlatform* CreatePlatform( int thread_pool_size, - TracingController* tracing_controller) { + node::tracing::TracingController* tracing_controller) { return new NodePlatform(thread_pool_size, tracing_controller); } diff --git a/src/node_platform.cc b/src/node_platform.cc index ad0cd0db3ec684..fd8d045404ecc7 100644 --- a/src/node_platform.cc +++ b/src/node_platform.cc @@ -14,7 +14,7 @@ using v8::Local; using v8::Object; using v8::Platform; using v8::Task; -using v8::TracingController; +using node::tracing::TracingController; struct PlatformWorkerData { TaskQueue* task_queue; diff --git a/src/node_platform.h b/src/node_platform.h index c89c6a5ff6708e..91c3cad81ad754 100644 --- a/src/node_platform.h +++ b/src/node_platform.h @@ -11,6 +11,7 @@ #include "libplatform/libplatform.h" #include "node.h" #include "node_mutex.h" +#include "tracing/agent.h" #include "uv.h" namespace node { @@ -126,7 +127,8 @@ class BackgroundTaskRunner : public v8::TaskRunner { class NodePlatform : public MultiIsolatePlatform { public: - NodePlatform(int thread_pool_size, v8::TracingController* tracing_controller); + NodePlatform(int thread_pool_size, + node::tracing::TracingController* tracing_controller); virtual ~NodePlatform() {} void DrainBackgroundTasks(v8::Isolate* isolate) override; @@ -143,7 +145,7 @@ class NodePlatform : public MultiIsolatePlatform { bool IdleTasksEnabled(v8::Isolate* isolate) override; double MonotonicallyIncreasingTime() override; double CurrentClockTimeMillis() override; - v8::TracingController* GetTracingController() override; + node::tracing::TracingController* GetTracingController() override; bool FlushForegroundTasks(v8::Isolate* isolate) override; void RegisterIsolate(IsolateData* isolate_data, uv_loop_t* loop) override; @@ -161,8 +163,7 @@ class NodePlatform : public MultiIsolatePlatform { std::unordered_map> per_isolate_; - - v8::TracingController* tracing_controller_; + node::tracing::TracingController* tracing_controller_; std::shared_ptr background_task_runner_; }; diff --git a/src/tracing/agent.cc b/src/tracing/agent.cc index fd5cb3387b14ae..103df55da5236e 100644 --- a/src/tracing/agent.cc +++ b/src/tracing/agent.cc @@ -1,6 +1,7 @@ #include "tracing/agent.h" #include +#include "trace_event.h" #include "tracing/node_trace_buffer.h" #include "debug_utils.h" #include "env-inl.h" @@ -207,9 +208,35 @@ void Agent::AppendTraceEvent(TraceObject* trace_event) { } void Agent::Flush(bool blocking) { + for (const auto& event : metadata_events_) + AppendTraceEvent(event.get()); + for (const auto& id_writer : writers_) id_writer.second->Flush(blocking); } +void TracingController::AddMetadataEvent( + const unsigned char* category_group_enabled, + const char* name, + int num_args, + const char** arg_names, + const unsigned char* arg_types, + const uint64_t* arg_values, + std::unique_ptr* convertable_values, + unsigned int flags) { + std::unique_ptr trace_event(new TraceObject); + trace_event->Initialize( + TRACE_EVENT_PHASE_METADATA, category_group_enabled, name, + node::tracing::kGlobalScope, // scope + node::tracing::kNoId, // id + node::tracing::kNoId, // bind_id + num_args, arg_names, arg_types, arg_values, convertable_values, + TRACE_EVENT_FLAG_NONE, + CurrentTimestampMicroseconds(), + CurrentCpuTimestampMicroseconds()); + node::tracing::TraceEventHelper::GetAgent()->AddMetadataEvent( + std::move(trace_event)); +} + } // namespace tracing } // namespace node diff --git a/src/tracing/agent.h b/src/tracing/agent.h index bb2e514aee2914..e1a4ffbe893249 100644 --- a/src/tracing/agent.h +++ b/src/tracing/agent.h @@ -7,6 +7,7 @@ #include "util.h" #include "node_mutex.h" +#include #include #include #include @@ -34,6 +35,15 @@ class TracingController : public v8::platform::tracing::TracingController { int64_t CurrentTimestampMicroseconds() override { return uv_hrtime() / 1000; } + void AddMetadataEvent( + const unsigned char* category_group_enabled, + const char* name, + int num_args, + const char** arg_names, + const unsigned char* arg_types, + const uint64_t* arg_values, + std::unique_ptr* convertable_values, + unsigned int flags); }; class AgentWriterHandle { @@ -91,6 +101,10 @@ class Agent { // Writes to all writers registered through AddClient(). void AppendTraceEvent(TraceObject* trace_event); + + void AddMetadataEvent(std::unique_ptr event) { + metadata_events_.push_back(std::move(event)); + } // Flushes all writers registered through AddClient(). void Flush(bool blocking); @@ -129,6 +143,7 @@ class Agent { ConditionVariable initialize_writer_condvar_; uv_async_t initialize_writer_async_; std::set to_be_initialized_; + std::list> metadata_events_; }; void AgentWriterHandle::reset() { diff --git a/src/tracing/trace_event.cc b/src/tracing/trace_event.cc index f661dd5c69a07a..9232c34c4ca322 100644 --- a/src/tracing/trace_event.cc +++ b/src/tracing/trace_event.cc @@ -3,14 +3,18 @@ namespace node { namespace tracing { -v8::TracingController* g_controller = nullptr; +Agent* g_agent = nullptr; -void TraceEventHelper::SetTracingController(v8::TracingController* controller) { - g_controller = controller; +void TraceEventHelper::SetAgent(Agent* agent) { + g_agent = agent; } -v8::TracingController* TraceEventHelper::GetTracingController() { - return g_controller; +Agent* TraceEventHelper::GetAgent() { + return g_agent; +} + +TracingController* TraceEventHelper::GetTracingController() { + return g_agent->GetTracingController(); } } // namespace tracing diff --git a/src/tracing/trace_event.h b/src/tracing/trace_event.h index 1165fca59a99ea..d5d4befb14600a 100644 --- a/src/tracing/trace_event.h +++ b/src/tracing/trace_event.h @@ -310,8 +310,9 @@ const uint64_t kNoId = 0; class TraceEventHelper { public: - static v8::TracingController* GetTracingController(); - static void SetTracingController(v8::TracingController* controller); + static TracingController* GetTracingController(); + static Agent* GetAgent(); + static void SetAgent(Agent* agent); }; // TraceID encapsulates an ID that can either be an integer or pointer. Pointers @@ -487,6 +488,26 @@ static V8_INLINE uint64_t AddTraceEventWithTimestampImpl( arg_names, arg_types, arg_values, arg_convertables, flags, timestamp); } +static V8_INLINE void AddMetadataEventImpl( + const uint8_t* category_group_enabled, const char* name, int32_t num_args, + const char** arg_names, const uint8_t* arg_types, + const uint64_t* arg_values, unsigned int flags) { + std::unique_ptr arg_convertibles[2]; + if (num_args > 0 && arg_types[0] == TRACE_VALUE_TYPE_CONVERTABLE) { + arg_convertibles[0].reset(reinterpret_cast( + static_cast(arg_values[0]))); + } + if (num_args > 1 && arg_types[1] == TRACE_VALUE_TYPE_CONVERTABLE) { + arg_convertibles[1].reset(reinterpret_cast( + static_cast(arg_values[1]))); + } + node::tracing::TracingController* controller = + node::tracing::TraceEventHelper::GetTracingController(); + return controller->AddMetadataEvent( + category_group_enabled, name, num_args, arg_names, arg_types, arg_values, + arg_convertibles, flags); +} + // Define SetTraceValue for each allowed type. It stores the type and // value in the return arguments. This allows this API to avoid declaring any // structures so that it is portable to third_party libraries. @@ -632,23 +653,16 @@ static V8_INLINE uint64_t AddTraceEventWithTimestamp( } template -static V8_INLINE uint64_t AddMetadataEvent( +static V8_INLINE void AddMetadataEvent( const uint8_t* category_group_enabled, const char* name, const char* arg1_name, ARG1_TYPE&& arg1_val) { const int num_args = 1; uint8_t arg_type; uint64_t arg_value; SetTraceValue(std::forward(arg1_val), &arg_type, &arg_value); - // TODO(ofrobots): It would be good to add metadata events to a separate - // buffer so that they can be periodically reemitted. For now, we have a - // single buffer, so we just add them to the main buffer. - return TRACE_EVENT_API_ADD_TRACE_EVENT( - TRACE_EVENT_PHASE_METADATA, - category_group_enabled, name, - node::tracing::kGlobalScope, // scope - node::tracing::kNoId, // id - node::tracing::kNoId, // bind_id - num_args, &arg1_name, &arg_type, &arg_value, TRACE_EVENT_FLAG_NONE); + AddMetadataEventImpl( + category_group_enabled, name, num_args, &arg1_name, &arg_type, &arg_value, + TRACE_EVENT_FLAG_NONE); } // Used by TRACE_EVENTx macros. Do not use directly. diff --git a/test/cctest/node_test_fixture.cc b/test/cctest/node_test_fixture.cc index acc975a4cb3c6e..f13481824734fb 100644 --- a/test/cctest/node_test_fixture.cc +++ b/test/cctest/node_test_fixture.cc @@ -3,4 +3,4 @@ ArrayBufferUniquePtr NodeTestFixture::allocator{nullptr, nullptr}; uv_loop_t NodeTestFixture::current_loop; NodePlatformUniquePtr NodeTestFixture::platform; -TracingControllerUniquePtr NodeTestFixture::tracing_controller; +TracingAgentUniquePtr NodeTestFixture::tracing_agent; diff --git a/test/cctest/node_test_fixture.h b/test/cctest/node_test_fixture.h index 8cba5d99ba3c64..be3d82db643dd7 100644 --- a/test/cctest/node_test_fixture.h +++ b/test/cctest/node_test_fixture.h @@ -55,22 +55,22 @@ struct Argv { using ArrayBufferUniquePtr = std::unique_ptr; -using TracingControllerUniquePtr = std::unique_ptr; +using TracingAgentUniquePtr = std::unique_ptr; using NodePlatformUniquePtr = std::unique_ptr; class NodeTestFixture : public ::testing::Test { protected: static ArrayBufferUniquePtr allocator; - static TracingControllerUniquePtr tracing_controller; + static TracingAgentUniquePtr tracing_agent; static NodePlatformUniquePtr platform; static uv_loop_t current_loop; v8::Isolate* isolate_; static void SetUpTestCase() { - tracing_controller.reset(new v8::TracingController()); - node::tracing::TraceEventHelper::SetTracingController( - tracing_controller.get()); - platform.reset(new node::NodePlatform(4, nullptr)); + tracing_agent.reset(new node::tracing::Agent()); + node::tracing::TraceEventHelper::SetAgent(tracing_agent.get()); + platform.reset( + new node::NodePlatform(4, tracing_agent->GetTracingController())); CHECK_EQ(0, uv_loop_init(¤t_loop)); v8::V8::InitializePlatform(platform.get()); v8::V8::Initialize(); diff --git a/test/parallel/test-trace-events-dynamic-enable.js b/test/parallel/test-trace-events-dynamic-enable.js index 24a186c15a85c7..645dcb2764a1be 100644 --- a/test/parallel/test-trace-events-dynamic-enable.js +++ b/test/parallel/test-trace-events-dynamic-enable.js @@ -25,9 +25,12 @@ function post(message, data) { async function test() { session.connect(); - let traceNotification = null; + const events = []; let tracingComplete = false; - session.on('NodeTracing.dataCollected', (n) => traceNotification = n); + session.on('NodeTracing.dataCollected', (n) => { + assert.ok(n && n.data && n.data.value); + events.push(...n.data.value); // append the events. + }); session.on('NodeTracing.tracingComplete', () => tracingComplete = true); // Generate a node.perf event before tracing is enabled. @@ -47,10 +50,7 @@ async function test() { session.disconnect(); assert.ok(tracingComplete); - assert.ok(traceNotification); - assert.ok(traceNotification.data && traceNotification.data.value); - const events = traceNotification.data.value; const marks = events.filter((t) => null !== /node\.perf\.usertim/.exec(t.cat)); assert.strictEqual(marks.length, 1); assert.strictEqual(marks[0].name, 'mark2'); From 9a7554a85bdb5ea44cb39077f2b42fb7100782b3 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Sun, 28 Oct 2018 17:51:10 -0700 Subject: [PATCH 230/328] src: fix CreatePlatform header param mismatch Backport-PR-URL: https://github.com/nodejs/node/pull/23700 PR-URL: https://github.com/nodejs/node/pull/23947 Reviewed-By: Refael Ackermann Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Ali Ijaz Sheikh Reviewed-By: Matheus Marchini --- src/node.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/node.h b/src/node.h index 54136ec4987dc1..2a6f5b59ce56a7 100644 --- a/src/node.h +++ b/src/node.h @@ -100,15 +100,16 @@ // Forward-declare libuv loop struct uv_loop_s; -// Forward-declare TracingController, used by CreatePlatform. -namespace v8 { -class TracingController; -} - // Forward-declare these functions now to stop MSVS from becoming // terminally confused when it's done in node_internals.h namespace node { +namespace tracing { + +class TracingController; + +} + NODE_EXTERN v8::Local ErrnoException(v8::Isolate* isolate, int errorno, const char* syscall = nullptr, @@ -298,7 +299,8 @@ NODE_EXTERN MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform(); NODE_EXTERN MultiIsolatePlatform* CreatePlatform( int thread_pool_size, - v8::TracingController* tracing_controller); + node::tracing::TracingController* tracing_controller); +MultiIsolatePlatform* InitializeV8Platform(int thread_pool_size); NODE_EXTERN void FreePlatform(MultiIsolatePlatform* platform); NODE_EXTERN void EmitBeforeExit(Environment* env); From 469473d5501e922e3b094429f732617cd107e922 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Tue, 13 Nov 2018 14:48:52 -0500 Subject: [PATCH 231/328] Revert "win,msi: install tools for native modules" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts: Revision: 257a5e9c389b648aca08b02aae9e19f142ce0493 win: add prompt to tools installation script Revision: e9a291582d145a00df27aaaa54b66e42c725d89e win: clarify Boxstarter behavior on install tools Revision: 3b895d12584a91acf3866a728ed490841490dc95 win,msi: display license notes before installing tools Revision: cf284c80a9c82d4baebf095c356179c753da493c win,msi: install Boxstarter from elevated shell Revision: 2b7e18dec5ccb51270df7c8bd554ffdf2e28e603 win,msi: highlight installation of 3rd-party tools Revision: ebf36cd18018faab5427327c3469a71dd1d35129 win,msi: install tools for native modules PR-URL: https://github.com/nodejs/node/pull/24344 Refs: https://github.com/nodejs/node/pull/22645 Refs: https://github.com/nodejs/node/pull/23987 Refs: https://github.com/nodejs/Release/issues/369 Refs: https://github.com/nodejs/node/issues/23838 Refs: https://github.com/nodejs/security-wg/issues/439 Reviewed-By: João Reis Reviewed-By: Richard Lau --- tools/msvs/install_tools/install_tools.bat | 76 ---------------------- tools/msvs/install_tools/install_tools.txt | 3 - tools/msvs/msi/i18n/en-us.wxl | 8 --- tools/msvs/msi/product.wxs | 43 +----------- 4 files changed, 2 insertions(+), 128 deletions(-) delete mode 100644 tools/msvs/install_tools/install_tools.bat delete mode 100644 tools/msvs/install_tools/install_tools.txt diff --git a/tools/msvs/install_tools/install_tools.bat b/tools/msvs/install_tools/install_tools.bat deleted file mode 100644 index 36456fa6f656a9..00000000000000 --- a/tools/msvs/install_tools/install_tools.bat +++ /dev/null @@ -1,76 +0,0 @@ -@echo off - -setlocal - -cls -echo ==================================================== -echo Tools for Node.js Native Modules Installation Script -echo ==================================================== -echo. -echo This Boxstarter script will install Python and the Visual Studio Build Tools, -echo necessary to compile Node.js native modules. Note that Boxstarter, -echo Chocolatey and required Windows updates will also be installed. -echo. -echo This will require about 3 Gb of free disk space, plus any space necessary to -echo install Windows updates. -echo. -echo This will take a while to run. Your computer may reboot during the -echo installation, and will resume automatically. -echo. -echo Please close all open programs for the duration of the installation. -echo. -echo You can close this window to stop now. This script can be invoked from the -echo Start menu. Detailed instructions to install these tools manually are -echo available at https://github.com/nodejs/node-gyp#on-windows -echo. -pause - -cls -REM Adapted from https://github.com/Microsoft/windows-dev-box-setup-scripts/blob/79bbe5bdc4867088b3e074f9610932f8e4e192c2/README.md#legal -echo Using this script downloads third party software -echo ------------------------------------------------ -echo This script will direct to Chocolatey to install packages. By using -echo Chocolatey to install a package, you are accepting the license for the -echo application, executable(s), or other artifacts delivered to your machine as a -echo result of a Chocolatey install. This acceptance occurs whether you know the -echo license terms or not. Read and understand the license terms of the packages -echo being installed and their dependencies prior to installation: -echo - https://chocolatey.org/packages/chocolatey -echo - https://chocolatey.org/packages/boxstarter -echo - https://chocolatey.org/packages/python2 -echo - https://chocolatey.org/packages/visualstudio2017buildtools -echo - https://chocolatey.org/packages/visualstudio2017-workload-vctools -echo. -echo This script is provided AS-IS without any warranties of any kind -echo ---------------------------------------------------------------- -echo Chocolatey has implemented security safeguards in their process to help -echo protect the community from malicious or pirated software, but any use of this -echo script is at your own risk. Please read the Chocolatey's legal terms of use -echo and the Boxstarter project license as well as how the community repository -echo for Chocolatey.org is maintained. -echo. -pause - -cls -echo !!!!!WARNING!!!!! -echo ----------------- -echo Use of Boxstarter may reboot your computer automatically multiple times. -echo When performing a reboot, Boxstarter will need to disable User Account -echo Control (UAC) to allow the script to run immediately after the reboot. When -echo the scripts have completed, Boxstarter will re-enable UAC. If you prematurely -echo stop the process, UAC will need to be re-enabled manually. -echo. -echo Sometimes the scripts may install all necessary Windows Updates which -echo could cause a high number of reboots that appear to be a reboot loop when -echo in fact it is just a normal Windows Updates reboot cycle. -:acceptretry -echo. -echo Your computer may REBOOT SEVERAL TIMES WITHOUT FURTHER WARNING. -echo Please type YES followed by enter to confirm that you have saved all your -set /p "ACCEPT_PROMPT=work and closed all open programs: " -if /i not "%ACCEPT_PROMPT%"=="yes" ( - echo Please type YES to confirm, or close the window to exit. - goto acceptretry -) - -"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command Start-Process '%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe' -ArgumentList '-NoProfile -InputFormat None -ExecutionPolicy Bypass -Command iex ((New-Object System.Net.WebClient).DownloadString(''https://boxstarter.org/bootstrapper.ps1'')); get-boxstarter -Force; Install-BoxstarterPackage -PackageName ''%~dp0\install_tools.txt''; Read-Host ''Type ENTER to exit'' ' -Verb RunAs diff --git a/tools/msvs/install_tools/install_tools.txt b/tools/msvs/install_tools/install_tools.txt deleted file mode 100644 index baf530a774759b..00000000000000 --- a/tools/msvs/install_tools/install_tools.txt +++ /dev/null @@ -1,3 +0,0 @@ -choco upgrade -y python2 -choco upgrade -y visualstudio2017buildtools -choco upgrade -y visualstudio2017-workload-vctools diff --git a/tools/msvs/msi/i18n/en-us.wxl b/tools/msvs/msi/i18n/en-us.wxl index 9b948156a5481d..86da6ecc40ecaf 100644 --- a/tools/msvs/msi/i18n/en-us.wxl +++ b/tools/msvs/msi/i18n/en-us.wxl @@ -8,14 +8,6 @@ A later version of [ProductName] is already installed. Setup will now exit. - [ProductName] Setup - {\WixUI_Font_Title}Tools for Native Modules - Optionally install the tools necessary to compile native modules. - WixUI_Bmp_Banner - Some npm modules need to be compiled from C/C++ when installing. If you want to be able to install such modules, some tools (Python 2 and Visual Studio Build Tools) need to be installed. - Automatically install the necessary tools. Note that this will also install Boxstarter and Chocolatey. The script will pop-up in a new window after the installation completes. - Alternatively, follow the instructions at https://github.com/nodejs/node-gyp#on-windows]]> to install the dependencies yourself. - Node.js runtime Install the core [ProductName] runtime (node.exe). diff --git a/tools/msvs/msi/product.wxs b/tools/msvs/msi/product.wxs index ad48fedafd9ea0..e9e4e33751d254 100755 --- a/tools/msvs/msi/product.wxs +++ b/tools/msvs/msi/product.wxs @@ -72,8 +72,6 @@ - - - - - - - - - - @@ -205,12 +195,6 @@ Arguments='/k "[INSTALLDIR]nodevars.bat"' Show="normal" WorkingDirectory="INSTALLDIR"/> - - - - @@ -359,23 +340,6 @@ - - - - - - - - - - - - - - - 1 - - NOT Installed Installed AND PATCH @@ -386,6 +350,7 @@ 1 1 1 + 1 NOT Installed OR WixUI_InstallMode = "Change" Installed AND NOT PATCH Installed AND PATCH @@ -396,11 +361,7 @@ 1 Installed NOT Installed - 1 - 1 - 1 - NATIVETOOLSCHECKBOX = 1 - 1 + 1 From d4c8d778e8dbd0bd9803db3a49a42e2af1c47bda Mon Sep 17 00:00:00 2001 From: Vasili Skurydzin Date: Mon, 15 Oct 2018 16:34:29 -0400 Subject: [PATCH 232/328] deps: cherry-pick d9e7832 from V8 upstream Original commit message: fix gn builds on aix Change-Id: I60aed7bf8207703fa6ceddb6165e173e68b5ff5f Reviewed-on: https://chromium-review.googlesource.com/1103533 Commit-Queue: Michael Achenbach Reviewed-by: Michael Achenbach Cr-Commit-Position: refs/heads/master@{#54386} PR-URL: https://github.com/nodejs/node/pull/23695 Reviewed-By: Michael Dawson Reviewed-By: Refael Ackermann Reviewed-By: Yang Guo Reviewed-By: Ujjwal Sharma --- common.gypi | 2 +- deps/v8/infra/mb/mb_config.pyl | 50 ++++++++++++++++++----------- deps/v8/third_party/antlr4/BUILD.gn | 3 ++ deps/v8/tools/mb/mb.py | 2 ++ 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/common.gypi b/common.gypi index da85dc58fd4825..0b05986cc22f61 100644 --- a/common.gypi +++ b/common.gypi @@ -33,7 +33,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.38', + 'v8_embedder_string': '-node.39', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/infra/mb/mb_config.pyl b/deps/v8/infra/mb/mb_config.pyl index 23b00624557606..f018eaa2c1cf51 100644 --- a/deps/v8/infra/mb/mb_config.pyl +++ b/deps/v8/infra/mb/mb_config.pyl @@ -27,18 +27,21 @@ 'mips64el.debug': 'default_debug_mips64el', 'mips64el.optdebug': 'default_optdebug_mips64el', 'mips64el.release': 'default_release_mips64el', - 'ppc.debug': 'default_debug_ppc', - 'ppc.optdebug': 'default_optdebug_ppc', - 'ppc.release': 'default_release_ppc', + 'ppc.debug.sim': 'default_debug_ppc_sim', + 'ppc.optdebug.sim': 'default_optdebug_ppc_sim', + 'ppc.release.sim': 'default_release_ppc_sim', 'ppc64.debug': 'default_debug_ppc64', + 'ppc64.debug.sim': 'default_debug_ppc64_sim', 'ppc64.optdebug': 'default_optdebug_ppc64', + 'ppc64.optdebug.sim': 'default_optdebug_ppc64_sim', 'ppc64.release': 'default_release_ppc64', - 's390.debug': 'default_debug_s390', - 's390.optdebug': 'default_optdebug_s390', - 's390.release': 'default_release_s390', - 's390x.debug': 'default_debug_s390x', - 's390x.optdebug': 'default_optdebug_s390x', - 's390x.release': 'default_release_s390x', + 'ppc64.release.sim': 'default_release_ppc64_sim', + 's390.debug.sim': 'default_debug_s390_sim', + 's390.optdebug.sim': 'default_optdebug_s390_sim', + 's390.release.sim': 'default_release_s390_sim', + 's390x.debug.sim': 'default_debug_s390x_sim', + 's390x.optdebug.sim': 'default_optdebug_s390x_sim', + 's390x.release.sim': 'default_release_s390x_sim', 'x64.debug': 'default_debug_x64', 'x64.optdebug': 'default_optdebug_x64', 'x64.release': 'default_release_x64', @@ -252,6 +255,7 @@ # To ease readability, config values are ordered by: # release/debug, arch type, other values alphabetically. + # TODO: create separate native configurations for ppc,s390[x]. 'configs': { # Developer default configs. 'default_debug_arm': [ @@ -284,29 +288,35 @@ 'debug', 'simulate_mips64el', 'v8_enable_slow_dchecks'], 'default_release_mips64el': [ 'release', 'simulate_mips64el'], - 'default_debug_ppc': [ + 'default_debug_ppc_sim': [ 'debug', 'simulate_ppc', 'v8_enable_slow_dchecks', 'v8_full_debug'], - 'default_optdebug_ppc': [ + 'default_optdebug_ppc_sim': [ 'debug', 'simulate_ppc', 'v8_enable_slow_dchecks'], - 'default_release_ppc': [ + 'default_release_ppc_sim': [ 'release', 'simulate_ppc'], 'default_debug_ppc64': [ + 'debug', 'ppc64', 'gcc', 'v8_enable_slow_dchecks', 'v8_full_debug'], + 'default_debug_ppc64_sim': [ 'debug', 'simulate_ppc64', 'v8_enable_slow_dchecks', 'v8_full_debug'], 'default_optdebug_ppc64': [ + 'debug', 'ppc64', 'gcc', 'v8_enable_slow_dchecks'], + 'default_optdebug_ppc64_sim': [ 'debug', 'simulate_ppc64', 'v8_enable_slow_dchecks'], 'default_release_ppc64': [ + 'release', 'ppc64', 'gcc'], + 'default_release_ppc64_sim': [ 'release', 'simulate_ppc64'], - 'default_debug_s390': [ + 'default_debug_s390_sim': [ 'debug', 'simulate_s390', 'v8_enable_slow_dchecks', 'v8_full_debug'], - 'default_optdebug_s390': [ + 'default_optdebug_s390_sim': [ 'debug', 'simulate_s390', 'v8_enable_slow_dchecks'], - 'default_release_s390': [ + 'default_release_s390_sim': [ 'release', 'simulate_s390'], - 'default_debug_s390x': [ + 'default_debug_s390x_sim': [ 'debug', 'simulate_s390x', 'v8_enable_slow_dchecks', 'v8_full_debug'], - 'default_optdebug_s390x': [ + 'default_optdebug_s390x_sim': [ 'debug', 'simulate_s390x', 'v8_enable_slow_dchecks'], - 'default_release_s390x': [ + 'default_release_s390x_sim': [ 'release', 'simulate_s390x'], 'default_debug_x64': [ 'debug', 'x64', 'v8_enable_slow_dchecks', 'v8_full_debug'], @@ -823,5 +833,9 @@ 'x86': { 'gn_args': 'target_cpu="x86"', }, + + 'ppc64': { + 'gn_args': 'target_cpu="ppc64"', + }, }, } diff --git a/deps/v8/third_party/antlr4/BUILD.gn b/deps/v8/third_party/antlr4/BUILD.gn index bd58a1804d1558..65e2a78eb4c398 100644 --- a/deps/v8/third_party/antlr4/BUILD.gn +++ b/deps/v8/third_party/antlr4/BUILD.gn @@ -9,6 +9,9 @@ config("antlr-compatibility") { "-Wno-unused-but-set-variable", ] } + if (is_aix) { + cflags += [ "-fdollars-in-identifiers" ] + } } source_set("antlr4") { diff --git a/deps/v8/tools/mb/mb.py b/deps/v8/tools/mb/mb.py index b2ae0c763f6a15..189de8b6b7f2d7 100755 --- a/deps/v8/tools/mb/mb.py +++ b/deps/v8/tools/mb/mb.py @@ -832,6 +832,8 @@ def GNCmd(self, subcommand, path, *args): subdir, exe = 'linux64', 'gn' elif self.platform == 'darwin': subdir, exe = 'mac', 'gn' + elif self.platform == 'aix6': + subdir, exe = 'aix', 'gn' else: subdir, exe = 'win', 'gn.exe' From 01544e122468276bb7a304476715f0515fa0fc39 Mon Sep 17 00:00:00 2001 From: Vasili Skurydzin Date: Mon, 15 Oct 2018 16:40:50 -0400 Subject: [PATCH 233/328] deps: cherry-pick abab9fb from V8 upstream Original commit message: s390, ppc64: Enable v8gen.py on Linux s390, ppc64 Change-Id: Ia05e949e1a823e30a45894c47f6f6df2e159befe Reviewed-on: https://chromium-review.googlesource.com/1135540 Commit-Queue: Michael Achenbach Reviewed-by: Michael Achenbach Cr-Commit-Position: refs/heads/master@{#54485} PR-URL: https://github.com/nodejs/node/pull/23695 Reviewed-By: Michael Dawson Reviewed-By: Refael Ackermann Reviewed-By: Yang Guo Reviewed-By: Ujjwal Sharma --- common.gypi | 2 +- deps/v8/infra/mb/mb_config.pyl | 59 ++++++++++++++++++++++++++++------ deps/v8/tools/mb/mb.py | 8 ++++- 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/common.gypi b/common.gypi index 0b05986cc22f61..1a1bdb5f005a16 100644 --- a/common.gypi +++ b/common.gypi @@ -33,7 +33,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.39', + 'v8_embedder_string': '-node.40', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/infra/mb/mb_config.pyl b/deps/v8/infra/mb/mb_config.pyl index f018eaa2c1cf51..f863cedee87e5a 100644 --- a/deps/v8/infra/mb/mb_config.pyl +++ b/deps/v8/infra/mb/mb_config.pyl @@ -27,18 +27,27 @@ 'mips64el.debug': 'default_debug_mips64el', 'mips64el.optdebug': 'default_optdebug_mips64el', 'mips64el.release': 'default_release_mips64el', + 'ppc.debug': 'default_debug_ppc', + 'ppc.optdebug': 'default_optdebug_ppc', + 'ppc.release': 'default_release_ppc', 'ppc.debug.sim': 'default_debug_ppc_sim', 'ppc.optdebug.sim': 'default_optdebug_ppc_sim', 'ppc.release.sim': 'default_release_ppc_sim', 'ppc64.debug': 'default_debug_ppc64', - 'ppc64.debug.sim': 'default_debug_ppc64_sim', 'ppc64.optdebug': 'default_optdebug_ppc64', - 'ppc64.optdebug.sim': 'default_optdebug_ppc64_sim', 'ppc64.release': 'default_release_ppc64', + 'ppc64.debug.sim': 'default_debug_ppc64_sim', + 'ppc64.optdebug.sim': 'default_optdebug_ppc64_sim', 'ppc64.release.sim': 'default_release_ppc64_sim', + 's390.debug': 'default_debug_s390', + 's390.optdebug': 'default_optdebug_s390', + 's390.release': 'default_release_s390', 's390.debug.sim': 'default_debug_s390_sim', 's390.optdebug.sim': 'default_optdebug_s390_sim', 's390.release.sim': 'default_release_s390_sim', + 's390x.debug': 'default_debug_s390x', + 's390x.optdebug': 'default_optdebug_s390x', + 's390x.release': 'default_release_s390x', 's390x.debug.sim': 'default_debug_s390x_sim', 's390x.optdebug.sim': 'default_optdebug_s390x_sim', 's390x.release.sim': 'default_release_s390x_sim', @@ -255,7 +264,6 @@ # To ease readability, config values are ordered by: # release/debug, arch type, other values alphabetically. - # TODO: create separate native configurations for ppc,s390[x]. 'configs': { # Developer default configs. 'default_debug_arm': [ @@ -288,6 +296,12 @@ 'debug', 'simulate_mips64el', 'v8_enable_slow_dchecks'], 'default_release_mips64el': [ 'release', 'simulate_mips64el'], + 'default_debug_ppc': [ + 'debug', 'ppc', 'v8_enable_slow_dchecks', 'v8_full_debug'], + 'default_optdebug_ppc': [ + 'debug', 'ppc', 'v8_enable_slow_dchecks'], + 'default_release_ppc': [ + 'release', 'ppc'], 'default_debug_ppc_sim': [ 'debug', 'simulate_ppc', 'v8_enable_slow_dchecks', 'v8_full_debug'], 'default_optdebug_ppc_sim': [ @@ -296,22 +310,34 @@ 'release', 'simulate_ppc'], 'default_debug_ppc64': [ 'debug', 'ppc64', 'gcc', 'v8_enable_slow_dchecks', 'v8_full_debug'], - 'default_debug_ppc64_sim': [ - 'debug', 'simulate_ppc64', 'v8_enable_slow_dchecks', 'v8_full_debug'], 'default_optdebug_ppc64': [ 'debug', 'ppc64', 'gcc', 'v8_enable_slow_dchecks'], - 'default_optdebug_ppc64_sim': [ - 'debug', 'simulate_ppc64', 'v8_enable_slow_dchecks'], 'default_release_ppc64': [ 'release', 'ppc64', 'gcc'], + 'default_debug_ppc64_sim': [ + 'debug', 'simulate_ppc64', 'v8_enable_slow_dchecks', 'v8_full_debug'], + 'default_optdebug_ppc64_sim': [ + 'debug', 'simulate_ppc64', 'v8_enable_slow_dchecks'], 'default_release_ppc64_sim': [ 'release', 'simulate_ppc64'], + 'default_debug_s390': [ + 'debug', 's390', 'v8_enable_slow_dchecks', 'v8_full_debug'], + 'default_optdebug_s390': [ + 'debug', 's390', 'v8_enable_slow_dchecks'], + 'default_release_s390': [ + 'release', 's390'], 'default_debug_s390_sim': [ 'debug', 'simulate_s390', 'v8_enable_slow_dchecks', 'v8_full_debug'], 'default_optdebug_s390_sim': [ 'debug', 'simulate_s390', 'v8_enable_slow_dchecks'], 'default_release_s390_sim': [ 'release', 'simulate_s390'], + 'default_debug_s390x': [ + 'debug', 's390x', 'v8_enable_slow_dchecks', 'v8_full_debug'], + 'default_optdebug_s390x': [ + 'debug', 's390x', 'v8_enable_slow_dchecks'], + 'default_release_s390x': [ + 'release', 's390x'], 'default_debug_s390x_sim': [ 'debug', 'simulate_s390x', 'v8_enable_slow_dchecks', 'v8_full_debug'], 'default_optdebug_s390x_sim': [ @@ -826,6 +852,22 @@ 'gn_args': 'v8_enable_verify_csa=true', }, + 's390': { + 'gn_args': 'target_cpu="s390x" v8_target_cpu="s390"', + }, + + 's390x': { + 'gn_args': 'target_cpu="s390x" v8_target_cpu="s390x"', + }, + + 'ppc': { + 'gn_args': 'target_cpu="ppc"', + }, + + 'ppc64': { + 'gn_args': 'target_cpu="ppc64" use_custom_libcxx=false', + }, + 'x64': { 'gn_args': 'target_cpu="x64"', }, @@ -834,8 +876,5 @@ 'gn_args': 'target_cpu="x86"', }, - 'ppc64': { - 'gn_args': 'target_cpu="ppc64"', - }, }, } diff --git a/deps/v8/tools/mb/mb.py b/deps/v8/tools/mb/mb.py index 189de8b6b7f2d7..0c768886bf190b 100755 --- a/deps/v8/tools/mb/mb.py +++ b/deps/v8/tools/mb/mb.py @@ -837,7 +837,13 @@ def GNCmd(self, subcommand, path, *args): else: subdir, exe = 'win', 'gn.exe' - gn_path = self.PathJoin(self.chromium_src_dir, 'buildtools', subdir, exe) + arch = platform.machine() + if (self.platform == 'linux2' and + (arch.startswith('s390') or arch.startswith('ppc'))): + # use gn in PATH + gn_path = 'gn' + else: + gn_path = self.PathJoin(self.chromium_src_dir, 'buildtools', subdir, exe) return [gn_path, subcommand, path] + list(args) From a4d67c95b6ddae9683e80c56fe06c9dfab1a33ce Mon Sep 17 00:00:00 2001 From: Vasili Skurydzin Date: Mon, 15 Oct 2018 16:44:38 -0400 Subject: [PATCH 234/328] deps: cherry-pick a51f429 from V8 upstream Original commit message: Use gn from PATH on aix Change-Id: I853f7899dbba9112ba1ca2ce78e2838b5a09c975 Reviewed-on: https://chromium-review.googlesource.com/1168087 Commit-Queue: John Barboza Reviewed-by: Michael Achenbach Cr-Commit-Position: refs/heads/master@{#55028} PR-URL: https://github.com/nodejs/node/pull/23695 Reviewed-By: Michael Dawson Reviewed-By: Refael Ackermann Reviewed-By: Yang Guo Reviewed-By: Ujjwal Sharma --- common.gypi | 2 +- deps/v8/tools/mb/mb.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/common.gypi b/common.gypi index 1a1bdb5f005a16..24702b7f62bdf5 100644 --- a/common.gypi +++ b/common.gypi @@ -33,7 +33,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.40', + 'v8_embedder_string': '-node.41', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/tools/mb/mb.py b/deps/v8/tools/mb/mb.py index 0c768886bf190b..cbb5b5dd6d5bd6 100755 --- a/deps/v8/tools/mb/mb.py +++ b/deps/v8/tools/mb/mb.py @@ -832,14 +832,12 @@ def GNCmd(self, subcommand, path, *args): subdir, exe = 'linux64', 'gn' elif self.platform == 'darwin': subdir, exe = 'mac', 'gn' - elif self.platform == 'aix6': - subdir, exe = 'aix', 'gn' else: subdir, exe = 'win', 'gn.exe' arch = platform.machine() - if (self.platform == 'linux2' and - (arch.startswith('s390') or arch.startswith('ppc'))): + if (arch.startswith('s390') or arch.startswith('ppc') or + self.platform.startswith('aix')): # use gn in PATH gn_path = 'gn' else: From f2d3bade813db1266222d7506bcea21708256d5a Mon Sep 17 00:00:00 2001 From: Vasili Skurydzin Date: Mon, 15 Oct 2018 16:59:52 -0400 Subject: [PATCH 235/328] deps: cherry-pick d2e0166 from V8 upstream Original commit message: ppc64, aix: Pass CallFrequency object by const reference to avoid value copy error. Bug: v8:8193 GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61976 Change-Id: I0d4efca4da03ef82651325e15ddf2160022bc8de Reviewed-on: https://chromium-review.googlesource.com/1228633 Reviewed-by: Michael Starzinger Reviewed-by: Daniel Clifford Reviewed-by: Junliang Yan Commit-Queue: Junliang Yan Cr-Commit-Position: refs/heads/master@{#56275} PR-URL: https://github.com/nodejs/node/pull/23695 Reviewed-By: Michael Dawson Reviewed-By: Refael Ackermann Reviewed-By: Yang Guo Reviewed-By: Ujjwal Sharma --- common.gypi | 2 +- deps/v8/src/compiler/bytecode-graph-builder.cc | 2 +- deps/v8/src/compiler/bytecode-graph-builder.h | 2 +- deps/v8/src/compiler/js-inlining.cc | 3 ++- deps/v8/src/compiler/js-operator.cc | 7 ++++--- deps/v8/src/compiler/js-operator.h | 8 ++++---- deps/v8/src/compiler/pipeline.cc | 3 ++- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/common.gypi b/common.gypi index 24702b7f62bdf5..589c82526cd093 100644 --- a/common.gypi +++ b/common.gypi @@ -33,7 +33,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.41', + 'v8_embedder_string': '-node.42', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/src/compiler/bytecode-graph-builder.cc b/deps/v8/src/compiler/bytecode-graph-builder.cc index ade917de476ef7..8a60d680332e61 100644 --- a/deps/v8/src/compiler/bytecode-graph-builder.cc +++ b/deps/v8/src/compiler/bytecode-graph-builder.cc @@ -514,7 +514,7 @@ Node* BytecodeGraphBuilder::Environment::Checkpoint( BytecodeGraphBuilder::BytecodeGraphBuilder( Zone* local_zone, Handle shared_info, Handle feedback_vector, BailoutId osr_offset, - JSGraph* jsgraph, CallFrequency invocation_frequency, + JSGraph* jsgraph, CallFrequency& invocation_frequency, SourcePositionTable* source_positions, Handle native_context, int inlining_id, JSTypeHintLowering::Flags flags, bool stack_check, bool analyze_environment_liveness) diff --git a/deps/v8/src/compiler/bytecode-graph-builder.h b/deps/v8/src/compiler/bytecode-graph-builder.h index 9025d477d57fe3..15eef5d844e140 100644 --- a/deps/v8/src/compiler/bytecode-graph-builder.h +++ b/deps/v8/src/compiler/bytecode-graph-builder.h @@ -31,7 +31,7 @@ class BytecodeGraphBuilder { BytecodeGraphBuilder( Zone* local_zone, Handle shared, Handle feedback_vector, BailoutId osr_offset, - JSGraph* jsgraph, CallFrequency invocation_frequency, + JSGraph* jsgraph, CallFrequency& invocation_frequency, SourcePositionTable* source_positions, Handle native_context, int inlining_id = SourcePosition::kNotInlined, JSTypeHintLowering::Flags flags = JSTypeHintLowering::kNoFlags, diff --git a/deps/v8/src/compiler/js-inlining.cc b/deps/v8/src/compiler/js-inlining.cc index 08917ab78bd93d..075155c2496ba7 100644 --- a/deps/v8/src/compiler/js-inlining.cc +++ b/deps/v8/src/compiler/js-inlining.cc @@ -484,9 +484,10 @@ Reduction JSInliner::ReduceJSCall(Node* node) { if (info_->is_bailout_on_uninitialized()) { flags |= JSTypeHintLowering::kBailoutOnUninitialized; } + CallFrequency frequency = call.frequency(); BytecodeGraphBuilder graph_builder( zone(), shared_info, feedback_vector, BailoutId::None(), jsgraph(), - call.frequency(), source_positions_, native_context(), inlining_id, + frequency, source_positions_, native_context(), inlining_id, flags, false, info_->is_analyze_environment_liveness()); graph_builder.CreateGraph(); diff --git a/deps/v8/src/compiler/js-operator.cc b/deps/v8/src/compiler/js-operator.cc index 8fe10bb36a83d7..04feec6827aad0 100644 --- a/deps/v8/src/compiler/js-operator.cc +++ b/deps/v8/src/compiler/js-operator.cc @@ -794,7 +794,8 @@ const Operator* JSOperatorBuilder::CallForwardVarargs(size_t arity, parameters); // parameter } -const Operator* JSOperatorBuilder::Call(size_t arity, CallFrequency frequency, +const Operator* JSOperatorBuilder::Call(size_t arity, + CallFrequency const& frequency, VectorSlotPair const& feedback, ConvertReceiverMode convert_mode, SpeculationMode speculation_mode) { @@ -818,8 +819,8 @@ const Operator* JSOperatorBuilder::CallWithArrayLike(CallFrequency frequency) { } const Operator* JSOperatorBuilder::CallWithSpread( - uint32_t arity, CallFrequency frequency, VectorSlotPair const& feedback, - SpeculationMode speculation_mode) { + uint32_t arity, CallFrequency const& frequency, + VectorSlotPair const& feedback, SpeculationMode speculation_mode) { DCHECK_IMPLIES(speculation_mode == SpeculationMode::kAllowSpeculation, feedback.IsValid()); CallParameters parameters(arity, frequency, feedback, diff --git a/deps/v8/src/compiler/js-operator.h b/deps/v8/src/compiler/js-operator.h index 6d89e5ac09a9de..ac09ed229bd7b2 100644 --- a/deps/v8/src/compiler/js-operator.h +++ b/deps/v8/src/compiler/js-operator.h @@ -160,7 +160,7 @@ CallForwardVarargsParameters const& CallForwardVarargsParametersOf( // used as a parameter by JSCall and JSCallWithSpread operators. class CallParameters final { public: - CallParameters(size_t arity, CallFrequency frequency, + CallParameters(size_t arity, CallFrequency const& frequency, VectorSlotPair const& feedback, ConvertReceiverMode convert_mode, SpeculationMode speculation_mode) @@ -171,7 +171,7 @@ class CallParameters final { feedback_(feedback) {} size_t arity() const { return ArityField::decode(bit_field_); } - CallFrequency frequency() const { return frequency_; } + CallFrequency const& frequency() const { return frequency_; } ConvertReceiverMode convert_mode() const { return ConvertReceiverModeField::decode(bit_field_); } @@ -721,13 +721,13 @@ class V8_EXPORT_PRIVATE JSOperatorBuilder final const Operator* CallForwardVarargs(size_t arity, uint32_t start_index); const Operator* Call( - size_t arity, CallFrequency frequency = CallFrequency(), + size_t arity, CallFrequency const& frequency = CallFrequency(), VectorSlotPair const& feedback = VectorSlotPair(), ConvertReceiverMode convert_mode = ConvertReceiverMode::kAny, SpeculationMode speculation_mode = SpeculationMode::kDisallowSpeculation); const Operator* CallWithArrayLike(CallFrequency frequency); const Operator* CallWithSpread( - uint32_t arity, CallFrequency frequency = CallFrequency(), + uint32_t arity, CallFrequency const& frequency = CallFrequency(), VectorSlotPair const& feedback = VectorSlotPair(), SpeculationMode speculation_mode = SpeculationMode::kDisallowSpeculation); const Operator* CallRuntime(Runtime::FunctionId id); diff --git a/deps/v8/src/compiler/pipeline.cc b/deps/v8/src/compiler/pipeline.cc index 779457bcf76c34..0bc4bdd41428e2 100644 --- a/deps/v8/src/compiler/pipeline.cc +++ b/deps/v8/src/compiler/pipeline.cc @@ -1059,10 +1059,11 @@ struct GraphBuilderPhase { if (data->info()->is_bailout_on_uninitialized()) { flags |= JSTypeHintLowering::kBailoutOnUninitialized; } + CallFrequency frequency = CallFrequency(1.0f); BytecodeGraphBuilder graph_builder( temp_zone, data->info()->shared_info(), handle(data->info()->closure()->feedback_vector()), - data->info()->osr_offset(), data->jsgraph(), CallFrequency(1.0f), + data->info()->osr_offset(), data->jsgraph(), frequency, data->source_positions(), data->native_context(), SourcePosition::kNotInlined, flags, true, data->info()->is_analyze_environment_liveness()); From d3fb599b611a913e8bf07baf5224f086a6fd9e3e Mon Sep 17 00:00:00 2001 From: Vasili Skurydzin Date: Mon, 15 Oct 2018 17:02:48 -0400 Subject: [PATCH 236/328] deps: cherry-pick 67b5499 from V8 upstream Original commit message: PPC: disable failing cctest on AIX temporarily Change-Id: I8a0081acb9c5eb662bf43eceb52218096eac327c Reviewed-on: https://chromium-review.googlesource.com/1174560 Reviewed-by: Adam Klein Reviewed-by: Camillo Bruni Reviewed-by: Junliang Yan Commit-Queue: Junliang Yan Cr-Commit-Position: refs/heads/master@{#55229} PR-URL: https://github.com/nodejs/node/pull/23695 Reviewed-By: Michael Dawson Reviewed-By: Refael Ackermann Reviewed-By: Yang Guo Reviewed-By: Ujjwal Sharma --- common.gypi | 2 +- deps/v8/test/cctest/cctest.status | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/common.gypi b/common.gypi index 589c82526cd093..7d11d9e1382588 100644 --- a/common.gypi +++ b/common.gypi @@ -33,7 +33,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.42', + 'v8_embedder_string': '-node.43', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/test/cctest/cctest.status b/deps/v8/test/cctest/cctest.status index da069e0a269386..85e2554f5ec77f 100644 --- a/deps/v8/test/cctest/cctest.status +++ b/deps/v8/test/cctest/cctest.status @@ -390,6 +390,7 @@ # TODO(ppc): Implement load/store reverse byte instructions 'test-run-wasm-simd/RunWasmCompiled_SimdLoadStoreLoad': [SKIP], 'test-run-wasm-simd/RunWasm_SimdLoadStoreLoad': [SKIP], + 'test-run-wasm-simd/RunWasm_SimdLoadStoreLoad_turbofan': [SKIP], }], # 'system == aix or (arch == ppc64 and byteorder == big)' From 20430ae487c312c4a2bbd2a6df22bcf6770a7cd5 Mon Sep 17 00:00:00 2001 From: Vasili Skurydzin Date: Tue, 16 Oct 2018 10:36:48 -0400 Subject: [PATCH 237/328] deps: V8: Add virtual dtor to avoid aix gcc error deps/v8/src/torque/file-visitor.h: * Not currently present in v8/master deps/v8/third_party/antlr4/BUILD.gn: * Use current_os variable to avoid is_aix being undefined. The following patch to v8/build solves this issue for v8/master: * a1a12ef3b343f9e75c630ed6dc8f1ea44a8a747b However, the version of '/chromium/src/build.git' cannot be updated to include this patch in v8/DEPS file. (could potentially cause issues for other platforms) The change to deps/v8/src/torque/file-visitor.h is a workaround for origin/v10.x-staging branch. PR-URL: https://github.com/nodejs/node/pull/23695 Reviewed-By: Michael Dawson Reviewed-By: Refael Ackermann Reviewed-By: Yang Guo Reviewed-By: Ujjwal Sharma --- common.gypi | 2 +- deps/v8/src/torque/file-visitor.h | 4 ++++ deps/v8/third_party/antlr4/BUILD.gn | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/common.gypi b/common.gypi index 7d11d9e1382588..f0315b198a85a0 100644 --- a/common.gypi +++ b/common.gypi @@ -33,7 +33,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.43', + 'v8_embedder_string': '-node.44', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/src/torque/file-visitor.h b/deps/v8/src/torque/file-visitor.h index 5aac1bad46d6a4..45820c5b6bf8ef 100644 --- a/deps/v8/src/torque/file-visitor.h +++ b/deps/v8/src/torque/file-visitor.h @@ -21,6 +21,10 @@ namespace torque { class FileVisitor { public: +#if defined(__GNUC__) && V8_OS_AIX + // prevent non-virtual-dtor gcc error on Aix + virtual ~FileVisitor() = default; +#endif explicit FileVisitor(GlobalContext& global_context) : global_context_(global_context), declarations_(global_context.declarations()), diff --git a/deps/v8/third_party/antlr4/BUILD.gn b/deps/v8/third_party/antlr4/BUILD.gn index 65e2a78eb4c398..8d3d98a399f0f6 100644 --- a/deps/v8/third_party/antlr4/BUILD.gn +++ b/deps/v8/third_party/antlr4/BUILD.gn @@ -9,7 +9,7 @@ config("antlr-compatibility") { "-Wno-unused-but-set-variable", ] } - if (is_aix) { + if (current_os == "aix") { cflags += [ "-fdollars-in-identifiers" ] } } From b2252ea81d7638a0280df23f74f460bf69b49c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulises=20Gasc=C3=B3n?= Date: Fri, 22 Jun 2018 17:41:42 +0000 Subject: [PATCH 238/328] dns: fix inconsistent (hostname vs host) Fixes: https://github.com/nodejs/node/issues/20892 PR-URL: https://github.com/nodejs/node/pull/23572 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- lib/dns.js | 20 ++++++++++---------- lib/internal/dns/promises.js | 18 +++++++++--------- test/common/dns.js | 6 +++--- test/parallel/test-dns.js | 7 ++++--- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/lib/dns.js b/lib/dns.js index 326499497b1580..b2ae92a9d6999c 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -150,21 +150,21 @@ Object.defineProperty(lookup, customPromisifyArgs, { value: ['address', 'family'], enumerable: false }); -function onlookupservice(err, host, service) { +function onlookupservice(err, hostname, service) { if (err) - return this.callback(dnsException(err, 'getnameinfo', this.host)); + return this.callback(dnsException(err, 'getnameinfo', this.hostname)); - this.callback(null, host, service); + this.callback(null, hostname, service); } // lookupService(address, port, callback) -function lookupService(host, port, callback) { +function lookupService(hostname, port, callback) { if (arguments.length !== 3) - throw new ERR_MISSING_ARGS('host', 'port', 'callback'); + throw new ERR_MISSING_ARGS('hostname', 'port', 'callback'); - if (isIP(host) === 0) - throw new ERR_INVALID_OPT_VALUE('host', host); + if (isIP(hostname) === 0) + throw new ERR_INVALID_OPT_VALUE('hostname', hostname); if (!isLegalPort(port)) throw new ERR_SOCKET_BAD_PORT(port); @@ -176,12 +176,12 @@ function lookupService(host, port, callback) { var req = new GetNameInfoReqWrap(); req.callback = callback; - req.host = host; + req.hostname = hostname; req.port = port; req.oncomplete = onlookupservice; - var err = cares.getnameinfo(req, host, port); - if (err) throw dnsException(err, 'getnameinfo', host); + var err = cares.getnameinfo(req, hostname, port); + if (err) throw dnsException(err, 'getnameinfo', hostname); return req; } diff --git a/lib/internal/dns/promises.js b/lib/internal/dns/promises.js index 9ba202e5b2c575..65abd33b7bd92b 100644 --- a/lib/internal/dns/promises.js +++ b/lib/internal/dns/promises.js @@ -127,34 +127,34 @@ function onlookupservice(err, hostname, service) { this.resolve({ hostname, service }); } -function createLookupServicePromise(host, port) { +function createLookupServicePromise(hostname, port) { return new Promise((resolve, reject) => { const req = new GetNameInfoReqWrap(); - req.host = host; + req.hostname = hostname; req.port = port; req.oncomplete = onlookupservice; req.resolve = resolve; req.reject = reject; - const err = getnameinfo(req, host, port); + const err = getnameinfo(req, hostname, port); if (err) - reject(dnsException(err, 'getnameinfo', host)); + reject(dnsException(err, 'getnameinfo', hostname)); }); } -function lookupService(host, port) { +function lookupService(hostname, port) { if (arguments.length !== 2) - throw new ERR_MISSING_ARGS('host', 'port'); + throw new ERR_MISSING_ARGS('hostname', 'port'); - if (isIP(host) === 0) - throw new ERR_INVALID_OPT_VALUE('host', host); + if (isIP(hostname) === 0) + throw new ERR_INVALID_OPT_VALUE('hostname', hostname); if (!isLegalPort(port)) throw new ERR_SOCKET_BAD_PORT(port); - return createLookupServicePromise(host, +port); + return createLookupServicePromise(hostname, +port); } diff --git a/test/common/dns.js b/test/common/dns.js index 7b2f1ef76e2889..01245c33d6997c 100644 --- a/test/common/dns.js +++ b/test/common/dns.js @@ -291,12 +291,12 @@ const mockedErrorCode = 'ENOTFOUND'; const mockedSysCall = 'getaddrinfo'; function errorLookupMock(code = mockedErrorCode, syscall = mockedSysCall) { - return function lookupWithError(host, dnsopts, cb) { - const err = new Error(`${syscall} ${code} ${host}`); + return function lookupWithError(hostname, dnsopts, cb) { + const err = new Error(`${syscall} ${code} ${hostname}`); err.code = code; err.errno = code; err.syscall = syscall; - err.hostname = host; + err.hostname = hostname; cb(err); }; } diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js index a618bccd89ac13..eb02d4e92d647d 100644 --- a/test/parallel/test-dns.js +++ b/test/parallel/test-dns.js @@ -261,11 +261,12 @@ dns.lookup('', { const err = { code: 'ERR_MISSING_ARGS', type: TypeError, - message: 'The "host", "port", and "callback" arguments must be specified' + message: 'The "hostname", "port", and "callback" arguments must be ' + + 'specified' }; common.expectsError(() => dns.lookupService('0.0.0.0'), err); - err.message = 'The "host" and "port" arguments must be specified'; + err.message = 'The "hostname" and "port" arguments must be specified'; common.expectsError(() => dnsPromises.lookupService('0.0.0.0'), err); } @@ -274,7 +275,7 @@ dns.lookup('', { const err = { code: 'ERR_INVALID_OPT_VALUE', type: TypeError, - message: `The value "${invalidHost}" is invalid for option "host"` + message: `The value "${invalidHost}" is invalid for option "hostname"` }; common.expectsError(() => { From 30b1a4a61f3a2f0ecc1f4ac34a074895bd10d0f8 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 22 Sep 2018 20:43:53 +0200 Subject: [PATCH 239/328] doc: formalize non-const reference usage in C++ style guide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We generally avoid using non-const references if not necessary. This formalizes this rules by writing them down in the C++ style guide. (Note: Some reviews are from the original PR.) Refs: https://github.com/nodejs/node/pull/23028 PR-URL: https://github.com/nodejs/node/pull/23155 Reviewed-By: Tobias Nießen Reviewed-By: Luigi Pinca Reviewed-By: Joyee Cheung Reviewed-By: Gireesh Punathil Reviewed-By: Daniel Bevenius Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Michael Dawson Reviewed-By: Refael Ackermann Reviewed-By: James M Snell Reviewed-By: Michaël Zasso Reviewed-By: Ali Ijaz Sheikh Reviewed-By: Anatoli Papirovski --- CPP_STYLE_GUIDE.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/CPP_STYLE_GUIDE.md b/CPP_STYLE_GUIDE.md index 36c3538f418a55..e14de6cc48b1e3 100644 --- a/CPP_STYLE_GUIDE.md +++ b/CPP_STYLE_GUIDE.md @@ -19,6 +19,7 @@ * [Memory allocation](#memory-allocation) * [Use `nullptr` instead of `NULL` or `0`](#use-nullptr-instead-of-null-or-0) * [Ownership and Smart Pointers](#ownership-and-smart-pointers) + * [Avoid non-const references](#avoid-non-const-references) * [Others](#others) * [Type casting](#type-casting) * [Using `auto`](#using-auto) @@ -212,6 +213,43 @@ ownership to the callee and invalidates the caller's instance. Don't use `std::auto_ptr`, it is deprecated ([Reference][cppref_auto_ptr]). +### Avoid non-const references + +Using non-const references often obscures which values are changed by an +assignment. Consider using a pointer instead, which requires more explicit +syntax to indicate that modifications take place. + +```c++ +class ExampleClass { + public: + explicit ExampleClass(OtherClass* other_ptr) : pointer_to_other_(other_ptr) {} + + void SomeMethod(const std::string& input_param, + std::string* in_out_param); // Pointer instead of reference + + const std::string& get_foo() const { return foo_string_; } + void set_foo(const std::string& new_value) { foo_string_ = new_value; } + + void ReplaceCharacterInFoo(char from, char to) { + // A non-const reference is okay here, because the method name already tells + // users that this modifies 'foo_string_' -- if that is not the case, + // it can still be better to use an indexed for loop, or leave appropriate + // comments. + for (char& character : foo_string_) { + if (character == from) + character = to; + } + } + + private: + std::string foo_string_; + // Pointer instead of reference. If this object 'owns' the other object, + // this should be a `std::unique_ptr`; a + // `std::shared_ptr` can also be a better choice. + OtherClass* pointer_to_other_; +}; +``` + ## Others ### Type casting From ce03acac71f1ef5496ce1a8df7c141202268ebf6 Mon Sep 17 00:00:00 2001 From: jn99 Date: Fri, 12 Oct 2018 10:36:32 -0700 Subject: [PATCH 240/328] test: skip failing tests for osx mojave MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: https://github.com/nodejs/node/issues/21679 PR-URL: https://github.com/nodejs/node/pull/23550 Reviewed-By: Ruben Bridgewater Reviewed-By: George Adams Reviewed-By: Gus Caplan Reviewed-By: James M Snell Reviewed-By: Santiago Gimeno Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Michael Dawson Reviewed-By: Сковорода Никита Андреевич --- test/common/index.js | 3 +++ .../test-cluster-bind-privileged-port.js | 25 +++++++++++++++++++ .../test-cluster-bind-privileged-port.js | 5 ++++ ...ster-shared-handle-bind-privileged-port.js | 5 ++++ 4 files changed, 38 insertions(+) create mode 100644 test/known_issues/test-cluster-bind-privileged-port.js diff --git a/test/common/index.js b/test/common/index.js index 4930f6163e8fde..71759bae142ec3 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -57,6 +57,8 @@ const isOpenBSD = process.platform === 'openbsd'; const isLinux = process.platform === 'linux'; const isOSX = process.platform === 'darwin'; +const isOSXMojave = isOSX && (os.release().startsWith('18')); + const enoughTestMem = os.totalmem() > 0x70000000; /* 1.75 Gb */ const cpus = os.cpus(); const enoughTestCpu = Array.isArray(cpus) && @@ -711,6 +713,7 @@ module.exports = { isMainThread, isOpenBSD, isOSX, + isOSXMojave, isSunOS, isWindows, localIPv6Hosts, diff --git a/test/known_issues/test-cluster-bind-privileged-port.js b/test/known_issues/test-cluster-bind-privileged-port.js new file mode 100644 index 00000000000000..6ada04aa030b31 --- /dev/null +++ b/test/known_issues/test-cluster-bind-privileged-port.js @@ -0,0 +1,25 @@ +'use strict'; +const common = require('../common'); + +// This test should fail on macOS (10.14) due to an issue with privileged ports. + +const assert = require('assert'); +const cluster = require('cluster'); +const net = require('net'); + +if (!common.isOSXMojave) + assert.fail('Code should fail only on macOS Mojave.'); + + +if (cluster.isMaster) { + cluster.fork().on('exit', common.mustCall((exitCode) => { + assert.strictEqual(exitCode, 0); + })); +} else { + const s = net.createServer(common.mustNotCall()); + s.listen(42, common.mustNotCall('listen should have failed')); + s.on('error', common.mustCall((err) => { + assert.strictEqual(err.code, 'EACCES'); + process.disconnect(); + })); +} diff --git a/test/parallel/test-cluster-bind-privileged-port.js b/test/parallel/test-cluster-bind-privileged-port.js index 99f7a20c4946be..9d155259c3789e 100644 --- a/test/parallel/test-cluster-bind-privileged-port.js +++ b/test/parallel/test-cluster-bind-privileged-port.js @@ -21,6 +21,11 @@ 'use strict'; const common = require('../common'); + +// Skip on OS X Mojave. https://github.com/nodejs/node/issues/21679 +if (common.isOSXMojave) + common.skip('bypass test for Mojave due to OSX issue'); + if (common.isWindows) common.skip('not reliable on Windows.'); diff --git a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js index 8f05b28fed3308..1edece30af6de9 100644 --- a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js +++ b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js @@ -21,6 +21,11 @@ 'use strict'; const common = require('../common'); + +// Skip on OS X Mojave. https://github.com/nodejs/node/issues/21679 +if (common.isOSXMojave) + common.skip('bypass test for Mojave due to OSX issue'); + if (common.isWindows) common.skip('not reliable on Windows'); From 874371df890706150c6c0053d202836e248e8949 Mon Sep 17 00:00:00 2001 From: christian-bromann Date: Fri, 12 Oct 2018 10:43:58 -0700 Subject: [PATCH 241/328] test: increase coverage for readfile with withFileTypes According to the test coverage report a test case was missings checking if an error is passed into the callback for readdir calls with withFileTypes option. PR-URL: https://github.com/nodejs/node/pull/23557 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell --- test/parallel/test-fs-readdir-types.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/parallel/test-fs-readdir-types.js b/test/parallel/test-fs-readdir-types.js index 0faaeb00dadeb1..fa179eccfe26eb 100644 --- a/test/parallel/test-fs-readdir-types.js +++ b/test/parallel/test-fs-readdir-types.js @@ -49,6 +49,19 @@ function assertDirents(dirents) { // Check the readdir Sync version assertDirents(fs.readdirSync(readdirDir, { withFileTypes: true })); +fs.readdir(__filename, { + withFileTypes: true +}, common.mustCall((err) => { + assert.throws( + () => { throw err; }, + { + code: 'ENOTDIR', + name: 'Error', + message: `ENOTDIR: not a directory, scandir '${__filename}'` + } + ); +})); + // Check the readdir async version fs.readdir(readdirDir, { withFileTypes: true From 9aec3e68639d1707670bbf0de09140d33ca2e275 Mon Sep 17 00:00:00 2001 From: Ouyang Yadong Date: Sun, 14 Oct 2018 20:13:03 +0800 Subject: [PATCH 242/328] tls: close StreamWrap and its stream correctly When sockets of the "net" module destroyed, they will call `this._handle.close()` which will also emit EOF if not emitted before. This feature makes sockets on the other side emit "end" and "close" even though we haven't called `end()`. As `stream` of `StreamWrap` are likely to be instances of `net.Socket`, calling `destroy()` manually will avoid issues that don't properly close wrapped connections. Fixes: https://github.com/nodejs/node/issues/14605 PR-URL: https://github.com/nodejs/node/pull/23654 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- lib/internal/wrap_js_stream.js | 14 +++ test/parallel/test-tls-destroy-stream.js | 69 +++++++++++ test/parallel/test-wrap-js-stream-destroy.js | 118 +++++++++++++++++++ 3 files changed, 201 insertions(+) create mode 100644 test/parallel/test-tls-destroy-stream.js create mode 100644 test/parallel/test-wrap-js-stream-destroy.js diff --git a/lib/internal/wrap_js_stream.js b/lib/internal/wrap_js_stream.js index e6de433676f7d3..7ca7ff8bf49d25 100644 --- a/lib/internal/wrap_js_stream.js +++ b/lib/internal/wrap_js_stream.js @@ -68,6 +68,12 @@ class JSStreamWrap extends Socket { if (this._handle) this._handle.emitEOF(); }); + // Some `Stream` don't pass `hasError` parameters when closed. + stream.once('close', () => { + // Errors emitted from `stream` have also been emitted to this instance + // so that we don't pass errors to `destroy()` again. + this.destroy(); + }); super({ handle, manualStart: true }); this.stream = stream; @@ -188,6 +194,14 @@ class JSStreamWrap extends Socket { doClose(cb) { const handle = this._handle; + // When sockets of the "net" module destroyed, they will call + // `this._handle.close()` which will also emit EOF if not emitted before. + // This feature makes sockets on the other side emit "end" and "close" + // even though we haven't called `end()`. As `stream` are likely to be + // instances of `net.Socket`, calling `stream.destroy()` manually will + // avoid issues that don't properly close wrapped connections. + this.stream.destroy(); + setImmediate(() => { // Should be already set by net.js assert.strictEqual(this._handle, null); diff --git a/test/parallel/test-tls-destroy-stream.js b/test/parallel/test-tls-destroy-stream.js new file mode 100644 index 00000000000000..eb7a2ca338bd40 --- /dev/null +++ b/test/parallel/test-tls-destroy-stream.js @@ -0,0 +1,69 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) common.skip('missing crypto'); + +const fixtures = require('../common/fixtures'); +const makeDuplexPair = require('../common/duplexpair'); +const net = require('net'); +const assert = require('assert'); +const tls = require('tls'); + +// This test ensures that an instance of StreamWrap should emit "end" and +// "close" when the socket on the other side call `destroy()` instead of +// `end()`. +// Refs: https://github.com/nodejs/node/issues/14605 +const CONTENT = 'Hello World'; +const tlsServer = tls.createServer( + { + key: fixtures.readSync('test_key.pem'), + cert: fixtures.readSync('test_cert.pem'), + ca: [fixtures.readSync('test_ca.pem')], + }, + (socket) => { + socket.on('error', common.mustNotCall()); + socket.on('close', common.mustCall()); + socket.write(CONTENT); + socket.destroy(); + }, +); + +const server = net.createServer((conn) => { + conn.on('error', common.mustNotCall()); + // Assume that we want to use data to determine what to do with connections. + conn.once('data', common.mustCall((chunk) => { + const { clientSide, serverSide } = makeDuplexPair(); + serverSide.on('close', common.mustCall(() => { + conn.destroy(); + })); + clientSide.pipe(conn); + conn.pipe(clientSide); + + conn.on('close', common.mustCall(() => { + clientSide.destroy(); + })); + clientSide.on('close', common.mustCall(() => { + conn.destroy(); + })); + + process.nextTick(() => { + conn.unshift(chunk); + }); + + tlsServer.emit('connection', serverSide); + })); +}); + +server.listen(0, () => { + const port = server.address().port; + const conn = tls.connect({ port, rejectUnauthorized: false }, () => { + conn.on('data', common.mustCall((data) => { + assert.strictEqual(data.toString('utf8'), CONTENT); + })); + conn.on('error', common.mustNotCall()); + conn.on( + 'close', + common.mustCall(() => server.close()), + ); + }); +}); diff --git a/test/parallel/test-wrap-js-stream-destroy.js b/test/parallel/test-wrap-js-stream-destroy.js new file mode 100644 index 00000000000000..16d3e75e2ca7e3 --- /dev/null +++ b/test/parallel/test-wrap-js-stream-destroy.js @@ -0,0 +1,118 @@ +'use strict'; + +const common = require('../common'); +const StreamWrap = require('_stream_wrap'); +const net = require('net'); + +// This test ensures that when we directly call `socket.destroy()` without +// having called `socket.end()` on an instance of streamWrap, it will +// still emit EOF which makes the socket on the other side emit "end" and +// "close" events, and vice versa. +{ + let port; + const server = net.createServer((socket) => { + socket.on('error', common.mustNotCall()); + socket.on('end', common.mustNotCall()); + socket.on('close', common.mustCall()); + socket.destroy(); + }); + + server.listen(() => { + port = server.address().port; + createSocket(); + }); + + function createSocket() { + let streamWrap; + const socket = new net.connect({ + port, + }, () => { + socket.on('error', common.mustNotCall()); + socket.on('end', common.mustCall()); + socket.on('close', common.mustCall()); + + streamWrap.on('error', common.mustNotCall()); + // The "end" events will be emitted which is as same as + // the same situation for an instance of `net.Socket` without + // `StreamWrap`. + streamWrap.on('end', common.mustCall()); + // Destroying a socket in the server side should emit EOF and cause + // the corresponding client-side socket closed. + streamWrap.on('close', common.mustCall(() => { + server.close(); + })); + }); + streamWrap = new StreamWrap(socket); + } +} + +// Destroy the streamWrap and test again. +{ + let port; + const server = net.createServer((socket) => { + socket.on('error', common.mustNotCall()); + socket.on('end', common.mustCall()); + socket.on('close', common.mustCall(() => { + server.close(); + })); + // Do not `socket.end()` and directly `socket.destroy()`. + }); + + server.listen(() => { + port = server.address().port; + createSocket(); + }); + + function createSocket() { + let streamWrap; + const socket = new net.connect({ + port, + }, () => { + socket.on('error', common.mustNotCall()); + socket.on('end', common.mustNotCall()); + socket.on('close', common.mustCall()); + + streamWrap.on('error', common.mustNotCall()); + streamWrap.on('end', common.mustNotCall()); + // Destroying a socket in the server side should emit EOF and cause + // the corresponding client-side socket closed. + streamWrap.on('close', common.mustCall()); + streamWrap.destroy(); + }); + streamWrap = new StreamWrap(socket); + } +} + +// Destroy the client socket and test again. +{ + let port; + const server = net.createServer((socket) => { + socket.on('error', common.mustNotCall()); + socket.on('end', common.mustCall()); + socket.on('close', common.mustCall(() => { + server.close(); + })); + }); + + server.listen(() => { + port = server.address().port; + createSocket(); + }); + + function createSocket() { + let streamWrap; + const socket = new net.connect({ + port, + }, () => { + socket.on('error', common.mustNotCall()); + socket.on('end', common.mustNotCall()); + socket.on('close', common.mustCall()); + + streamWrap.on('error', common.mustNotCall()); + streamWrap.on('end', common.mustNotCall()); + streamWrap.on('close', common.mustCall()); + socket.destroy(); + }); + streamWrap = new StreamWrap(socket); + } +} From 9ad176ab50410db4e8c034233cb0f8ef7e4ed70f Mon Sep 17 00:00:00 2001 From: Ouyang Yadong Date: Sun, 4 Nov 2018 23:33:10 +0800 Subject: [PATCH 243/328] test: add a test for `tls.Socket` with `allowHalfOpen` This test ensures that a tls client socket using `StreamWrap` with `allowHalfOpen` option won't hang. PR-URL: https://github.com/nodejs/node/pull/23866 Refs: https://github.com/nodejs/node/pull/23654 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- .../parallel/test-tls-net-socket-keepalive.js | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 test/parallel/test-tls-net-socket-keepalive.js diff --git a/test/parallel/test-tls-net-socket-keepalive.js b/test/parallel/test-tls-net-socket-keepalive.js new file mode 100644 index 00000000000000..c184e902b42685 --- /dev/null +++ b/test/parallel/test-tls-net-socket-keepalive.js @@ -0,0 +1,53 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); + +const fixtures = require('../common/fixtures'); +const tls = require('tls'); +const net = require('net'); + +// This test ensures that when tls sockets are created with `allowHalfOpen`, +// they won't hang. +const key = fixtures.readKey('agent1-key.pem'); +const cert = fixtures.readKey('agent1-cert.pem'); +const ca = fixtures.readKey('ca1-cert.pem'); +const options = { + key, + cert, + ca: [ca], +}; + +const server = tls.createServer(options, common.mustCall((conn) => { + conn.write('hello'); + conn.on('data', common.mustCall()); + conn.end(); +})).listen(0, common.mustCall(() => { + const netSocket = new net.Socket({ + allowHalfOpen: true, + }); + + const socket = tls.connect({ + socket: netSocket, + rejectUnauthorized: false, + }); + + const { port, address } = server.address(); + + // Doing `net.Socket.connect()` after `tls.connect()` will make tls module + // wrap the socket in StreamWrap. + netSocket.connect({ + port, + address, + }); + + socket.on('end', common.mustCall()); + socket.on('data', common.mustCall()); + socket.on('close', common.mustCall(() => { + server.close(); + })); + + socket.write('hello'); + socket.end(); +})); From 4673848025d2aaf180d344be3198895080fdf619 Mon Sep 17 00:00:00 2001 From: Ian Sutherland Date: Fri, 19 Oct 2018 11:31:46 -0600 Subject: [PATCH 244/328] test: add blocks and comments to fs-promises tests PR-URL: https://github.com/nodejs/node/pull/23627 Reviewed-By: Joyee Cheung Reviewed-By: Colin Ihrig Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Ben Coe Reviewed-By: Refael Ackermann Reviewed-By: James M Snell --- test/parallel/test-fs-promises.js | 284 +++++++++++++++++------------- 1 file changed, 159 insertions(+), 125 deletions(-) diff --git a/test/parallel/test-fs-promises.js b/test/parallel/test-fs-promises.js index 797f8e4ea269f8..6b8fe3bb250899 100644 --- a/test/parallel/test-fs-promises.js +++ b/test/parallel/test-fs-promises.js @@ -74,31 +74,37 @@ async function getHandle(dest) { { async function doTest() { tmpdir.refresh(); + const dest = path.resolve(tmpDir, 'baz.js'); - await copyFile(fixtures.path('baz.js'), dest); - await access(dest, 'r'); - const handle = await open(dest, 'r+'); - assert.strictEqual(typeof handle, 'object'); + // handle is object + { + const handle = await getHandle(dest); + assert.strictEqual(typeof handle, 'object'); + } - let stats = await handle.stat(); - verifyStatObject(stats); - assert.strictEqual(stats.size, 35); + // file stats + { + const handle = await getHandle(dest); + let stats = await handle.stat(); + verifyStatObject(stats); + assert.strictEqual(stats.size, 35); - await handle.truncate(1); + await handle.truncate(1); - stats = await handle.stat(); - verifyStatObject(stats); - assert.strictEqual(stats.size, 1); + stats = await handle.stat(); + verifyStatObject(stats); + assert.strictEqual(stats.size, 1); - stats = await stat(dest); - verifyStatObject(stats); + stats = await stat(dest); + verifyStatObject(stats); - stats = await handle.stat(); - verifyStatObject(stats); + stats = await handle.stat(); + verifyStatObject(stats); - await handle.datasync(); - await handle.sync(); + await handle.datasync(); + await handle.sync(); + } // test fs.read promises when length to read is zero bytes { @@ -113,115 +119,140 @@ async function getHandle(dest) { await unlink(dest); } - const buf = Buffer.from('hello fsPromises'); - const bufLen = buf.length; - await handle.write(buf); - const ret = await handle.read(Buffer.alloc(bufLen), 0, bufLen, 0); - assert.strictEqual(ret.bytesRead, bufLen); - assert.deepStrictEqual(ret.buffer, buf); - - const buf2 = Buffer.from('hello FileHandle'); - const buf2Len = buf2.length; - await handle.write(buf2, 0, buf2Len, 0); - const ret2 = await handle.read(Buffer.alloc(buf2Len), 0, buf2Len, 0); - assert.strictEqual(ret2.bytesRead, buf2Len); - assert.deepStrictEqual(ret2.buffer, buf2); - await truncate(dest, 5); - assert.deepStrictEqual((await readFile(dest)).toString(), 'hello'); - - await chmod(dest, 0o666); - await handle.chmod(0o666); - - await chmod(dest, (0o10777)); - await handle.chmod(0o10777); - - if (!common.isWindows) { - await chown(dest, process.getuid(), process.getgid()); - await handle.chown(process.getuid(), process.getgid()); + // bytes written to file match buffer + { + const handle = await getHandle(dest); + const buf = Buffer.from('hello fsPromises'); + const bufLen = buf.length; + await handle.write(buf); + const ret = await handle.read(Buffer.alloc(bufLen), 0, bufLen, 0); + assert.strictEqual(ret.bytesRead, bufLen); + assert.deepStrictEqual(ret.buffer, buf); } - assert.rejects( - async () => { - await chown(dest, 1, -1); - }, - { - code: 'ERR_OUT_OF_RANGE', - name: 'RangeError [ERR_OUT_OF_RANGE]', - message: 'The value of "gid" is out of range. ' + - 'It must be >= 0 && < 4294967296. Received -1' - }); + // truncate file to specified length + { + const handle = await getHandle(dest); + const buf = Buffer.from('hello FileHandle'); + const bufLen = buf.length; + await handle.write(buf, 0, bufLen, 0); + const ret = await handle.read(Buffer.alloc(bufLen), 0, bufLen, 0); + assert.strictEqual(ret.bytesRead, bufLen); + assert.deepStrictEqual(ret.buffer, buf); + await truncate(dest, 5); + assert.deepStrictEqual((await readFile(dest)).toString(), 'hello'); + } - assert.rejects( - async () => { - await handle.chown(1, -1); - }, - { - code: 'ERR_OUT_OF_RANGE', - name: 'RangeError [ERR_OUT_OF_RANGE]', - message: 'The value of "gid" is out of range. ' + - 'It must be >= 0 && < 4294967296. Received -1' - }); + // invalid change of ownership + { + const handle = await getHandle(dest); - await utimes(dest, new Date(), new Date()); - - try { - await handle.utimes(new Date(), new Date()); - } catch (err) { - // Some systems do not have futimes. If there is an error, - // expect it to be ENOSYS - common.expectsError({ - code: 'ENOSYS', - type: Error - })(err); + await chmod(dest, 0o666); + await handle.chmod(0o666); + + await chmod(dest, (0o10777)); + await handle.chmod(0o10777); + + if (!common.isWindows) { + await chown(dest, process.getuid(), process.getgid()); + await handle.chown(process.getuid(), process.getgid()); + } + + assert.rejects( + async () => { + await chown(dest, 1, -1); + }, + { + code: 'ERR_OUT_OF_RANGE', + name: 'RangeError [ERR_OUT_OF_RANGE]', + message: 'The value of "gid" is out of range. ' + + 'It must be >= 0 && < 4294967296. Received -1' + }); + + assert.rejects( + async () => { + await handle.chown(1, -1); + }, + { + code: 'ERR_OUT_OF_RANGE', + name: 'RangeError [ERR_OUT_OF_RANGE]', + message: 'The value of "gid" is out of range. ' + + 'It must be >= 0 && < 4294967296. Received -1' + }); } - await handle.close(); + // set modification times + { + const handle = await getHandle(dest); - const newPath = path.resolve(tmpDir, 'baz2.js'); - await rename(dest, newPath); - stats = await stat(newPath); - verifyStatObject(stats); + await utimes(dest, new Date(), new Date()); - if (common.canCreateSymLink()) { - const newLink = path.resolve(tmpDir, 'baz3.js'); - await symlink(newPath, newLink); - if (!common.isWindows) { - await lchown(newLink, process.getuid(), process.getgid()); + try { + await handle.utimes(new Date(), new Date()); + } catch (err) { + // Some systems do not have futimes. If there is an error, + // expect it to be ENOSYS + common.expectsError({ + code: 'ENOSYS', + type: Error + })(err); } - stats = await lstat(newLink); - verifyStatObject(stats); - assert.strictEqual(newPath.toLowerCase(), - (await realpath(newLink)).toLowerCase()); - assert.strictEqual(newPath.toLowerCase(), - (await readlink(newLink)).toLowerCase()); + await handle.close(); + } + + // create symlink + { + const newPath = path.resolve(tmpDir, 'baz2.js'); + await rename(dest, newPath); + let stats = await stat(newPath); + verifyStatObject(stats); - const newMode = 0o666; - if (common.isOSX) { - // lchmod is only available on macOS - await lchmod(newLink, newMode); + if (common.canCreateSymLink()) { + const newLink = path.resolve(tmpDir, 'baz3.js'); + await symlink(newPath, newLink); + if (!common.isWindows) { + await lchown(newLink, process.getuid(), process.getgid()); + } stats = await lstat(newLink); - assert.strictEqual(stats.mode & 0o777, newMode); - } else { - await Promise.all([ - assert.rejects( - lchmod(newLink, newMode), - common.expectsError({ - code: 'ERR_METHOD_NOT_IMPLEMENTED', - type: Error, - message: 'The lchmod() method is not implemented' - }) - ) - ]); + verifyStatObject(stats); + + assert.strictEqual(newPath.toLowerCase(), + (await realpath(newLink)).toLowerCase()); + assert.strictEqual(newPath.toLowerCase(), + (await readlink(newLink)).toLowerCase()); + + const newMode = 0o666; + if (common.isOSX) { + // lchmod is only available on macOS + await lchmod(newLink, newMode); + stats = await lstat(newLink); + assert.strictEqual(stats.mode & 0o777, newMode); + } else { + await Promise.all([ + assert.rejects( + lchmod(newLink, newMode), + common.expectsError({ + code: 'ERR_METHOD_NOT_IMPLEMENTED', + type: Error, + message: 'The lchmod() method is not implemented' + }) + ) + ]); + } + + await unlink(newLink); } - - await unlink(newLink); } - const newLink2 = path.resolve(tmpDir, 'baz4.js'); - await link(newPath, newLink2); + // create hard link + { + const newPath = path.resolve(tmpDir, 'baz2.js'); + const newLink = path.resolve(tmpDir, 'baz4.js'); + await link(newPath, newLink); - await unlink(newLink2); + await unlink(newLink); + } // testing readdir lists both files and directories { @@ -231,7 +262,7 @@ async function getHandle(dest) { await mkdir(newDir); await writeFile(newFile, 'DAWGS WIN!', 'utf8'); - stats = await stat(newDir); + const stats = await stat(newDir); assert(stats.isDirectory()); const list = await readdir(tmpDir); assert.notStrictEqual(list.indexOf('dir'), -1); @@ -244,7 +275,7 @@ async function getHandle(dest) { { const dir = path.join(tmpDir, nextdir()); await mkdir(dir, 777); - stats = await stat(dir); + const stats = await stat(dir); assert(stats.isDirectory()); } @@ -252,7 +283,7 @@ async function getHandle(dest) { { const dir = path.join(tmpDir, nextdir()); await mkdir(dir, '777'); - stats = await stat(dir); + const stats = await stat(dir); assert(stats.isDirectory()); } @@ -260,7 +291,7 @@ async function getHandle(dest) { { const dir = path.join(tmpDir, nextdir(), nextdir()); await mkdir(dir, { recursive: true }); - stats = await stat(dir); + const stats = await stat(dir); assert(stats.isDirectory()); } @@ -283,7 +314,7 @@ async function getHandle(dest) { { const dir = path.resolve(tmpDir, `${nextdir()}/./${nextdir()}`); await mkdir(dir, { recursive: true }); - stats = await stat(dir); + const stats = await stat(dir); assert(stats.isDirectory()); } @@ -291,7 +322,7 @@ async function getHandle(dest) { { const dir = path.resolve(tmpDir, `${nextdir()}/../${nextdir()}`); await mkdir(dir, { recursive: true }); - stats = await stat(dir); + const stats = await stat(dir); assert(stats.isDirectory()); } @@ -313,15 +344,18 @@ async function getHandle(dest) { }); } - await mkdtemp(path.resolve(tmpDir, 'FOO')); - assert.rejects( - // mkdtemp() expects to get a string prefix. - async () => mkdtemp(1), - { - code: 'ERR_INVALID_ARG_TYPE', - name: 'TypeError [ERR_INVALID_ARG_TYPE]' - } - ); + // mkdtemp with invalid numeric prefix + { + await mkdtemp(path.resolve(tmpDir, 'FOO')); + assert.rejects( + // mkdtemp() expects to get a string prefix. + async () => mkdtemp(1), + { + code: 'ERR_INVALID_ARG_TYPE', + name: 'TypeError [ERR_INVALID_ARG_TYPE]' + } + ); + } } From da65cb61e5ff6950a05e5440e7776b73db19b50d Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 19 Oct 2018 11:07:50 -0700 Subject: [PATCH 245/328] doc: revise security-reporting example text Edit for simplicity and clarity. PR-URL: https://github.com/nodejs/node/pull/23759 Reviewed-By: Sam Roberts Reviewed-By: Matheus Marchini Reviewed-By: Vladimir de Turckheim Reviewed-By: Ben Noordhuis --- README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5c5848313acf77..540c0ed18c899c 100644 --- a/README.md +++ b/README.md @@ -175,17 +175,15 @@ nonetheless. ### Public disclosure preferred - [#14519](https://github.com/nodejs/node/issues/14519): _Internal domain - function can be used to cause segfaults_. Causing program termination using - either the public JavaScript APIs or the private bindings layer APIs requires - the ability to execute arbitrary JavaScript code, which is already the highest - level of privilege possible. + function can be used to cause segfaults_. Requires the ability to execute + arbitrary JavaScript code. That is already the highest level of privilege + possible. - [#12141](https://github.com/nodejs/node/pull/12141): _buffer: zero fill - Buffer(num) by default_. The buffer constructor behavior was documented, - but found to be prone to [mis-use](https://snyk.io/blog/exploiting-buffer/). - It has since been changed, but despite much debate, was not considered misuse - prone enough to justify fixing in older release lines and breaking our - API stability contract. + Buffer(num) by default_. The documented `Buffer()` behavior was prone to + [misuse](https://snyk.io/blog/exploiting-buffer/). It has since changed. It + was not deemed serious enough to fix in older releases and breaking API + stability. ### Private disclosure preferred From f8bd7c0f02368b0c24ca6667ba75cfc3b48e69d5 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Thu, 18 Oct 2018 18:02:13 -0700 Subject: [PATCH 246/328] doc: remove reference to sslv3 in tls.md PR-URL: https://github.com/nodejs/node/pull/23745 Fixes: https://github.com/nodejs/node/issues/9822 Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat --- doc/api/tls.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/api/tls.md b/doc/api/tls.md index 364ec07e1729c2..d6ead9060182c5 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -677,7 +677,6 @@ be returned for server sockets or disconnected client sockets. Example responses include: -* `SSLv3` * `TLSv1` * `TLSv1.1` * `TLSv1.2` From a5530159c1954c2a46ea9966d58a1c6742e2f5f5 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Fri, 19 Oct 2018 17:26:40 -0400 Subject: [PATCH 247/328] build: fix coverage generation Changes in command line options for nyc resulted in the coverage target no longer working. Pin the major version of nyc and update the options to get it working again. PR-URL: https://github.com/nodejs/node/pull/23769 Fixes: https://github.com/nodejs/node/issues/23690 Reviewed-By: James M Snell Reviewed-By: Refael Ackermann Reviewed-By: Joyee Cheung Reviewed-By: George Adams --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a98772faea6dca..eeb65c38e05eb6 100644 --- a/Makefile +++ b/Makefile @@ -203,7 +203,7 @@ coverage: coverage-test ## Run the tests and generate a coverage report. coverage-build: all mkdir -p node_modules if [ ! -d node_modules/nyc ]; then \ - $(NODE) ./deps/npm install nyc --no-save --no-package-lock; fi + $(NODE) ./deps/npm install nyc@13 --no-save --no-package-lock; fi if [ ! -d gcovr ]; then git clone -b 3.4 --depth=1 \ --single-branch git://github.com/gcovr/gcovr.git; fi if [ ! -d build ]; then git clone --depth=1 \ @@ -234,8 +234,9 @@ coverage-test: coverage-build $(NODE) ./node_modules/.bin/nyc merge 'out/Release/.coverage' \ .cov_tmp/libcov.json (cd lib && .$(NODE) ../node_modules/.bin/nyc report \ - --temp-directory "$(CURDIR)/.cov_tmp" \ - --report-dir "$(CURDIR)/coverage") + --temp-dir "$(CURDIR)/.cov_tmp" \ + --report-dir "$(CURDIR)/coverage" \ + --reporter html) -(cd out && "../gcovr/scripts/gcovr" --gcov-exclude='.*deps' \ --gcov-exclude='.*usr' -v -r Release/obj.target \ --html --html-detail -o ../coverage/cxxcoverage.html \ From 30bcddcaeb33d1254d71784c4d881df4bc139e34 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sun, 21 Oct 2018 23:29:45 +0300 Subject: [PATCH 248/328] doc: add missing YAML labels PR-URL: https://github.com/nodejs/node/pull/23810 Reviewed-By: Refael Ackermann Reviewed-By: James M Snell Reviewed-By: Richard Lau Reviewed-By: Yuta Hiroto Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca --- doc/api/cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index a99190c0b47170..06270219db01b0 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -156,7 +156,7 @@ and profile Node.js instances. The tools attach to Node.js instances via a tcp port and communicate using the [Chrome DevTools Protocol][]. ### `--loader=file` - From 4116788f76046bb2b22dd87f0928e662df87eafa Mon Sep 17 00:00:00 2001 From: Elian Gutierrez Date: Sat, 20 Oct 2018 11:12:46 -0400 Subject: [PATCH 249/328] test: fix assertion arguments order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23787 Reviewed-By: Denys Otrishko Reviewed-By: Michaël Zasso Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- test/parallel/test-http-remove-header-stays-removed.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http-remove-header-stays-removed.js b/test/parallel/test-http-remove-header-stays-removed.js index 6617a1775441b7..337fcd3becd177 100644 --- a/test/parallel/test-http-remove-header-stays-removed.js +++ b/test/parallel/test-http-remove-header-stays-removed.js @@ -44,13 +44,13 @@ const server = http.createServer(function(request, response) { let response = ''; process.on('exit', function() { - assert.strictEqual('beep boop\n', response); + assert.strictEqual(response, 'beep boop\n'); console.log('ok'); }); server.listen(0, function() { http.get({ port: this.address().port }, function(res) { - assert.strictEqual(200, res.statusCode); + assert.strictEqual(res.statusCode, 200); assert.deepStrictEqual(res.headers, { date: 'coffee o clock' }); res.setEncoding('ascii'); From d1c082729451c7ec5021250b91417855fb5a5ad1 Mon Sep 17 00:00:00 2001 From: Jose Bucio Date: Mon, 15 Oct 2018 23:13:18 -0500 Subject: [PATCH 250/328] repl: migrate from process.binding('config') to getOptions() PR-URL: https://github.com/nodejs/node/pull/23684 Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani --- lib/repl.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/repl.js b/lib/repl.js index 4ec7229e05b464..3d0020d82d8f18 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -71,7 +71,9 @@ const { ERR_SCRIPT_EXECUTION_INTERRUPTED } = require('internal/errors').codes; const { sendInspectorCommand } = require('internal/util/inspector'); -const { experimentalREPLAwait } = process.binding('config'); +const experimentalREPLAwait = internalBinding('options').getOptions( + '--experimental-repl-await' +); const { isRecoverableError } = require('internal/repl/recoverable'); const { getOwnNonIndexProperties, From cbc54d4f5db2f7808b6336cedb465da844949034 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Mon, 15 Oct 2018 15:15:26 -0700 Subject: [PATCH 251/328] crypto: strip unwanted space from openssl version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove trailing " \n" from `process.versions.openssl`. d3d6cd3ecad19 was incorrectly printing this trailer, but because the target buffer size was claimed to be the length of the version string, the trailer was truncated off. 9ed4646df05b9 corrected the target buffer size, but then the trailer started to appear in process.versions. Added a test to check for regressions. PR-URL: https://github.com/nodejs/node/pull/23678 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Refael Ackermann Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Tobias Nießen Reviewed-By: Ben Noordhuis Reviewed-By: Tiancheng "Timothy" Gu --- src/node_crypto.cc | 4 ++-- test/parallel/test-process-versions.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 7d9294d65a53b6..97a2956b2ee631 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -5733,9 +5733,9 @@ std::string GetOpenSSLVersion() { // for reference: "OpenSSL 1.1.0i 14 Aug 2018" char buf[128]; const int start = search(OPENSSL_VERSION_TEXT, 0, ' ') + 1; - const int end = search(OPENSSL_VERSION_TEXT + start, start, ' ') + 1; + const int end = search(OPENSSL_VERSION_TEXT + start, start, ' '); const int len = end - start; - snprintf(buf, sizeof(buf), "%.*s\n", len, &OPENSSL_VERSION_TEXT[start]); + snprintf(buf, sizeof(buf), "%.*s", len, &OPENSSL_VERSION_TEXT[start]); return std::string(buf); } diff --git a/test/parallel/test-process-versions.js b/test/parallel/test-process-versions.js index 8f706c6954cd2c..9a211286770586 100644 --- a/test/parallel/test-process-versions.js +++ b/test/parallel/test-process-versions.js @@ -33,6 +33,10 @@ assert(/^\d+\.\d+\.\d+(?:\.\d+)?-node\.\d+(?: \(candidate\))?$/ .test(process.versions.v8)); assert(/^\d+$/.test(process.versions.modules)); +if (common.hasCrypto) { + assert(/^\d+\.\d+\.\d+[a-z]?$/.test(process.versions.openssl)); +} + for (let i = 0; i < expected_keys.length; i++) { const key = expected_keys[i]; const descriptor = Object.getOwnPropertyDescriptor(process.versions, key); From 6ee9273e9e0a3156413e2c0b5ab77002ef971c30 Mon Sep 17 00:00:00 2001 From: Thomas GENTILHOMME Date: Fri, 19 Oct 2018 23:18:30 +0200 Subject: [PATCH 252/328] test: fix strictEqual() arguments order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23771 Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig --- test/parallel/test-http-parser-bad-ref.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http-parser-bad-ref.js b/test/parallel/test-http-parser-bad-ref.js index 5ecb715529e3e6..712e8f8c863d4b 100644 --- a/test/parallel/test-http-parser-bad-ref.js +++ b/test/parallel/test-http-parser-bad-ref.js @@ -81,7 +81,7 @@ demoBug('POST /1/22 HTTP/1.1\r\n' + 'pong'); process.on('exit', function() { - assert.strictEqual(2, headersComplete); - assert.strictEqual(2, messagesComplete); + assert.strictEqual(headersComplete, 2); + assert.strictEqual(messagesComplete, 2); console.log('done!'); }); From fd12699f7d98da09a07605bf63c0e0bfd8e0dd6c Mon Sep 17 00:00:00 2001 From: Romain Lanz Date: Fri, 19 Oct 2018 23:23:44 +0200 Subject: [PATCH 253/328] test: fix strictEqual() argument order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23768 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Michaël Zasso --- test/parallel/test-http-write-empty-string.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http-write-empty-string.js b/test/parallel/test-http-write-empty-string.js index 35a7aca61b4030..d4ab070667ef6d 100644 --- a/test/parallel/test-http-write-empty-string.js +++ b/test/parallel/test-http-write-empty-string.js @@ -42,13 +42,13 @@ server.listen(0, common.mustCall(function() { http.get({ port: this.address().port }, common.mustCall(function(res) { let response = ''; - assert.strictEqual(200, res.statusCode); + assert.strictEqual(res.statusCode, 200); res.setEncoding('ascii'); res.on('data', function(chunk) { response += chunk; }); res.on('end', common.mustCall(function() { - assert.strictEqual('1\n2\n3\n', response); + assert.strictEqual(response, '1\n2\n3\n'); })); })); })); From cdf89339e4b96526564b3d2ef8ffb4386d8e88e7 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Tue, 16 Oct 2018 15:54:02 +0200 Subject: [PATCH 254/328] test: fix test-require-symlink on Windows Creating directory symlinks on Windows require 'dir' parameter to be provided. Fixes: https://github.com/nodejs/node/issues/23596 PR-URL: https://github.com/nodejs/node/pull/23691 Reviewed-By: Colin Ihrig Reviewed-By: Refael Ackermann Reviewed-By: James M Snell --- test/parallel/test-require-symlink.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-require-symlink.js b/test/parallel/test-require-symlink.js index 7aad3ee0a7e7e9..c73fdcd41e6efa 100644 --- a/test/parallel/test-require-symlink.js +++ b/test/parallel/test-require-symlink.js @@ -60,7 +60,7 @@ const linkScriptTarget = path.join(dirName, 'symlinked.js'); test(); function test() { - fs.symlinkSync(linkTarget, linkDir); + fs.symlinkSync(linkTarget, linkDir, 'dir'); fs.symlinkSync(linkScriptTarget, linkScript); // load symlinked-module From 64f9a3c1387fecd266c333aa5b85581ce8d7b127 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Thu, 18 Oct 2018 18:12:59 -0700 Subject: [PATCH 255/328] doc: document that addMembership must be called once in a cluster Fixes: https://github.com/nodejs/node/issues/12572 Refs: https://github.com/nodejs/node/pull/16240 PR-URL: https://github.com/nodejs/node/pull/23746 Reviewed-By: Refael Ackermann Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat --- doc/api/dgram.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/api/dgram.md b/doc/api/dgram.md index fd99401868d54e..6541959d3adc27 100644 --- a/doc/api/dgram.md +++ b/doc/api/dgram.md @@ -95,6 +95,24 @@ Tells the kernel to join a multicast group at the given `multicastAddress` and one interface and will add membership to it. To add membership to every available interface, call `addMembership` multiple times, once per interface. +When sharing a UDP socket across multiple `cluster` workers, the +`socket.addMembership()` function must be called only once or an +`EADDRINUSE` error will occur: + +```js +const cluster = require('cluster'); +const dgram = require('dgram'); +if (cluster.isMaster) { + cluster.fork(); // Works ok. + cluster.fork(); // Fails with EADDRINUSE. +} else { + const s = dgram.createSocket('udp4'); + s.bind(1234, () => { + s.addMembership('224.0.0.114'); + }); +} +``` + ### socket.address() * `data` {string|Buffer|Uint8Array} * `encoding` {string} Only used when data is `string`. **Default:** `'utf8'`. +* `callback` {Function} Optional callback for when the socket is finished. * Returns: {net.Socket} The socket itself. Half-closes the socket. i.e., it sends a FIN packet. It is possible the @@ -1168,7 +1169,7 @@ Returns `true` if input is a version 6 IP address, otherwise returns `false`. [`socket.connect(path)`]: #net_socket_connect_path_connectlistener [`socket.connect(port, host)`]: #net_socket_connect_port_host_connectlistener [`socket.destroy()`]: #net_socket_destroy_exception -[`socket.end()`]: #net_socket_end_data_encoding +[`socket.end()`]: #net_socket_end_data_encoding_callback [`socket.pause()`]: #net_socket_pause [`socket.resume()`]: #net_socket_resume [`socket.setEncoding()`]: #net_socket_setencoding_encoding From 3249a57f2b08aff22a890fef6e72a62addf1dec4 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 26 Oct 2018 12:35:42 -0400 Subject: [PATCH 290/328] tools: update ESLint to 5.8.0 Update ESLint to 5.8.0. PR-URL: https://github.com/nodejs/node/pull/23904 Reviewed-By: Rich Trott Reviewed-By: Trivikram Kamat Reviewed-By: Daniel Bevenius --- tools/node_modules/eslint/lib/linter.js | 9 + .../lib/rules/no-irregular-whitespace.js | 12 +- .../eslint/lib/rules/prefer-const.js | 67 +- .../eslint/lib/testers/rule-tester.js | 4 +- .../eslint/node_modules/acorn-jsx/README.md | 32 +- .../eslint/node_modules/acorn-jsx/index.js | 432 ++++- .../eslint/node_modules/acorn-jsx/inject.js | 449 ------ .../node_modules/acorn-jsx/package.json | 11 +- .../eslint/node_modules/acorn/AUTHORS | 79 - .../eslint/node_modules/acorn/README.md | 302 +--- .../eslint/node_modules/acorn/bin/acorn | 2 +- .../node_modules/acorn/bin/run_test262.js | 21 - .../node_modules/acorn/bin/test262.whitelist | 404 ----- .../eslint/node_modules/acorn/dist/.keep | 0 .../eslint/node_modules/acorn/dist/acorn.d.ts | 208 +++ .../eslint/node_modules/acorn/dist/acorn.js | 433 +++-- .../node_modules/acorn/dist/acorn.js.map | 1 + .../acorn/dist/{acorn.es.js => acorn.mjs} | 435 +++-- .../node_modules/acorn/dist/acorn.mjs.map | 1 + .../node_modules/acorn/dist/acorn_loose.es.js | 1424 ---------------- .../node_modules/acorn/dist/acorn_loose.js | 1434 ----------------- .../acorn/{bin/_acorn.js => dist/bin.js} | 3 +- .../eslint/node_modules/acorn/dist/walk.es.js | 423 ----- .../eslint/node_modules/acorn/dist/walk.js | 443 ----- .../eslint/node_modules/acorn/package.json | 270 +--- .../eslint/node_modules/espree/README.md | 4 +- .../eslint/node_modules/espree/espree.js | 565 +------ .../eslint/node_modules/espree/lib/espree.js | 314 ++++ .../node_modules/espree/lib/visitor-keys.js | 123 -- .../eslint/node_modules/espree/package.json | 22 +- .../progress/lib/node-progress.js | 22 +- .../eslint/node_modules/progress/package.json | 6 +- tools/node_modules/eslint/package.json | 14 +- 33 files changed, 1583 insertions(+), 6386 deletions(-) delete mode 100644 tools/node_modules/eslint/node_modules/acorn-jsx/inject.js delete mode 100644 tools/node_modules/eslint/node_modules/acorn/AUTHORS delete mode 100644 tools/node_modules/eslint/node_modules/acorn/bin/run_test262.js delete mode 100644 tools/node_modules/eslint/node_modules/acorn/bin/test262.whitelist delete mode 100644 tools/node_modules/eslint/node_modules/acorn/dist/.keep create mode 100644 tools/node_modules/eslint/node_modules/acorn/dist/acorn.d.ts create mode 100644 tools/node_modules/eslint/node_modules/acorn/dist/acorn.js.map rename tools/node_modules/eslint/node_modules/acorn/dist/{acorn.es.js => acorn.mjs} (94%) create mode 100644 tools/node_modules/eslint/node_modules/acorn/dist/acorn.mjs.map delete mode 100644 tools/node_modules/eslint/node_modules/acorn/dist/acorn_loose.es.js delete mode 100644 tools/node_modules/eslint/node_modules/acorn/dist/acorn_loose.js rename tools/node_modules/eslint/node_modules/acorn/{bin/_acorn.js => dist/bin.js} (97%) delete mode 100644 tools/node_modules/eslint/node_modules/acorn/dist/walk.es.js delete mode 100644 tools/node_modules/eslint/node_modules/acorn/dist/walk.js create mode 100644 tools/node_modules/eslint/node_modules/espree/lib/espree.js delete mode 100644 tools/node_modules/eslint/node_modules/espree/lib/visitor-keys.js diff --git a/tools/node_modules/eslint/lib/linter.js b/tools/node_modules/eslint/lib/linter.js index 8f7bdf9e4c79c3..b47e6eb1fcfb6a 100644 --- a/tools/node_modules/eslint/lib/linter.js +++ b/tools/node_modules/eslint/lib/linter.js @@ -888,6 +888,15 @@ module.exports = class Linter { this.environments = new Environments(); } + /** + * Getter for package version. + * @static + * @returns {string} The version from package.json. + */ + static get version() { + return pkg.version; + } + /** * Configuration object for the `verify` API. A JS representation of the eslintrc files. * @typedef {Object} ESLintConfig diff --git a/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js b/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js index 729f829a1f71ea..de6934c635ac33 100644 --- a/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js +++ b/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js @@ -81,9 +81,7 @@ module.exports = { const locStart = node.loc.start; const locEnd = node.loc.end; - errors = errors.filter(error => { - const errorLoc = error[1]; - + errors = errors.filter(({ loc: errorLoc }) => { if (errorLoc.line >= locStart.line && errorLoc.line <= locEnd.line) { if (errorLoc.column >= locStart.column && (errorLoc.column <= locEnd.column || errorLoc.line < locEnd.line)) { return false; @@ -157,7 +155,7 @@ module.exports = { column: match.index }; - errors.push([node, location, "Irregular whitespace not allowed."]); + errors.push({ node, message: "Irregular whitespace not allowed.", loc: location }); } }); } @@ -182,7 +180,7 @@ module.exports = { column: sourceLines[lineIndex].length }; - errors.push([node, location, "Irregular whitespace not allowed."]); + errors.push({ node, message: "Irregular whitespace not allowed.", loc: location }); lastLineIndex = lineIndex; } } @@ -224,9 +222,7 @@ module.exports = { } // If we have any errors remaining report on them - errors.forEach(error => { - context.report(...error); - }); + errors.forEach(error => context.report(error)); }; } else { nodes.Program = noop; diff --git a/tools/node_modules/eslint/lib/rules/prefer-const.js b/tools/node_modules/eslint/lib/rules/prefer-const.js index 774fcf06437626..8b3bc5e0e436d3 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-const.js +++ b/tools/node_modules/eslint/lib/rules/prefer-const.js @@ -57,6 +57,7 @@ function canBecomeVariableDeclaration(identifier) { * @returns {boolean} Indicates if the variable is from outer scope or function parameters. */ function isOuterVariableInDestructing(name, initScope) { + if (initScope.through.find(ref => ref.resolved && ref.resolved.name === name)) { return true; } @@ -96,6 +97,54 @@ function getDestructuringHost(reference) { return node; } +/** + * Determines if a destructuring assignment node contains + * any MemberExpression nodes. This is used to determine if a + * variable that is only written once using destructuring can be + * safely converted into a const declaration. + * @param {ASTNode} node The ObjectPattern or ArrayPattern node to check. + * @returns {boolean} True if the destructuring pattern contains + * a MemberExpression, false if not. + */ +function hasMemberExpressionAssignment(node) { + switch (node.type) { + case "ObjectPattern": + return node.properties.some(prop => { + if (prop) { + + /* + * Spread elements have an argument property while + * others have a value property. Because different + * parsers use different node types for spread elements, + * we just check if there is an argument property. + */ + return hasMemberExpressionAssignment(prop.argument || prop.value); + } + + return false; + }); + + case "ArrayPattern": + return node.elements.some(element => { + if (element) { + return hasMemberExpressionAssignment(element); + } + + return false; + }); + + case "AssignmentPattern": + return hasMemberExpressionAssignment(node.left); + + case "MemberExpression": + return true; + + // no default + } + + return false; +} + /** * Gets an identifier node of a given variable. * @@ -148,7 +197,8 @@ function getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign) { if (destructuringHost !== null && destructuringHost.left !== void 0) { const leftNode = destructuringHost.left; - let hasOuterVariables = false; + let hasOuterVariables = false, + hasNonIdentifiers = false; if (leftNode.type === "ObjectPattern") { const properties = leftNode.properties; @@ -157,16 +207,23 @@ function getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign) { .filter(prop => prop.value) .map(prop => prop.value.name) .some(name => isOuterVariableInDestructing(name, variable.scope)); + + hasNonIdentifiers = hasMemberExpressionAssignment(leftNode); + } else if (leftNode.type === "ArrayPattern") { const elements = leftNode.elements; hasOuterVariables = elements .map(element => element && element.name) .some(name => isOuterVariableInDestructing(name, variable.scope)); + + hasNonIdentifiers = hasMemberExpressionAssignment(leftNode); } - if (hasOuterVariables) { + + if (hasOuterVariables || hasNonIdentifiers) { return null; } + } writer = reference; @@ -192,9 +249,11 @@ function getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign) { if (!shouldBeConst) { return null; } + if (isReadBeforeInit) { return variable.defs[0].name; } + return writer.identifier; } @@ -295,7 +354,7 @@ module.exports = { create(context) { const options = context.options[0] || {}; const sourceCode = context.getSourceCode(); - const checkingMixedDestructuring = options.destructuring !== "all"; + const shouldMatchAnyDestructuredVariable = options.destructuring !== "all"; const ignoreReadBeforeAssign = options.ignoreReadBeforeAssign === true; const variables = []; @@ -316,7 +375,7 @@ module.exports = { function checkGroup(nodes) { const nodesToReport = nodes.filter(Boolean); - if (nodes.length && (checkingMixedDestructuring || nodesToReport.length === nodes.length)) { + if (nodes.length && (shouldMatchAnyDestructuredVariable || nodesToReport.length === nodes.length)) { const varDeclParent = findUp(nodes[0], "VariableDeclaration", parentNode => parentNode.type.endsWith("Statement")); const shouldFix = varDeclParent && diff --git a/tools/node_modules/eslint/lib/testers/rule-tester.js b/tools/node_modules/eslint/lib/testers/rule-tester.js index 9fbca945b62ee4..6d1bba989fdeea 100644 --- a/tools/node_modules/eslint/lib/testers/rule-tester.js +++ b/tools/node_modules/eslint/lib/testers/rule-tester.js @@ -397,7 +397,7 @@ class RuleTester { */ function assertASTDidntChange(beforeAST, afterAST) { if (!lodash.isEqual(beforeAST, afterAST)) { - assert.fail(null, null, "Rule should not modify AST."); + assert.fail("Rule should not modify AST."); } } @@ -551,7 +551,7 @@ class RuleTester { } else { // Message was an unexpected type - assert.fail(message, null, "Error should be a string, object, or RegExp."); + assert.fail(`Error should be a string, object, or RegExp, but found (${util.inspect(message)})`); } } } diff --git a/tools/node_modules/eslint/node_modules/acorn-jsx/README.md b/tools/node_modules/eslint/node_modules/acorn-jsx/README.md index cd9674c0b38b03..2bbb1d99fd8cfa 100644 --- a/tools/node_modules/eslint/node_modules/acorn-jsx/README.md +++ b/tools/node_modules/eslint/node_modules/acorn-jsx/README.md @@ -17,44 +17,24 @@ Please note that this tool only parses source code to JSX AST, which is useful f ## Usage -You can use module directly in order to get Acorn instance with plugin installed: +Requiring this module provides you with an Acorn plugin that you can use like this: ```javascript -var acorn = require('acorn-jsx'); -``` - -Or you can use `inject.js` for injecting plugin into your own version of Acorn like following: - -```javascript -var acorn = require('acorn-jsx/inject')(require('./custom-acorn')); -``` - -Then, use `plugins` option whenever you need to support JSX while parsing: - -```javascript -var ast = acorn.parse(code, { - plugins: { jsx: true } -}); +var acorn = require("acorn"); +var jsx = require("acorn-jsx"); +acorn.Parser.extend(jsx()).parse("my(, 'code');"); ``` Note that official spec doesn't support mix of XML namespaces and object-style access in tag names (#27) like in ``, so it was deprecated in `acorn-jsx@3.0`. If you still want to opt-in to support of such constructions, you can pass the following option: ```javascript -var ast = acorn.parse(code, { - plugins: { - jsx: { allowNamespacedObjects: true } - } -}); +acorn.Parser.extend(jsx({ allowNamespacedObjects: true })) ``` Also, since most apps use pure React transformer, a new option was introduced that allows to prohibit namespaces completely: ```javascript -var ast = acorn.parse(code, { - plugins: { - jsx: { allowNamespaces: false } - } -}); +acorn.Parser.extend(jsx({ allowNamespaces: false })) ``` Note that by default `allowNamespaces` is enabled for spec compliancy. diff --git a/tools/node_modules/eslint/node_modules/acorn-jsx/index.js b/tools/node_modules/eslint/node_modules/acorn-jsx/index.js index 58c8677740ce26..292315f65bfc90 100644 --- a/tools/node_modules/eslint/node_modules/acorn-jsx/index.js +++ b/tools/node_modules/eslint/node_modules/acorn-jsx/index.js @@ -1,3 +1,431 @@ -'use strict'; +const XHTMLEntities = require('./xhtml'); -module.exports = require('./inject')(require('acorn')); +const hexNumber = /^[\da-fA-F]+$/; +const decimalNumber = /^\d+$/; + +const {tokTypes: tt, TokContext, tokContexts, TokenType, isNewLine, isIdentifierStart, isIdentifierChar} = require("acorn"); + +const tc_oTag = new TokContext('...', true, true); + +const tok = { + jsxName: new TokenType('jsxName'), + jsxText: new TokenType('jsxText', {beforeExpr: true}), + jsxTagStart: new TokenType('jsxTagStart'), + jsxTagEnd: new TokenType('jsxTagEnd') +} + +tok.jsxTagStart.updateContext = function() { + this.context.push(tc_expr); // treat as beginning of JSX expression + this.context.push(tc_oTag); // start opening tag context + this.exprAllowed = false; +}; +tok.jsxTagEnd.updateContext = function(prevType) { + let out = this.context.pop(); + if (out === tc_oTag && prevType === tt.slash || out === tc_cTag) { + this.context.pop(); + this.exprAllowed = this.curContext() === tc_expr; + } else { + this.exprAllowed = true; + } +}; + +// Transforms JSX element name to string. + +function getQualifiedJSXName(object) { + if (!object) + return object; + + if (object.type === 'JSXIdentifier') + return object.name; + + if (object.type === 'JSXNamespacedName') + return object.namespace.name + ':' + object.name.name; + + if (object.type === 'JSXMemberExpression') + return getQualifiedJSXName(object.object) + '.' + + getQualifiedJSXName(object.property); +} + +module.exports = function(options = {}) { + return function(Parser) { + return plugin({ + allowNamespaces: options.allowNamespaces !== false, + allowNamespacedObjects: !!options.allowNamespacedObjects + }, Parser); + } +} +module.exports.tokTypes = tok + +function plugin(options, Parser) { + return class extends Parser { + // Reads inline JSX contents token. + jsx_readToken() { + let out = '', chunkStart = this.pos; + for (;;) { + if (this.pos >= this.input.length) + this.raise(this.start, 'Unterminated JSX contents'); + let ch = this.input.charCodeAt(this.pos); + + switch (ch) { + case 60: // '<' + case 123: // '{' + if (this.pos === this.start) { + if (ch === 60 && this.exprAllowed) { + ++this.pos; + return this.finishToken(tok.jsxTagStart); + } + return this.getTokenFromCode(ch); + } + out += this.input.slice(chunkStart, this.pos); + return this.finishToken(tok.jsxText, out); + + case 38: // '&' + out += this.input.slice(chunkStart, this.pos); + out += this.jsx_readEntity(); + chunkStart = this.pos; + break; + + default: + if (isNewLine(ch)) { + out += this.input.slice(chunkStart, this.pos); + out += this.jsx_readNewLine(true); + chunkStart = this.pos; + } else { + ++this.pos; + } + } + } + } + + jsx_readNewLine(normalizeCRLF) { + let ch = this.input.charCodeAt(this.pos); + let out; + ++this.pos; + if (ch === 13 && this.input.charCodeAt(this.pos) === 10) { + ++this.pos; + out = normalizeCRLF ? '\n' : '\r\n'; + } else { + out = String.fromCharCode(ch); + } + if (this.options.locations) { + ++this.curLine; + this.lineStart = this.pos; + } + + return out; + }; + + jsx_readString(quote) { + let out = '', chunkStart = ++this.pos; + for (;;) { + if (this.pos >= this.input.length) + this.raise(this.start, 'Unterminated string constant'); + let ch = this.input.charCodeAt(this.pos); + if (ch === quote) break; + if (ch === 38) { // '&' + out += this.input.slice(chunkStart, this.pos); + out += this.jsx_readEntity(); + chunkStart = this.pos; + } else if (isNewLine(ch)) { + out += this.input.slice(chunkStart, this.pos); + out += this.jsx_readNewLine(false); + chunkStart = this.pos; + } else { + ++this.pos; + } + } + out += this.input.slice(chunkStart, this.pos++); + return this.finishToken(tt.string, out); + } + + jsx_readEntity() { + let str = '', count = 0, entity; + let ch = this.input[this.pos]; + if (ch !== '&') + this.raise(this.pos, 'Entity must start with an ampersand'); + let startPos = ++this.pos; + while (this.pos < this.input.length && count++ < 10) { + ch = this.input[this.pos++]; + if (ch === ';') { + if (str[0] === '#') { + if (str[1] === 'x') { + str = str.substr(2); + if (hexNumber.test(str)) + entity = String.fromCharCode(parseInt(str, 16)); + } else { + str = str.substr(1); + if (decimalNumber.test(str)) + entity = String.fromCharCode(parseInt(str, 10)); + } + } else { + entity = XHTMLEntities[str]; + } + break; + } + str += ch; + } + if (!entity) { + this.pos = startPos; + return '&'; + } + return entity; + } + + // Read a JSX identifier (valid tag or attribute name). + // + // Optimized version since JSX identifiers can't contain + // escape characters and so can be read as single slice. + // Also assumes that first character was already checked + // by isIdentifierStart in readToken. + + jsx_readWord() { + let ch, start = this.pos; + do { + ch = this.input.charCodeAt(++this.pos); + } while (isIdentifierChar(ch) || ch === 45); // '-' + return this.finishToken(tok.jsxName, this.input.slice(start, this.pos)); + } + + // Parse next token as JSX identifier + + jsx_parseIdentifier() { + let node = this.startNode(); + if (this.type === tok.jsxName) + node.name = this.value; + else if (this.type.keyword) + node.name = this.type.keyword; + else + this.unexpected(); + this.next(); + return this.finishNode(node, 'JSXIdentifier'); + } + + // Parse namespaced identifier. + + jsx_parseNamespacedName() { + let startPos = this.start, startLoc = this.startLoc; + let name = this.jsx_parseIdentifier(); + if (!options.allowNamespaces || !this.eat(tt.colon)) return name; + var node = this.startNodeAt(startPos, startLoc); + node.namespace = name; + node.name = this.jsx_parseIdentifier(); + return this.finishNode(node, 'JSXNamespacedName'); + } + + // Parses element name in any form - namespaced, member + // or single identifier. + + jsx_parseElementName() { + if (this.type === tok.jsxTagEnd) return ''; + let startPos = this.start, startLoc = this.startLoc; + let node = this.jsx_parseNamespacedName(); + if (this.type === tt.dot && node.type === 'JSXNamespacedName' && !options.allowNamespacedObjects) { + this.unexpected(); + } + while (this.eat(tt.dot)) { + let newNode = this.startNodeAt(startPos, startLoc); + newNode.object = node; + newNode.property = this.jsx_parseIdentifier(); + node = this.finishNode(newNode, 'JSXMemberExpression'); + } + return node; + } + + // Parses any type of JSX attribute value. + + jsx_parseAttributeValue() { + switch (this.type) { + case tt.braceL: + let node = this.jsx_parseExpressionContainer(); + if (node.expression.type === 'JSXEmptyExpression') + this.raise(node.start, 'JSX attributes must only be assigned a non-empty expression'); + return node; + + case tok.jsxTagStart: + case tt.string: + return this.parseExprAtom(); + + default: + this.raise(this.start, 'JSX value should be either an expression or a quoted JSX text'); + } + } + + // JSXEmptyExpression is unique type since it doesn't actually parse anything, + // and so it should start at the end of last read token (left brace) and finish + // at the beginning of the next one (right brace). + + jsx_parseEmptyExpression() { + let node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc); + return this.finishNodeAt(node, 'JSXEmptyExpression', this.start, this.startLoc); + } + + // Parses JSX expression enclosed into curly brackets. + + jsx_parseExpressionContainer() { + let node = this.startNode(); + this.next(); + node.expression = this.type === tt.braceR + ? this.jsx_parseEmptyExpression() + : this.parseExpression(); + this.expect(tt.braceR); + return this.finishNode(node, 'JSXExpressionContainer'); + } + + // Parses following JSX attribute name-value pair. + + jsx_parseAttribute() { + let node = this.startNode(); + if (this.eat(tt.braceL)) { + this.expect(tt.ellipsis); + node.argument = this.parseMaybeAssign(); + this.expect(tt.braceR); + return this.finishNode(node, 'JSXSpreadAttribute'); + } + node.name = this.jsx_parseNamespacedName(); + node.value = this.eat(tt.eq) ? this.jsx_parseAttributeValue() : null; + return this.finishNode(node, 'JSXAttribute'); + } + + // Parses JSX opening tag starting after '<'. + + jsx_parseOpeningElementAt(startPos, startLoc) { + let node = this.startNodeAt(startPos, startLoc); + node.attributes = []; + let nodeName = this.jsx_parseElementName(); + if (nodeName) node.name = nodeName; + while (this.type !== tt.slash && this.type !== tok.jsxTagEnd) + node.attributes.push(this.jsx_parseAttribute()); + node.selfClosing = this.eat(tt.slash); + this.expect(tok.jsxTagEnd); + return this.finishNode(node, nodeName ? 'JSXOpeningElement' : 'JSXOpeningFragment'); + } + + // Parses JSX closing tag starting after ''); + } + } + let fragmentOrElement = openingElement.name ? 'Element' : 'Fragment'; + + node['opening' + fragmentOrElement] = openingElement; + node['closing' + fragmentOrElement] = closingElement; + node.children = children; + if (this.type === tt.relational && this.value === "<") { + this.raise(this.start, "Adjacent JSX elements must be wrapped in an enclosing tag"); + } + return this.finishNode(node, 'JSX' + fragmentOrElement); + } + + // Parse JSX text + + jsx_parseText(value) { + let node = this.parseLiteral(value); + node.type = "JSXText"; + return node; + } + + // Parses entire JSX element from current position. + + jsx_parseElement() { + let startPos = this.start, startLoc = this.startLoc; + this.next(); + return this.jsx_parseElementAt(startPos, startLoc); + } + + parseExprAtom(refShortHandDefaultPos) { + if (this.type === tok.jsxText) + return this.jsx_parseText(this.value); + else if (this.type === tok.jsxTagStart) + return this.jsx_parseElement(); + else + return super.parseExprAtom(refShortHandDefaultPos); + } + + readToken(code) { + let context = this.curContext(); + + if (context === tc_expr) return this.jsx_readToken(); + + if (context === tc_oTag || context === tc_cTag) { + if (isIdentifierStart(code)) return this.jsx_readWord(); + + if (code == 62) { + ++this.pos; + return this.finishToken(tok.jsxTagEnd); + } + + if ((code === 34 || code === 39) && context == tc_oTag) + return this.jsx_readString(code); + } + + if (code === 60 && this.exprAllowed && this.input.charCodeAt(this.pos + 1) !== 33) { + ++this.pos; + return this.finishToken(tok.jsxTagStart); + } + return super.readToken(code) + } + + updateContext(prevType) { + if (this.type == tt.braceL) { + var curContext = this.curContext(); + if (curContext == tc_oTag) this.context.push(tokContexts.b_expr); + else if (curContext == tc_expr) this.context.push(tokContexts.b_tmpl); + else super.updateContext(prevType) + this.exprAllowed = true; + } else if (this.type === tt.slash && prevType === tok.jsxTagStart) { + this.context.length -= 2; // do not consider JSX expr -> JSX open tag -> ... anymore + this.context.push(tc_cTag); // reconsider as closing tag context + this.exprAllowed = false; + } else { + return super.updateContext(prevType); + } + } + }; +}; diff --git a/tools/node_modules/eslint/node_modules/acorn-jsx/inject.js b/tools/node_modules/eslint/node_modules/acorn-jsx/inject.js deleted file mode 100644 index 33806c72ce0a1c..00000000000000 --- a/tools/node_modules/eslint/node_modules/acorn-jsx/inject.js +++ /dev/null @@ -1,449 +0,0 @@ -'use strict'; - -var XHTMLEntities = require('./xhtml'); - -var hexNumber = /^[\da-fA-F]+$/; -var decimalNumber = /^\d+$/; - -module.exports = function(acorn) { - var tt = acorn.tokTypes; - var tc = acorn.tokContexts; - - tc.j_oTag = new acorn.TokContext('...', true, true); - - tt.jsxName = new acorn.TokenType('jsxName'); - tt.jsxText = new acorn.TokenType('jsxText', {beforeExpr: true}); - tt.jsxTagStart = new acorn.TokenType('jsxTagStart'); - tt.jsxTagEnd = new acorn.TokenType('jsxTagEnd'); - - tt.jsxTagStart.updateContext = function() { - this.context.push(tc.j_expr); // treat as beginning of JSX expression - this.context.push(tc.j_oTag); // start opening tag context - this.exprAllowed = false; - }; - tt.jsxTagEnd.updateContext = function(prevType) { - var out = this.context.pop(); - if (out === tc.j_oTag && prevType === tt.slash || out === tc.j_cTag) { - this.context.pop(); - this.exprAllowed = this.curContext() === tc.j_expr; - } else { - this.exprAllowed = true; - } - }; - - var pp = acorn.Parser.prototype; - - // Reads inline JSX contents token. - - pp.jsx_readToken = function() { - var out = '', chunkStart = this.pos; - for (;;) { - if (this.pos >= this.input.length) - this.raise(this.start, 'Unterminated JSX contents'); - var ch = this.input.charCodeAt(this.pos); - - switch (ch) { - case 60: // '<' - case 123: // '{' - if (this.pos === this.start) { - if (ch === 60 && this.exprAllowed) { - ++this.pos; - return this.finishToken(tt.jsxTagStart); - } - return this.getTokenFromCode(ch); - } - out += this.input.slice(chunkStart, this.pos); - return this.finishToken(tt.jsxText, out); - - case 38: // '&' - out += this.input.slice(chunkStart, this.pos); - out += this.jsx_readEntity(); - chunkStart = this.pos; - break; - - default: - if (acorn.isNewLine(ch)) { - out += this.input.slice(chunkStart, this.pos); - out += this.jsx_readNewLine(true); - chunkStart = this.pos; - } else { - ++this.pos; - } - } - } - }; - - pp.jsx_readNewLine = function(normalizeCRLF) { - var ch = this.input.charCodeAt(this.pos); - var out; - ++this.pos; - if (ch === 13 && this.input.charCodeAt(this.pos) === 10) { - ++this.pos; - out = normalizeCRLF ? '\n' : '\r\n'; - } else { - out = String.fromCharCode(ch); - } - if (this.options.locations) { - ++this.curLine; - this.lineStart = this.pos; - } - - return out; - }; - - pp.jsx_readString = function(quote) { - var out = '', chunkStart = ++this.pos; - for (;;) { - if (this.pos >= this.input.length) - this.raise(this.start, 'Unterminated string constant'); - var ch = this.input.charCodeAt(this.pos); - if (ch === quote) break; - if (ch === 38) { // '&' - out += this.input.slice(chunkStart, this.pos); - out += this.jsx_readEntity(); - chunkStart = this.pos; - } else if (acorn.isNewLine(ch)) { - out += this.input.slice(chunkStart, this.pos); - out += this.jsx_readNewLine(false); - chunkStart = this.pos; - } else { - ++this.pos; - } - } - out += this.input.slice(chunkStart, this.pos++); - return this.finishToken(tt.string, out); - }; - - pp.jsx_readEntity = function() { - var str = '', count = 0, entity; - var ch = this.input[this.pos]; - if (ch !== '&') - this.raise(this.pos, 'Entity must start with an ampersand'); - var startPos = ++this.pos; - while (this.pos < this.input.length && count++ < 10) { - ch = this.input[this.pos++]; - if (ch === ';') { - if (str[0] === '#') { - if (str[1] === 'x') { - str = str.substr(2); - if (hexNumber.test(str)) - entity = String.fromCharCode(parseInt(str, 16)); - } else { - str = str.substr(1); - if (decimalNumber.test(str)) - entity = String.fromCharCode(parseInt(str, 10)); - } - } else { - entity = XHTMLEntities[str]; - } - break; - } - str += ch; - } - if (!entity) { - this.pos = startPos; - return '&'; - } - return entity; - }; - - - // Read a JSX identifier (valid tag or attribute name). - // - // Optimized version since JSX identifiers can't contain - // escape characters and so can be read as single slice. - // Also assumes that first character was already checked - // by isIdentifierStart in readToken. - - pp.jsx_readWord = function() { - var ch, start = this.pos; - do { - ch = this.input.charCodeAt(++this.pos); - } while (acorn.isIdentifierChar(ch) || ch === 45); // '-' - return this.finishToken(tt.jsxName, this.input.slice(start, this.pos)); - }; - - // Transforms JSX element name to string. - - function getQualifiedJSXName(object) { - if (!object) - return object; - - if (object.type === 'JSXIdentifier') - return object.name; - - if (object.type === 'JSXNamespacedName') - return object.namespace.name + ':' + object.name.name; - - if (object.type === 'JSXMemberExpression') - return getQualifiedJSXName(object.object) + '.' + - getQualifiedJSXName(object.property); - } - - // Parse next token as JSX identifier - - pp.jsx_parseIdentifier = function() { - var node = this.startNode(); - if (this.type === tt.jsxName) - node.name = this.value; - else if (this.type.keyword) - node.name = this.type.keyword; - else - this.unexpected(); - this.next(); - return this.finishNode(node, 'JSXIdentifier'); - }; - - // Parse namespaced identifier. - - pp.jsx_parseNamespacedName = function() { - var startPos = this.start, startLoc = this.startLoc; - var name = this.jsx_parseIdentifier(); - if (!this.options.plugins.jsx.allowNamespaces || !this.eat(tt.colon)) return name; - var node = this.startNodeAt(startPos, startLoc); - node.namespace = name; - node.name = this.jsx_parseIdentifier(); - return this.finishNode(node, 'JSXNamespacedName'); - }; - - // Parses element name in any form - namespaced, member - // or single identifier. - - pp.jsx_parseElementName = function() { - if (this.type === tt.jsxTagEnd) - return ''; - var startPos = this.start, startLoc = this.startLoc; - var node = this.jsx_parseNamespacedName(); - if (this.type === tt.dot && node.type === 'JSXNamespacedName' && !this.options.plugins.jsx.allowNamespacedObjects) { - this.unexpected(); - } - while (this.eat(tt.dot)) { - var newNode = this.startNodeAt(startPos, startLoc); - newNode.object = node; - newNode.property = this.jsx_parseIdentifier(); - node = this.finishNode(newNode, 'JSXMemberExpression'); - } - return node; - }; - - // Parses any type of JSX attribute value. - - pp.jsx_parseAttributeValue = function() { - switch (this.type) { - case tt.braceL: - var node = this.jsx_parseExpressionContainer(); - if (node.expression.type === 'JSXEmptyExpression') - this.raise(node.start, 'JSX attributes must only be assigned a non-empty expression'); - return node; - - case tt.jsxTagStart: - case tt.string: - return this.parseExprAtom(); - - default: - this.raise(this.start, 'JSX value should be either an expression or a quoted JSX text'); - } - }; - - // JSXEmptyExpression is unique type since it doesn't actually parse anything, - // and so it should start at the end of last read token (left brace) and finish - // at the beginning of the next one (right brace). - - pp.jsx_parseEmptyExpression = function() { - var node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc); - return this.finishNodeAt(node, 'JSXEmptyExpression', this.start, this.startLoc); - }; - - // Parses JSX expression enclosed into curly brackets. - - - pp.jsx_parseExpressionContainer = function() { - var node = this.startNode(); - this.next(); - node.expression = this.type === tt.braceR - ? this.jsx_parseEmptyExpression() - : this.parseExpression(); - this.expect(tt.braceR); - return this.finishNode(node, 'JSXExpressionContainer'); - }; - - // Parses following JSX attribute name-value pair. - - pp.jsx_parseAttribute = function() { - var node = this.startNode(); - if (this.eat(tt.braceL)) { - this.expect(tt.ellipsis); - node.argument = this.parseMaybeAssign(); - this.expect(tt.braceR); - return this.finishNode(node, 'JSXSpreadAttribute'); - } - node.name = this.jsx_parseNamespacedName(); - node.value = this.eat(tt.eq) ? this.jsx_parseAttributeValue() : null; - return this.finishNode(node, 'JSXAttribute'); - }; - - // Parses JSX opening tag starting after '<'. - - pp.jsx_parseOpeningElementAt = function(startPos, startLoc) { - var node = this.startNodeAt(startPos, startLoc); - node.attributes = []; - var nodeName = this.jsx_parseElementName(); - if (nodeName) node.name = nodeName; - while (this.type !== tt.slash && this.type !== tt.jsxTagEnd) - node.attributes.push(this.jsx_parseAttribute()); - node.selfClosing = this.eat(tt.slash); - this.expect(tt.jsxTagEnd); - return this.finishNode(node, nodeName ? 'JSXOpeningElement' : 'JSXOpeningFragment'); - }; - - // Parses JSX closing tag starting after ''); - } - } - - node.openingElement = openingElement; - node.closingElement = closingElement; - node.children = children; - if (this.type === tt.relational && this.value === "<") { - this.raise(this.start, "Adjacent JSX elements must be wrapped in an enclosing tag"); - } - return this.finishNode(node, openingElement.name ? 'JSXElement' : 'JSXFragment'); - }; - - // Parse JSX text - - pp.jsx_parseText = function(value) { - var node = this.parseLiteral(value); - node.type = "JSXText"; - - return node; - }; - - // Parses entire JSX element from current position. - - pp.jsx_parseElement = function() { - var startPos = this.start, startLoc = this.startLoc; - this.next(); - return this.jsx_parseElementAt(startPos, startLoc); - }; - - acorn.plugins.jsx = function(instance, opts) { - if (!opts) { - return; - } - - if (typeof opts !== 'object') { - opts = {}; - } - - instance.options.plugins.jsx = { - allowNamespaces: opts.allowNamespaces !== false, - allowNamespacedObjects: !!opts.allowNamespacedObjects - }; - - instance.extend('parseExprAtom', function(inner) { - return function(refShortHandDefaultPos) { - if (this.type === tt.jsxText) - return this.jsx_parseText(this.value); - else if (this.type === tt.jsxTagStart) - return this.jsx_parseElement(); - else - return inner.call(this, refShortHandDefaultPos); - }; - }); - - instance.extend('readToken', function(inner) { - return function(code) { - var context = this.curContext(); - - if (context === tc.j_expr) return this.jsx_readToken(); - - if (context === tc.j_oTag || context === tc.j_cTag) { - if (acorn.isIdentifierStart(code)) return this.jsx_readWord(); - - if (code == 62) { - ++this.pos; - return this.finishToken(tt.jsxTagEnd); - } - - if ((code === 34 || code === 39) && context == tc.j_oTag) - return this.jsx_readString(code); - } - - if (code === 60 && this.exprAllowed && this.input.charCodeAt(this.pos + 1) !== 33) { - ++this.pos; - return this.finishToken(tt.jsxTagStart); - } - return inner.call(this, code); - }; - }); - - instance.extend('updateContext', function(inner) { - return function(prevType) { - if (this.type == tt.braceL) { - var curContext = this.curContext(); - if (curContext == tc.j_oTag) this.context.push(tc.b_expr); - else if (curContext == tc.j_expr) this.context.push(tc.b_tmpl); - else inner.call(this, prevType); - this.exprAllowed = true; - } else if (this.type === tt.slash && prevType === tt.jsxTagStart) { - this.context.length -= 2; // do not consider JSX expr -> JSX open tag -> ... anymore - this.context.push(tc.j_cTag); // reconsider as closing tag context - this.exprAllowed = false; - } else { - return inner.call(this, prevType); - } - }; - }); - }; - - return acorn; -}; diff --git a/tools/node_modules/eslint/node_modules/acorn-jsx/package.json b/tools/node_modules/eslint/node_modules/acorn-jsx/package.json index 138fee460f07f0..d22757b6a8d450 100644 --- a/tools/node_modules/eslint/node_modules/acorn-jsx/package.json +++ b/tools/node_modules/eslint/node_modules/acorn-jsx/package.json @@ -3,14 +3,10 @@ "url": "https://github.com/RReverser/acorn-jsx/issues" }, "bundleDependencies": false, - "dependencies": { - "acorn": "^5.0.3" - }, "deprecated": false, "description": "Alternative, faster React.js JSX parser", "devDependencies": { - "chai": "^3.0.0", - "mocha": "^3.3.0" + "acorn": "^6.0.0" }, "homepage": "https://github.com/RReverser/acorn-jsx", "license": "MIT", @@ -22,6 +18,9 @@ } ], "name": "acorn-jsx", + "peerDependencies": { + "acorn": "^6.0.0" + }, "repository": { "type": "git", "url": "git+https://github.com/RReverser/acorn-jsx.git" @@ -29,5 +28,5 @@ "scripts": { "test": "node test/run.js" }, - "version": "4.1.1" + "version": "5.0.0" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/acorn/AUTHORS b/tools/node_modules/eslint/node_modules/acorn/AUTHORS deleted file mode 100644 index c5ac22cbd7c6ba..00000000000000 --- a/tools/node_modules/eslint/node_modules/acorn/AUTHORS +++ /dev/null @@ -1,79 +0,0 @@ -List of Acorn contributors. Updated before every release. - -Adrian Heine -Adrian Rakovsky -Alistair Braidwood -Amila Welihinda -Andres Suarez -Angelo -Aparajita Fishman -Arian Stolwijk -Artem Govorov -Boopesh Mahendran -Bradley Heinz -Brandon Mills -Charles Hughes -Charmander -Chris McKnight -Conrad Irwin -Daniel Tschinder -David Bonnet -Domenico Matteo -ehmicky -Eugene Obrezkov -Felix Maier -Forbes Lindesay -Gilad Peleg -impinball -Ingvar Stepanyan -Jackson Ray Hamilton -Jesse McCarthy -Jiaxing Wang -Joel Kemp -Johannes Herr -John-David Dalton -Jordan Klassen -Jürg Lehni -Kai Cataldo -keeyipchan -Keheliya Gallaba -Kevin Irish -Kevin Kwok -krator -laosb -luckyzeng -Marek -Marijn Haverbeke -Martin Carlberg -Mat Garcia -Mathias Bynens -Mathieu 'p01' Henri -Matthew Bastien -Max Schaefer -Max Zerzouri -Mihai Bazon -Mike Rennie -naoh -Nicholas C. Zakas -Nick Fitzgerald -Olivier Thomann -Oskar Schöldström -Paul Harper -Peter Rust -PlNG -Prayag Verma -ReadmeCritic -r-e-d -Renée Kooi -Richard Gibson -Rich Harris -Sebastian McKenzie -Shahar Soel -Sheel Bedi -Simen Bekkhus -Teddy Katz -Timothy Gu -Toru Nagashima -Victor Homyakov -Wexpo Lyu -zsjforcn diff --git a/tools/node_modules/eslint/node_modules/acorn/README.md b/tools/node_modules/eslint/node_modules/acorn/README.md index de53f513f49e2f..e66dac31de22b2 100644 --- a/tools/node_modules/eslint/node_modules/acorn/README.md +++ b/tools/node_modules/eslint/node_modules/acorn/README.md @@ -1,11 +1,6 @@ # Acorn -[![Build Status](https://travis-ci.org/acornjs/acorn.svg?branch=master)](https://travis-ci.org/acornjs/acorn) -[![NPM version](https://img.shields.io/npm/v/acorn.svg)](https://www.npmjs.com/package/acorn) -[![CDNJS](https://img.shields.io/cdnjs/v/acorn.svg)](https://cdnjs.com/libraries/acorn) -[Author funding status: ![maintainer happiness](https://marijnhaverbeke.nl/fund/status_s.png?force)](https://marijnhaverbeke.nl/fund/) - -A tiny, fast JavaScript parser, written completely in JavaScript. +A tiny, fast JavaScript parser written in JavaScript. ## Community @@ -20,9 +15,7 @@ and discussion, please use the ## Installation -The easiest way to install acorn is with [`npm`][npm]. - -[npm]: https://www.npmjs.com/ +The easiest way to install acorn is from [`npm`](https://www.npmjs.com/): ```sh npm install acorn @@ -34,36 +27,29 @@ Alternately, you can download the source and build acorn yourself: git clone https://github.com/acornjs/acorn.git cd acorn npm install -npm run build ``` -## Components - -When run in a CommonJS (node.js) or AMD environment, exported values -appear in the interfaces exposed by the individual files, as usual. -When loaded in the browser (Acorn works in any JS-enabled browser more -recent than IE5) without any kind of module management, a single -global object `acorn` will be defined, and all the exported properties -will be added to that. +## Interface -### Main parser +**parse**`(input, options)` is the main interface to the library. The +`input` parameter is a string, `options` can be undefined or an object +setting some of the options listed below. The return value will be an +abstract syntax tree object as specified by the [ESTree +spec](https://github.com/estree/estree). -This is implemented in `dist/acorn.js`, and is what you get when you -`require("acorn")` in node.js. - -**parse**`(input, options)` is used to parse a JavaScript program. -The `input` parameter is a string, `options` can be undefined or an -object setting some of the options listed below. The return value will -be an abstract syntax tree object as specified by the -[ESTree spec][estree]. +```javascript +let acorn = require("acorn"); +console.log(acorn.parse("1 + 1")); +``` -When encountering a syntax error, the parser will raise a -`SyntaxError` object with a meaningful message. The error object will -have a `pos` property that indicates the character offset at which the -error occurred, and a `loc` object that contains a `{line, column}` +When encountering a syntax error, the parser will raise a +`SyntaxError` object with a meaningful message. The error object will +have a `pos` property that indicates the string offset at which the +error occurred, and a `loc` object that contains a `{line, column}` object referring to that same position. -[estree]: https://github.com/estree/estree +Options can be provided by passing a second argument, which should be +an object containing any of these fields: - **ecmaVersion**: Indicates the ECMAScript version to parse. Must be either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018) or 10 (2019, partial @@ -71,7 +57,8 @@ object referring to that same position. reserved words, and support for new syntax features. Default is 7. **NOTE**: Only 'stage 4' (finalized) ECMAScript features are being - implemented by Acorn. + implemented by Acorn. Other proposed new features can be implemented + through plugins. - **sourceType**: Indicate the mode the code should be parsed in. Can be either `"script"` or `"module"`. This influences global strict mode @@ -100,7 +87,10 @@ object referring to that same position. declarations can only appear at a program's top level. Setting this option to `true` allows them anywhere where a statement is allowed. -- **allowAwaitOutsideFunction**: By default, `await` expressions can only appear inside `async` functions. Setting this option to `true` allows to have top-level `await` expressions. They are still not allowed in non-`async` functions, though. +- **allowAwaitOutsideFunction**: By default, `await` expressions can + only appear inside `async` functions. Setting this option to + `true` allows to have top-level `await` expressions. They are + still not allowed in non-`async` functions, though. - **allowHashBang**: When this is enabled (off by default), if the code starts with the characters `#!` (as in a shellscript), the @@ -159,9 +149,10 @@ object referring to that same position. - **ranges**: Nodes have their start and end characters offsets recorded in `start` and `end` properties (directly on the node, rather than the `loc` object, which holds line/column data. To also - add a [semi-standardized][range] `range` property holding a - `[start, end]` array with the same numbers, set the `ranges` option - to `true`. + add a + [semi-standardized](https://bugzilla.mozilla.org/show_bug.cgi?id=745678) + `range` property holding a `[start, end]` array with the same + numbers, set the `ranges` option to `true`. - **program**: It is possible to parse multiple files into a single AST by passing the tree produced by parsing the first file as the @@ -184,15 +175,10 @@ object referring to that same position. that have a single `expression` property containing the expression inside parentheses. -[range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678 - **parseExpressionAt**`(input, offset, options)` will parse a single expression in a string, and return its AST. It will not complain if there is more of the string left after the expression. -**getLineInfo**`(input, offset)` can be used to get a `{line, -column}` object for a given program string and character offset. - **tokenizer**`(input, options)` returns an object with a `getToken` method that can be called repeatedly to get the next token, a `{start, end, type, value}` object (with added `loc` property when the @@ -216,139 +202,30 @@ var tokens = [...acorn.tokenizer(str)]; **tokTypes** holds an object mapping names to the token type objects that end up in the `type` properties of tokens. -#### Note on using with [Escodegen][escodegen] - -Escodegen supports generating comments from AST, attached in -Esprima-specific format. In order to simulate same format in -Acorn, consider following example: - -```javascript -var comments = [], tokens = []; - -var ast = acorn.parse('var x = 42; // answer', { - // collect ranges for each node - ranges: true, - // collect comments in Esprima's format - onComment: comments, - // collect token ranges - onToken: tokens -}); - -// attach comments using collected information -escodegen.attachComments(ast, comments, tokens); - -// generate code -console.log(escodegen.generate(ast, {comment: true})); -// > 'var x = 42; // answer' -``` - -[escodegen]: https://github.com/estools/escodegen - -### dist/acorn_loose.js ### - -This file implements an error-tolerant parser. It exposes a single -function. The loose parser is accessible in node.js via `require("acorn/dist/acorn_loose")`. - -**parse_dammit**`(input, options)` takes the same arguments and -returns the same syntax tree as the `parse` function in `acorn.js`, -but never raises an error, and will do its best to parse syntactically -invalid code in as meaningful a way as it can. It'll insert identifier -nodes with name `"✖"` as placeholders in places where it can't make -sense of the input. Depends on `acorn.js`, because it uses the same -tokenizer. - -### dist/walk.js ### - -Implements an abstract syntax tree walker. Will store its interface in -`acorn.walk` when loaded without a module system. - -**simple**`(node, visitors, base, state)` does a 'simple' walk over -a tree. `node` should be the AST node to walk, and `visitors` an -object with properties whose names correspond to node types in the -[ESTree spec][estree]. The properties should contain functions -that will be called with the node object and, if applicable the state -at that point. The last two arguments are optional. `base` is a walker -algorithm, and `state` is a start state. The default walker will -simply visit all statements and expressions and not produce a -meaningful state. (An example of a use of state is to track scope at -each point in the tree.) - -```js -const acorn = require("acorn") -const walk = require("acorn/dist/walk") - -walk.simple(acorn.parse("let x = 10"), { - Literal(node) { - console.log(`Found a literal: ${node.value}`) - } -}) -``` +**getLineInfo**`(input, offset)` can be used to get a `{line, +column}` object for a given program string and offset. -**ancestor**`(node, visitors, base, state)` does a 'simple' walk over -a tree, building up an array of ancestor nodes (including the current node) -and passing the array to the callbacks as a third parameter. +### The `Parser` class -```js -const acorn = require("acorn") -const walk = require("acorn/dist/walk") +Instances of the **`Parser`** class contain all the state and logic +that drives a parse. It has static methods `parse`, +`parseExpressionAt`, and `tokenizer` that match the top-level +functions by the same name. -walk.ancestor(acorn.parse("foo('hi')"), { - Literal(_, ancestors) { - console.log("This literal's ancestors are:", - ancestors.map(n => n.type)) - } -}) -``` +When extending the parser with plugins, you need to call these methods +on the extended version of the class. To extend a parser with plugins, +you can use its static `extend` method. -**recursive**`(node, state, functions, base)` does a 'recursive' -walk, where the walker functions are responsible for continuing the -walk on the child nodes of their target node. `state` is the start -state, and `functions` should contain an object that maps node types -to walker functions. Such functions are called with `(node, state, c)` -arguments, and can cause the walk to continue on a sub-node by calling -the `c` argument on it with `(node, state)` arguments. The optional -`base` argument provides the fallback walker functions for node types -that aren't handled in the `functions` object. If not given, the -default walkers will be used. - -**make**`(functions, base)` builds a new walker object by using the -walker functions in `functions` and filling in the missing ones by -taking defaults from `base`. - -**full**`(node, callback, base, state)` does a 'full' -walk over a tree, calling the callback with the arguments (node, state, type) -for each node - -**fullAncestor**`(node, callback, base, state)` does a 'full' walk over -a tree, building up an array of ancestor nodes (including the current node) -and passing the array to the callbacks as a third parameter. - -```js -const acorn = require("acorn") -const walk = require("acorn/dist/walk") - -walk.full(acorn.parse("1 + 1"), node => { - console.log(`There's a ${node.type} node at ${node.ch}`) -}) +```javascript +var acorn = require("acorn"); +var jsx = require("acorn-jsx"); +var JSXParser = acorn.Parser.extend(jsx()); +JSXParser.parse("foo()"); ``` -**findNodeAt**`(node, start, end, test, base, state)` tries to -locate a node in a tree at the given start and/or end offsets, which -satisfies the predicate `test`. `start` and `end` can be either `null` -(as wildcard) or a number. `test` may be a string (indicating a node -type) or a function that takes `(nodeType, node)` arguments and -returns a boolean indicating whether this node is interesting. `base` -and `state` are optional, and can be used to specify a custom walker. -Nodes are tested from inner to outer, so if two nodes match the -boundaries, the inner one will be preferred. - -**findNodeAround**`(node, pos, test, base, state)` is a lot like -`findNodeAt`, but will match any node that exists 'around' (spanning) -the given position. - -**findNodeAfter**`(node, pos, test, base, state)` is similar to -`findNodeAround`, but will match all nodes *after* the given position -(testing outer nodes before inner nodes). +The `extend` method takes any number of plugin values, and returns a +new `Parser` class that includes the extra parser logic provided by +the plugins. ## Command line interface @@ -357,7 +234,7 @@ line. It accepts as arguments its input file and the following options: - `--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|--ecma10`: Sets the ECMAScript version - to parse. Default is version 7. + to parse. Default is version 9. - `--module`: Sets the parsing mode to `"module"`. Is set to `"script"` otherwise. @@ -365,7 +242,8 @@ options: "end" subobjects, each of which contains the one-based line and zero-based column numbers in `{line, column}` form. -- `--allow-hash-bang`: If the code starts with the characters #! (as in a shellscript), the first line will be treated as a comment. +- `--allow-hash-bang`: If the code starts with the characters #! (as + in a shellscript), the first line will be treated as a comment. - `--compact`: No whitespace is used in the AST output. @@ -375,82 +253,11 @@ options: The utility spits out the syntax tree as JSON data. -## Build system - -Acorn is written in ECMAScript 6, as a set of small modules, in the -project's `src` directory, and compiled down to bigger ECMAScript 3 -files in `dist` using [Browserify](http://browserify.org) and -[Babel](http://babeljs.io/). If you are already using Babel, you can -consider including the modules directly. - -The command-line test runner (`npm test`) uses the ES6 modules. The -browser-based test page (`test/index.html`) uses the compiled modules. -The `bin/build-acorn.js` script builds the latter from the former. - -If you are working on Acorn, you'll probably want to try the code out -directly, without an intermediate build step. In your scripts, you can -register the Babel require shim like this: - - require("babel-core/register") - -That will allow you to directly `require` the ES6 modules. - -## Plugins - -Acorn is designed support allow plugins which, within reasonable -bounds, redefine the way the parser works. Plugins can add new token -types and new tokenizer contexts (if necessary), and extend methods in -the parser object. This is not a clean, elegant API—using it requires -an understanding of Acorn's internals, and plugins are likely to break -whenever those internals are significantly changed. But still, it is -_possible_, in this way, to create parsers for JavaScript dialects -without forking all of Acorn. And in principle it is even possible to -combine such plugins, so that if you have, for example, a plugin for -parsing types and a plugin for parsing JSX-style XML literals, you -could load them both and parse code with both JSX tags and types. - -A plugin should register itself by adding a property to -`acorn.plugins`, which holds a function. Calling `acorn.parse`, a -`plugins` option can be passed, holding an object mapping plugin names -to configuration values (or just `true` for plugins that don't take -options). After the parser object has been created, the initialization -functions for the chosen plugins are called with `(parser, -configValue)` arguments. They are expected to use the `parser.extend` -method to extend parser methods. For example, the `readToken` method -could be extended like this: - -```javascript -parser.extend("readToken", function(nextMethod) { - return function(code) { - console.log("Reading a token!") - return nextMethod.call(this, code) - } -}) -``` - -The `nextMethod` argument passed to `extend`'s second argument is the -previous value of this method, and should usually be called through to -whenever the extended method does not handle the call itself. - -Similarly, the loose parser allows plugins to register themselves via -`acorn.pluginsLoose`. The extension mechanism is the same as for the -normal parser: - -```javascript -looseParser.extend("readToken", function(nextMethod) { - return function() { - console.log("Reading a token in the loose parser!") - return nextMethod.call(this) - } -}) -``` - -### Existing plugins +## Existing plugins - [`acorn-jsx`](https://github.com/RReverser/acorn-jsx): Parse [Facebook JSX syntax extensions](https://github.com/facebook/jsx) - - [`acorn-objj`](https://github.com/cappuccino/acorn-objj): [Objective-J](http://www.cappuccino-project.org/learn/objective-j.html) language parser built as Acorn plugin - Plugins for ECMAScript proposals: +Plugins for ECMAScript proposals: - [`acorn-stage3`](https://github.com/acornjs/acorn-stage3): Parse most stage 3 proposals, bundling: - [`acorn-async-iteration`](https://github.com/acornjs/acorn-async-iteration): Parse [async iteration proposal](https://github.com/tc39/proposal-async-iteration) @@ -459,9 +266,4 @@ looseParser.extend("readToken", function(nextMethod) { - [`acorn-dynamic-import`](https://github.com/kesne/acorn-dynamic-import): Parse [import() proposal](https://github.com/tc39/proposal-dynamic-import) - [`acorn-import-meta`](https://github.com/acornjs/acorn-import-meta): Parse [import.meta proposal](https://github.com/tc39/proposal-import-meta) - [`acorn-numeric-separator`](https://github.com/acornjs/acorn-numeric-separator): Parse [numeric separator proposal](https://github.com/tc39/proposal-numeric-separator) - - [`acorn-optional-catch-binding`](https://github.com/acornjs/acorn-optional-catch-binding): Parse [optional catch binding proposal](https://github.com/tc39/proposal-optional-catch-binding) - - [`acorn-private-methods`](https://github.com/acornjs/acorn-private-methods): parse [private methods, getters and setters proposal](https://github.com/tc39/proposal-private-methods) - - [`acorn5-object-spread`](https://github.com/adrianheine/acorn5-object-spread): Parse [Object Rest/Spread Properties proposal](https://github.com/tc39/proposal-object-rest-spread) - - [`acorn-object-rest-spread`](https://github.com/victor-homyakov/acorn-object-rest-spread): Parse [Object Rest/Spread Properties proposal](https://github.com/tc39/proposal-object-rest-spread) - - [`acorn-es7`](https://github.com/angelozerr/acorn-es7): Parse [decorator syntax proposal](https://github.com/wycats/javascript-decorators) - - [`acorn-static-class-property-initializer`](https://github.com/victor-homyakov/acorn-static-class-property-initializer): Partial support for static class properties from [ES Class Fields & Static Properties Proposal](https://github.com/tc39/proposal-class-public-fields) to support static property initializers in [React components written as ES6+ classes](https://babeljs.io/blog/2015/07/07/react-on-es6-plus) + - [`acorn-private-methods`](https://github.com/acornjs/acorn-private-methods): parse [private methods, getters and setters proposal](https://github.com/tc39/proposal-private-methods)n diff --git a/tools/node_modules/eslint/node_modules/acorn/bin/acorn b/tools/node_modules/eslint/node_modules/acorn/bin/acorn index 03888d0aecac17..cf7df46890fdd4 100755 --- a/tools/node_modules/eslint/node_modules/acorn/bin/acorn +++ b/tools/node_modules/eslint/node_modules/acorn/bin/acorn @@ -1,4 +1,4 @@ #!/usr/bin/env node 'use strict'; -require('./_acorn.js'); +require('../dist/bin.js'); diff --git a/tools/node_modules/eslint/node_modules/acorn/bin/run_test262.js b/tools/node_modules/eslint/node_modules/acorn/bin/run_test262.js deleted file mode 100644 index 150429a1f20957..00000000000000 --- a/tools/node_modules/eslint/node_modules/acorn/bin/run_test262.js +++ /dev/null @@ -1,21 +0,0 @@ -const fs = require("fs") -const path = require("path") -const run = require("test262-parser-runner") -const parse = require("..").parse - -const unsupportedFeatures = [ - "BigInt", - "class-fields", - "class-fields-private", - "class-fields-public", - "numeric-separator-literal" -]; - -run( - (content, {sourceType}) => parse(content, {sourceType, ecmaVersion: 10}), - { - testsDirectory: path.dirname(require.resolve("test262/package.json")), - skip: test => (test.attrs.features && unsupportedFeatures.some(f => test.attrs.features.includes(f))), - whitelist: fs.readFileSync("./bin/test262.whitelist", "utf8").split("\n").filter(v => v) - } -) diff --git a/tools/node_modules/eslint/node_modules/acorn/bin/test262.whitelist b/tools/node_modules/eslint/node_modules/acorn/bin/test262.whitelist deleted file mode 100644 index c8c6ce4a82774b..00000000000000 --- a/tools/node_modules/eslint/node_modules/acorn/bin/test262.whitelist +++ /dev/null @@ -1,404 +0,0 @@ -annexB/language/function-code/block-decl-func-no-skip-try.js (default) -annexB/language/function-code/block-decl-func-skip-early-err-block.js (default) -annexB/language/function-code/block-decl-func-skip-early-err.js (default) -annexB/language/function-code/block-decl-func-skip-early-err-switch.js (default) -annexB/language/function-code/block-decl-func-skip-early-err-try.js (default) -annexB/language/function-code/if-decl-else-decl-a-func-no-skip-try.js (default) -annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-block.js (default) -annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err.js (default) -annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-switch.js (default) -annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-try.js (default) -annexB/language/function-code/if-decl-else-decl-b-func-no-skip-try.js (default) -annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-block.js (default) -annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err.js (default) -annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-switch.js (default) -annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-try.js (default) -annexB/language/function-code/if-decl-else-stmt-func-no-skip-try.js (default) -annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-block.js (default) -annexB/language/function-code/if-decl-else-stmt-func-skip-early-err.js (default) -annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-switch.js (default) -annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-try.js (default) -annexB/language/function-code/if-decl-no-else-func-no-skip-try.js (default) -annexB/language/function-code/if-decl-no-else-func-skip-early-err-block.js (default) -annexB/language/function-code/if-decl-no-else-func-skip-early-err.js (default) -annexB/language/function-code/if-decl-no-else-func-skip-early-err-switch.js (default) -annexB/language/function-code/if-decl-no-else-func-skip-early-err-try.js (default) -annexB/language/function-code/if-stmt-else-decl-func-no-skip-try.js (default) -annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-block.js (default) -annexB/language/function-code/if-stmt-else-decl-func-skip-early-err.js (default) -annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-switch.js (default) -annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-try.js (default) -annexB/language/function-code/switch-case-func-no-skip-try.js (default) -annexB/language/function-code/switch-case-func-skip-early-err-block.js (default) -annexB/language/function-code/switch-case-func-skip-early-err.js (default) -annexB/language/function-code/switch-case-func-skip-early-err-switch.js (default) -annexB/language/function-code/switch-case-func-skip-early-err-try.js (default) -annexB/language/function-code/switch-dflt-func-no-skip-try.js (default) -annexB/language/function-code/switch-dflt-func-skip-early-err-block.js (default) -annexB/language/function-code/switch-dflt-func-skip-early-err.js (default) -annexB/language/function-code/switch-dflt-func-skip-early-err-switch.js (default) -annexB/language/function-code/switch-dflt-func-skip-early-err-try.js (default) -annexB/language/global-code/block-decl-global-no-skip-try.js (default) -annexB/language/global-code/block-decl-global-skip-early-err-block.js (default) -annexB/language/global-code/block-decl-global-skip-early-err.js (default) -annexB/language/global-code/block-decl-global-skip-early-err-switch.js (default) -annexB/language/global-code/block-decl-global-skip-early-err-try.js (default) -annexB/language/global-code/if-decl-else-decl-a-global-no-skip-try.js (default) -annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-block.js (default) -annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err.js (default) -annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-switch.js (default) -annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-try.js (default) -annexB/language/global-code/if-decl-else-decl-b-global-no-skip-try.js (default) -annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-block.js (default) -annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err.js (default) -annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-switch.js (default) -annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-try.js (default) -annexB/language/global-code/if-decl-else-stmt-global-no-skip-try.js (default) -annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-block.js (default) -annexB/language/global-code/if-decl-else-stmt-global-skip-early-err.js (default) -annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-switch.js (default) -annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-try.js (default) -annexB/language/global-code/if-decl-no-else-global-no-skip-try.js (default) -annexB/language/global-code/if-decl-no-else-global-skip-early-err-block.js (default) -annexB/language/global-code/if-decl-no-else-global-skip-early-err.js (default) -annexB/language/global-code/if-decl-no-else-global-skip-early-err-switch.js (default) -annexB/language/global-code/if-decl-no-else-global-skip-early-err-try.js (default) -annexB/language/global-code/if-stmt-else-decl-global-no-skip-try.js (default) -annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-block.js (default) -annexB/language/global-code/if-stmt-else-decl-global-skip-early-err.js (default) -annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-switch.js (default) -annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-try.js (default) -annexB/language/global-code/switch-case-global-no-skip-try.js (default) -annexB/language/global-code/switch-case-global-skip-early-err-block.js (default) -annexB/language/global-code/switch-case-global-skip-early-err.js (default) -annexB/language/global-code/switch-case-global-skip-early-err-switch.js (default) -annexB/language/global-code/switch-case-global-skip-early-err-try.js (default) -annexB/language/global-code/switch-dflt-global-no-skip-try.js (default) -annexB/language/global-code/switch-dflt-global-skip-early-err-block.js (default) -annexB/language/global-code/switch-dflt-global-skip-early-err.js (default) -annexB/language/global-code/switch-dflt-global-skip-early-err-switch.js (default) -annexB/language/global-code/switch-dflt-global-skip-early-err-try.js (default) -annexB/language/statements/try/catch-redeclared-for-in-var.js (default) -annexB/language/statements/try/catch-redeclared-for-in-var.js (strict mode) -annexB/language/statements/try/catch-redeclared-for-var.js (default) -annexB/language/statements/try/catch-redeclared-for-var.js (strict mode) -annexB/language/statements/try/catch-redeclared-var-statement-captured.js (default) -annexB/language/statements/try/catch-redeclared-var-statement-captured.js (strict mode) -annexB/language/statements/try/catch-redeclared-var-statement.js (default) -annexB/language/statements/try/catch-redeclared-var-statement.js (strict mode) -language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) -language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-function-declaration.js (default) -language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-generator-declaration.js (default) -language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-var-declaration.js (default) -language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) -language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) -language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) -language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-function-declaration.js (default) -language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-generator-declaration.js (default) -language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-var-declaration.js (default) -language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) -language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) -language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) -language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-const-declaration.js (default) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-const-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-function-declaration.js (default) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-generator-declaration.js (default) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-let-declaration.js (default) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-let-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-var-declaration.js (default) -language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/const-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/block-scope/syntax/redeclaration/const-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) -language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-generator-declaration.js (default) -language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-var-declaration.js (default) -language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) -language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-function-declaration.js (default) -language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-generator-declaration.js (default) -language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-var-declaration.js (default) -language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/let-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/block-scope/syntax/redeclaration/let-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) -language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-function-declaration.js (default) -language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) -language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-generator-declaration.js (default) -language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) -language/expressions/async-arrow-function/early-errors-arrow-await-in-formals-default.js (default) -language/expressions/async-arrow-function/early-errors-arrow-await-in-formals-default.js (strict mode) -language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-call.js (default) -language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-call.js (strict mode) -language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-property.js (default) -language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-property.js (strict mode) -language/expressions/async-function/early-errors-expression-body-contains-super-call.js (default) -language/expressions/async-function/early-errors-expression-body-contains-super-call.js (strict mode) -language/expressions/async-function/early-errors-expression-body-contains-super-property.js (default) -language/expressions/async-function/early-errors-expression-body-contains-super-property.js (strict mode) -language/expressions/async-function/early-errors-expression-formals-contains-super-call.js (default) -language/expressions/async-function/early-errors-expression-formals-contains-super-call.js (strict mode) -language/expressions/async-function/early-errors-expression-formals-contains-super-property.js (default) -language/expressions/async-function/early-errors-expression-formals-contains-super-property.js (strict mode) -language/expressions/class/method-param-dflt-yield.js (default) -language/expressions/class/static-method-param-dflt-yield.js (default) -language/expressions/function/early-body-super-call.js (default) -language/expressions/function/early-body-super-call.js (strict mode) -language/expressions/function/early-body-super-prop.js (default) -language/expressions/function/early-body-super-prop.js (strict mode) -language/expressions/function/early-params-super-call.js (default) -language/expressions/function/early-params-super-call.js (strict mode) -language/expressions/function/early-params-super-prop.js (default) -language/expressions/function/early-params-super-prop.js (strict mode) -language/expressions/object/method-definition/early-errors-object-method-body-contains-super-call.js (default) -language/expressions/object/method-definition/early-errors-object-method-body-contains-super-call.js (strict mode) -language/expressions/object/method-definition/early-errors-object-method-duplicate-parameters.js (default) -language/expressions/object/method-definition/early-errors-object-method-formals-contains-super-call.js (default) -language/expressions/object/method-definition/early-errors-object-method-formals-contains-super-call.js (strict mode) -language/expressions/object/method-definition/generator-super-call-body.js (default) -language/expressions/object/method-definition/generator-super-call-body.js (strict mode) -language/expressions/object/method-definition/generator-super-call-param.js (default) -language/expressions/object/method-definition/generator-super-call-param.js (strict mode) -language/expressions/object/prop-def-invalid-async-prefix.js (default) -language/expressions/object/prop-def-invalid-async-prefix.js (strict mode) -language/expressions/yield/in-iteration-stmt.js (default) -language/expressions/yield/in-iteration-stmt.js (strict mode) -language/expressions/yield/star-in-iteration-stmt.js (default) -language/expressions/yield/star-in-iteration-stmt.js (strict mode) -language/global-code/new.target-arrow.js (default) -language/global-code/new.target-arrow.js (strict mode) -language/global-code/super-call-arrow.js (default) -language/global-code/super-call-arrow.js (strict mode) -language/global-code/super-prop-arrow.js (default) -language/global-code/super-prop-arrow.js (strict mode) -language/module-code/early-export-global.js (default) -language/module-code/early-export-global.js (strict mode) -language/module-code/early-export-unresolvable.js (default) -language/module-code/early-export-unresolvable.js (strict mode) -language/statements/async-function/early-errors-declaration-body-contains-super-call.js (default) -language/statements/async-function/early-errors-declaration-body-contains-super-call.js (strict mode) -language/statements/async-function/early-errors-declaration-body-contains-super-property.js (default) -language/statements/async-function/early-errors-declaration-body-contains-super-property.js (strict mode) -language/statements/async-function/early-errors-declaration-formals-contains-super-call.js (default) -language/statements/async-function/early-errors-declaration-formals-contains-super-call.js (strict mode) -language/statements/async-function/early-errors-declaration-formals-contains-super-property.js (default) -language/statements/async-function/early-errors-declaration-formals-contains-super-property.js (strict mode) -language/expressions/async-generator/early-errors-expression-body-contains-super-call.js (default) -language/expressions/async-generator/early-errors-expression-body-contains-super-call.js (strict mode) -language/expressions/async-generator/early-errors-expression-body-contains-super-property.js (default) -language/expressions/async-generator/early-errors-expression-body-contains-super-property.js (strict mode) -language/expressions/async-generator/early-errors-expression-formals-contains-super-call.js (default) -language/expressions/async-generator/early-errors-expression-formals-contains-super-call.js (strict mode) -language/expressions/async-generator/early-errors-expression-formals-contains-super-property.js (default) -language/expressions/async-generator/early-errors-expression-formals-contains-super-property.js (strict mode) -language/statements/class/definition/early-errors-class-method-arguments-in-formal-parameters.js (default) -language/statements/class/definition/early-errors-class-method-body-contains-super-call.js (default) -language/statements/class/definition/early-errors-class-method-body-contains-super-call.js (strict mode) -language/statements/class/definition/early-errors-class-method-duplicate-parameters.js (default) -language/statements/class/definition/early-errors-class-method-eval-in-formal-parameters.js (default) -language/statements/class/definition/early-errors-class-method-formals-contains-super-call.js (default) -language/statements/class/definition/early-errors-class-method-formals-contains-super-call.js (strict mode) -language/statements/class/definition/methods-gen-yield-as-function-expression-binding-identifier.js (default) -language/statements/class/definition/methods-gen-yield-as-identifier-in-nested-function.js (default) -language/statements/class/method-param-yield.js (default) -language/statements/class/static-method-param-yield.js (default) -language/statements/class/strict-mode/with.js (default) -language/statements/class/syntax/early-errors/class-body-has-direct-super-missing-class-heritage.js (default) -language/statements/class/syntax/early-errors/class-body-has-direct-super-missing-class-heritage.js (strict mode) -language/statements/class/syntax/early-errors/class-body-method-contains-direct-super.js (default) -language/statements/class/syntax/early-errors/class-body-method-contains-direct-super.js (strict mode) -language/statements/class/syntax/early-errors/class-body-special-method-generator-contains-direct-super.js (default) -language/statements/class/syntax/early-errors/class-body-special-method-generator-contains-direct-super.js (strict mode) -language/statements/class/syntax/early-errors/class-body-special-method-get-contains-direct-super.js (default) -language/statements/class/syntax/early-errors/class-body-special-method-get-contains-direct-super.js (strict mode) -language/statements/class/syntax/early-errors/class-body-special-method-set-contains-direct-super.js (default) -language/statements/class/syntax/early-errors/class-body-special-method-set-contains-direct-super.js (strict mode) -language/statements/class/syntax/early-errors/class-body-static-method-contains-direct-super.js (default) -language/statements/class/syntax/early-errors/class-body-static-method-contains-direct-super.js (strict mode) -language/statements/class/syntax/early-errors/class-body-static-method-get-contains-direct-super.js (default) -language/statements/class/syntax/early-errors/class-body-static-method-get-contains-direct-super.js (strict mode) -language/statements/class/syntax/early-errors/class-body-static-method-set-contains-direct-super.js (default) -language/statements/class/syntax/early-errors/class-body-static-method-set-contains-direct-super.js (strict mode) -language/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js (default) -language/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js (strict mode) -language/statements/class/syntax/early-errors/class-definition-evaluation-scriptbody-duplicate-binding.js (default) -language/statements/class/syntax/early-errors/class-definition-evaluation-scriptbody-duplicate-binding.js (strict mode) -language/statements/const/syntax/const-declaring-let-split-across-two-lines.js (default) -language/statements/do-while/labelled-fn-stmt.js (default) -language/statements/for/head-let-bound-names-in-stmt.js (default) -language/statements/for/head-let-bound-names-in-stmt.js (strict mode) -language/statements/for-in/head-const-bound-names-in-stmt.js (default) -language/statements/for-in/head-const-bound-names-in-stmt.js (strict mode) -language/statements/for-in/head-const-bound-names-let.js (default) -language/statements/for-in/head-let-bound-names-in-stmt.js (default) -language/statements/for-in/head-let-bound-names-in-stmt.js (strict mode) -language/statements/for-in/head-let-bound-names-let.js (default) -language/statements/for-in/labelled-fn-stmt-const.js (default) -language/statements/for-in/labelled-fn-stmt-let.js (default) -language/statements/for-in/labelled-fn-stmt-lhs.js (default) -language/statements/for-in/labelled-fn-stmt-var.js (default) -language/statements/for-in/let-block-with-newline.js (default) -language/statements/for-in/let-identifier-with-newline.js (default) -language/statements/for/labelled-fn-stmt-expr.js (default) -language/statements/for/labelled-fn-stmt-let.js (default) -language/statements/for/labelled-fn-stmt-var.js (default) -language/statements/for/let-block-with-newline.js (default) -language/statements/for/let-identifier-with-newline.js (default) -language/statements/for-of/head-const-bound-names-in-stmt.js (default) -language/statements/for-of/head-const-bound-names-in-stmt.js (strict mode) -language/statements/for-of/head-const-bound-names-let.js (default) -language/statements/for-of/head-let-bound-names-in-stmt.js (default) -language/statements/for-of/head-let-bound-names-in-stmt.js (strict mode) -language/statements/for-of/head-let-bound-names-let.js (default) -language/statements/for-of/labelled-fn-stmt-const.js (default) -language/statements/for-of/labelled-fn-stmt-let.js (default) -language/statements/for-of/labelled-fn-stmt-lhs.js (default) -language/statements/for-of/labelled-fn-stmt-var.js (default) -language/statements/for-of/let-block-with-newline.js (default) -language/statements/for-of/let-identifier-with-newline.js (default) -language/statements/for-await-of/let-block-with-newline.js (default) -language/statements/for-await-of/let-identifier-with-newline.js (default) -language/statements/function/early-body-super-call.js (default) -language/statements/function/early-body-super-call.js (strict mode) -language/statements/function/early-body-super-prop.js (default) -language/statements/function/early-body-super-prop.js (strict mode) -language/statements/function/early-params-super-call.js (default) -language/statements/function/early-params-super-call.js (strict mode) -language/statements/function/early-params-super-prop.js (default) -language/statements/function/early-params-super-prop.js (strict mode) -language/statements/if/if-gen-else-gen.js (default) -language/statements/if/if-gen-else-stmt.js (default) -language/statements/if/if-gen-no-else.js (default) -language/statements/if/if-stmt-else-gen.js (default) -language/statements/if/labelled-fn-stmt-first.js (default) -language/statements/if/labelled-fn-stmt-lone.js (default) -language/statements/if/labelled-fn-stmt-second.js (default) -language/statements/if/let-block-with-newline.js (default) -language/statements/if/let-identifier-with-newline.js (default) -language/statements/labeled/let-block-with-newline.js (default) -language/statements/labeled/let-identifier-with-newline.js (default) -language/statements/let/syntax/identifier-let-disallowed-as-boundname.js (default) -language/statements/let/syntax/let-let-declaration-split-across-two-lines.js (default) -language/statements/let/syntax/let-let-declaration-with-initializer-split-across-two-lines.js (default) -language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) -language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-function-declaration.js (default) -language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-generator-declaration.js (default) -language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-var-declaration.js (default) -language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) -language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) -language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) -language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-function-declaration.js (default) -language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-generator-declaration.js (default) -language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-var-declaration.js (default) -language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) -language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) -language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) -language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-const-declaration.js (default) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-const-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-function-declaration.js (default) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-generator-declaration.js (default) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-let-declaration.js (default) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-let-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-var-declaration.js (default) -language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/const-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/statements/switch/syntax/redeclaration/const-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) -language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-generator-declaration.js (default) -language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-var-declaration.js (default) -language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) -language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-function-declaration.js (default) -language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-generator-declaration.js (default) -language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-var-declaration.js (default) -language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/let-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/statements/switch/syntax/redeclaration/let-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) -language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-class-declaration.js (default) -language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-function-declaration.js (default) -language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) -language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-generator-declaration.js (default) -language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) -language/statements/while/labelled-fn-stmt.js (default) -language/statements/while/let-block-with-newline.js (default) -language/statements/while/let-identifier-with-newline.js (default) -language/statements/with/labelled-fn-stmt.js (default) -language/statements/with/let-block-with-newline.js (default) -language/statements/with/let-identifier-with-newline.js (default) -language/white-space/mongolian-vowel-separator.js (default) -language/white-space/mongolian-vowel-separator.js (strict mode) diff --git a/tools/node_modules/eslint/node_modules/acorn/dist/.keep b/tools/node_modules/eslint/node_modules/acorn/dist/.keep deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/tools/node_modules/eslint/node_modules/acorn/dist/acorn.d.ts b/tools/node_modules/eslint/node_modules/acorn/dist/acorn.d.ts new file mode 100644 index 00000000000000..1c8d927d6ecc8c --- /dev/null +++ b/tools/node_modules/eslint/node_modules/acorn/dist/acorn.d.ts @@ -0,0 +1,208 @@ +export as namespace acorn +export = acorn + +declare namespace acorn { + function parse(input: string, options?: Options): Node + + function parseExpressionAt(input: string, pos?: number, options?: Options): Node + + function tokenizer(input: string, options?: Options): { + getToken(): Token + [Symbol.iterator](): Iterator + } + + interface Options { + ecmaVersion?: 3 | 5 | 6 | 7 | 8 | 9 | 10 | 2015 | 2016 | 2017 | 2018 | 2019 + sourceType?: 'script' | 'module' + onInsertedSemicolon?: (lastTokEnd: number, lastTokEndLoc?: Position) => void + onTrailingComma?: (lastTokEnd: number, lastTokEndLoc?: Position) => void + allowReserved?: boolean + allowReturnOutsideFunction?: boolean + allowImportExportEverywhere?: boolean + allowHashBang?: boolean + locations?: boolean + onToken?: ((token: Token) => any) | Token[] + onComment?: (( + isBlock: boolean, text: string, start: number, end: number, startLoc?: Position, + endLoc?: Position + ) => void) | Comment[] + ranges?: boolean + program?: Node + sourceFile?: string + directSourceFile?: string + preserveParens?: boolean + } + + class Parser { + constructor(options: Options, input: string, startPos?: number) + parse(): Node + static parse(input: string, options?: Options): Node + static parseExpressionAt(input: string, pos: number, options?: Options): Node + static tokenizer(input: string, options?: Options): { + getToken(): Token + [Symbol.iterator](): Iterator + } + static extend(...plugins: (typeof Parser)[]): typeof Parser + } + + interface Position { line: number; column: number; offset: number } + + const defaultOptions: Options + + function getLineInfo(input: string, offset: number): Position + + class SourceLocation { + start: Position + end: Position + source?: string | null + constructor(p: Parser, start: Position, end: Position) + } + + class Node { + type: string + start: number + end: number + loc?: SourceLocation + sourceFile?: string + range?: [number, number] + constructor(parser: Parser, pos: number, loc?: SourceLocation) + } + + class TokenType { + label: string + keyword: string + beforeExpr: boolean + startsExpr: boolean + isLoop: boolean + isAssign: boolean + prefix: boolean + postfix: boolean + binop: number + updateContext?: (prevType: TokenType) => void + constructor(label: string, conf?: any) + } + + const tokTypes: { + num: TokenType + regexp: TokenType + string: TokenType + name: TokenType + eof: TokenType + bracketL: TokenType + bracketR: TokenType + braceL: TokenType + braceR: TokenType + parenL: TokenType + parenR: TokenType + comma: TokenType + semi: TokenType + colon: TokenType + dot: TokenType + question: TokenType + arrow: TokenType + template: TokenType + ellipsis: TokenType + backQuote: TokenType + dollarBraceL: TokenType + eq: TokenType + assign: TokenType + incDec: TokenType + prefix: TokenType + logicalOR: TokenType + logicalAND: TokenType + bitwiseOR: TokenType + bitwiseXOR: TokenType + bitwiseAND: TokenType + equality: TokenType + relational: TokenType + bitShift: TokenType + plusMin: TokenType + modulo: TokenType + star: TokenType + slash: TokenType + starstar: TokenType + _break: TokenType + _case: TokenType + _catch: TokenType + _continue: TokenType + _debugger: TokenType + _default: TokenType + _do: TokenType + _else: TokenType + _finally: TokenType + _for: TokenType + _function: TokenType + _if: TokenType + _return: TokenType + _switch: TokenType + _throw: TokenType + _try: TokenType + _var: TokenType + _const: TokenType + _while: TokenType + _with: TokenType + _new: TokenType + _this: TokenType + _super: TokenType + _class: TokenType + _extends: TokenType + _export: TokenType + _import: TokenType + _null: TokenType + _true: TokenType + _false: TokenType + _in: TokenType + _instanceof: TokenType + _typeof: TokenType + _void: TokenType + _delete: TokenType + } + + class TokContext { + constructor(token: string, isExpr: boolean, preserveSpace: boolean, override?: (p: Parser) => void) + } + + const tokContexts: { + b_stat: TokContext + b_expr: TokContext + b_tmpl: TokContext + p_stat: TokContext + p_expr: TokContext + q_tmpl: TokContext + f_expr: TokContext + } + + function isIdentifierStart(code: number, astral?: boolean): boolean + + function isIdentifierChar(code: number, astral?: boolean): boolean + + interface AbstractToken { + } + + interface Comment extends AbstractToken { + type: string + value: string + start: number + end: number + loc?: SourceLocation + range?: [number, number] + } + + class Token { + type: TokenType + value: any + start: number + end: number + loc?: SourceLocation + range?: [number, number] + constructor(p: Parser) + } + + function isNewLine(code: number): boolean + + const lineBreak: RegExp + + const lineBreakG: RegExp + + const version: string +} diff --git a/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js b/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js index dada6a37a56339..922ff0c9fc9c1b 100644 --- a/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js +++ b/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js @@ -313,11 +313,12 @@ function getLineInfo(input, offset) { // the parser process. These options are recognized: var defaultOptions = { - // `ecmaVersion` indicates the ECMAScript version to parse. Must - // be either 3, 5, 6 (2015), 7 (2016), or 8 (2017). This influences support - // for strict mode, the set of reserved words, and support for - // new syntax features. The default is 7. - ecmaVersion: 7, + // `ecmaVersion` indicates the ECMAScript version to parse. Must be + // either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018), or 10 + // (2019). This influences support for strict mode, the set of + // reserved words, and support for new syntax features. The default + // is 9. + ecmaVersion: 9, // `sourceType` indicates the mode the code should be parsed in. // Can be either `"script"` or `"module"`. This influences global // strict mode and parsing of `import` and `export` declarations. @@ -393,8 +394,7 @@ var defaultOptions = { directSourceFile: null, // When enabled, parenthesized expressions are represented by // (non-standard) ParenthesizedExpression nodes - preserveParens: false, - plugins: {} + preserveParens: false }; // Interpret and default an options object @@ -437,8 +437,26 @@ function pushComment(options, array) { } } -// Registered plugins -var plugins = {}; +// Each scope gets a bitset that may contain these flags +var SCOPE_TOP = 1; +var SCOPE_FUNCTION = 2; +var SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION; +var SCOPE_ASYNC = 4; +var SCOPE_GENERATOR = 8; +var SCOPE_ARROW = 16; +var SCOPE_SIMPLE_CATCH = 32; + +function functionFlags(async, generator) { + return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0) +} + +// Used in checkLVal and declareName to determine the type of a binding +var BIND_NONE = 0; +var BIND_VAR = 1; +var BIND_LEXICAL = 2; +var BIND_FUNCTION = 3; +var BIND_SIMPLE_CATCH = 4; +var BIND_OUTSIDE = 5; // Special case for function names as bound inside the function function keywordRegexp(words) { return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$") @@ -465,9 +483,6 @@ var Parser = function Parser(options, input, startPos) { // escape sequences must not be interpreted as keywords. this.containsEsc = false; - // Load plugins - this.loadPlugins(options.plugins); - // Set up token state // The current position of the tokenizer in the input. @@ -508,8 +523,6 @@ var Parser = function Parser(options, input, startPos) { // Used to signify the start of a potential arrow function this.potentialArrowAt = -1; - // Flags to track whether we are in a function, a generator, an async function. - this.inFunction = this.inGenerator = this.inAsync = false; // Positions to delayed-check that yield/await does not exist in default parameters. this.yieldPos = this.awaitPos = 0; // Labels in scope. @@ -521,36 +534,49 @@ var Parser = function Parser(options, input, startPos) { // Scope tracking for duplicate variable names (see scope.js) this.scopeStack = []; - this.enterFunctionScope(); + this.enterScope(SCOPE_TOP); // For RegExp validation this.regexpState = null; }; -// DEPRECATED Kept for backwards compatibility until 3.0 in case a plugin uses them -Parser.prototype.isKeyword = function isKeyword (word) { return this.keywords.test(word) }; -Parser.prototype.isReservedWord = function isReservedWord (word) { return this.reservedWords.test(word) }; +var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true } }; -Parser.prototype.extend = function extend (name, f) { - this[name] = f(this[name]); +Parser.prototype.parse = function parse () { + var node = this.options.program || this.startNode(); + this.nextToken(); + return this.parseTopLevel(node) }; -Parser.prototype.loadPlugins = function loadPlugins (pluginConfigs) { - var this$1 = this; +prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 }; +prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 }; +prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 }; - for (var name in pluginConfigs) { - var plugin = plugins[name]; - if (!plugin) { throw new Error("Plugin '" + name + "' not found") } - plugin(this$1, pluginConfigs[name]); - } +Parser.extend = function extend () { + var plugins = [], len = arguments.length; + while ( len-- ) plugins[ len ] = arguments[ len ]; + + var cls = this; + for (var i = 0; i < plugins.length; i++) { cls = plugins[i](cls); } + return cls }; -Parser.prototype.parse = function parse () { - var node = this.options.program || this.startNode(); - this.nextToken(); - return this.parseTopLevel(node) +Parser.parse = function parse (input, options) { + return new this(options, input).parse() +}; + +Parser.parseExpressionAt = function parseExpressionAt (input, pos, options) { + var parser = new this(options, input, pos); + parser.nextToken(); + return parser.parseExpression() }; +Parser.tokenizer = function tokenizer (input, options) { + return new this(options, input) +}; + +Object.defineProperties( Parser.prototype, prototypeAccessors ); + var pp = Parser.prototype; // ## Parser utilities @@ -703,7 +729,7 @@ pp$1.parseTopLevel = function(node) { var exports = {}; if (!node.body) { node.body = []; } while (this.type !== types.eof) { - var stmt = this$1.parseStatement(true, true, exports); + var stmt = this$1.parseStatement(null, true, exports); node.body.push(stmt); } this.adaptDirectivePrologue(node.body); @@ -754,7 +780,7 @@ pp$1.isAsyncFunction = function() { // `if (foo) /blah/.exec(foo)`, where looking at the previous token // does not help. -pp$1.parseStatement = function(declaration, topLevel, exports) { +pp$1.parseStatement = function(context, topLevel, exports) { var starttype = this.type, node = this.startNode(), kind; if (this.isLet()) { @@ -772,10 +798,10 @@ pp$1.parseStatement = function(declaration, topLevel, exports) { case types._do: return this.parseDoStatement(node) case types._for: return this.parseForStatement(node) case types._function: - if (!declaration && this.options.ecmaVersion >= 6) { this.unexpected(); } - return this.parseFunctionStatement(node, false) + if ((context && (this.strict || context !== "if")) && this.options.ecmaVersion >= 6) { this.unexpected(); } + return this.parseFunctionStatement(node, false, !context) case types._class: - if (!declaration) { this.unexpected(); } + if (context) { this.unexpected(); } return this.parseClass(node, true) case types._if: return this.parseIfStatement(node) case types._return: return this.parseReturnStatement(node) @@ -784,11 +810,11 @@ pp$1.parseStatement = function(declaration, topLevel, exports) { case types._try: return this.parseTryStatement(node) case types._const: case types._var: kind = kind || this.value; - if (!declaration && kind !== "var") { this.unexpected(); } + if (context && kind !== "var") { this.unexpected(); } return this.parseVarStatement(node, kind) case types._while: return this.parseWhileStatement(node) case types._with: return this.parseWithStatement(node) - case types.braceL: return this.parseBlock() + case types.braceL: return this.parseBlock(true, node) case types.semi: return this.parseEmptyStatement(node) case types._export: case types._import: @@ -807,14 +833,14 @@ pp$1.parseStatement = function(declaration, topLevel, exports) { // Identifier node, we switch to interpreting it as a label. default: if (this.isAsyncFunction()) { - if (!declaration) { this.unexpected(); } + if (context) { this.unexpected(); } this.next(); - return this.parseFunctionStatement(node, true) + return this.parseFunctionStatement(node, true, !context) } var maybeName = this.value, expr = this.parseExpression(); if (starttype === types.name && expr.type === "Identifier" && this.eat(types.colon)) - { return this.parseLabeledStatement(node, maybeName, expr) } + { return this.parseLabeledStatement(node, maybeName, expr, context) } else { return this.parseExpressionStatement(node, expr) } } }; @@ -854,7 +880,7 @@ pp$1.parseDebuggerStatement = function(node) { pp$1.parseDoStatement = function(node) { this.next(); this.labels.push(loopLabel); - node.body = this.parseStatement(false); + node.body = this.parseStatement("do"); this.labels.pop(); this.expect(types._while); node.test = this.parseParenExpression(); @@ -877,7 +903,7 @@ pp$1.parseForStatement = function(node) { this.next(); var awaitAt = (this.options.ecmaVersion >= 9 && (this.inAsync || (!this.inFunction && this.options.allowAwaitOutsideFunction)) && this.eatContextual("await")) ? this.lastTokStart : -1; this.labels.push(loopLabel); - this.enterLexicalScope(); + this.enterScope(0); this.expect(types.parenL); if (this.type === types.semi) { if (awaitAt > -1) { this.unexpected(awaitAt); } @@ -919,17 +945,17 @@ pp$1.parseForStatement = function(node) { return this.parseFor(node, init) }; -pp$1.parseFunctionStatement = function(node, isAsync) { +pp$1.parseFunctionStatement = function(node, isAsync, declarationPosition) { this.next(); - return this.parseFunction(node, true, false, isAsync) + return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync) }; pp$1.parseIfStatement = function(node) { this.next(); node.test = this.parseParenExpression(); // allow function declarations in branches, but only in non-strict mode - node.consequent = this.parseStatement(!this.strict && this.type === types._function); - node.alternate = this.eat(types._else) ? this.parseStatement(!this.strict && this.type === types._function) : null; + node.consequent = this.parseStatement("if"); + node.alternate = this.eat(types._else) ? this.parseStatement("if") : null; return this.finishNode(node, "IfStatement") }; @@ -955,7 +981,7 @@ pp$1.parseSwitchStatement = function(node) { node.cases = []; this.expect(types.braceL); this.labels.push(switchLabel); - this.enterLexicalScope(); + this.enterScope(0); // Statements under must be grouped (by label) in SwitchCase // nodes. `cur` is used to keep the node that we are currently @@ -979,10 +1005,10 @@ pp$1.parseSwitchStatement = function(node) { this$1.expect(types.colon); } else { if (!cur) { this$1.unexpected(); } - cur.consequent.push(this$1.parseStatement(true)); + cur.consequent.push(this$1.parseStatement(null)); } } - this.exitLexicalScope(); + this.exitScope(); if (cur) { this.finishNode(cur, "SwitchCase"); } this.next(); // Closing brace this.labels.pop(); @@ -1011,16 +1037,17 @@ pp$1.parseTryStatement = function(node) { this.next(); if (this.eat(types.parenL)) { clause.param = this.parseBindingAtom(); - this.enterLexicalScope(); - this.checkLVal(clause.param, "let"); + var simple = clause.param.type === "Identifier"; + this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0); + this.checkLVal(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL); this.expect(types.parenR); } else { if (this.options.ecmaVersion < 10) { this.unexpected(); } clause.param = null; - this.enterLexicalScope(); + this.enterScope(0); } clause.body = this.parseBlock(false); - this.exitLexicalScope(); + this.exitScope(); node.handler = this.finishNode(clause, "CatchClause"); } node.finalizer = this.eat(types._finally) ? this.parseBlock() : null; @@ -1040,7 +1067,7 @@ pp$1.parseWhileStatement = function(node) { this.next(); node.test = this.parseParenExpression(); this.labels.push(loopLabel); - node.body = this.parseStatement(false); + node.body = this.parseStatement("while"); this.labels.pop(); return this.finishNode(node, "WhileStatement") }; @@ -1049,7 +1076,7 @@ pp$1.parseWithStatement = function(node) { if (this.strict) { this.raise(this.start, "'with' in strict mode"); } this.next(); node.object = this.parseParenExpression(); - node.body = this.parseStatement(false); + node.body = this.parseStatement("with"); return this.finishNode(node, "WithStatement") }; @@ -1058,7 +1085,7 @@ pp$1.parseEmptyStatement = function(node) { return this.finishNode(node, "EmptyStatement") }; -pp$1.parseLabeledStatement = function(node, maybeName, expr) { +pp$1.parseLabeledStatement = function(node, maybeName, expr, context) { var this$1 = this; for (var i$1 = 0, list = this$1.labels; i$1 < list.length; i$1 += 1) @@ -1078,7 +1105,7 @@ pp$1.parseLabeledStatement = function(node, maybeName, expr) { } else { break } } this.labels.push({name: maybeName, kind: kind, statementStart: this.start}); - node.body = this.parseStatement(true); + node.body = this.parseStatement(context); if (node.body.type === "ClassDeclaration" || node.body.type === "VariableDeclaration" && node.body.kind !== "var" || node.body.type === "FunctionDeclaration" && (this.strict || node.body.generator || node.body.async)) @@ -1098,23 +1125,19 @@ pp$1.parseExpressionStatement = function(node, expr) { // strict"` declarations when `allowStrict` is true (used for // function bodies). -pp$1.parseBlock = function(createNewLexicalScope) { +pp$1.parseBlock = function(createNewLexicalScope, node) { var this$1 = this; if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true; + if ( node === void 0 ) node = this.startNode(); - var node = this.startNode(); node.body = []; this.expect(types.braceL); - if (createNewLexicalScope) { - this.enterLexicalScope(); - } + if (createNewLexicalScope) { this.enterScope(0); } while (!this.eat(types.braceR)) { - var stmt = this$1.parseStatement(true); + var stmt = this$1.parseStatement(null); node.body.push(stmt); } - if (createNewLexicalScope) { - this.exitLexicalScope(); - } + if (createNewLexicalScope) { this.exitScope(); } return this.finishNode(node, "BlockStatement") }; @@ -1129,8 +1152,8 @@ pp$1.parseFor = function(node, init) { this.expect(types.semi); node.update = this.type === types.parenR ? null : this.parseExpression(); this.expect(types.parenR); - this.exitLexicalScope(); - node.body = this.parseStatement(false); + this.exitScope(); + node.body = this.parseStatement("for"); this.labels.pop(); return this.finishNode(node, "ForStatement") }; @@ -1150,8 +1173,8 @@ pp$1.parseForIn = function(node, init) { node.left = init; node.right = type === "ForInStatement" ? this.parseExpression() : this.parseMaybeAssign(); this.expect(types.parenR); - this.exitLexicalScope(); - node.body = this.parseStatement(false); + this.exitScope(); + node.body = this.parseStatement("for"); this.labels.pop(); return this.finishNode(node, type) }; @@ -1183,47 +1206,43 @@ pp$1.parseVar = function(node, isFor, kind) { pp$1.parseVarId = function(decl, kind) { decl.id = this.parseBindingAtom(kind); - this.checkLVal(decl.id, kind, false); + this.checkLVal(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false); }; +var FUNC_STATEMENT = 1; +var FUNC_HANGING_STATEMENT = 2; +var FUNC_NULLABLE_ID = 4; + // Parse a function declaration or literal (depending on the // `isStatement` parameter). -pp$1.parseFunction = function(node, isStatement, allowExpressionBody, isAsync) { +pp$1.parseFunction = function(node, statement, allowExpressionBody, isAsync) { this.initFunction(node); if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) { node.generator = this.eat(types.star); } if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; } - if (isStatement) { - node.id = isStatement === "nullableID" && this.type !== types.name ? null : this.parseIdent(); - if (node.id) { - this.checkLVal(node.id, this.inModule && !this.inFunction ? "let" : "var"); - } + if (statement & FUNC_STATEMENT) { + node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types.name ? null : this.parseIdent(); + if (node.id && !(statement & FUNC_HANGING_STATEMENT)) + { this.checkLVal(node.id, this.inModule && !this.inFunction ? BIND_LEXICAL : BIND_FUNCTION); } } - var oldInGen = this.inGenerator, oldInAsync = this.inAsync, - oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction; - this.inGenerator = node.generator; - this.inAsync = node.async; + var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos; this.yieldPos = 0; this.awaitPos = 0; - this.inFunction = true; - this.enterFunctionScope(); + this.enterScope(functionFlags(node.async, node.generator)); - if (!isStatement) + if (!(statement & FUNC_STATEMENT)) { node.id = this.type === types.name ? this.parseIdent() : null; } this.parseFunctionParams(node); this.parseFunctionBody(node, allowExpressionBody); - this.inGenerator = oldInGen; - this.inAsync = oldInAsync; this.yieldPos = oldYieldPos; this.awaitPos = oldAwaitPos; - this.inFunction = oldInFunc; - return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression") + return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression") }; pp$1.parseFunctionParams = function(node) { @@ -1247,17 +1266,20 @@ pp$1.parseClass = function(node, isStatement) { classBody.body = []; this.expect(types.braceL); while (!this.eat(types.braceR)) { - var member = this$1.parseClassMember(classBody); - if (member && member.type === "MethodDefinition" && member.kind === "constructor") { - if (hadConstructor) { this$1.raise(member.start, "Duplicate constructor in the same class"); } - hadConstructor = true; + var element = this$1.parseClassElement(); + if (element) { + classBody.body.push(element); + if (element.type === "MethodDefinition" && element.kind === "constructor") { + if (hadConstructor) { this$1.raise(element.start, "Duplicate constructor in the same class"); } + hadConstructor = true; + } } } node.body = this.finishNode(classBody, "ClassBody"); return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression") }; -pp$1.parseClassMember = function(classBody) { +pp$1.parseClassElement = function() { var this$1 = this; if (this.eat(types.semi)) { return null } @@ -1302,7 +1324,7 @@ pp$1.parseClassMember = function(classBody) { } else if (method.static && key.type === "Identifier" && key.name === "prototype") { this.raise(key.start, "Classes may not have a static property named prototype"); } - this.parseClassMethod(classBody, method, isGenerator, isAsync); + this.parseClassMethod(method, isGenerator, isAsync); if (method.kind === "get" && method.value.params.length !== 0) { this.raiseRecoverable(method.value.start, "getter should have no params"); } if (method.kind === "set" && method.value.params.length !== 1) @@ -1312,9 +1334,9 @@ pp$1.parseClassMember = function(classBody) { return method }; -pp$1.parseClassMethod = function(classBody, method, isGenerator, isAsync) { +pp$1.parseClassMethod = function(method, isGenerator, isAsync) { method.value = this.parseMethod(isGenerator, isAsync); - classBody.body.push(this.finishNode(method, "MethodDefinition")); + return this.finishNode(method, "MethodDefinition") }; pp$1.parseClassId = function(node, isStatement) { @@ -1346,7 +1368,7 @@ pp$1.parseExport = function(node, exports) { var fNode = this.startNode(); this.next(); if (isAsync) { this.next(); } - node.declaration = this.parseFunction(fNode, "nullableID", false, isAsync); + node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync, true); } else if (this.type === types._class) { var cNode = this.startNode(); node.declaration = this.parseClass(cNode, "nullableID"); @@ -1358,7 +1380,7 @@ pp$1.parseExport = function(node, exports) { } // export var|const|let|function|class ... if (this.shouldParseExportStatement()) { - node.declaration = this.parseStatement(true); + node.declaration = this.parseStatement(null); if (node.declaration.type === "VariableDeclaration") { this.checkVariableExport(exports, node.declaration.declarations); } else @@ -1493,7 +1515,7 @@ pp$1.parseImportSpecifiers = function() { // import defaultObj, { x, y as z } from '...' var node = this.startNode(); node.local = this.parseIdent(); - this.checkLVal(node.local, "let"); + this.checkLVal(node.local, BIND_LEXICAL); nodes.push(this.finishNode(node, "ImportDefaultSpecifier")); if (!this.eat(types.comma)) { return nodes } } @@ -1502,7 +1524,7 @@ pp$1.parseImportSpecifiers = function() { this.next(); this.expectContextual("as"); node$1.local = this.parseIdent(); - this.checkLVal(node$1.local, "let"); + this.checkLVal(node$1.local, BIND_LEXICAL); nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier")); return nodes } @@ -1521,7 +1543,7 @@ pp$1.parseImportSpecifiers = function() { this$1.checkUnreserved(node$2.imported); node$2.local = node$2.imported; } - this$1.checkLVal(node$2.local, "let"); + this$1.checkLVal(node$2.local, BIND_LEXICAL); nodes.push(this$1.finishNode(node$2, "ImportSpecifier")); } return nodes @@ -1736,6 +1758,7 @@ pp$2.parseMaybeDefault = function(startPos, startLoc, left) { pp$2.checkLVal = function(expr, bindingType, checkClashes) { var this$1 = this; + if ( bindingType === void 0 ) bindingType = BIND_NONE; switch (expr.type) { case "Identifier": @@ -1746,19 +1769,7 @@ pp$2.checkLVal = function(expr, bindingType, checkClashes) { { this.raiseRecoverable(expr.start, "Argument name clash"); } checkClashes[expr.name] = true; } - if (bindingType && bindingType !== "none") { - if ( - bindingType === "var" && !this.canDeclareVarName(expr.name) || - bindingType !== "var" && !this.canDeclareLexicalName(expr.name) - ) { - this.raiseRecoverable(expr.start, ("Identifier '" + (expr.name) + "' has already been declared")); - } - if (bindingType === "var") { - this.declareVarName(expr.name); - } else { - this.declareLexicalName(expr.name); - } - } + if (bindingType !== BIND_NONE && bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); } break case "MemberExpression": @@ -1907,13 +1918,19 @@ pp$3.parseExpression = function(noIn, refDestructuringErrors) { // operators like `+=`. pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) { - if (this.inGenerator && this.isContextual("yield")) { return this.parseYield() } + if (this.isContextual("yield")) { + if (this.inGenerator) { return this.parseYield() } + // The tokenizer will assume an expression is allowed after + // `yield`, but this isn't that kind of yield + else { this.exprAllowed = false; } + } - var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1; + var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldShorthandAssign = -1; if (refDestructuringErrors) { oldParenAssign = refDestructuringErrors.parenthesizedAssign; oldTrailingComma = refDestructuringErrors.trailingComma; - refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1; + oldShorthandAssign = refDestructuringErrors.shorthandAssign; + refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.shorthandAssign = -1; } else { refDestructuringErrors = new DestructuringErrors; ownDestructuringErrors = true; @@ -1939,6 +1956,7 @@ pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) { } if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; } if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; } + if (oldShorthandAssign > -1) { refDestructuringErrors.shorthandAssign = oldShorthandAssign; } return left }; @@ -2130,7 +2148,7 @@ pp$3.parseExprAtom = function(refDestructuringErrors) { var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc; var id = this.parseIdent(this.type !== types.name); if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types._function)) - { return this.parseFunction(this.startNodeAt(startPos, startLoc), false, false, true) } + { return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true) } if (canBeArrow && !this.canInsertSemicolon()) { if (this.eat(types.arrow)) { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false) } @@ -2181,7 +2199,7 @@ pp$3.parseExprAtom = function(refDestructuringErrors) { case types._function: node = this.startNode(); this.next(); - return this.parseFunction(node, false) + return this.parseFunction(node, 0) case types._class: return this.parseClass(this.startNode(), false) @@ -2300,7 +2318,7 @@ pp$3.parseNew = function() { node.property = this.parseIdent(true); if (node.property.name !== "target" || containsEsc) { this.raiseRecoverable(node.property.start, "The only valid meta property for new is new.target"); } - if (!this.inFunction) + if (!this.inNonArrowFunction()) { this.raiseRecoverable(node.start, "new.target can only be used in functions"); } return this.finishNode(node, "MetaProperty") } @@ -2500,19 +2518,14 @@ pp$3.parsePropertyName = function(prop) { pp$3.initFunction = function(node) { node.id = null; - if (this.options.ecmaVersion >= 6) { - node.generator = false; - node.expression = false; - } - if (this.options.ecmaVersion >= 8) - { node.async = false; } + if (this.options.ecmaVersion >= 6) { node.generator = node.expression = false; } + if (this.options.ecmaVersion >= 8) { node.async = false; } }; // Parse object or class method. pp$3.parseMethod = function(isGenerator, isAsync) { - var node = this.startNode(), oldInGen = this.inGenerator, oldInAsync = this.inAsync, - oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction; + var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos; this.initFunction(node); if (this.options.ecmaVersion >= 6) @@ -2520,51 +2533,37 @@ pp$3.parseMethod = function(isGenerator, isAsync) { if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; } - this.inGenerator = node.generator; - this.inAsync = node.async; this.yieldPos = 0; this.awaitPos = 0; - this.inFunction = true; - this.enterFunctionScope(); + this.enterScope(functionFlags(isAsync, node.generator)); this.expect(types.parenL); node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8); this.checkYieldAwaitInDefaultParams(); this.parseFunctionBody(node, false); - this.inGenerator = oldInGen; - this.inAsync = oldInAsync; this.yieldPos = oldYieldPos; this.awaitPos = oldAwaitPos; - this.inFunction = oldInFunc; return this.finishNode(node, "FunctionExpression") }; // Parse arrow function expression with given parameters. pp$3.parseArrowExpression = function(node, params, isAsync) { - var oldInGen = this.inGenerator, oldInAsync = this.inAsync, - oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction; + var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos; - this.enterFunctionScope(); + this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW); this.initFunction(node); - if (this.options.ecmaVersion >= 8) - { node.async = !!isAsync; } + if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; } - this.inGenerator = false; - this.inAsync = node.async; this.yieldPos = 0; this.awaitPos = 0; - this.inFunction = true; node.params = this.toAssignableList(params, true); this.parseFunctionBody(node, true); - this.inGenerator = oldInGen; - this.inAsync = oldInAsync; this.yieldPos = oldYieldPos; this.awaitPos = oldAwaitPos; - this.inFunction = oldInFunc; return this.finishNode(node, "ArrowFunctionExpression") }; @@ -2602,12 +2601,10 @@ pp$3.parseFunctionBody = function(node, isArrowFunction) { this.adaptDirectivePrologue(node.body.body); this.labels = oldLabels; } - this.exitFunctionScope(); + this.exitScope(); - if (this.strict && node.id) { - // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval' - this.checkLVal(node.id, "none"); - } + // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval' + if (this.strict && node.id) { this.checkLVal(node.id, BIND_OUTSIDE); } this.strict = oldStrict; }; @@ -2632,7 +2629,7 @@ pp$3.checkParams = function(node, allowDuplicates) { { var param = list[i]; - this$1.checkLVal(param, "var", allowDuplicates ? null : nameHash); + this$1.checkLVal(param, BIND_VAR, allowDuplicates ? null : nameHash); } }; @@ -2676,7 +2673,7 @@ pp$3.checkUnreserved = function(ref) { { this.raiseRecoverable(start, "Can not use 'yield' as identifier inside a generator"); } if (this.inAsync && name === "await") { this.raiseRecoverable(start, "Can not use 'await' as identifier inside an async function"); } - if (this.isKeyword(name)) + if (this.keywords.test(name)) { this.raise(start, ("Unexpected keyword '" + name + "'")); } if (this.options.ecmaVersion < 6 && this.input.slice(start, end).indexOf("\\") !== -1) { return } @@ -2769,79 +2766,69 @@ pp$4.curPosition = function() { var pp$5 = Parser.prototype; -// Object.assign polyfill -var assign = Object.assign || function(target) { - var sources = [], len = arguments.length - 1; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; - - for (var i = 0, list = sources; i < list.length; i += 1) { - var source = list[i]; - - for (var key in source) { - if (has(source, key)) { - target[key] = source[key]; - } - } - } - return target +var Scope = function Scope(flags) { + this.flags = flags; + // A list of var-declared names in the current lexical scope + this.var = []; + // A list of lexically-declared names in the current lexical scope + this.lexical = []; }; // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names. -pp$5.enterFunctionScope = function() { - // var: a hash of var-declared names in the current lexical scope - // lexical: a hash of lexically-declared names in the current lexical scope - // childVar: a hash of var-declared names in all child lexical scopes of the current lexical scope (within the current function scope) - // parentLexical: a hash of lexically-declared names in all parent lexical scopes of the current lexical scope (within the current function scope) - this.scopeStack.push({var: {}, lexical: {}, childVar: {}, parentLexical: {}}); +pp$5.enterScope = function(flags) { + this.scopeStack.push(new Scope(flags)); }; -pp$5.exitFunctionScope = function() { +pp$5.exitScope = function() { this.scopeStack.pop(); }; -pp$5.enterLexicalScope = function() { - var parentScope = this.scopeStack[this.scopeStack.length - 1]; - var childScope = {var: {}, lexical: {}, childVar: {}, parentLexical: {}}; - - this.scopeStack.push(childScope); - assign(childScope.parentLexical, parentScope.lexical, parentScope.parentLexical); -}; - -pp$5.exitLexicalScope = function() { - var childScope = this.scopeStack.pop(); - var parentScope = this.scopeStack[this.scopeStack.length - 1]; +pp$5.declareName = function(name, bindingType, pos) { + var this$1 = this; - assign(parentScope.childVar, childScope.var, childScope.childVar); + var redeclared = false; + if (bindingType === BIND_LEXICAL) { + var scope = this.currentScope(); + redeclared = scope.lexical.indexOf(name) > -1 || scope.var.indexOf(name) > -1; + scope.lexical.push(name); + } else if (bindingType === BIND_SIMPLE_CATCH) { + var scope$1 = this.currentScope(); + scope$1.lexical.push(name); + } else if (bindingType === BIND_FUNCTION) { + var scope$2 = this.currentScope(); + redeclared = scope$2.lexical.indexOf(name) > -1; + scope$2.var.push(name); + } else { + for (var i = this.scopeStack.length - 1; i >= 0; --i) { + var scope$3 = this$1.scopeStack[i]; + if (scope$3.lexical.indexOf(name) > -1 && !(scope$3.flags & SCOPE_SIMPLE_CATCH) && scope$3.lexical[0] === name) { redeclared = true; } + scope$3.var.push(name); + if (scope$3.flags & SCOPE_VAR) { break } + } + } + if (redeclared) { this.raiseRecoverable(pos, ("Identifier '" + name + "' has already been declared")); } }; -/** - * A name can be declared with `var` if there are no variables with the same name declared with `let`/`const` - * in the current lexical scope or any of the parent lexical scopes in this function. - */ -pp$5.canDeclareVarName = function(name) { - var currentScope = this.scopeStack[this.scopeStack.length - 1]; - - return !has(currentScope.lexical, name) && !has(currentScope.parentLexical, name) +pp$5.currentScope = function() { + return this.scopeStack[this.scopeStack.length - 1] }; -/** - * A name can be declared with `let`/`const` if there are no variables with the same name declared with `let`/`const` - * in the current scope, and there are no variables with the same name declared with `var` in the current scope or in - * any child lexical scopes in this function. - */ -pp$5.canDeclareLexicalName = function(name) { - var currentScope = this.scopeStack[this.scopeStack.length - 1]; +pp$5.currentVarScope = function() { + var this$1 = this; - return !has(currentScope.lexical, name) && !has(currentScope.var, name) && !has(currentScope.childVar, name) + for (var i = this.scopeStack.length - 1;; i--) { + var scope = this$1.scopeStack[i]; + if (scope.flags & SCOPE_VAR) { return scope } + } }; -pp$5.declareVarName = function(name) { - this.scopeStack[this.scopeStack.length - 1].var[name] = true; -}; +pp$5.inNonArrowFunction = function() { + var this$1 = this; -pp$5.declareLexicalName = function(name) { - this.scopeStack[this.scopeStack.length - 1].lexical[name] = true; + for (var i = this.scopeStack.length - 1; i >= 0; i--) + { if (this$1.scopeStack[i].flags & SCOPE_FUNCTION && !(this$1.scopeStack[i].flags & SCOPE_ARROW)) { return true } } + return false }; var Node = function Node(parser, pos, loc) { @@ -5268,14 +5255,9 @@ pp$8.readWord = function() { // // [ghbt]: https://github.com/acornjs/acorn/issues // -// This file defines the main parser interface. The library also comes -// with a [error-tolerant parser][dammit] and an -// [abstract syntax tree walker][walk], defined in other files. -// -// [dammit]: acorn_loose.js // [walk]: util/walk.js -var version = "5.7.3"; +var version = "6.0.2"; // The main exported interface (under `self.acorn` when in the // browser) is a `parse` function that takes a code string and @@ -5285,7 +5267,7 @@ var version = "5.7.3"; // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API function parse(input, options) { - return new Parser(options, input).parse() + return Parser.parse(input, options) } // This function tries to parse a single expression at a given @@ -5293,35 +5275,21 @@ function parse(input, options) { // that embed JavaScript expressions. function parseExpressionAt(input, pos, options) { - var p = new Parser(options, input, pos); - p.nextToken(); - return p.parseExpression() + return Parser.parseExpressionAt(input, pos, options) } // Acorn is organized as a tokenizer and a recursive-descent parser. // The `tokenizer` export provides an interface to the tokenizer. function tokenizer(input, options) { - return new Parser(options, input) -} - -// This is a terrible kludge to support the existing, pre-ES6 -// interface where the loose parser module retroactively adds exports -// to this module. - // eslint-disable-line camelcase -function addLooseExports(parse, Parser$$1, plugins$$1) { - exports.parse_dammit = parse; // eslint-disable-line camelcase - exports.LooseParser = Parser$$1; - exports.pluginsLoose = plugins$$1; + return Parser.tokenizer(input, options) } exports.version = version; exports.parse = parse; exports.parseExpressionAt = parseExpressionAt; exports.tokenizer = tokenizer; -exports.addLooseExports = addLooseExports; exports.Parser = Parser; -exports.plugins = plugins; exports.defaultOptions = defaultOptions; exports.Position = Position; exports.SourceLocation = SourceLocation; @@ -5343,3 +5311,4 @@ exports.nonASCIIwhitespace = nonASCIIwhitespace; Object.defineProperty(exports, '__esModule', { value: true }); }))); +//# sourceMappingURL=acorn.js.map diff --git a/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js.map b/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js.map new file mode 100644 index 00000000000000..57c8681c2eac8e --- /dev/null +++ b/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js.map @@ -0,0 +1 @@ +{"version":3,"file":"acorn.js","sources":["../src/identifier.js","../src/tokentype.js","../src/whitespace.js","../src/util.js","../src/locutil.js","../src/options.js","../src/scopeflags.js","../src/state.js","../src/parseutil.js","../src/statement.js","../src/lval.js","../src/expression.js","../src/location.js","../src/scope.js","../src/node.js","../src/tokencontext.js","../src/unicode-property-data.js","../src/regexp.js","../src/tokenize.js","../src/index.js"],"sourcesContent":["// Reserved word lists for various dialects of the language\n\nexport const reservedWords = {\n 3: \"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile\",\n 5: \"class enum extends super const export import\",\n 6: \"enum\",\n strict: \"implements interface let package private protected public static yield\",\n strictBind: \"eval arguments\"\n}\n\n// And the keywords\n\nconst ecma5AndLessKeywords = \"break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this\"\n\nexport const keywords = {\n 5: ecma5AndLessKeywords,\n 6: ecma5AndLessKeywords + \" const class extends export import super\"\n}\n\nexport const keywordRelationalOperator = /^in(stanceof)?$/\n\n// ## Character categories\n\n// Big ugly regular expressions that match characters in the\n// whitespace, identifier, and identifier-start categories. These\n// are only applied when a character is found to actually have a\n// code point above 128.\n// Generated by `bin/generate-identifier-regex.js`.\n\nlet nonASCIIidentifierStartChars = \"\\xaa\\xb5\\xba\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02c1\\u02c6-\\u02d1\\u02e0-\\u02e4\\u02ec\\u02ee\\u0370-\\u0374\\u0376\\u0377\\u037a-\\u037d\\u037f\\u0386\\u0388-\\u038a\\u038c\\u038e-\\u03a1\\u03a3-\\u03f5\\u03f7-\\u0481\\u048a-\\u052f\\u0531-\\u0556\\u0559\\u0560-\\u0588\\u05d0-\\u05ea\\u05ef-\\u05f2\\u0620-\\u064a\\u066e\\u066f\\u0671-\\u06d3\\u06d5\\u06e5\\u06e6\\u06ee\\u06ef\\u06fa-\\u06fc\\u06ff\\u0710\\u0712-\\u072f\\u074d-\\u07a5\\u07b1\\u07ca-\\u07ea\\u07f4\\u07f5\\u07fa\\u0800-\\u0815\\u081a\\u0824\\u0828\\u0840-\\u0858\\u0860-\\u086a\\u08a0-\\u08b4\\u08b6-\\u08bd\\u0904-\\u0939\\u093d\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098c\\u098f\\u0990\\u0993-\\u09a8\\u09aa-\\u09b0\\u09b2\\u09b6-\\u09b9\\u09bd\\u09ce\\u09dc\\u09dd\\u09df-\\u09e1\\u09f0\\u09f1\\u09fc\\u0a05-\\u0a0a\\u0a0f\\u0a10\\u0a13-\\u0a28\\u0a2a-\\u0a30\\u0a32\\u0a33\\u0a35\\u0a36\\u0a38\\u0a39\\u0a59-\\u0a5c\\u0a5e\\u0a72-\\u0a74\\u0a85-\\u0a8d\\u0a8f-\\u0a91\\u0a93-\\u0aa8\\u0aaa-\\u0ab0\\u0ab2\\u0ab3\\u0ab5-\\u0ab9\\u0abd\\u0ad0\\u0ae0\\u0ae1\\u0af9\\u0b05-\\u0b0c\\u0b0f\\u0b10\\u0b13-\\u0b28\\u0b2a-\\u0b30\\u0b32\\u0b33\\u0b35-\\u0b39\\u0b3d\\u0b5c\\u0b5d\\u0b5f-\\u0b61\\u0b71\\u0b83\\u0b85-\\u0b8a\\u0b8e-\\u0b90\\u0b92-\\u0b95\\u0b99\\u0b9a\\u0b9c\\u0b9e\\u0b9f\\u0ba3\\u0ba4\\u0ba8-\\u0baa\\u0bae-\\u0bb9\\u0bd0\\u0c05-\\u0c0c\\u0c0e-\\u0c10\\u0c12-\\u0c28\\u0c2a-\\u0c39\\u0c3d\\u0c58-\\u0c5a\\u0c60\\u0c61\\u0c80\\u0c85-\\u0c8c\\u0c8e-\\u0c90\\u0c92-\\u0ca8\\u0caa-\\u0cb3\\u0cb5-\\u0cb9\\u0cbd\\u0cde\\u0ce0\\u0ce1\\u0cf1\\u0cf2\\u0d05-\\u0d0c\\u0d0e-\\u0d10\\u0d12-\\u0d3a\\u0d3d\\u0d4e\\u0d54-\\u0d56\\u0d5f-\\u0d61\\u0d7a-\\u0d7f\\u0d85-\\u0d96\\u0d9a-\\u0db1\\u0db3-\\u0dbb\\u0dbd\\u0dc0-\\u0dc6\\u0e01-\\u0e30\\u0e32\\u0e33\\u0e40-\\u0e46\\u0e81\\u0e82\\u0e84\\u0e87\\u0e88\\u0e8a\\u0e8d\\u0e94-\\u0e97\\u0e99-\\u0e9f\\u0ea1-\\u0ea3\\u0ea5\\u0ea7\\u0eaa\\u0eab\\u0ead-\\u0eb0\\u0eb2\\u0eb3\\u0ebd\\u0ec0-\\u0ec4\\u0ec6\\u0edc-\\u0edf\\u0f00\\u0f40-\\u0f47\\u0f49-\\u0f6c\\u0f88-\\u0f8c\\u1000-\\u102a\\u103f\\u1050-\\u1055\\u105a-\\u105d\\u1061\\u1065\\u1066\\u106e-\\u1070\\u1075-\\u1081\\u108e\\u10a0-\\u10c5\\u10c7\\u10cd\\u10d0-\\u10fa\\u10fc-\\u1248\\u124a-\\u124d\\u1250-\\u1256\\u1258\\u125a-\\u125d\\u1260-\\u1288\\u128a-\\u128d\\u1290-\\u12b0\\u12b2-\\u12b5\\u12b8-\\u12be\\u12c0\\u12c2-\\u12c5\\u12c8-\\u12d6\\u12d8-\\u1310\\u1312-\\u1315\\u1318-\\u135a\\u1380-\\u138f\\u13a0-\\u13f5\\u13f8-\\u13fd\\u1401-\\u166c\\u166f-\\u167f\\u1681-\\u169a\\u16a0-\\u16ea\\u16ee-\\u16f8\\u1700-\\u170c\\u170e-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176c\\u176e-\\u1770\\u1780-\\u17b3\\u17d7\\u17dc\\u1820-\\u1878\\u1880-\\u18a8\\u18aa\\u18b0-\\u18f5\\u1900-\\u191e\\u1950-\\u196d\\u1970-\\u1974\\u1980-\\u19ab\\u19b0-\\u19c9\\u1a00-\\u1a16\\u1a20-\\u1a54\\u1aa7\\u1b05-\\u1b33\\u1b45-\\u1b4b\\u1b83-\\u1ba0\\u1bae\\u1baf\\u1bba-\\u1be5\\u1c00-\\u1c23\\u1c4d-\\u1c4f\\u1c5a-\\u1c7d\\u1c80-\\u1c88\\u1c90-\\u1cba\\u1cbd-\\u1cbf\\u1ce9-\\u1cec\\u1cee-\\u1cf1\\u1cf5\\u1cf6\\u1d00-\\u1dbf\\u1e00-\\u1f15\\u1f18-\\u1f1d\\u1f20-\\u1f45\\u1f48-\\u1f4d\\u1f50-\\u1f57\\u1f59\\u1f5b\\u1f5d\\u1f5f-\\u1f7d\\u1f80-\\u1fb4\\u1fb6-\\u1fbc\\u1fbe\\u1fc2-\\u1fc4\\u1fc6-\\u1fcc\\u1fd0-\\u1fd3\\u1fd6-\\u1fdb\\u1fe0-\\u1fec\\u1ff2-\\u1ff4\\u1ff6-\\u1ffc\\u2071\\u207f\\u2090-\\u209c\\u2102\\u2107\\u210a-\\u2113\\u2115\\u2118-\\u211d\\u2124\\u2126\\u2128\\u212a-\\u2139\\u213c-\\u213f\\u2145-\\u2149\\u214e\\u2160-\\u2188\\u2c00-\\u2c2e\\u2c30-\\u2c5e\\u2c60-\\u2ce4\\u2ceb-\\u2cee\\u2cf2\\u2cf3\\u2d00-\\u2d25\\u2d27\\u2d2d\\u2d30-\\u2d67\\u2d6f\\u2d80-\\u2d96\\u2da0-\\u2da6\\u2da8-\\u2dae\\u2db0-\\u2db6\\u2db8-\\u2dbe\\u2dc0-\\u2dc6\\u2dc8-\\u2dce\\u2dd0-\\u2dd6\\u2dd8-\\u2dde\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303c\\u3041-\\u3096\\u309b-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u31a0-\\u31ba\\u31f0-\\u31ff\\u3400-\\u4db5\\u4e00-\\u9fef\\ua000-\\ua48c\\ua4d0-\\ua4fd\\ua500-\\ua60c\\ua610-\\ua61f\\ua62a\\ua62b\\ua640-\\ua66e\\ua67f-\\ua69d\\ua6a0-\\ua6ef\\ua717-\\ua71f\\ua722-\\ua788\\ua78b-\\ua7b9\\ua7f7-\\ua801\\ua803-\\ua805\\ua807-\\ua80a\\ua80c-\\ua822\\ua840-\\ua873\\ua882-\\ua8b3\\ua8f2-\\ua8f7\\ua8fb\\ua8fd\\ua8fe\\ua90a-\\ua925\\ua930-\\ua946\\ua960-\\ua97c\\ua984-\\ua9b2\\ua9cf\\ua9e0-\\ua9e4\\ua9e6-\\ua9ef\\ua9fa-\\ua9fe\\uaa00-\\uaa28\\uaa40-\\uaa42\\uaa44-\\uaa4b\\uaa60-\\uaa76\\uaa7a\\uaa7e-\\uaaaf\\uaab1\\uaab5\\uaab6\\uaab9-\\uaabd\\uaac0\\uaac2\\uaadb-\\uaadd\\uaae0-\\uaaea\\uaaf2-\\uaaf4\\uab01-\\uab06\\uab09-\\uab0e\\uab11-\\uab16\\uab20-\\uab26\\uab28-\\uab2e\\uab30-\\uab5a\\uab5c-\\uab65\\uab70-\\uabe2\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufb00-\\ufb06\\ufb13-\\ufb17\\ufb1d\\ufb1f-\\ufb28\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40\\ufb41\\ufb43\\ufb44\\ufb46-\\ufbb1\\ufbd3-\\ufd3d\\ufd50-\\ufd8f\\ufd92-\\ufdc7\\ufdf0-\\ufdfb\\ufe70-\\ufe74\\ufe76-\\ufefc\\uff21-\\uff3a\\uff41-\\uff5a\\uff66-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc\"\nlet nonASCIIidentifierChars = \"\\u200c\\u200d\\xb7\\u0300-\\u036f\\u0387\\u0483-\\u0487\\u0591-\\u05bd\\u05bf\\u05c1\\u05c2\\u05c4\\u05c5\\u05c7\\u0610-\\u061a\\u064b-\\u0669\\u0670\\u06d6-\\u06dc\\u06df-\\u06e4\\u06e7\\u06e8\\u06ea-\\u06ed\\u06f0-\\u06f9\\u0711\\u0730-\\u074a\\u07a6-\\u07b0\\u07c0-\\u07c9\\u07eb-\\u07f3\\u07fd\\u0816-\\u0819\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0859-\\u085b\\u08d3-\\u08e1\\u08e3-\\u0903\\u093a-\\u093c\\u093e-\\u094f\\u0951-\\u0957\\u0962\\u0963\\u0966-\\u096f\\u0981-\\u0983\\u09bc\\u09be-\\u09c4\\u09c7\\u09c8\\u09cb-\\u09cd\\u09d7\\u09e2\\u09e3\\u09e6-\\u09ef\\u09fe\\u0a01-\\u0a03\\u0a3c\\u0a3e-\\u0a42\\u0a47\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a66-\\u0a71\\u0a75\\u0a81-\\u0a83\\u0abc\\u0abe-\\u0ac5\\u0ac7-\\u0ac9\\u0acb-\\u0acd\\u0ae2\\u0ae3\\u0ae6-\\u0aef\\u0afa-\\u0aff\\u0b01-\\u0b03\\u0b3c\\u0b3e-\\u0b44\\u0b47\\u0b48\\u0b4b-\\u0b4d\\u0b56\\u0b57\\u0b62\\u0b63\\u0b66-\\u0b6f\\u0b82\\u0bbe-\\u0bc2\\u0bc6-\\u0bc8\\u0bca-\\u0bcd\\u0bd7\\u0be6-\\u0bef\\u0c00-\\u0c04\\u0c3e-\\u0c44\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55\\u0c56\\u0c62\\u0c63\\u0c66-\\u0c6f\\u0c81-\\u0c83\\u0cbc\\u0cbe-\\u0cc4\\u0cc6-\\u0cc8\\u0cca-\\u0ccd\\u0cd5\\u0cd6\\u0ce2\\u0ce3\\u0ce6-\\u0cef\\u0d00-\\u0d03\\u0d3b\\u0d3c\\u0d3e-\\u0d44\\u0d46-\\u0d48\\u0d4a-\\u0d4d\\u0d57\\u0d62\\u0d63\\u0d66-\\u0d6f\\u0d82\\u0d83\\u0dca\\u0dcf-\\u0dd4\\u0dd6\\u0dd8-\\u0ddf\\u0de6-\\u0def\\u0df2\\u0df3\\u0e31\\u0e34-\\u0e3a\\u0e47-\\u0e4e\\u0e50-\\u0e59\\u0eb1\\u0eb4-\\u0eb9\\u0ebb\\u0ebc\\u0ec8-\\u0ecd\\u0ed0-\\u0ed9\\u0f18\\u0f19\\u0f20-\\u0f29\\u0f35\\u0f37\\u0f39\\u0f3e\\u0f3f\\u0f71-\\u0f84\\u0f86\\u0f87\\u0f8d-\\u0f97\\u0f99-\\u0fbc\\u0fc6\\u102b-\\u103e\\u1040-\\u1049\\u1056-\\u1059\\u105e-\\u1060\\u1062-\\u1064\\u1067-\\u106d\\u1071-\\u1074\\u1082-\\u108d\\u108f-\\u109d\\u135d-\\u135f\\u1369-\\u1371\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17b4-\\u17d3\\u17dd\\u17e0-\\u17e9\\u180b-\\u180d\\u1810-\\u1819\\u18a9\\u1920-\\u192b\\u1930-\\u193b\\u1946-\\u194f\\u19d0-\\u19da\\u1a17-\\u1a1b\\u1a55-\\u1a5e\\u1a60-\\u1a7c\\u1a7f-\\u1a89\\u1a90-\\u1a99\\u1ab0-\\u1abd\\u1b00-\\u1b04\\u1b34-\\u1b44\\u1b50-\\u1b59\\u1b6b-\\u1b73\\u1b80-\\u1b82\\u1ba1-\\u1bad\\u1bb0-\\u1bb9\\u1be6-\\u1bf3\\u1c24-\\u1c37\\u1c40-\\u1c49\\u1c50-\\u1c59\\u1cd0-\\u1cd2\\u1cd4-\\u1ce8\\u1ced\\u1cf2-\\u1cf4\\u1cf7-\\u1cf9\\u1dc0-\\u1df9\\u1dfb-\\u1dff\\u203f\\u2040\\u2054\\u20d0-\\u20dc\\u20e1\\u20e5-\\u20f0\\u2cef-\\u2cf1\\u2d7f\\u2de0-\\u2dff\\u302a-\\u302f\\u3099\\u309a\\ua620-\\ua629\\ua66f\\ua674-\\ua67d\\ua69e\\ua69f\\ua6f0\\ua6f1\\ua802\\ua806\\ua80b\\ua823-\\ua827\\ua880\\ua881\\ua8b4-\\ua8c5\\ua8d0-\\ua8d9\\ua8e0-\\ua8f1\\ua8ff-\\ua909\\ua926-\\ua92d\\ua947-\\ua953\\ua980-\\ua983\\ua9b3-\\ua9c0\\ua9d0-\\ua9d9\\ua9e5\\ua9f0-\\ua9f9\\uaa29-\\uaa36\\uaa43\\uaa4c\\uaa4d\\uaa50-\\uaa59\\uaa7b-\\uaa7d\\uaab0\\uaab2-\\uaab4\\uaab7\\uaab8\\uaabe\\uaabf\\uaac1\\uaaeb-\\uaaef\\uaaf5\\uaaf6\\uabe3-\\uabea\\uabec\\uabed\\uabf0-\\uabf9\\ufb1e\\ufe00-\\ufe0f\\ufe20-\\ufe2f\\ufe33\\ufe34\\ufe4d-\\ufe4f\\uff10-\\uff19\\uff3f\"\n\nconst nonASCIIidentifierStart = new RegExp(\"[\" + nonASCIIidentifierStartChars + \"]\")\nconst nonASCIIidentifier = new RegExp(\"[\" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + \"]\")\n\nnonASCIIidentifierStartChars = nonASCIIidentifierChars = null\n\n// These are a run-length and offset encoded representation of the\n// >0xffff code points that are a valid part of identifiers. The\n// offset starts at 0x10000, and each pair of numbers represents an\n// offset to the next range, and then a size of the range. They were\n// generated by bin/generate-identifier-regex.js\n\n// eslint-disable-next-line comma-spacing\nconst astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,477,28,11,0,9,21,190,52,76,44,33,24,27,35,30,0,12,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,26,230,43,117,63,32,0,257,0,11,39,8,0,22,0,12,39,3,3,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,270,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,68,12,0,67,12,65,1,31,6129,15,754,9486,286,82,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541]\n\n// eslint-disable-next-line comma-spacing\nconst astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,525,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,4,9,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,280,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239]\n\n// This has a complexity linear to the value of the code. The\n// assumption is that looking up astral identifier characters is\n// rare.\nfunction isInAstralSet(code, set) {\n let pos = 0x10000\n for (let i = 0; i < set.length; i += 2) {\n pos += set[i]\n if (pos > code) return false\n pos += set[i + 1]\n if (pos >= code) return true\n }\n}\n\n// Test whether a given character code starts an identifier.\n\nexport function isIdentifierStart(code, astral) {\n if (code < 65) return code === 36\n if (code < 91) return true\n if (code < 97) return code === 95\n if (code < 123) return true\n if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code))\n if (astral === false) return false\n return isInAstralSet(code, astralIdentifierStartCodes)\n}\n\n// Test whether a given character is part of an identifier.\n\nexport function isIdentifierChar(code, astral) {\n if (code < 48) return code === 36\n if (code < 58) return true\n if (code < 65) return false\n if (code < 91) return true\n if (code < 97) return code === 95\n if (code < 123) return true\n if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code))\n if (astral === false) return false\n return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes)\n}\n","// ## Token types\n\n// The assignment of fine-grained, information-carrying type objects\n// allows the tokenizer to store the information it has about a\n// token in a way that is very cheap for the parser to look up.\n\n// All token type variables start with an underscore, to make them\n// easy to recognize.\n\n// The `beforeExpr` property is used to disambiguate between regular\n// expressions and divisions. It is set on all token types that can\n// be followed by an expression (thus, a slash after them would be a\n// regular expression).\n//\n// The `startsExpr` property is used to check if the token ends a\n// `yield` expression. It is set on all token types that either can\n// directly start an expression (like a quotation mark) or can\n// continue an expression (like the body of a string).\n//\n// `isLoop` marks a keyword as starting a loop, which is important\n// to know when parsing a label, in order to allow or disallow\n// continue jumps to that label.\n\nexport class TokenType {\n constructor(label, conf = {}) {\n this.label = label\n this.keyword = conf.keyword\n this.beforeExpr = !!conf.beforeExpr\n this.startsExpr = !!conf.startsExpr\n this.isLoop = !!conf.isLoop\n this.isAssign = !!conf.isAssign\n this.prefix = !!conf.prefix\n this.postfix = !!conf.postfix\n this.binop = conf.binop || null\n this.updateContext = null\n }\n}\n\nfunction binop(name, prec) {\n return new TokenType(name, {beforeExpr: true, binop: prec})\n}\nconst beforeExpr = {beforeExpr: true}, startsExpr = {startsExpr: true}\n\n// Map keyword names to token types.\n\nexport const keywords = {}\n\n// Succinct definitions of keyword token types\nfunction kw(name, options = {}) {\n options.keyword = name\n return keywords[name] = new TokenType(name, options)\n}\n\nexport const types = {\n num: new TokenType(\"num\", startsExpr),\n regexp: new TokenType(\"regexp\", startsExpr),\n string: new TokenType(\"string\", startsExpr),\n name: new TokenType(\"name\", startsExpr),\n eof: new TokenType(\"eof\"),\n\n // Punctuation token types.\n bracketL: new TokenType(\"[\", {beforeExpr: true, startsExpr: true}),\n bracketR: new TokenType(\"]\"),\n braceL: new TokenType(\"{\", {beforeExpr: true, startsExpr: true}),\n braceR: new TokenType(\"}\"),\n parenL: new TokenType(\"(\", {beforeExpr: true, startsExpr: true}),\n parenR: new TokenType(\")\"),\n comma: new TokenType(\",\", beforeExpr),\n semi: new TokenType(\";\", beforeExpr),\n colon: new TokenType(\":\", beforeExpr),\n dot: new TokenType(\".\"),\n question: new TokenType(\"?\", beforeExpr),\n arrow: new TokenType(\"=>\", beforeExpr),\n template: new TokenType(\"template\"),\n invalidTemplate: new TokenType(\"invalidTemplate\"),\n ellipsis: new TokenType(\"...\", beforeExpr),\n backQuote: new TokenType(\"`\", startsExpr),\n dollarBraceL: new TokenType(\"${\", {beforeExpr: true, startsExpr: true}),\n\n // Operators. These carry several kinds of properties to help the\n // parser use them properly (the presence of these properties is\n // what categorizes them as operators).\n //\n // `binop`, when present, specifies that this operator is a binary\n // operator, and will refer to its precedence.\n //\n // `prefix` and `postfix` mark the operator as a prefix or postfix\n // unary operator.\n //\n // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as\n // binary operators with a very low precedence, that should result\n // in AssignmentExpression nodes.\n\n eq: new TokenType(\"=\", {beforeExpr: true, isAssign: true}),\n assign: new TokenType(\"_=\", {beforeExpr: true, isAssign: true}),\n incDec: new TokenType(\"++/--\", {prefix: true, postfix: true, startsExpr: true}),\n prefix: new TokenType(\"!/~\", {beforeExpr: true, prefix: true, startsExpr: true}),\n logicalOR: binop(\"||\", 1),\n logicalAND: binop(\"&&\", 2),\n bitwiseOR: binop(\"|\", 3),\n bitwiseXOR: binop(\"^\", 4),\n bitwiseAND: binop(\"&\", 5),\n equality: binop(\"==/!=/===/!==\", 6),\n relational: binop(\"/<=/>=\", 7),\n bitShift: binop(\"<>/>>>\", 8),\n plusMin: new TokenType(\"+/-\", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),\n modulo: binop(\"%\", 10),\n star: binop(\"*\", 10),\n slash: binop(\"/\", 10),\n starstar: new TokenType(\"**\", {beforeExpr: true}),\n\n // Keyword token types.\n _break: kw(\"break\"),\n _case: kw(\"case\", beforeExpr),\n _catch: kw(\"catch\"),\n _continue: kw(\"continue\"),\n _debugger: kw(\"debugger\"),\n _default: kw(\"default\", beforeExpr),\n _do: kw(\"do\", {isLoop: true, beforeExpr: true}),\n _else: kw(\"else\", beforeExpr),\n _finally: kw(\"finally\"),\n _for: kw(\"for\", {isLoop: true}),\n _function: kw(\"function\", startsExpr),\n _if: kw(\"if\"),\n _return: kw(\"return\", beforeExpr),\n _switch: kw(\"switch\"),\n _throw: kw(\"throw\", beforeExpr),\n _try: kw(\"try\"),\n _var: kw(\"var\"),\n _const: kw(\"const\"),\n _while: kw(\"while\", {isLoop: true}),\n _with: kw(\"with\"),\n _new: kw(\"new\", {beforeExpr: true, startsExpr: true}),\n _this: kw(\"this\", startsExpr),\n _super: kw(\"super\", startsExpr),\n _class: kw(\"class\", startsExpr),\n _extends: kw(\"extends\", beforeExpr),\n _export: kw(\"export\"),\n _import: kw(\"import\"),\n _null: kw(\"null\", startsExpr),\n _true: kw(\"true\", startsExpr),\n _false: kw(\"false\", startsExpr),\n _in: kw(\"in\", {beforeExpr: true, binop: 7}),\n _instanceof: kw(\"instanceof\", {beforeExpr: true, binop: 7}),\n _typeof: kw(\"typeof\", {beforeExpr: true, prefix: true, startsExpr: true}),\n _void: kw(\"void\", {beforeExpr: true, prefix: true, startsExpr: true}),\n _delete: kw(\"delete\", {beforeExpr: true, prefix: true, startsExpr: true})\n}\n","// Matches a whole line break (where CRLF is considered a single\n// line break). Used to count lines.\n\nexport const lineBreak = /\\r\\n?|\\n|\\u2028|\\u2029/\nexport const lineBreakG = new RegExp(lineBreak.source, \"g\")\n\nexport function isNewLine(code, ecma2019String) {\n return code === 10 || code === 13 || (!ecma2019String && (code === 0x2028 || code === 0x2029))\n}\n\nexport const nonASCIIwhitespace = /[\\u1680\\u180e\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]/\n\nexport const skipWhiteSpace = /(?:\\s|\\/\\/.*|\\/\\*[^]*?\\*\\/)*/g\n","const {hasOwnProperty, toString} = Object.prototype\n\n// Checks if an object has a property.\n\nexport function has(obj, propName) {\n return hasOwnProperty.call(obj, propName)\n}\n\nexport const isArray = Array.isArray || ((obj) => (\n toString.call(obj) === \"[object Array]\"\n))\n","import {lineBreakG} from \"./whitespace\"\n\n// These are used when `options.locations` is on, for the\n// `startLoc` and `endLoc` properties.\n\nexport class Position {\n constructor(line, col) {\n this.line = line\n this.column = col\n }\n\n offset(n) {\n return new Position(this.line, this.column + n)\n }\n}\n\nexport class SourceLocation {\n constructor(p, start, end) {\n this.start = start\n this.end = end\n if (p.sourceFile !== null) this.source = p.sourceFile\n }\n}\n\n// The `getLineInfo` function is mostly useful when the\n// `locations` option is off (for performance reasons) and you\n// want to find the line/column position for a given character\n// offset. `input` should be the code string that the offset refers\n// into.\n\nexport function getLineInfo(input, offset) {\n for (let line = 1, cur = 0;;) {\n lineBreakG.lastIndex = cur\n let match = lineBreakG.exec(input)\n if (match && match.index < offset) {\n ++line\n cur = match.index + match[0].length\n } else {\n return new Position(line, offset - cur)\n }\n }\n}\n","import {has, isArray} from \"./util\"\nimport {SourceLocation} from \"./locutil\"\n\n// A second optional argument can be given to further configure\n// the parser process. These options are recognized:\n\nexport const defaultOptions = {\n // `ecmaVersion` indicates the ECMAScript version to parse. Must be\n // either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018), or 10\n // (2019). This influences support for strict mode, the set of\n // reserved words, and support for new syntax features. The default\n // is 9.\n ecmaVersion: 9,\n // `sourceType` indicates the mode the code should be parsed in.\n // Can be either `\"script\"` or `\"module\"`. This influences global\n // strict mode and parsing of `import` and `export` declarations.\n sourceType: \"script\",\n // `onInsertedSemicolon` can be a callback that will be called\n // when a semicolon is automatically inserted. It will be passed\n // th position of the comma as an offset, and if `locations` is\n // enabled, it is given the location as a `{line, column}` object\n // as second argument.\n onInsertedSemicolon: null,\n // `onTrailingComma` is similar to `onInsertedSemicolon`, but for\n // trailing commas.\n onTrailingComma: null,\n // By default, reserved words are only enforced if ecmaVersion >= 5.\n // Set `allowReserved` to a boolean value to explicitly turn this on\n // an off. When this option has the value \"never\", reserved words\n // and keywords can also not be used as property names.\n allowReserved: null,\n // When enabled, a return at the top level is not considered an\n // error.\n allowReturnOutsideFunction: false,\n // When enabled, import/export statements are not constrained to\n // appearing at the top of the program.\n allowImportExportEverywhere: false,\n // When enabled, await identifiers are allowed to appear at the top-level scope,\n // but they are still not allowed in non-async functions.\n allowAwaitOutsideFunction: false,\n // When enabled, hashbang directive in the beginning of file\n // is allowed and treated as a line comment.\n allowHashBang: false,\n // When `locations` is on, `loc` properties holding objects with\n // `start` and `end` properties in `{line, column}` form (with\n // line being 1-based and column 0-based) will be attached to the\n // nodes.\n locations: false,\n // A function can be passed as `onToken` option, which will\n // cause Acorn to call that function with object in the same\n // format as tokens returned from `tokenizer().getToken()`. Note\n // that you are not allowed to call the parser from the\n // callback—that will corrupt its internal state.\n onToken: null,\n // A function can be passed as `onComment` option, which will\n // cause Acorn to call that function with `(block, text, start,\n // end)` parameters whenever a comment is skipped. `block` is a\n // boolean indicating whether this is a block (`/* */`) comment,\n // `text` is the content of the comment, and `start` and `end` are\n // character offsets that denote the start and end of the comment.\n // When the `locations` option is on, two more parameters are\n // passed, the full `{line, column}` locations of the start and\n // end of the comments. Note that you are not allowed to call the\n // parser from the callback—that will corrupt its internal state.\n onComment: null,\n // Nodes have their start and end characters offsets recorded in\n // `start` and `end` properties (directly on the node, rather than\n // the `loc` object, which holds line/column data. To also add a\n // [semi-standardized][range] `range` property holding a `[start,\n // end]` array with the same numbers, set the `ranges` option to\n // `true`.\n //\n // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678\n ranges: false,\n // It is possible to parse multiple files into a single AST by\n // passing the tree produced by parsing the first file as\n // `program` option in subsequent parses. This will add the\n // toplevel forms of the parsed file to the `Program` (top) node\n // of an existing parse tree.\n program: null,\n // When `locations` is on, you can pass this to record the source\n // file in every node's `loc` object.\n sourceFile: null,\n // This value, if given, is stored in every node, whether\n // `locations` is on or off.\n directSourceFile: null,\n // When enabled, parenthesized expressions are represented by\n // (non-standard) ParenthesizedExpression nodes\n preserveParens: false\n}\n\n// Interpret and default an options object\n\nexport function getOptions(opts) {\n let options = {}\n\n for (let opt in defaultOptions)\n options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt]\n\n if (options.ecmaVersion >= 2015)\n options.ecmaVersion -= 2009\n\n if (options.allowReserved == null)\n options.allowReserved = options.ecmaVersion < 5\n\n if (isArray(options.onToken)) {\n let tokens = options.onToken\n options.onToken = (token) => tokens.push(token)\n }\n if (isArray(options.onComment))\n options.onComment = pushComment(options, options.onComment)\n\n return options\n}\n\nfunction pushComment(options, array) {\n return function(block, text, start, end, startLoc, endLoc) {\n let comment = {\n type: block ? \"Block\" : \"Line\",\n value: text,\n start: start,\n end: end\n }\n if (options.locations)\n comment.loc = new SourceLocation(this, startLoc, endLoc)\n if (options.ranges)\n comment.range = [start, end]\n array.push(comment)\n }\n}\n","// Each scope gets a bitset that may contain these flags\nexport const\n SCOPE_TOP = 1,\n SCOPE_FUNCTION = 2,\n SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION,\n SCOPE_ASYNC = 4,\n SCOPE_GENERATOR = 8,\n SCOPE_ARROW = 16,\n SCOPE_SIMPLE_CATCH = 32\n\nexport function functionFlags(async, generator) {\n return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0)\n}\n\n// Used in checkLVal and declareName to determine the type of a binding\nexport const\n BIND_NONE = 0, // Not a binding\n BIND_VAR = 1, // Var-style binding\n BIND_LEXICAL = 2, // Let- or const-style binding\n BIND_FUNCTION = 3, // Function declaration\n BIND_SIMPLE_CATCH = 4, // Simple (identifier pattern) catch binding\n BIND_OUTSIDE = 5 // Special case for function names as bound inside the function\n","import {reservedWords, keywords} from \"./identifier\"\nimport {types as tt} from \"./tokentype\"\nimport {lineBreak} from \"./whitespace\"\nimport {getOptions} from \"./options\"\nimport {SCOPE_TOP, SCOPE_FUNCTION, SCOPE_ASYNC, SCOPE_GENERATOR} from \"./scopeflags\"\n\nfunction keywordRegexp(words) {\n return new RegExp(\"^(?:\" + words.replace(/ /g, \"|\") + \")$\")\n}\n\nexport class Parser {\n constructor(options, input, startPos) {\n this.options = options = getOptions(options)\n this.sourceFile = options.sourceFile\n this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5])\n let reserved = \"\"\n if (!options.allowReserved) {\n for (let v = options.ecmaVersion;; v--)\n if (reserved = reservedWords[v]) break\n if (options.sourceType === \"module\") reserved += \" await\"\n }\n this.reservedWords = keywordRegexp(reserved)\n let reservedStrict = (reserved ? reserved + \" \" : \"\") + reservedWords.strict\n this.reservedWordsStrict = keywordRegexp(reservedStrict)\n this.reservedWordsStrictBind = keywordRegexp(reservedStrict + \" \" + reservedWords.strictBind)\n this.input = String(input)\n\n // Used to signal to callers of `readWord1` whether the word\n // contained any escape sequences. This is needed because words with\n // escape sequences must not be interpreted as keywords.\n this.containsEsc = false\n\n // Set up token state\n\n // The current position of the tokenizer in the input.\n if (startPos) {\n this.pos = startPos\n this.lineStart = this.input.lastIndexOf(\"\\n\", startPos - 1) + 1\n this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length\n } else {\n this.pos = this.lineStart = 0\n this.curLine = 1\n }\n\n // Properties of the current token:\n // Its type\n this.type = tt.eof\n // For tokens that include more information than their type, the value\n this.value = null\n // Its start and end offset\n this.start = this.end = this.pos\n // And, if locations are used, the {line, column} object\n // corresponding to those offsets\n this.startLoc = this.endLoc = this.curPosition()\n\n // Position information for the previous token\n this.lastTokEndLoc = this.lastTokStartLoc = null\n this.lastTokStart = this.lastTokEnd = this.pos\n\n // The context stack is used to superficially track syntactic\n // context to predict whether a regular expression is allowed in a\n // given position.\n this.context = this.initialContext()\n this.exprAllowed = true\n\n // Figure out if it's a module code.\n this.inModule = options.sourceType === \"module\"\n this.strict = this.inModule || this.strictDirective(this.pos)\n\n // Used to signify the start of a potential arrow function\n this.potentialArrowAt = -1\n\n // Positions to delayed-check that yield/await does not exist in default parameters.\n this.yieldPos = this.awaitPos = 0\n // Labels in scope.\n this.labels = []\n\n // If enabled, skip leading hashbang line.\n if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === \"#!\")\n this.skipLineComment(2)\n\n // Scope tracking for duplicate variable names (see scope.js)\n this.scopeStack = []\n this.enterScope(SCOPE_TOP)\n\n // For RegExp validation\n this.regexpState = null\n }\n\n parse() {\n let node = this.options.program || this.startNode()\n this.nextToken()\n return this.parseTopLevel(node)\n }\n\n get inFunction() { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 }\n get inGenerator() { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 }\n get inAsync() { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 }\n\n static extend(...plugins) {\n let cls = this\n for (let i = 0; i < plugins.length; i++) cls = plugins[i](cls)\n return cls\n }\n\n static parse(input, options) {\n return new this(options, input).parse()\n }\n\n static parseExpressionAt(input, pos, options) {\n let parser = new this(options, input, pos)\n parser.nextToken()\n return parser.parseExpression()\n }\n\n static tokenizer(input, options) {\n return new this(options, input)\n }\n}\n","import {types as tt} from \"./tokentype\"\nimport {Parser} from \"./state\"\nimport {lineBreak, skipWhiteSpace} from \"./whitespace\"\n\nconst pp = Parser.prototype\n\n// ## Parser utilities\n\nconst literal = /^(?:'((?:\\\\.|[^'])*?)'|\"((?:\\\\.|[^\"])*?)\"|;)/\npp.strictDirective = function(start) {\n for (;;) {\n skipWhiteSpace.lastIndex = start\n start += skipWhiteSpace.exec(this.input)[0].length\n let match = literal.exec(this.input.slice(start))\n if (!match) return false\n if ((match[1] || match[2]) === \"use strict\") return true\n start += match[0].length\n }\n}\n\n// Predicate that tests whether the next token is of the given\n// type, and if yes, consumes it as a side effect.\n\npp.eat = function(type) {\n if (this.type === type) {\n this.next()\n return true\n } else {\n return false\n }\n}\n\n// Tests whether parsed token is a contextual keyword.\n\npp.isContextual = function(name) {\n return this.type === tt.name && this.value === name && !this.containsEsc\n}\n\n// Consumes contextual keyword if possible.\n\npp.eatContextual = function(name) {\n if (!this.isContextual(name)) return false\n this.next()\n return true\n}\n\n// Asserts that following token is given contextual keyword.\n\npp.expectContextual = function(name) {\n if (!this.eatContextual(name)) this.unexpected()\n}\n\n// Test whether a semicolon can be inserted at the current position.\n\npp.canInsertSemicolon = function() {\n return this.type === tt.eof ||\n this.type === tt.braceR ||\n lineBreak.test(this.input.slice(this.lastTokEnd, this.start))\n}\n\npp.insertSemicolon = function() {\n if (this.canInsertSemicolon()) {\n if (this.options.onInsertedSemicolon)\n this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc)\n return true\n }\n}\n\n// Consume a semicolon, or, failing that, see if we are allowed to\n// pretend that there is a semicolon at this position.\n\npp.semicolon = function() {\n if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected()\n}\n\npp.afterTrailingComma = function(tokType, notNext) {\n if (this.type === tokType) {\n if (this.options.onTrailingComma)\n this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc)\n if (!notNext)\n this.next()\n return true\n }\n}\n\n// Expect a token of a given type. If found, consume it, otherwise,\n// raise an unexpected token error.\n\npp.expect = function(type) {\n this.eat(type) || this.unexpected()\n}\n\n// Raise an unexpected token error.\n\npp.unexpected = function(pos) {\n this.raise(pos != null ? pos : this.start, \"Unexpected token\")\n}\n\nexport function DestructuringErrors() {\n this.shorthandAssign =\n this.trailingComma =\n this.parenthesizedAssign =\n this.parenthesizedBind =\n this.doubleProto =\n -1\n}\n\npp.checkPatternErrors = function(refDestructuringErrors, isAssign) {\n if (!refDestructuringErrors) return\n if (refDestructuringErrors.trailingComma > -1)\n this.raiseRecoverable(refDestructuringErrors.trailingComma, \"Comma is not permitted after the rest element\")\n let parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind\n if (parens > -1) this.raiseRecoverable(parens, \"Parenthesized pattern\")\n}\n\npp.checkExpressionErrors = function(refDestructuringErrors, andThrow) {\n if (!refDestructuringErrors) return false\n let {shorthandAssign, doubleProto} = refDestructuringErrors\n if (!andThrow) return shorthandAssign >= 0 || doubleProto >= 0\n if (shorthandAssign >= 0)\n this.raise(shorthandAssign, \"Shorthand property assignments are valid only in destructuring patterns\")\n if (doubleProto >= 0)\n this.raiseRecoverable(doubleProto, \"Redefinition of __proto__ property\")\n}\n\npp.checkYieldAwaitInDefaultParams = function() {\n if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos))\n this.raise(this.yieldPos, \"Yield expression cannot be a default value\")\n if (this.awaitPos)\n this.raise(this.awaitPos, \"Await expression cannot be a default value\")\n}\n\npp.isSimpleAssignTarget = function(expr) {\n if (expr.type === \"ParenthesizedExpression\")\n return this.isSimpleAssignTarget(expr.expression)\n return expr.type === \"Identifier\" || expr.type === \"MemberExpression\"\n}\n","import {types as tt} from \"./tokentype\"\nimport {Parser} from \"./state\"\nimport {lineBreak, skipWhiteSpace} from \"./whitespace\"\nimport {isIdentifierStart, isIdentifierChar, keywordRelationalOperator} from \"./identifier\"\nimport {has} from \"./util\"\nimport {DestructuringErrors} from \"./parseutil\"\nimport {functionFlags, SCOPE_SIMPLE_CATCH, BIND_SIMPLE_CATCH, BIND_LEXICAL, BIND_VAR, BIND_FUNCTION} from \"./scopeflags\"\n\nconst pp = Parser.prototype\n\n// ### Statement parsing\n\n// Parse a program. Initializes the parser, reads any number of\n// statements, and wraps them in a Program node. Optionally takes a\n// `program` argument. If present, the statements will be appended\n// to its body instead of creating a new node.\n\npp.parseTopLevel = function(node) {\n let exports = {}\n if (!node.body) node.body = []\n while (this.type !== tt.eof) {\n let stmt = this.parseStatement(null, true, exports)\n node.body.push(stmt)\n }\n this.adaptDirectivePrologue(node.body)\n this.next()\n if (this.options.ecmaVersion >= 6) {\n node.sourceType = this.options.sourceType\n }\n return this.finishNode(node, \"Program\")\n}\n\nconst loopLabel = {kind: \"loop\"}, switchLabel = {kind: \"switch\"}\n\npp.isLet = function() {\n if (this.options.ecmaVersion < 6 || !this.isContextual(\"let\")) return false\n skipWhiteSpace.lastIndex = this.pos\n let skip = skipWhiteSpace.exec(this.input)\n let next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next)\n if (nextCh === 91 || nextCh === 123) return true // '{' and '['\n if (isIdentifierStart(nextCh, true)) {\n let pos = next + 1\n while (isIdentifierChar(this.input.charCodeAt(pos), true)) ++pos\n let ident = this.input.slice(next, pos)\n if (!keywordRelationalOperator.test(ident)) return true\n }\n return false\n}\n\n// check 'async [no LineTerminator here] function'\n// - 'async /*foo*/ function' is OK.\n// - 'async /*\\n*/ function' is invalid.\npp.isAsyncFunction = function() {\n if (this.options.ecmaVersion < 8 || !this.isContextual(\"async\"))\n return false\n\n skipWhiteSpace.lastIndex = this.pos\n let skip = skipWhiteSpace.exec(this.input)\n let next = this.pos + skip[0].length\n return !lineBreak.test(this.input.slice(this.pos, next)) &&\n this.input.slice(next, next + 8) === \"function\" &&\n (next + 8 === this.input.length || !isIdentifierChar(this.input.charAt(next + 8)))\n}\n\n// Parse a single statement.\n//\n// If expecting a statement and finding a slash operator, parse a\n// regular expression literal. This is to handle cases like\n// `if (foo) /blah/.exec(foo)`, where looking at the previous token\n// does not help.\n\npp.parseStatement = function(context, topLevel, exports) {\n let starttype = this.type, node = this.startNode(), kind\n\n if (this.isLet()) {\n starttype = tt._var\n kind = \"let\"\n }\n\n // Most types of statements are recognized by the keyword they\n // start with. Many are trivial to parse, some require a bit of\n // complexity.\n\n switch (starttype) {\n case tt._break: case tt._continue: return this.parseBreakContinueStatement(node, starttype.keyword)\n case tt._debugger: return this.parseDebuggerStatement(node)\n case tt._do: return this.parseDoStatement(node)\n case tt._for: return this.parseForStatement(node)\n case tt._function:\n if ((context && (this.strict || context !== \"if\")) && this.options.ecmaVersion >= 6) this.unexpected()\n return this.parseFunctionStatement(node, false, !context)\n case tt._class:\n if (context) this.unexpected()\n return this.parseClass(node, true)\n case tt._if: return this.parseIfStatement(node)\n case tt._return: return this.parseReturnStatement(node)\n case tt._switch: return this.parseSwitchStatement(node)\n case tt._throw: return this.parseThrowStatement(node)\n case tt._try: return this.parseTryStatement(node)\n case tt._const: case tt._var:\n kind = kind || this.value\n if (context && kind !== \"var\") this.unexpected()\n return this.parseVarStatement(node, kind)\n case tt._while: return this.parseWhileStatement(node)\n case tt._with: return this.parseWithStatement(node)\n case tt.braceL: return this.parseBlock(true, node)\n case tt.semi: return this.parseEmptyStatement(node)\n case tt._export:\n case tt._import:\n if (!this.options.allowImportExportEverywhere) {\n if (!topLevel)\n this.raise(this.start, \"'import' and 'export' may only appear at the top level\")\n if (!this.inModule)\n this.raise(this.start, \"'import' and 'export' may appear only with 'sourceType: module'\")\n }\n return starttype === tt._import ? this.parseImport(node) : this.parseExport(node, exports)\n\n // If the statement does not start with a statement keyword or a\n // brace, it's an ExpressionStatement or LabeledStatement. We\n // simply start parsing an expression, and afterwards, if the\n // next token is a colon and the expression was a simple\n // Identifier node, we switch to interpreting it as a label.\n default:\n if (this.isAsyncFunction()) {\n if (context) this.unexpected()\n this.next()\n return this.parseFunctionStatement(node, true, !context)\n }\n\n let maybeName = this.value, expr = this.parseExpression()\n if (starttype === tt.name && expr.type === \"Identifier\" && this.eat(tt.colon))\n return this.parseLabeledStatement(node, maybeName, expr, context)\n else return this.parseExpressionStatement(node, expr)\n }\n}\n\npp.parseBreakContinueStatement = function(node, keyword) {\n let isBreak = keyword === \"break\"\n this.next()\n if (this.eat(tt.semi) || this.insertSemicolon()) node.label = null\n else if (this.type !== tt.name) this.unexpected()\n else {\n node.label = this.parseIdent()\n this.semicolon()\n }\n\n // Verify that there is an actual destination to break or\n // continue to.\n let i = 0\n for (; i < this.labels.length; ++i) {\n let lab = this.labels[i]\n if (node.label == null || lab.name === node.label.name) {\n if (lab.kind != null && (isBreak || lab.kind === \"loop\")) break\n if (node.label && isBreak) break\n }\n }\n if (i === this.labels.length) this.raise(node.start, \"Unsyntactic \" + keyword)\n return this.finishNode(node, isBreak ? \"BreakStatement\" : \"ContinueStatement\")\n}\n\npp.parseDebuggerStatement = function(node) {\n this.next()\n this.semicolon()\n return this.finishNode(node, \"DebuggerStatement\")\n}\n\npp.parseDoStatement = function(node) {\n this.next()\n this.labels.push(loopLabel)\n node.body = this.parseStatement(\"do\")\n this.labels.pop()\n this.expect(tt._while)\n node.test = this.parseParenExpression()\n if (this.options.ecmaVersion >= 6)\n this.eat(tt.semi)\n else\n this.semicolon()\n return this.finishNode(node, \"DoWhileStatement\")\n}\n\n// Disambiguating between a `for` and a `for`/`in` or `for`/`of`\n// loop is non-trivial. Basically, we have to parse the init `var`\n// statement or expression, disallowing the `in` operator (see\n// the second parameter to `parseExpression`), and then check\n// whether the next token is `in` or `of`. When there is no init\n// part (semicolon immediately after the opening parenthesis), it\n// is a regular `for` loop.\n\npp.parseForStatement = function(node) {\n this.next()\n let awaitAt = (this.options.ecmaVersion >= 9 && (this.inAsync || (!this.inFunction && this.options.allowAwaitOutsideFunction)) && this.eatContextual(\"await\")) ? this.lastTokStart : -1\n this.labels.push(loopLabel)\n this.enterScope(0)\n this.expect(tt.parenL)\n if (this.type === tt.semi) {\n if (awaitAt > -1) this.unexpected(awaitAt)\n return this.parseFor(node, null)\n }\n let isLet = this.isLet()\n if (this.type === tt._var || this.type === tt._const || isLet) {\n let init = this.startNode(), kind = isLet ? \"let\" : this.value\n this.next()\n this.parseVar(init, true, kind)\n this.finishNode(init, \"VariableDeclaration\")\n if ((this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual(\"of\"))) && init.declarations.length === 1 &&\n !(kind !== \"var\" && init.declarations[0].init)) {\n if (this.options.ecmaVersion >= 9) {\n if (this.type === tt._in) {\n if (awaitAt > -1) this.unexpected(awaitAt)\n } else node.await = awaitAt > -1\n }\n return this.parseForIn(node, init)\n }\n if (awaitAt > -1) this.unexpected(awaitAt)\n return this.parseFor(node, init)\n }\n let refDestructuringErrors = new DestructuringErrors\n let init = this.parseExpression(true, refDestructuringErrors)\n if (this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual(\"of\"))) {\n if (this.options.ecmaVersion >= 9) {\n if (this.type === tt._in) {\n if (awaitAt > -1) this.unexpected(awaitAt)\n } else node.await = awaitAt > -1\n }\n this.toAssignable(init, false, refDestructuringErrors)\n this.checkLVal(init)\n return this.parseForIn(node, init)\n } else {\n this.checkExpressionErrors(refDestructuringErrors, true)\n }\n if (awaitAt > -1) this.unexpected(awaitAt)\n return this.parseFor(node, init)\n}\n\npp.parseFunctionStatement = function(node, isAsync, declarationPosition) {\n this.next()\n return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)\n}\n\npp.parseIfStatement = function(node) {\n this.next()\n node.test = this.parseParenExpression()\n // allow function declarations in branches, but only in non-strict mode\n node.consequent = this.parseStatement(\"if\")\n node.alternate = this.eat(tt._else) ? this.parseStatement(\"if\") : null\n return this.finishNode(node, \"IfStatement\")\n}\n\npp.parseReturnStatement = function(node) {\n if (!this.inFunction && !this.options.allowReturnOutsideFunction)\n this.raise(this.start, \"'return' outside of function\")\n this.next()\n\n // In `return` (and `break`/`continue`), the keywords with\n // optional arguments, we eagerly look for a semicolon or the\n // possibility to insert one.\n\n if (this.eat(tt.semi) || this.insertSemicolon()) node.argument = null\n else { node.argument = this.parseExpression(); this.semicolon() }\n return this.finishNode(node, \"ReturnStatement\")\n}\n\npp.parseSwitchStatement = function(node) {\n this.next()\n node.discriminant = this.parseParenExpression()\n node.cases = []\n this.expect(tt.braceL)\n this.labels.push(switchLabel)\n this.enterScope(0)\n\n // Statements under must be grouped (by label) in SwitchCase\n // nodes. `cur` is used to keep the node that we are currently\n // adding statements to.\n\n let cur\n for (let sawDefault = false; this.type !== tt.braceR;) {\n if (this.type === tt._case || this.type === tt._default) {\n let isCase = this.type === tt._case\n if (cur) this.finishNode(cur, \"SwitchCase\")\n node.cases.push(cur = this.startNode())\n cur.consequent = []\n this.next()\n if (isCase) {\n cur.test = this.parseExpression()\n } else {\n if (sawDefault) this.raiseRecoverable(this.lastTokStart, \"Multiple default clauses\")\n sawDefault = true\n cur.test = null\n }\n this.expect(tt.colon)\n } else {\n if (!cur) this.unexpected()\n cur.consequent.push(this.parseStatement(null))\n }\n }\n this.exitScope()\n if (cur) this.finishNode(cur, \"SwitchCase\")\n this.next() // Closing brace\n this.labels.pop()\n return this.finishNode(node, \"SwitchStatement\")\n}\n\npp.parseThrowStatement = function(node) {\n this.next()\n if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))\n this.raise(this.lastTokEnd, \"Illegal newline after throw\")\n node.argument = this.parseExpression()\n this.semicolon()\n return this.finishNode(node, \"ThrowStatement\")\n}\n\n// Reused empty array added for node fields that are always empty.\n\nconst empty = []\n\npp.parseTryStatement = function(node) {\n this.next()\n node.block = this.parseBlock()\n node.handler = null\n if (this.type === tt._catch) {\n let clause = this.startNode()\n this.next()\n if (this.eat(tt.parenL)) {\n clause.param = this.parseBindingAtom()\n let simple = clause.param.type === \"Identifier\"\n this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0)\n this.checkLVal(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL)\n this.expect(tt.parenR)\n } else {\n if (this.options.ecmaVersion < 10) this.unexpected()\n clause.param = null\n this.enterScope(0)\n }\n clause.body = this.parseBlock(false)\n this.exitScope()\n node.handler = this.finishNode(clause, \"CatchClause\")\n }\n node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null\n if (!node.handler && !node.finalizer)\n this.raise(node.start, \"Missing catch or finally clause\")\n return this.finishNode(node, \"TryStatement\")\n}\n\npp.parseVarStatement = function(node, kind) {\n this.next()\n this.parseVar(node, false, kind)\n this.semicolon()\n return this.finishNode(node, \"VariableDeclaration\")\n}\n\npp.parseWhileStatement = function(node) {\n this.next()\n node.test = this.parseParenExpression()\n this.labels.push(loopLabel)\n node.body = this.parseStatement(\"while\")\n this.labels.pop()\n return this.finishNode(node, \"WhileStatement\")\n}\n\npp.parseWithStatement = function(node) {\n if (this.strict) this.raise(this.start, \"'with' in strict mode\")\n this.next()\n node.object = this.parseParenExpression()\n node.body = this.parseStatement(\"with\")\n return this.finishNode(node, \"WithStatement\")\n}\n\npp.parseEmptyStatement = function(node) {\n this.next()\n return this.finishNode(node, \"EmptyStatement\")\n}\n\npp.parseLabeledStatement = function(node, maybeName, expr, context) {\n for (let label of this.labels)\n if (label.name === maybeName)\n this.raise(expr.start, \"Label '\" + maybeName + \"' is already declared\")\n let kind = this.type.isLoop ? \"loop\" : this.type === tt._switch ? \"switch\" : null\n for (let i = this.labels.length - 1; i >= 0; i--) {\n let label = this.labels[i]\n if (label.statementStart === node.start) {\n // Update information about previous labels on this node\n label.statementStart = this.start\n label.kind = kind\n } else break\n }\n this.labels.push({name: maybeName, kind, statementStart: this.start})\n node.body = this.parseStatement(context)\n if (node.body.type === \"ClassDeclaration\" ||\n node.body.type === \"VariableDeclaration\" && node.body.kind !== \"var\" ||\n node.body.type === \"FunctionDeclaration\" && (this.strict || node.body.generator || node.body.async))\n this.raiseRecoverable(node.body.start, \"Invalid labeled declaration\")\n this.labels.pop()\n node.label = expr\n return this.finishNode(node, \"LabeledStatement\")\n}\n\npp.parseExpressionStatement = function(node, expr) {\n node.expression = expr\n this.semicolon()\n return this.finishNode(node, \"ExpressionStatement\")\n}\n\n// Parse a semicolon-enclosed block of statements, handling `\"use\n// strict\"` declarations when `allowStrict` is true (used for\n// function bodies).\n\npp.parseBlock = function(createNewLexicalScope = true, node = this.startNode()) {\n node.body = []\n this.expect(tt.braceL)\n if (createNewLexicalScope) this.enterScope(0)\n while (!this.eat(tt.braceR)) {\n let stmt = this.parseStatement(null)\n node.body.push(stmt)\n }\n if (createNewLexicalScope) this.exitScope()\n return this.finishNode(node, \"BlockStatement\")\n}\n\n// Parse a regular `for` loop. The disambiguation code in\n// `parseStatement` will already have parsed the init statement or\n// expression.\n\npp.parseFor = function(node, init) {\n node.init = init\n this.expect(tt.semi)\n node.test = this.type === tt.semi ? null : this.parseExpression()\n this.expect(tt.semi)\n node.update = this.type === tt.parenR ? null : this.parseExpression()\n this.expect(tt.parenR)\n this.exitScope()\n node.body = this.parseStatement(\"for\")\n this.labels.pop()\n return this.finishNode(node, \"ForStatement\")\n}\n\n// Parse a `for`/`in` and `for`/`of` loop, which are almost\n// same from parser's perspective.\n\npp.parseForIn = function(node, init) {\n let type = this.type === tt._in ? \"ForInStatement\" : \"ForOfStatement\"\n this.next()\n if (type === \"ForInStatement\") {\n if (init.type === \"AssignmentPattern\" ||\n (init.type === \"VariableDeclaration\" && init.declarations[0].init != null &&\n (this.strict || init.declarations[0].id.type !== \"Identifier\")))\n this.raise(init.start, \"Invalid assignment in for-in loop head\")\n }\n node.left = init\n node.right = type === \"ForInStatement\" ? this.parseExpression() : this.parseMaybeAssign()\n this.expect(tt.parenR)\n this.exitScope()\n node.body = this.parseStatement(\"for\")\n this.labels.pop()\n return this.finishNode(node, type)\n}\n\n// Parse a list of variable declarations.\n\npp.parseVar = function(node, isFor, kind) {\n node.declarations = []\n node.kind = kind\n for (;;) {\n let decl = this.startNode()\n this.parseVarId(decl, kind)\n if (this.eat(tt.eq)) {\n decl.init = this.parseMaybeAssign(isFor)\n } else if (kind === \"const\" && !(this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual(\"of\")))) {\n this.unexpected()\n } else if (decl.id.type !== \"Identifier\" && !(isFor && (this.type === tt._in || this.isContextual(\"of\")))) {\n this.raise(this.lastTokEnd, \"Complex binding patterns require an initialization value\")\n } else {\n decl.init = null\n }\n node.declarations.push(this.finishNode(decl, \"VariableDeclarator\"))\n if (!this.eat(tt.comma)) break\n }\n return node\n}\n\npp.parseVarId = function(decl, kind) {\n decl.id = this.parseBindingAtom(kind)\n this.checkLVal(decl.id, kind === \"var\" ? BIND_VAR : BIND_LEXICAL, false)\n}\n\nconst FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4\n\n// Parse a function declaration or literal (depending on the\n// `isStatement` parameter).\n\npp.parseFunction = function(node, statement, allowExpressionBody, isAsync) {\n this.initFunction(node)\n if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync)\n node.generator = this.eat(tt.star)\n if (this.options.ecmaVersion >= 8)\n node.async = !!isAsync\n\n if (statement & FUNC_STATEMENT) {\n node.id = (statement & FUNC_NULLABLE_ID) && this.type !== tt.name ? null : this.parseIdent()\n if (node.id && !(statement & FUNC_HANGING_STATEMENT))\n this.checkLVal(node.id, this.inModule && !this.inFunction ? BIND_LEXICAL : BIND_FUNCTION)\n }\n\n let oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos\n this.yieldPos = 0\n this.awaitPos = 0\n this.enterScope(functionFlags(node.async, node.generator))\n\n if (!(statement & FUNC_STATEMENT))\n node.id = this.type === tt.name ? this.parseIdent() : null\n\n this.parseFunctionParams(node)\n this.parseFunctionBody(node, allowExpressionBody)\n\n this.yieldPos = oldYieldPos\n this.awaitPos = oldAwaitPos\n return this.finishNode(node, (statement & FUNC_STATEMENT) ? \"FunctionDeclaration\" : \"FunctionExpression\")\n}\n\npp.parseFunctionParams = function(node) {\n this.expect(tt.parenL)\n node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8)\n this.checkYieldAwaitInDefaultParams()\n}\n\n// Parse a class declaration or literal (depending on the\n// `isStatement` parameter).\n\npp.parseClass = function(node, isStatement) {\n this.next()\n\n this.parseClassId(node, isStatement)\n this.parseClassSuper(node)\n let classBody = this.startNode()\n let hadConstructor = false\n classBody.body = []\n this.expect(tt.braceL)\n while (!this.eat(tt.braceR)) {\n const element = this.parseClassElement()\n if (element) {\n classBody.body.push(element)\n if (element.type === \"MethodDefinition\" && element.kind === \"constructor\") {\n if (hadConstructor) this.raise(element.start, \"Duplicate constructor in the same class\")\n hadConstructor = true\n }\n }\n }\n node.body = this.finishNode(classBody, \"ClassBody\")\n return this.finishNode(node, isStatement ? \"ClassDeclaration\" : \"ClassExpression\")\n}\n\npp.parseClassElement = function() {\n if (this.eat(tt.semi)) return null\n\n let method = this.startNode()\n const tryContextual = (k, noLineBreak = false) => {\n const start = this.start, startLoc = this.startLoc\n if (!this.eatContextual(k)) return false\n if (this.type !== tt.parenL && (!noLineBreak || !this.canInsertSemicolon())) return true\n if (method.key) this.unexpected()\n method.computed = false\n method.key = this.startNodeAt(start, startLoc)\n method.key.name = k\n this.finishNode(method.key, \"Identifier\")\n return false\n }\n\n method.kind = \"method\"\n method.static = tryContextual(\"static\")\n let isGenerator = this.eat(tt.star)\n let isAsync = false\n if (!isGenerator) {\n if (this.options.ecmaVersion >= 8 && tryContextual(\"async\", true)) {\n isAsync = true\n isGenerator = this.options.ecmaVersion >= 9 && this.eat(tt.star)\n } else if (tryContextual(\"get\")) {\n method.kind = \"get\"\n } else if (tryContextual(\"set\")) {\n method.kind = \"set\"\n }\n }\n if (!method.key) this.parsePropertyName(method)\n let {key} = method\n if (!method.computed && !method.static && (key.type === \"Identifier\" && key.name === \"constructor\" ||\n key.type === \"Literal\" && key.value === \"constructor\")) {\n if (method.kind !== \"method\") this.raise(key.start, \"Constructor can't have get/set modifier\")\n if (isGenerator) this.raise(key.start, \"Constructor can't be a generator\")\n if (isAsync) this.raise(key.start, \"Constructor can't be an async method\")\n method.kind = \"constructor\"\n } else if (method.static && key.type === \"Identifier\" && key.name === \"prototype\") {\n this.raise(key.start, \"Classes may not have a static property named prototype\")\n }\n this.parseClassMethod(method, isGenerator, isAsync)\n if (method.kind === \"get\" && method.value.params.length !== 0)\n this.raiseRecoverable(method.value.start, \"getter should have no params\")\n if (method.kind === \"set\" && method.value.params.length !== 1)\n this.raiseRecoverable(method.value.start, \"setter should have exactly one param\")\n if (method.kind === \"set\" && method.value.params[0].type === \"RestElement\")\n this.raiseRecoverable(method.value.params[0].start, \"Setter cannot use rest params\")\n return method\n}\n\npp.parseClassMethod = function(method, isGenerator, isAsync) {\n method.value = this.parseMethod(isGenerator, isAsync)\n return this.finishNode(method, \"MethodDefinition\")\n}\n\npp.parseClassId = function(node, isStatement) {\n node.id = this.type === tt.name ? this.parseIdent() : isStatement === true ? this.unexpected() : null\n}\n\npp.parseClassSuper = function(node) {\n node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null\n}\n\n// Parses module export declaration.\n\npp.parseExport = function(node, exports) {\n this.next()\n // export * from '...'\n if (this.eat(tt.star)) {\n this.expectContextual(\"from\")\n if (this.type !== tt.string) this.unexpected()\n node.source = this.parseExprAtom()\n this.semicolon()\n return this.finishNode(node, \"ExportAllDeclaration\")\n }\n if (this.eat(tt._default)) { // export default ...\n this.checkExport(exports, \"default\", this.lastTokStart)\n let isAsync\n if (this.type === tt._function || (isAsync = this.isAsyncFunction())) {\n let fNode = this.startNode()\n this.next()\n if (isAsync) this.next()\n node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync, true)\n } else if (this.type === tt._class) {\n let cNode = this.startNode()\n node.declaration = this.parseClass(cNode, \"nullableID\")\n } else {\n node.declaration = this.parseMaybeAssign()\n this.semicolon()\n }\n return this.finishNode(node, \"ExportDefaultDeclaration\")\n }\n // export var|const|let|function|class ...\n if (this.shouldParseExportStatement()) {\n node.declaration = this.parseStatement(null)\n if (node.declaration.type === \"VariableDeclaration\")\n this.checkVariableExport(exports, node.declaration.declarations)\n else\n this.checkExport(exports, node.declaration.id.name, node.declaration.id.start)\n node.specifiers = []\n node.source = null\n } else { // export { x, y as z } [from '...']\n node.declaration = null\n node.specifiers = this.parseExportSpecifiers(exports)\n if (this.eatContextual(\"from\")) {\n if (this.type !== tt.string) this.unexpected()\n node.source = this.parseExprAtom()\n } else {\n // check for keywords used as local names\n for (let spec of node.specifiers) {\n this.checkUnreserved(spec.local)\n }\n\n node.source = null\n }\n this.semicolon()\n }\n return this.finishNode(node, \"ExportNamedDeclaration\")\n}\n\npp.checkExport = function(exports, name, pos) {\n if (!exports) return\n if (has(exports, name))\n this.raiseRecoverable(pos, \"Duplicate export '\" + name + \"'\")\n exports[name] = true\n}\n\npp.checkPatternExport = function(exports, pat) {\n let type = pat.type\n if (type === \"Identifier\")\n this.checkExport(exports, pat.name, pat.start)\n else if (type === \"ObjectPattern\")\n for (let prop of pat.properties)\n this.checkPatternExport(exports, prop)\n else if (type === \"ArrayPattern\")\n for (let elt of pat.elements) {\n if (elt) this.checkPatternExport(exports, elt)\n }\n else if (type === \"Property\")\n this.checkPatternExport(exports, pat.value)\n else if (type === \"AssignmentPattern\")\n this.checkPatternExport(exports, pat.left)\n else if (type === \"RestElement\")\n this.checkPatternExport(exports, pat.argument)\n else if (type === \"ParenthesizedExpression\")\n this.checkPatternExport(exports, pat.expression)\n}\n\npp.checkVariableExport = function(exports, decls) {\n if (!exports) return\n for (let decl of decls)\n this.checkPatternExport(exports, decl.id)\n}\n\npp.shouldParseExportStatement = function() {\n return this.type.keyword === \"var\" ||\n this.type.keyword === \"const\" ||\n this.type.keyword === \"class\" ||\n this.type.keyword === \"function\" ||\n this.isLet() ||\n this.isAsyncFunction()\n}\n\n// Parses a comma-separated list of module exports.\n\npp.parseExportSpecifiers = function(exports) {\n let nodes = [], first = true\n // export { x, y as z } [from '...']\n this.expect(tt.braceL)\n while (!this.eat(tt.braceR)) {\n if (!first) {\n this.expect(tt.comma)\n if (this.afterTrailingComma(tt.braceR)) break\n } else first = false\n\n let node = this.startNode()\n node.local = this.parseIdent(true)\n node.exported = this.eatContextual(\"as\") ? this.parseIdent(true) : node.local\n this.checkExport(exports, node.exported.name, node.exported.start)\n nodes.push(this.finishNode(node, \"ExportSpecifier\"))\n }\n return nodes\n}\n\n// Parses import declaration.\n\npp.parseImport = function(node) {\n this.next()\n // import '...'\n if (this.type === tt.string) {\n node.specifiers = empty\n node.source = this.parseExprAtom()\n } else {\n node.specifiers = this.parseImportSpecifiers()\n this.expectContextual(\"from\")\n node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected()\n }\n this.semicolon()\n return this.finishNode(node, \"ImportDeclaration\")\n}\n\n// Parses a comma-separated list of module imports.\n\npp.parseImportSpecifiers = function() {\n let nodes = [], first = true\n if (this.type === tt.name) {\n // import defaultObj, { x, y as z } from '...'\n let node = this.startNode()\n node.local = this.parseIdent()\n this.checkLVal(node.local, BIND_LEXICAL)\n nodes.push(this.finishNode(node, \"ImportDefaultSpecifier\"))\n if (!this.eat(tt.comma)) return nodes\n }\n if (this.type === tt.star) {\n let node = this.startNode()\n this.next()\n this.expectContextual(\"as\")\n node.local = this.parseIdent()\n this.checkLVal(node.local, BIND_LEXICAL)\n nodes.push(this.finishNode(node, \"ImportNamespaceSpecifier\"))\n return nodes\n }\n this.expect(tt.braceL)\n while (!this.eat(tt.braceR)) {\n if (!first) {\n this.expect(tt.comma)\n if (this.afterTrailingComma(tt.braceR)) break\n } else first = false\n\n let node = this.startNode()\n node.imported = this.parseIdent(true)\n if (this.eatContextual(\"as\")) {\n node.local = this.parseIdent()\n } else {\n this.checkUnreserved(node.imported)\n node.local = node.imported\n }\n this.checkLVal(node.local, BIND_LEXICAL)\n nodes.push(this.finishNode(node, \"ImportSpecifier\"))\n }\n return nodes\n}\n\n// Set `ExpressionStatement#directive` property for directive prologues.\npp.adaptDirectivePrologue = function(statements) {\n for (let i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {\n statements[i].directive = statements[i].expression.raw.slice(1, -1)\n }\n}\npp.isDirectiveCandidate = function(statement) {\n return (\n statement.type === \"ExpressionStatement\" &&\n statement.expression.type === \"Literal\" &&\n typeof statement.expression.value === \"string\" &&\n // Reject parenthesized strings.\n (this.input[statement.start] === \"\\\"\" || this.input[statement.start] === \"'\")\n )\n}\n","import {types as tt} from \"./tokentype\"\nimport {Parser} from \"./state\"\nimport {has} from \"./util\"\nimport {BIND_NONE, BIND_OUTSIDE} from \"./scopeflags\"\n\nconst pp = Parser.prototype\n\n// Convert existing expression atom to assignable pattern\n// if possible.\n\npp.toAssignable = function(node, isBinding, refDestructuringErrors) {\n if (this.options.ecmaVersion >= 6 && node) {\n switch (node.type) {\n case \"Identifier\":\n if (this.inAsync && node.name === \"await\")\n this.raise(node.start, \"Can not use 'await' as identifier inside an async function\")\n break\n\n case \"ObjectPattern\":\n case \"ArrayPattern\":\n case \"RestElement\":\n break\n\n case \"ObjectExpression\":\n node.type = \"ObjectPattern\"\n if (refDestructuringErrors) this.checkPatternErrors(refDestructuringErrors, true)\n for (let prop of node.properties) {\n this.toAssignable(prop, isBinding)\n // Early error:\n // AssignmentRestProperty[Yield, Await] :\n // `...` DestructuringAssignmentTarget[Yield, Await]\n //\n // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.\n if (\n prop.type === \"RestElement\" &&\n (prop.argument.type === \"ArrayPattern\" || prop.argument.type === \"ObjectPattern\")\n ) {\n this.raise(prop.argument.start, \"Unexpected token\")\n }\n }\n break\n\n case \"Property\":\n // AssignmentProperty has type === \"Property\"\n if (node.kind !== \"init\") this.raise(node.key.start, \"Object pattern can't contain getter or setter\")\n this.toAssignable(node.value, isBinding)\n break\n\n case \"ArrayExpression\":\n node.type = \"ArrayPattern\"\n if (refDestructuringErrors) this.checkPatternErrors(refDestructuringErrors, true)\n this.toAssignableList(node.elements, isBinding)\n break\n\n case \"SpreadElement\":\n node.type = \"RestElement\"\n this.toAssignable(node.argument, isBinding)\n if (node.argument.type === \"AssignmentPattern\")\n this.raise(node.argument.start, \"Rest elements cannot have a default value\")\n break\n\n case \"AssignmentExpression\":\n if (node.operator !== \"=\") this.raise(node.left.end, \"Only '=' operator can be used for specifying default value.\")\n node.type = \"AssignmentPattern\"\n delete node.operator\n this.toAssignable(node.left, isBinding)\n // falls through to AssignmentPattern\n\n case \"AssignmentPattern\":\n break\n\n case \"ParenthesizedExpression\":\n this.toAssignable(node.expression, isBinding)\n break\n\n case \"MemberExpression\":\n if (!isBinding) break\n\n default:\n this.raise(node.start, \"Assigning to rvalue\")\n }\n } else if (refDestructuringErrors) this.checkPatternErrors(refDestructuringErrors, true)\n return node\n}\n\n// Convert list of expression atoms to binding list.\n\npp.toAssignableList = function(exprList, isBinding) {\n let end = exprList.length\n for (let i = 0; i < end; i++) {\n let elt = exprList[i]\n if (elt) this.toAssignable(elt, isBinding)\n }\n if (end) {\n let last = exprList[end - 1]\n if (this.options.ecmaVersion === 6 && isBinding && last && last.type === \"RestElement\" && last.argument.type !== \"Identifier\")\n this.unexpected(last.argument.start)\n }\n return exprList\n}\n\n// Parses spread element.\n\npp.parseSpread = function(refDestructuringErrors) {\n let node = this.startNode()\n this.next()\n node.argument = this.parseMaybeAssign(false, refDestructuringErrors)\n return this.finishNode(node, \"SpreadElement\")\n}\n\npp.parseRestBinding = function() {\n let node = this.startNode()\n this.next()\n\n // RestElement inside of a function parameter must be an identifier\n if (this.options.ecmaVersion === 6 && this.type !== tt.name)\n this.unexpected()\n\n node.argument = this.parseBindingAtom()\n\n return this.finishNode(node, \"RestElement\")\n}\n\n// Parses lvalue (assignable) atom.\n\npp.parseBindingAtom = function() {\n if (this.options.ecmaVersion >= 6) {\n switch (this.type) {\n case tt.bracketL:\n let node = this.startNode()\n this.next()\n node.elements = this.parseBindingList(tt.bracketR, true, true)\n return this.finishNode(node, \"ArrayPattern\")\n\n case tt.braceL:\n return this.parseObj(true)\n }\n }\n return this.parseIdent()\n}\n\npp.parseBindingList = function(close, allowEmpty, allowTrailingComma) {\n let elts = [], first = true\n while (!this.eat(close)) {\n if (first) first = false\n else this.expect(tt.comma)\n if (allowEmpty && this.type === tt.comma) {\n elts.push(null)\n } else if (allowTrailingComma && this.afterTrailingComma(close)) {\n break\n } else if (this.type === tt.ellipsis) {\n let rest = this.parseRestBinding()\n this.parseBindingListItem(rest)\n elts.push(rest)\n if (this.type === tt.comma) this.raise(this.start, \"Comma is not permitted after the rest element\")\n this.expect(close)\n break\n } else {\n let elem = this.parseMaybeDefault(this.start, this.startLoc)\n this.parseBindingListItem(elem)\n elts.push(elem)\n }\n }\n return elts\n}\n\npp.parseBindingListItem = function(param) {\n return param\n}\n\n// Parses assignment pattern around given atom if possible.\n\npp.parseMaybeDefault = function(startPos, startLoc, left) {\n left = left || this.parseBindingAtom()\n if (this.options.ecmaVersion < 6 || !this.eat(tt.eq)) return left\n let node = this.startNodeAt(startPos, startLoc)\n node.left = left\n node.right = this.parseMaybeAssign()\n return this.finishNode(node, \"AssignmentPattern\")\n}\n\n// Verify that a node is an lval — something that can be assigned\n// to.\n// bindingType can be either:\n// 'var' indicating that the lval creates a 'var' binding\n// 'let' indicating that the lval creates a lexical ('let' or 'const') binding\n// 'none' indicating that the binding should be checked for illegal identifiers, but not for duplicate references\n\npp.checkLVal = function(expr, bindingType = BIND_NONE, checkClashes) {\n switch (expr.type) {\n case \"Identifier\":\n if (this.strict && this.reservedWordsStrictBind.test(expr.name))\n this.raiseRecoverable(expr.start, (bindingType ? \"Binding \" : \"Assigning to \") + expr.name + \" in strict mode\")\n if (checkClashes) {\n if (has(checkClashes, expr.name))\n this.raiseRecoverable(expr.start, \"Argument name clash\")\n checkClashes[expr.name] = true\n }\n if (bindingType !== BIND_NONE && bindingType !== BIND_OUTSIDE) this.declareName(expr.name, bindingType, expr.start)\n break\n\n case \"MemberExpression\":\n if (bindingType) this.raiseRecoverable(expr.start, \"Binding member expression\")\n break\n\n case \"ObjectPattern\":\n for (let prop of expr.properties)\n this.checkLVal(prop, bindingType, checkClashes)\n break\n\n case \"Property\":\n // AssignmentProperty has type === \"Property\"\n this.checkLVal(expr.value, bindingType, checkClashes)\n break\n\n case \"ArrayPattern\":\n for (let elem of expr.elements) {\n if (elem) this.checkLVal(elem, bindingType, checkClashes)\n }\n break\n\n case \"AssignmentPattern\":\n this.checkLVal(expr.left, bindingType, checkClashes)\n break\n\n case \"RestElement\":\n this.checkLVal(expr.argument, bindingType, checkClashes)\n break\n\n case \"ParenthesizedExpression\":\n this.checkLVal(expr.expression, bindingType, checkClashes)\n break\n\n default:\n this.raise(expr.start, (bindingType ? \"Binding\" : \"Assigning to\") + \" rvalue\")\n }\n}\n","// A recursive descent parser operates by defining functions for all\n// syntactic elements, and recursively calling those, each function\n// advancing the input stream and returning an AST node. Precedence\n// of constructs (for example, the fact that `!x[1]` means `!(x[1])`\n// instead of `(!x)[1]` is handled by the fact that the parser\n// function that parses unary prefix operators is called first, and\n// in turn calls the function that parses `[]` subscripts — that\n// way, it'll receive the node for `x[1]` already parsed, and wraps\n// *that* in the unary operator node.\n//\n// Acorn uses an [operator precedence parser][opp] to handle binary\n// operator precedence, because it is much more compact than using\n// the technique outlined above, which uses different, nesting\n// functions to specify precedence, for all of the ten binary\n// precedence levels that JavaScript defines.\n//\n// [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser\n\nimport {types as tt} from \"./tokentype\"\nimport {Parser} from \"./state\"\nimport {DestructuringErrors} from \"./parseutil\"\nimport {lineBreak} from \"./whitespace\"\nimport {functionFlags, SCOPE_ARROW, BIND_OUTSIDE, BIND_VAR} from \"./scopeflags\"\n\nconst pp = Parser.prototype\n\n// Check if property name clashes with already added.\n// Object/class getters and setters are not allowed to clash —\n// either with each other or with an init property — and in\n// strict mode, init properties are also not allowed to be repeated.\n\npp.checkPropClash = function(prop, propHash, refDestructuringErrors) {\n if (this.options.ecmaVersion >= 9 && prop.type === \"SpreadElement\")\n return\n if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))\n return\n let {key} = prop, name\n switch (key.type) {\n case \"Identifier\": name = key.name; break\n case \"Literal\": name = String(key.value); break\n default: return\n }\n let {kind} = prop\n if (this.options.ecmaVersion >= 6) {\n if (name === \"__proto__\" && kind === \"init\") {\n if (propHash.proto) {\n if (refDestructuringErrors && refDestructuringErrors.doubleProto < 0) refDestructuringErrors.doubleProto = key.start\n // Backwards-compat kludge. Can be removed in version 6.0\n else this.raiseRecoverable(key.start, \"Redefinition of __proto__ property\")\n }\n propHash.proto = true\n }\n return\n }\n name = \"$\" + name\n let other = propHash[name]\n if (other) {\n let redefinition\n if (kind === \"init\") {\n redefinition = this.strict && other.init || other.get || other.set\n } else {\n redefinition = other.init || other[kind]\n }\n if (redefinition)\n this.raiseRecoverable(key.start, \"Redefinition of property\")\n } else {\n other = propHash[name] = {\n init: false,\n get: false,\n set: false\n }\n }\n other[kind] = true\n}\n\n// ### Expression parsing\n\n// These nest, from the most general expression type at the top to\n// 'atomic', nondivisible expression types at the bottom. Most of\n// the functions will simply let the function(s) below them parse,\n// and, *if* the syntactic construct they handle is present, wrap\n// the AST node that the inner parser gave them in another node.\n\n// Parse a full expression. The optional arguments are used to\n// forbid the `in` operator (in for loops initalization expressions)\n// and provide reference for storing '=' operator inside shorthand\n// property assignment in contexts where both object expression\n// and object pattern might appear (so it's possible to raise\n// delayed syntax error at correct position).\n\npp.parseExpression = function(noIn, refDestructuringErrors) {\n let startPos = this.start, startLoc = this.startLoc\n let expr = this.parseMaybeAssign(noIn, refDestructuringErrors)\n if (this.type === tt.comma) {\n let node = this.startNodeAt(startPos, startLoc)\n node.expressions = [expr]\n while (this.eat(tt.comma)) node.expressions.push(this.parseMaybeAssign(noIn, refDestructuringErrors))\n return this.finishNode(node, \"SequenceExpression\")\n }\n return expr\n}\n\n// Parse an assignment expression. This includes applications of\n// operators like `+=`.\n\npp.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) {\n if (this.isContextual(\"yield\")) {\n if (this.inGenerator) return this.parseYield()\n // The tokenizer will assume an expression is allowed after\n // `yield`, but this isn't that kind of yield\n else this.exprAllowed = false\n }\n\n let ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldShorthandAssign = -1\n if (refDestructuringErrors) {\n oldParenAssign = refDestructuringErrors.parenthesizedAssign\n oldTrailingComma = refDestructuringErrors.trailingComma\n oldShorthandAssign = refDestructuringErrors.shorthandAssign;\n refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.shorthandAssign = -1\n } else {\n refDestructuringErrors = new DestructuringErrors\n ownDestructuringErrors = true\n }\n\n let startPos = this.start, startLoc = this.startLoc\n if (this.type === tt.parenL || this.type === tt.name)\n this.potentialArrowAt = this.start\n let left = this.parseMaybeConditional(noIn, refDestructuringErrors)\n if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc)\n if (this.type.isAssign) {\n let node = this.startNodeAt(startPos, startLoc)\n node.operator = this.value\n node.left = this.type === tt.eq ? this.toAssignable(left, false, refDestructuringErrors) : left\n if (!ownDestructuringErrors) DestructuringErrors.call(refDestructuringErrors)\n refDestructuringErrors.shorthandAssign = -1 // reset because shorthand default was used correctly\n this.checkLVal(left)\n this.next()\n node.right = this.parseMaybeAssign(noIn)\n return this.finishNode(node, \"AssignmentExpression\")\n } else {\n if (ownDestructuringErrors) this.checkExpressionErrors(refDestructuringErrors, true)\n }\n if (oldParenAssign > -1) refDestructuringErrors.parenthesizedAssign = oldParenAssign\n if (oldTrailingComma > -1) refDestructuringErrors.trailingComma = oldTrailingComma\n if (oldShorthandAssign > -1) refDestructuringErrors.shorthandAssign = oldShorthandAssign\n return left\n}\n\n// Parse a ternary conditional (`?:`) operator.\n\npp.parseMaybeConditional = function(noIn, refDestructuringErrors) {\n let startPos = this.start, startLoc = this.startLoc\n let expr = this.parseExprOps(noIn, refDestructuringErrors)\n if (this.checkExpressionErrors(refDestructuringErrors)) return expr\n if (this.eat(tt.question)) {\n let node = this.startNodeAt(startPos, startLoc)\n node.test = expr\n node.consequent = this.parseMaybeAssign()\n this.expect(tt.colon)\n node.alternate = this.parseMaybeAssign(noIn)\n return this.finishNode(node, \"ConditionalExpression\")\n }\n return expr\n}\n\n// Start the precedence parser.\n\npp.parseExprOps = function(noIn, refDestructuringErrors) {\n let startPos = this.start, startLoc = this.startLoc\n let expr = this.parseMaybeUnary(refDestructuringErrors, false)\n if (this.checkExpressionErrors(refDestructuringErrors)) return expr\n return expr.start === startPos && expr.type === \"ArrowFunctionExpression\" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, noIn)\n}\n\n// Parse binary operators with the operator precedence parsing\n// algorithm. `left` is the left-hand side of the operator.\n// `minPrec` provides context that allows the function to stop and\n// defer further parser to one of its callers when it encounters an\n// operator that has a lower precedence than the set it is parsing.\n\npp.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) {\n let prec = this.type.binop\n if (prec != null && (!noIn || this.type !== tt._in)) {\n if (prec > minPrec) {\n let logical = this.type === tt.logicalOR || this.type === tt.logicalAND\n let op = this.value\n this.next()\n let startPos = this.start, startLoc = this.startLoc\n let right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn)\n let node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical)\n return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn)\n }\n }\n return left\n}\n\npp.buildBinary = function(startPos, startLoc, left, right, op, logical) {\n let node = this.startNodeAt(startPos, startLoc)\n node.left = left\n node.operator = op\n node.right = right\n return this.finishNode(node, logical ? \"LogicalExpression\" : \"BinaryExpression\")\n}\n\n// Parse unary operators, both prefix and postfix.\n\npp.parseMaybeUnary = function(refDestructuringErrors, sawUnary) {\n let startPos = this.start, startLoc = this.startLoc, expr\n if (this.isContextual(\"await\") && (this.inAsync || (!this.inFunction && this.options.allowAwaitOutsideFunction))) {\n expr = this.parseAwait()\n sawUnary = true\n } else if (this.type.prefix) {\n let node = this.startNode(), update = this.type === tt.incDec\n node.operator = this.value\n node.prefix = true\n this.next()\n node.argument = this.parseMaybeUnary(null, true)\n this.checkExpressionErrors(refDestructuringErrors, true)\n if (update) this.checkLVal(node.argument)\n else if (this.strict && node.operator === \"delete\" &&\n node.argument.type === \"Identifier\")\n this.raiseRecoverable(node.start, \"Deleting local variable in strict mode\")\n else sawUnary = true\n expr = this.finishNode(node, update ? \"UpdateExpression\" : \"UnaryExpression\")\n } else {\n expr = this.parseExprSubscripts(refDestructuringErrors)\n if (this.checkExpressionErrors(refDestructuringErrors)) return expr\n while (this.type.postfix && !this.canInsertSemicolon()) {\n let node = this.startNodeAt(startPos, startLoc)\n node.operator = this.value\n node.prefix = false\n node.argument = expr\n this.checkLVal(expr)\n this.next()\n expr = this.finishNode(node, \"UpdateExpression\")\n }\n }\n\n if (!sawUnary && this.eat(tt.starstar))\n return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), \"**\", false)\n else\n return expr\n}\n\n// Parse call, dot, and `[]`-subscript expressions.\n\npp.parseExprSubscripts = function(refDestructuringErrors) {\n let startPos = this.start, startLoc = this.startLoc\n let expr = this.parseExprAtom(refDestructuringErrors)\n let skipArrowSubscripts = expr.type === \"ArrowFunctionExpression\" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== \")\"\n if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) return expr\n let result = this.parseSubscripts(expr, startPos, startLoc)\n if (refDestructuringErrors && result.type === \"MemberExpression\") {\n if (refDestructuringErrors.parenthesizedAssign >= result.start) refDestructuringErrors.parenthesizedAssign = -1\n if (refDestructuringErrors.parenthesizedBind >= result.start) refDestructuringErrors.parenthesizedBind = -1\n }\n return result\n}\n\npp.parseSubscripts = function(base, startPos, startLoc, noCalls) {\n let maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === \"Identifier\" && base.name === \"async\" &&\n this.lastTokEnd === base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === \"async\"\n for (let computed;;) {\n if ((computed = this.eat(tt.bracketL)) || this.eat(tt.dot)) {\n let node = this.startNodeAt(startPos, startLoc)\n node.object = base\n node.property = computed ? this.parseExpression() : this.parseIdent(true)\n node.computed = !!computed\n if (computed) this.expect(tt.bracketR)\n base = this.finishNode(node, \"MemberExpression\")\n } else if (!noCalls && this.eat(tt.parenL)) {\n let refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos\n this.yieldPos = 0\n this.awaitPos = 0\n let exprList = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors)\n if (maybeAsyncArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {\n this.checkPatternErrors(refDestructuringErrors, false)\n this.checkYieldAwaitInDefaultParams()\n this.yieldPos = oldYieldPos\n this.awaitPos = oldAwaitPos\n return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true)\n }\n this.checkExpressionErrors(refDestructuringErrors, true)\n this.yieldPos = oldYieldPos || this.yieldPos\n this.awaitPos = oldAwaitPos || this.awaitPos\n let node = this.startNodeAt(startPos, startLoc)\n node.callee = base\n node.arguments = exprList\n base = this.finishNode(node, \"CallExpression\")\n } else if (this.type === tt.backQuote) {\n let node = this.startNodeAt(startPos, startLoc)\n node.tag = base\n node.quasi = this.parseTemplate({isTagged: true})\n base = this.finishNode(node, \"TaggedTemplateExpression\")\n } else {\n return base\n }\n }\n}\n\n// Parse an atomic expression — either a single token that is an\n// expression, an expression started by a keyword like `function` or\n// `new`, or an expression wrapped in punctuation like `()`, `[]`,\n// or `{}`.\n\npp.parseExprAtom = function(refDestructuringErrors) {\n let node, canBeArrow = this.potentialArrowAt === this.start\n switch (this.type) {\n case tt._super:\n if (!this.inFunction)\n this.raise(this.start, \"'super' outside of function or class\")\n node = this.startNode()\n this.next()\n // The `super` keyword can appear at below:\n // SuperProperty:\n // super [ Expression ]\n // super . IdentifierName\n // SuperCall:\n // super Arguments\n if (this.type !== tt.dot && this.type !== tt.bracketL && this.type !== tt.parenL)\n this.unexpected()\n return this.finishNode(node, \"Super\")\n\n case tt._this:\n node = this.startNode()\n this.next()\n return this.finishNode(node, \"ThisExpression\")\n\n case tt.name:\n let startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc\n let id = this.parseIdent(this.type !== tt.name)\n if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === \"async\" && !this.canInsertSemicolon() && this.eat(tt._function))\n return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true)\n if (canBeArrow && !this.canInsertSemicolon()) {\n if (this.eat(tt.arrow))\n return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false)\n if (this.options.ecmaVersion >= 8 && id.name === \"async\" && this.type === tt.name && !containsEsc) {\n id = this.parseIdent()\n if (this.canInsertSemicolon() || !this.eat(tt.arrow))\n this.unexpected()\n return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true)\n }\n }\n return id\n\n case tt.regexp:\n let value = this.value\n node = this.parseLiteral(value.value)\n node.regex = {pattern: value.pattern, flags: value.flags}\n return node\n\n case tt.num: case tt.string:\n return this.parseLiteral(this.value)\n\n case tt._null: case tt._true: case tt._false:\n node = this.startNode()\n node.value = this.type === tt._null ? null : this.type === tt._true\n node.raw = this.type.keyword\n this.next()\n return this.finishNode(node, \"Literal\")\n\n case tt.parenL:\n let start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow)\n if (refDestructuringErrors) {\n if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr))\n refDestructuringErrors.parenthesizedAssign = start\n if (refDestructuringErrors.parenthesizedBind < 0)\n refDestructuringErrors.parenthesizedBind = start\n }\n return expr\n\n case tt.bracketL:\n node = this.startNode()\n this.next()\n node.elements = this.parseExprList(tt.bracketR, true, true, refDestructuringErrors)\n return this.finishNode(node, \"ArrayExpression\")\n\n case tt.braceL:\n return this.parseObj(false, refDestructuringErrors)\n\n case tt._function:\n node = this.startNode()\n this.next()\n return this.parseFunction(node, 0)\n\n case tt._class:\n return this.parseClass(this.startNode(), false)\n\n case tt._new:\n return this.parseNew()\n\n case tt.backQuote:\n return this.parseTemplate()\n\n default:\n this.unexpected()\n }\n}\n\npp.parseLiteral = function(value) {\n let node = this.startNode()\n node.value = value\n node.raw = this.input.slice(this.start, this.end)\n this.next()\n return this.finishNode(node, \"Literal\")\n}\n\npp.parseParenExpression = function() {\n this.expect(tt.parenL)\n let val = this.parseExpression()\n this.expect(tt.parenR)\n return val\n}\n\npp.parseParenAndDistinguishExpression = function(canBeArrow) {\n let startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8\n if (this.options.ecmaVersion >= 6) {\n this.next()\n\n let innerStartPos = this.start, innerStartLoc = this.startLoc\n let exprList = [], first = true, lastIsComma = false\n let refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart\n this.yieldPos = 0\n this.awaitPos = 0\n while (this.type !== tt.parenR) {\n first ? first = false : this.expect(tt.comma)\n if (allowTrailingComma && this.afterTrailingComma(tt.parenR, true)) {\n lastIsComma = true\n break\n } else if (this.type === tt.ellipsis) {\n spreadStart = this.start\n exprList.push(this.parseParenItem(this.parseRestBinding()))\n if (this.type === tt.comma) this.raise(this.start, \"Comma is not permitted after the rest element\")\n break\n } else {\n exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem))\n }\n }\n let innerEndPos = this.start, innerEndLoc = this.startLoc\n this.expect(tt.parenR)\n\n if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {\n this.checkPatternErrors(refDestructuringErrors, false)\n this.checkYieldAwaitInDefaultParams()\n this.yieldPos = oldYieldPos\n this.awaitPos = oldAwaitPos\n return this.parseParenArrowList(startPos, startLoc, exprList)\n }\n\n if (!exprList.length || lastIsComma) this.unexpected(this.lastTokStart)\n if (spreadStart) this.unexpected(spreadStart)\n this.checkExpressionErrors(refDestructuringErrors, true)\n this.yieldPos = oldYieldPos || this.yieldPos\n this.awaitPos = oldAwaitPos || this.awaitPos\n\n if (exprList.length > 1) {\n val = this.startNodeAt(innerStartPos, innerStartLoc)\n val.expressions = exprList\n this.finishNodeAt(val, \"SequenceExpression\", innerEndPos, innerEndLoc)\n } else {\n val = exprList[0]\n }\n } else {\n val = this.parseParenExpression()\n }\n\n if (this.options.preserveParens) {\n let par = this.startNodeAt(startPos, startLoc)\n par.expression = val\n return this.finishNode(par, \"ParenthesizedExpression\")\n } else {\n return val\n }\n}\n\npp.parseParenItem = function(item) {\n return item\n}\n\npp.parseParenArrowList = function(startPos, startLoc, exprList) {\n return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList)\n}\n\n// New's precedence is slightly tricky. It must allow its argument to\n// be a `[]` or dot subscript expression, but not a call — at least,\n// not without wrapping it in parentheses. Thus, it uses the noCalls\n// argument to parseSubscripts to prevent it from consuming the\n// argument list.\n\nconst empty = []\n\npp.parseNew = function() {\n let node = this.startNode()\n let meta = this.parseIdent(true)\n if (this.options.ecmaVersion >= 6 && this.eat(tt.dot)) {\n node.meta = meta\n let containsEsc = this.containsEsc\n node.property = this.parseIdent(true)\n if (node.property.name !== \"target\" || containsEsc)\n this.raiseRecoverable(node.property.start, \"The only valid meta property for new is new.target\")\n if (!this.inNonArrowFunction())\n this.raiseRecoverable(node.start, \"new.target can only be used in functions\")\n return this.finishNode(node, \"MetaProperty\")\n }\n let startPos = this.start, startLoc = this.startLoc\n node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true)\n if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8, false)\n else node.arguments = empty\n return this.finishNode(node, \"NewExpression\")\n}\n\n// Parse template expression.\n\npp.parseTemplateElement = function({isTagged}) {\n let elem = this.startNode()\n if (this.type === tt.invalidTemplate) {\n if (!isTagged) {\n this.raiseRecoverable(this.start, \"Bad escape sequence in untagged template literal\")\n }\n elem.value = {\n raw: this.value,\n cooked: null\n }\n } else {\n elem.value = {\n raw: this.input.slice(this.start, this.end).replace(/\\r\\n?/g, \"\\n\"),\n cooked: this.value\n }\n }\n this.next()\n elem.tail = this.type === tt.backQuote\n return this.finishNode(elem, \"TemplateElement\")\n}\n\npp.parseTemplate = function({isTagged = false} = {}) {\n let node = this.startNode()\n this.next()\n node.expressions = []\n let curElt = this.parseTemplateElement({isTagged})\n node.quasis = [curElt]\n while (!curElt.tail) {\n if (this.type === tt.eof) this.raise(this.pos, \"Unterminated template literal\")\n this.expect(tt.dollarBraceL)\n node.expressions.push(this.parseExpression())\n this.expect(tt.braceR)\n node.quasis.push(curElt = this.parseTemplateElement({isTagged}))\n }\n this.next()\n return this.finishNode(node, \"TemplateLiteral\")\n}\n\npp.isAsyncProp = function(prop) {\n return !prop.computed && prop.key.type === \"Identifier\" && prop.key.name === \"async\" &&\n (this.type === tt.name || this.type === tt.num || this.type === tt.string || this.type === tt.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === tt.star)) &&\n !lineBreak.test(this.input.slice(this.lastTokEnd, this.start))\n}\n\n// Parse an object literal or binding pattern.\n\npp.parseObj = function(isPattern, refDestructuringErrors) {\n let node = this.startNode(), first = true, propHash = {}\n node.properties = []\n this.next()\n while (!this.eat(tt.braceR)) {\n if (!first) {\n this.expect(tt.comma)\n if (this.afterTrailingComma(tt.braceR)) break\n } else first = false\n\n const prop = this.parseProperty(isPattern, refDestructuringErrors)\n if (!isPattern) this.checkPropClash(prop, propHash, refDestructuringErrors)\n node.properties.push(prop)\n }\n return this.finishNode(node, isPattern ? \"ObjectPattern\" : \"ObjectExpression\")\n}\n\npp.parseProperty = function(isPattern, refDestructuringErrors) {\n let prop = this.startNode(), isGenerator, isAsync, startPos, startLoc\n if (this.options.ecmaVersion >= 9 && this.eat(tt.ellipsis)) {\n if (isPattern) {\n prop.argument = this.parseIdent(false)\n if (this.type === tt.comma) {\n this.raise(this.start, \"Comma is not permitted after the rest element\")\n }\n return this.finishNode(prop, \"RestElement\")\n }\n // To disallow parenthesized identifier via `this.toAssignable()`.\n if (this.type === tt.parenL && refDestructuringErrors) {\n if (refDestructuringErrors.parenthesizedAssign < 0) {\n refDestructuringErrors.parenthesizedAssign = this.start\n }\n if (refDestructuringErrors.parenthesizedBind < 0) {\n refDestructuringErrors.parenthesizedBind = this.start\n }\n }\n // Parse argument.\n prop.argument = this.parseMaybeAssign(false, refDestructuringErrors)\n // To disallow trailing comma via `this.toAssignable()`.\n if (this.type === tt.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {\n refDestructuringErrors.trailingComma = this.start\n }\n // Finish\n return this.finishNode(prop, \"SpreadElement\")\n }\n if (this.options.ecmaVersion >= 6) {\n prop.method = false\n prop.shorthand = false\n if (isPattern || refDestructuringErrors) {\n startPos = this.start\n startLoc = this.startLoc\n }\n if (!isPattern)\n isGenerator = this.eat(tt.star)\n }\n let containsEsc = this.containsEsc\n this.parsePropertyName(prop)\n if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {\n isAsync = true\n isGenerator = this.options.ecmaVersion >= 9 && this.eat(tt.star)\n this.parsePropertyName(prop, refDestructuringErrors)\n } else {\n isAsync = false\n }\n this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc)\n return this.finishNode(prop, \"Property\")\n}\n\npp.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {\n if ((isGenerator || isAsync) && this.type === tt.colon)\n this.unexpected()\n\n if (this.eat(tt.colon)) {\n prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors)\n prop.kind = \"init\"\n } else if (this.options.ecmaVersion >= 6 && this.type === tt.parenL) {\n if (isPattern) this.unexpected()\n prop.kind = \"init\"\n prop.method = true\n prop.value = this.parseMethod(isGenerator, isAsync)\n } else if (!isPattern && !containsEsc &&\n this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === \"Identifier\" &&\n (prop.key.name === \"get\" || prop.key.name === \"set\") &&\n (this.type !== tt.comma && this.type !== tt.braceR)) {\n if (isGenerator || isAsync) this.unexpected()\n prop.kind = prop.key.name\n this.parsePropertyName(prop)\n prop.value = this.parseMethod(false)\n let paramCount = prop.kind === \"get\" ? 0 : 1\n if (prop.value.params.length !== paramCount) {\n let start = prop.value.start\n if (prop.kind === \"get\")\n this.raiseRecoverable(start, \"getter should have no params\")\n else\n this.raiseRecoverable(start, \"setter should have exactly one param\")\n } else {\n if (prop.kind === \"set\" && prop.value.params[0].type === \"RestElement\")\n this.raiseRecoverable(prop.value.params[0].start, \"Setter cannot use rest params\")\n }\n } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === \"Identifier\") {\n this.checkUnreserved(prop.key)\n prop.kind = \"init\"\n if (isPattern) {\n prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key)\n } else if (this.type === tt.eq && refDestructuringErrors) {\n if (refDestructuringErrors.shorthandAssign < 0)\n refDestructuringErrors.shorthandAssign = this.start\n prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key)\n } else {\n prop.value = prop.key\n }\n prop.shorthand = true\n } else this.unexpected()\n}\n\npp.parsePropertyName = function(prop) {\n if (this.options.ecmaVersion >= 6) {\n if (this.eat(tt.bracketL)) {\n prop.computed = true\n prop.key = this.parseMaybeAssign()\n this.expect(tt.bracketR)\n return prop.key\n } else {\n prop.computed = false\n }\n }\n return prop.key = this.type === tt.num || this.type === tt.string ? this.parseExprAtom() : this.parseIdent(true)\n}\n\n// Initialize empty function node.\n\npp.initFunction = function(node) {\n node.id = null\n if (this.options.ecmaVersion >= 6) node.generator = node.expression = false\n if (this.options.ecmaVersion >= 8) node.async = false\n}\n\n// Parse object or class method.\n\npp.parseMethod = function(isGenerator, isAsync) {\n let node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos\n\n this.initFunction(node)\n if (this.options.ecmaVersion >= 6)\n node.generator = isGenerator\n if (this.options.ecmaVersion >= 8)\n node.async = !!isAsync\n\n this.yieldPos = 0\n this.awaitPos = 0\n this.enterScope(functionFlags(isAsync, node.generator))\n\n this.expect(tt.parenL)\n node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8)\n this.checkYieldAwaitInDefaultParams()\n this.parseFunctionBody(node, false)\n\n this.yieldPos = oldYieldPos\n this.awaitPos = oldAwaitPos\n return this.finishNode(node, \"FunctionExpression\")\n}\n\n// Parse arrow function expression with given parameters.\n\npp.parseArrowExpression = function(node, params, isAsync) {\n let oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos\n\n this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW)\n this.initFunction(node)\n if (this.options.ecmaVersion >= 8) node.async = !!isAsync\n\n this.yieldPos = 0\n this.awaitPos = 0\n\n node.params = this.toAssignableList(params, true)\n this.parseFunctionBody(node, true)\n\n this.yieldPos = oldYieldPos\n this.awaitPos = oldAwaitPos\n return this.finishNode(node, \"ArrowFunctionExpression\")\n}\n\n// Parse function body and check parameters.\n\npp.parseFunctionBody = function(node, isArrowFunction) {\n let isExpression = isArrowFunction && this.type !== tt.braceL\n let oldStrict = this.strict, useStrict = false\n\n if (isExpression) {\n node.body = this.parseMaybeAssign()\n node.expression = true\n this.checkParams(node, false)\n } else {\n let nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params)\n if (!oldStrict || nonSimple) {\n useStrict = this.strictDirective(this.end)\n // If this is a strict mode function, verify that argument names\n // are not repeated, and it does not try to bind the words `eval`\n // or `arguments`.\n if (useStrict && nonSimple)\n this.raiseRecoverable(node.start, \"Illegal 'use strict' directive in function with non-simple parameter list\")\n }\n // Start a new scope with regard to labels and the `inFunction`\n // flag (restore them to their old value afterwards).\n let oldLabels = this.labels\n this.labels = []\n if (useStrict) this.strict = true\n\n // Add the params to varDeclaredNames to ensure that an error is thrown\n // if a let/const declaration in the function clashes with one of the params.\n this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && this.isSimpleParamList(node.params))\n node.body = this.parseBlock(false)\n node.expression = false\n this.adaptDirectivePrologue(node.body.body)\n this.labels = oldLabels\n }\n this.exitScope()\n\n // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'\n if (this.strict && node.id) this.checkLVal(node.id, BIND_OUTSIDE)\n this.strict = oldStrict\n}\n\npp.isSimpleParamList = function(params) {\n for (let param of params)\n if (param.type !== \"Identifier\") return false\n return true\n}\n\n// Checks function params for various disallowed patterns such as using \"eval\"\n// or \"arguments\" and duplicate parameters.\n\npp.checkParams = function(node, allowDuplicates) {\n let nameHash = {}\n for (let param of node.params)\n this.checkLVal(param, BIND_VAR, allowDuplicates ? null : nameHash)\n}\n\n// Parses a comma-separated list of expressions, and returns them as\n// an array. `close` is the token type that ends the list, and\n// `allowEmpty` can be turned on to allow subsequent commas with\n// nothing in between them to be parsed as `null` (which is needed\n// for array literals).\n\npp.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {\n let elts = [], first = true\n while (!this.eat(close)) {\n if (!first) {\n this.expect(tt.comma)\n if (allowTrailingComma && this.afterTrailingComma(close)) break\n } else first = false\n\n let elt\n if (allowEmpty && this.type === tt.comma)\n elt = null\n else if (this.type === tt.ellipsis) {\n elt = this.parseSpread(refDestructuringErrors)\n if (refDestructuringErrors && this.type === tt.comma && refDestructuringErrors.trailingComma < 0)\n refDestructuringErrors.trailingComma = this.start\n } else {\n elt = this.parseMaybeAssign(false, refDestructuringErrors)\n }\n elts.push(elt)\n }\n return elts\n}\n\npp.checkUnreserved = function({start, end, name}) {\n if (this.inGenerator && name === \"yield\")\n this.raiseRecoverable(start, \"Can not use 'yield' as identifier inside a generator\")\n if (this.inAsync && name === \"await\")\n this.raiseRecoverable(start, \"Can not use 'await' as identifier inside an async function\")\n if (this.keywords.test(name))\n this.raise(start, `Unexpected keyword '${name}'`)\n if (this.options.ecmaVersion < 6 &&\n this.input.slice(start, end).indexOf(\"\\\\\") !== -1) return\n const re = this.strict ? this.reservedWordsStrict : this.reservedWords\n if (re.test(name)) {\n if (!this.inAsync && name === \"await\")\n this.raiseRecoverable(start, \"Can not use keyword 'await' outside an async function\")\n this.raiseRecoverable(start, `The keyword '${name}' is reserved`)\n }\n}\n\n// Parse the next token as an identifier. If `liberal` is true (used\n// when parsing properties), it will also convert keywords into\n// identifiers.\n\npp.parseIdent = function(liberal, isBinding) {\n let node = this.startNode()\n if (liberal && this.options.allowReserved === \"never\") liberal = false\n if (this.type === tt.name) {\n node.name = this.value\n } else if (this.type.keyword) {\n node.name = this.type.keyword\n\n // To fix https://github.com/acornjs/acorn/issues/575\n // `class` and `function` keywords push new context into this.context.\n // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.\n // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword\n if ((node.name === \"class\" || node.name === \"function\") &&\n (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {\n this.context.pop()\n }\n } else {\n this.unexpected()\n }\n this.next()\n this.finishNode(node, \"Identifier\")\n if (!liberal) this.checkUnreserved(node)\n return node\n}\n\n// Parses yield expression inside generator.\n\npp.parseYield = function() {\n if (!this.yieldPos) this.yieldPos = this.start\n\n let node = this.startNode()\n this.next()\n if (this.type === tt.semi || this.canInsertSemicolon() || (this.type !== tt.star && !this.type.startsExpr)) {\n node.delegate = false\n node.argument = null\n } else {\n node.delegate = this.eat(tt.star)\n node.argument = this.parseMaybeAssign()\n }\n return this.finishNode(node, \"YieldExpression\")\n}\n\npp.parseAwait = function() {\n if (!this.awaitPos) this.awaitPos = this.start\n\n let node = this.startNode()\n this.next()\n node.argument = this.parseMaybeUnary(null, true)\n return this.finishNode(node, \"AwaitExpression\")\n}\n","import {Parser} from \"./state\"\nimport {Position, getLineInfo} from \"./locutil\"\n\nconst pp = Parser.prototype\n\n// This function is used to raise exceptions on parse errors. It\n// takes an offset integer (into the current `input`) to indicate\n// the location of the error, attaches the position to the end\n// of the error message, and then raises a `SyntaxError` with that\n// message.\n\npp.raise = function(pos, message) {\n let loc = getLineInfo(this.input, pos)\n message += \" (\" + loc.line + \":\" + loc.column + \")\"\n let err = new SyntaxError(message)\n err.pos = pos; err.loc = loc; err.raisedAt = this.pos\n throw err\n}\n\npp.raiseRecoverable = pp.raise\n\npp.curPosition = function() {\n if (this.options.locations) {\n return new Position(this.curLine, this.pos - this.lineStart)\n }\n}\n","import {Parser} from \"./state\"\nimport {SCOPE_VAR, SCOPE_FUNCTION, SCOPE_ARROW, SCOPE_SIMPLE_CATCH, BIND_LEXICAL, BIND_SIMPLE_CATCH, BIND_FUNCTION} from \"./scopeflags\"\n\nconst pp = Parser.prototype\n\nclass Scope {\n constructor(flags) {\n this.flags = flags\n // A list of var-declared names in the current lexical scope\n this.var = []\n // A list of lexically-declared names in the current lexical scope\n this.lexical = []\n }\n}\n\n// The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.\n\npp.enterScope = function(flags) {\n this.scopeStack.push(new Scope(flags))\n}\n\npp.exitScope = function() {\n this.scopeStack.pop()\n}\n\npp.declareName = function(name, bindingType, pos) {\n let redeclared = false\n if (bindingType === BIND_LEXICAL) {\n const scope = this.currentScope()\n redeclared = scope.lexical.indexOf(name) > -1 || scope.var.indexOf(name) > -1\n scope.lexical.push(name)\n } else if (bindingType === BIND_SIMPLE_CATCH) {\n const scope = this.currentScope()\n scope.lexical.push(name)\n } else if (bindingType === BIND_FUNCTION) {\n const scope = this.currentScope()\n redeclared = scope.lexical.indexOf(name) > -1\n scope.var.push(name)\n } else {\n for (let i = this.scopeStack.length - 1; i >= 0; --i) {\n const scope = this.scopeStack[i]\n if (scope.lexical.indexOf(name) > -1 && !(scope.flags & SCOPE_SIMPLE_CATCH) && scope.lexical[0] === name) redeclared = true\n scope.var.push(name)\n if (scope.flags & SCOPE_VAR) break\n }\n }\n if (redeclared) this.raiseRecoverable(pos, `Identifier '${name}' has already been declared`)\n}\n\npp.currentScope = function() {\n return this.scopeStack[this.scopeStack.length - 1]\n}\n\npp.currentVarScope = function() {\n for (let i = this.scopeStack.length - 1;; i--) {\n let scope = this.scopeStack[i]\n if (scope.flags & SCOPE_VAR) return scope\n }\n}\n\npp.inNonArrowFunction = function() {\n for (let i = this.scopeStack.length - 1; i >= 0; i--)\n if (this.scopeStack[i].flags & SCOPE_FUNCTION && !(this.scopeStack[i].flags & SCOPE_ARROW)) return true\n return false\n}\n","import {Parser} from \"./state\"\nimport {SourceLocation} from \"./locutil\"\n\nexport class Node {\n constructor(parser, pos, loc) {\n this.type = \"\"\n this.start = pos\n this.end = 0\n if (parser.options.locations)\n this.loc = new SourceLocation(parser, loc)\n if (parser.options.directSourceFile)\n this.sourceFile = parser.options.directSourceFile\n if (parser.options.ranges)\n this.range = [pos, 0]\n }\n}\n\n// Start an AST node, attaching a start offset.\n\nconst pp = Parser.prototype\n\npp.startNode = function() {\n return new Node(this, this.start, this.startLoc)\n}\n\npp.startNodeAt = function(pos, loc) {\n return new Node(this, pos, loc)\n}\n\n// Finish an AST node, adding `type` and `end` properties.\n\nfunction finishNodeAt(node, type, pos, loc) {\n node.type = type\n node.end = pos\n if (this.options.locations)\n node.loc.end = loc\n if (this.options.ranges)\n node.range[1] = pos\n return node\n}\n\npp.finishNode = function(node, type) {\n return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc)\n}\n\n// Finish node at given position\n\npp.finishNodeAt = function(node, type, pos, loc) {\n return finishNodeAt.call(this, node, type, pos, loc)\n}\n","// The algorithm used to determine whether a regexp can appear at a\n// given point in the program is loosely based on sweet.js' approach.\n// See https://github.com/mozilla/sweet.js/wiki/design\n\nimport {Parser} from \"./state\"\nimport {types as tt} from \"./tokentype\"\nimport {lineBreak} from \"./whitespace\"\n\nexport class TokContext {\n constructor(token, isExpr, preserveSpace, override, generator) {\n this.token = token\n this.isExpr = !!isExpr\n this.preserveSpace = !!preserveSpace\n this.override = override\n this.generator = !!generator\n }\n}\n\nexport const types = {\n b_stat: new TokContext(\"{\", false),\n b_expr: new TokContext(\"{\", true),\n b_tmpl: new TokContext(\"${\", false),\n p_stat: new TokContext(\"(\", false),\n p_expr: new TokContext(\"(\", true),\n q_tmpl: new TokContext(\"`\", true, true, p => p.tryReadTemplateToken()),\n f_stat: new TokContext(\"function\", false),\n f_expr: new TokContext(\"function\", true),\n f_expr_gen: new TokContext(\"function\", true, false, null, true),\n f_gen: new TokContext(\"function\", false, false, null, true)\n}\n\nconst pp = Parser.prototype\n\npp.initialContext = function() {\n return [types.b_stat]\n}\n\npp.braceIsBlock = function(prevType) {\n let parent = this.curContext()\n if (parent === types.f_expr || parent === types.f_stat)\n return true\n if (prevType === tt.colon && (parent === types.b_stat || parent === types.b_expr))\n return !parent.isExpr\n\n // The check for `tt.name && exprAllowed` detects whether we are\n // after a `yield` or `of` construct. See the `updateContext` for\n // `tt.name`.\n if (prevType === tt._return || prevType === tt.name && this.exprAllowed)\n return lineBreak.test(this.input.slice(this.lastTokEnd, this.start))\n if (prevType === tt._else || prevType === tt.semi || prevType === tt.eof || prevType === tt.parenR || prevType === tt.arrow)\n return true\n if (prevType === tt.braceL)\n return parent === types.b_stat\n if (prevType === tt._var || prevType === tt.name)\n return false\n return !this.exprAllowed\n}\n\npp.inGeneratorContext = function() {\n for (let i = this.context.length - 1; i >= 1; i--) {\n let context = this.context[i]\n if (context.token === \"function\")\n return context.generator\n }\n return false\n}\n\npp.updateContext = function(prevType) {\n let update, type = this.type\n if (type.keyword && prevType === tt.dot)\n this.exprAllowed = false\n else if (update = type.updateContext)\n update.call(this, prevType)\n else\n this.exprAllowed = type.beforeExpr\n}\n\n// Token-specific context update code\n\ntt.parenR.updateContext = tt.braceR.updateContext = function() {\n if (this.context.length === 1) {\n this.exprAllowed = true\n return\n }\n let out = this.context.pop()\n if (out === types.b_stat && this.curContext().token === \"function\") {\n out = this.context.pop()\n }\n this.exprAllowed = !out.isExpr\n}\n\ntt.braceL.updateContext = function(prevType) {\n this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr)\n this.exprAllowed = true\n}\n\ntt.dollarBraceL.updateContext = function() {\n this.context.push(types.b_tmpl)\n this.exprAllowed = true\n}\n\ntt.parenL.updateContext = function(prevType) {\n let statementParens = prevType === tt._if || prevType === tt._for || prevType === tt._with || prevType === tt._while\n this.context.push(statementParens ? types.p_stat : types.p_expr)\n this.exprAllowed = true\n}\n\ntt.incDec.updateContext = function() {\n // tokExprAllowed stays unchanged\n}\n\ntt._function.updateContext = tt._class.updateContext = function(prevType) {\n if (prevType.beforeExpr && prevType !== tt.semi && prevType !== tt._else &&\n !((prevType === tt.colon || prevType === tt.braceL) && this.curContext() === types.b_stat))\n this.context.push(types.f_expr)\n else\n this.context.push(types.f_stat)\n this.exprAllowed = false\n}\n\ntt.backQuote.updateContext = function() {\n if (this.curContext() === types.q_tmpl)\n this.context.pop()\n else\n this.context.push(types.q_tmpl)\n this.exprAllowed = false\n}\n\ntt.star.updateContext = function(prevType) {\n if (prevType === tt._function) {\n let index = this.context.length - 1\n if (this.context[index] === types.f_expr)\n this.context[index] = types.f_expr_gen\n else\n this.context[index] = types.f_gen\n }\n this.exprAllowed = true\n}\n\ntt.name.updateContext = function(prevType) {\n let allowed = false\n if (this.options.ecmaVersion >= 6 && prevType !== tt.dot) {\n if (this.value === \"of\" && !this.exprAllowed ||\n this.value === \"yield\" && this.inGeneratorContext())\n allowed = true\n }\n this.exprAllowed = allowed\n}\n","const data = {\n \"$LONE\": [\n \"ASCII\",\n \"ASCII_Hex_Digit\",\n \"AHex\",\n \"Alphabetic\",\n \"Alpha\",\n \"Any\",\n \"Assigned\",\n \"Bidi_Control\",\n \"Bidi_C\",\n \"Bidi_Mirrored\",\n \"Bidi_M\",\n \"Case_Ignorable\",\n \"CI\",\n \"Cased\",\n \"Changes_When_Casefolded\",\n \"CWCF\",\n \"Changes_When_Casemapped\",\n \"CWCM\",\n \"Changes_When_Lowercased\",\n \"CWL\",\n \"Changes_When_NFKC_Casefolded\",\n \"CWKCF\",\n \"Changes_When_Titlecased\",\n \"CWT\",\n \"Changes_When_Uppercased\",\n \"CWU\",\n \"Dash\",\n \"Default_Ignorable_Code_Point\",\n \"DI\",\n \"Deprecated\",\n \"Dep\",\n \"Diacritic\",\n \"Dia\",\n \"Emoji\",\n \"Emoji_Component\",\n \"Emoji_Modifier\",\n \"Emoji_Modifier_Base\",\n \"Emoji_Presentation\",\n \"Extender\",\n \"Ext\",\n \"Grapheme_Base\",\n \"Gr_Base\",\n \"Grapheme_Extend\",\n \"Gr_Ext\",\n \"Hex_Digit\",\n \"Hex\",\n \"IDS_Binary_Operator\",\n \"IDSB\",\n \"IDS_Trinary_Operator\",\n \"IDST\",\n \"ID_Continue\",\n \"IDC\",\n \"ID_Start\",\n \"IDS\",\n \"Ideographic\",\n \"Ideo\",\n \"Join_Control\",\n \"Join_C\",\n \"Logical_Order_Exception\",\n \"LOE\",\n \"Lowercase\",\n \"Lower\",\n \"Math\",\n \"Noncharacter_Code_Point\",\n \"NChar\",\n \"Pattern_Syntax\",\n \"Pat_Syn\",\n \"Pattern_White_Space\",\n \"Pat_WS\",\n \"Quotation_Mark\",\n \"QMark\",\n \"Radical\",\n \"Regional_Indicator\",\n \"RI\",\n \"Sentence_Terminal\",\n \"STerm\",\n \"Soft_Dotted\",\n \"SD\",\n \"Terminal_Punctuation\",\n \"Term\",\n \"Unified_Ideograph\",\n \"UIdeo\",\n \"Uppercase\",\n \"Upper\",\n \"Variation_Selector\",\n \"VS\",\n \"White_Space\",\n \"space\",\n \"XID_Continue\",\n \"XIDC\",\n \"XID_Start\",\n \"XIDS\"\n ],\n \"General_Category\": [\n \"Cased_Letter\",\n \"LC\",\n \"Close_Punctuation\",\n \"Pe\",\n \"Connector_Punctuation\",\n \"Pc\",\n \"Control\",\n \"Cc\",\n \"cntrl\",\n \"Currency_Symbol\",\n \"Sc\",\n \"Dash_Punctuation\",\n \"Pd\",\n \"Decimal_Number\",\n \"Nd\",\n \"digit\",\n \"Enclosing_Mark\",\n \"Me\",\n \"Final_Punctuation\",\n \"Pf\",\n \"Format\",\n \"Cf\",\n \"Initial_Punctuation\",\n \"Pi\",\n \"Letter\",\n \"L\",\n \"Letter_Number\",\n \"Nl\",\n \"Line_Separator\",\n \"Zl\",\n \"Lowercase_Letter\",\n \"Ll\",\n \"Mark\",\n \"M\",\n \"Combining_Mark\",\n \"Math_Symbol\",\n \"Sm\",\n \"Modifier_Letter\",\n \"Lm\",\n \"Modifier_Symbol\",\n \"Sk\",\n \"Nonspacing_Mark\",\n \"Mn\",\n \"Number\",\n \"N\",\n \"Open_Punctuation\",\n \"Ps\",\n \"Other\",\n \"C\",\n \"Other_Letter\",\n \"Lo\",\n \"Other_Number\",\n \"No\",\n \"Other_Punctuation\",\n \"Po\",\n \"Other_Symbol\",\n \"So\",\n \"Paragraph_Separator\",\n \"Zp\",\n \"Private_Use\",\n \"Co\",\n \"Punctuation\",\n \"P\",\n \"punct\",\n \"Separator\",\n \"Z\",\n \"Space_Separator\",\n \"Zs\",\n \"Spacing_Mark\",\n \"Mc\",\n \"Surrogate\",\n \"Cs\",\n \"Symbol\",\n \"S\",\n \"Titlecase_Letter\",\n \"Lt\",\n \"Unassigned\",\n \"Cn\",\n \"Uppercase_Letter\",\n \"Lu\"\n ],\n \"Script\": [\n \"Adlam\",\n \"Adlm\",\n \"Ahom\",\n \"Anatolian_Hieroglyphs\",\n \"Hluw\",\n \"Arabic\",\n \"Arab\",\n \"Armenian\",\n \"Armn\",\n \"Avestan\",\n \"Avst\",\n \"Balinese\",\n \"Bali\",\n \"Bamum\",\n \"Bamu\",\n \"Bassa_Vah\",\n \"Bass\",\n \"Batak\",\n \"Batk\",\n \"Bengali\",\n \"Beng\",\n \"Bhaiksuki\",\n \"Bhks\",\n \"Bopomofo\",\n \"Bopo\",\n \"Brahmi\",\n \"Brah\",\n \"Braille\",\n \"Brai\",\n \"Buginese\",\n \"Bugi\",\n \"Buhid\",\n \"Buhd\",\n \"Canadian_Aboriginal\",\n \"Cans\",\n \"Carian\",\n \"Cari\",\n \"Caucasian_Albanian\",\n \"Aghb\",\n \"Chakma\",\n \"Cakm\",\n \"Cham\",\n \"Cherokee\",\n \"Cher\",\n \"Common\",\n \"Zyyy\",\n \"Coptic\",\n \"Copt\",\n \"Qaac\",\n \"Cuneiform\",\n \"Xsux\",\n \"Cypriot\",\n \"Cprt\",\n \"Cyrillic\",\n \"Cyrl\",\n \"Deseret\",\n \"Dsrt\",\n \"Devanagari\",\n \"Deva\",\n \"Duployan\",\n \"Dupl\",\n \"Egyptian_Hieroglyphs\",\n \"Egyp\",\n \"Elbasan\",\n \"Elba\",\n \"Ethiopic\",\n \"Ethi\",\n \"Georgian\",\n \"Geor\",\n \"Glagolitic\",\n \"Glag\",\n \"Gothic\",\n \"Goth\",\n \"Grantha\",\n \"Gran\",\n \"Greek\",\n \"Grek\",\n \"Gujarati\",\n \"Gujr\",\n \"Gurmukhi\",\n \"Guru\",\n \"Han\",\n \"Hani\",\n \"Hangul\",\n \"Hang\",\n \"Hanunoo\",\n \"Hano\",\n \"Hatran\",\n \"Hatr\",\n \"Hebrew\",\n \"Hebr\",\n \"Hiragana\",\n \"Hira\",\n \"Imperial_Aramaic\",\n \"Armi\",\n \"Inherited\",\n \"Zinh\",\n \"Qaai\",\n \"Inscriptional_Pahlavi\",\n \"Phli\",\n \"Inscriptional_Parthian\",\n \"Prti\",\n \"Javanese\",\n \"Java\",\n \"Kaithi\",\n \"Kthi\",\n \"Kannada\",\n \"Knda\",\n \"Katakana\",\n \"Kana\",\n \"Kayah_Li\",\n \"Kali\",\n \"Kharoshthi\",\n \"Khar\",\n \"Khmer\",\n \"Khmr\",\n \"Khojki\",\n \"Khoj\",\n \"Khudawadi\",\n \"Sind\",\n \"Lao\",\n \"Laoo\",\n \"Latin\",\n \"Latn\",\n \"Lepcha\",\n \"Lepc\",\n \"Limbu\",\n \"Limb\",\n \"Linear_A\",\n \"Lina\",\n \"Linear_B\",\n \"Linb\",\n \"Lisu\",\n \"Lycian\",\n \"Lyci\",\n \"Lydian\",\n \"Lydi\",\n \"Mahajani\",\n \"Mahj\",\n \"Malayalam\",\n \"Mlym\",\n \"Mandaic\",\n \"Mand\",\n \"Manichaean\",\n \"Mani\",\n \"Marchen\",\n \"Marc\",\n \"Masaram_Gondi\",\n \"Gonm\",\n \"Meetei_Mayek\",\n \"Mtei\",\n \"Mende_Kikakui\",\n \"Mend\",\n \"Meroitic_Cursive\",\n \"Merc\",\n \"Meroitic_Hieroglyphs\",\n \"Mero\",\n \"Miao\",\n \"Plrd\",\n \"Modi\",\n \"Mongolian\",\n \"Mong\",\n \"Mro\",\n \"Mroo\",\n \"Multani\",\n \"Mult\",\n \"Myanmar\",\n \"Mymr\",\n \"Nabataean\",\n \"Nbat\",\n \"New_Tai_Lue\",\n \"Talu\",\n \"Newa\",\n \"Nko\",\n \"Nkoo\",\n \"Nushu\",\n \"Nshu\",\n \"Ogham\",\n \"Ogam\",\n \"Ol_Chiki\",\n \"Olck\",\n \"Old_Hungarian\",\n \"Hung\",\n \"Old_Italic\",\n \"Ital\",\n \"Old_North_Arabian\",\n \"Narb\",\n \"Old_Permic\",\n \"Perm\",\n \"Old_Persian\",\n \"Xpeo\",\n \"Old_South_Arabian\",\n \"Sarb\",\n \"Old_Turkic\",\n \"Orkh\",\n \"Oriya\",\n \"Orya\",\n \"Osage\",\n \"Osge\",\n \"Osmanya\",\n \"Osma\",\n \"Pahawh_Hmong\",\n \"Hmng\",\n \"Palmyrene\",\n \"Palm\",\n \"Pau_Cin_Hau\",\n \"Pauc\",\n \"Phags_Pa\",\n \"Phag\",\n \"Phoenician\",\n \"Phnx\",\n \"Psalter_Pahlavi\",\n \"Phlp\",\n \"Rejang\",\n \"Rjng\",\n \"Runic\",\n \"Runr\",\n \"Samaritan\",\n \"Samr\",\n \"Saurashtra\",\n \"Saur\",\n \"Sharada\",\n \"Shrd\",\n \"Shavian\",\n \"Shaw\",\n \"Siddham\",\n \"Sidd\",\n \"SignWriting\",\n \"Sgnw\",\n \"Sinhala\",\n \"Sinh\",\n \"Sora_Sompeng\",\n \"Sora\",\n \"Soyombo\",\n \"Soyo\",\n \"Sundanese\",\n \"Sund\",\n \"Syloti_Nagri\",\n \"Sylo\",\n \"Syriac\",\n \"Syrc\",\n \"Tagalog\",\n \"Tglg\",\n \"Tagbanwa\",\n \"Tagb\",\n \"Tai_Le\",\n \"Tale\",\n \"Tai_Tham\",\n \"Lana\",\n \"Tai_Viet\",\n \"Tavt\",\n \"Takri\",\n \"Takr\",\n \"Tamil\",\n \"Taml\",\n \"Tangut\",\n \"Tang\",\n \"Telugu\",\n \"Telu\",\n \"Thaana\",\n \"Thaa\",\n \"Thai\",\n \"Tibetan\",\n \"Tibt\",\n \"Tifinagh\",\n \"Tfng\",\n \"Tirhuta\",\n \"Tirh\",\n \"Ugaritic\",\n \"Ugar\",\n \"Vai\",\n \"Vaii\",\n \"Warang_Citi\",\n \"Wara\",\n \"Yi\",\n \"Yiii\",\n \"Zanabazar_Square\",\n \"Zanb\"\n ]\n}\nArray.prototype.push.apply(data.$LONE, data.General_Category)\ndata.gc = data.General_Category\ndata.sc = data.Script_Extensions = data.scx = data.Script\n\nexport default data\n","import {isIdentifierStart, isIdentifierChar} from \"./identifier.js\"\nimport {Parser} from \"./state.js\"\nimport UNICODE_PROPERTY_VALUES from \"./unicode-property-data.js\"\n\nconst pp = Parser.prototype\n\nexport class RegExpValidationState {\n constructor(parser) {\n this.parser = parser\n this.validFlags = `gim${parser.options.ecmaVersion >= 6 ? \"uy\" : \"\"}${parser.options.ecmaVersion >= 9 ? \"s\" : \"\"}`\n this.source = \"\"\n this.flags = \"\"\n this.start = 0\n this.switchU = false\n this.switchN = false\n this.pos = 0\n this.lastIntValue = 0\n this.lastStringValue = \"\"\n this.lastAssertionIsQuantifiable = false\n this.numCapturingParens = 0\n this.maxBackReference = 0\n this.groupNames = []\n this.backReferenceNames = []\n }\n\n reset(start, pattern, flags) {\n const unicode = flags.indexOf(\"u\") !== -1\n this.start = start | 0\n this.source = pattern + \"\"\n this.flags = flags\n this.switchU = unicode && this.parser.options.ecmaVersion >= 6\n this.switchN = unicode && this.parser.options.ecmaVersion >= 9\n }\n\n raise(message) {\n this.parser.raiseRecoverable(this.start, `Invalid regular expression: /${this.source}/: ${message}`)\n }\n\n // If u flag is given, this returns the code point at the index (it combines a surrogate pair).\n // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).\n at(i) {\n const s = this.source\n const l = s.length\n if (i >= l) {\n return -1\n }\n const c = s.charCodeAt(i)\n if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {\n return c\n }\n return (c << 10) + s.charCodeAt(i + 1) - 0x35FDC00\n }\n\n nextIndex(i) {\n const s = this.source\n const l = s.length\n if (i >= l) {\n return l\n }\n const c = s.charCodeAt(i)\n if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {\n return i + 1\n }\n return i + 2\n }\n\n current() {\n return this.at(this.pos)\n }\n\n lookahead() {\n return this.at(this.nextIndex(this.pos))\n }\n\n advance() {\n this.pos = this.nextIndex(this.pos)\n }\n\n eat(ch) {\n if (this.current() === ch) {\n this.advance()\n return true\n }\n return false\n }\n}\n\nfunction codePointToString(ch) {\n if (ch <= 0xFFFF) return String.fromCharCode(ch)\n ch -= 0x10000\n return String.fromCharCode((ch >> 10) + 0xD800, (ch & 0x03FF) + 0xDC00)\n}\n\n/**\n * Validate the flags part of a given RegExpLiteral.\n *\n * @param {RegExpValidationState} state The state to validate RegExp.\n * @returns {void}\n */\npp.validateRegExpFlags = function(state) {\n const validFlags = state.validFlags\n const flags = state.flags\n\n for (let i = 0; i < flags.length; i++) {\n const flag = flags.charAt(i)\n if (validFlags.indexOf(flag) === -1) {\n this.raise(state.start, \"Invalid regular expression flag\")\n }\n if (flags.indexOf(flag, i + 1) > -1) {\n this.raise(state.start, \"Duplicate regular expression flag\")\n }\n }\n}\n\n/**\n * Validate the pattern part of a given RegExpLiteral.\n *\n * @param {RegExpValidationState} state The state to validate RegExp.\n * @returns {void}\n */\npp.validateRegExpPattern = function(state) {\n this.regexp_pattern(state)\n\n // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of\n // parsing contains a |GroupName|, reparse with the goal symbol\n // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*\n // exception if _P_ did not conform to the grammar, if any elements of _P_\n // were not matched by the parse, or if any Early Error conditions exist.\n if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {\n state.switchN = true\n this.regexp_pattern(state)\n }\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern\npp.regexp_pattern = function(state) {\n state.pos = 0\n state.lastIntValue = 0\n state.lastStringValue = \"\"\n state.lastAssertionIsQuantifiable = false\n state.numCapturingParens = 0\n state.maxBackReference = 0\n state.groupNames.length = 0\n state.backReferenceNames.length = 0\n\n this.regexp_disjunction(state)\n\n if (state.pos !== state.source.length) {\n // Make the same messages as V8.\n if (state.eat(0x29 /* ) */)) {\n state.raise(\"Unmatched ')'\")\n }\n if (state.eat(0x5D /* [ */) || state.eat(0x7D /* } */)) {\n state.raise(\"Lone quantifier brackets\")\n }\n }\n if (state.maxBackReference > state.numCapturingParens) {\n state.raise(\"Invalid escape\")\n }\n for (const name of state.backReferenceNames) {\n if (state.groupNames.indexOf(name) === -1) {\n state.raise(\"Invalid named capture referenced\")\n }\n }\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction\npp.regexp_disjunction = function(state) {\n this.regexp_alternative(state)\n while (state.eat(0x7C /* | */)) {\n this.regexp_alternative(state)\n }\n\n // Make the same message as V8.\n if (this.regexp_eatQuantifier(state, true)) {\n state.raise(\"Nothing to repeat\")\n }\n if (state.eat(0x7B /* { */)) {\n state.raise(\"Lone quantifier brackets\")\n }\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative\npp.regexp_alternative = function(state) {\n while (state.pos < state.source.length && this.regexp_eatTerm(state))\n ;\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term\npp.regexp_eatTerm = function(state) {\n if (this.regexp_eatAssertion(state)) {\n // Handle `QuantifiableAssertion Quantifier` alternative.\n // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion\n // is a QuantifiableAssertion.\n if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {\n // Make the same message as V8.\n if (state.switchU) {\n state.raise(\"Invalid quantifier\")\n }\n }\n return true\n }\n\n if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {\n this.regexp_eatQuantifier(state)\n return true\n }\n\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion\npp.regexp_eatAssertion = function(state) {\n const start = state.pos\n state.lastAssertionIsQuantifiable = false\n\n // ^, $\n if (state.eat(0x5E /* ^ */) || state.eat(0x24 /* $ */)) {\n return true\n }\n\n // \\b \\B\n if (state.eat(0x5C /* \\ */)) {\n if (state.eat(0x42 /* B */) || state.eat(0x62 /* b */)) {\n return true\n }\n state.pos = start\n }\n\n // Lookahead / Lookbehind\n if (state.eat(0x28 /* ( */) && state.eat(0x3F /* ? */)) {\n let lookbehind = false\n if (this.options.ecmaVersion >= 9) {\n lookbehind = state.eat(0x3C /* < */)\n }\n if (state.eat(0x3D /* = */) || state.eat(0x21 /* ! */)) {\n this.regexp_disjunction(state)\n if (!state.eat(0x29 /* ) */)) {\n state.raise(\"Unterminated group\")\n }\n state.lastAssertionIsQuantifiable = !lookbehind\n return true\n }\n }\n\n state.pos = start\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier\npp.regexp_eatQuantifier = function(state, noError = false) {\n if (this.regexp_eatQuantifierPrefix(state, noError)) {\n state.eat(0x3F /* ? */)\n return true\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix\npp.regexp_eatQuantifierPrefix = function(state, noError) {\n return (\n state.eat(0x2A /* * */) ||\n state.eat(0x2B /* + */) ||\n state.eat(0x3F /* ? */) ||\n this.regexp_eatBracedQuantifier(state, noError)\n )\n}\npp.regexp_eatBracedQuantifier = function(state, noError) {\n const start = state.pos\n if (state.eat(0x7B /* { */)) {\n let min = 0, max = -1\n if (this.regexp_eatDecimalDigits(state)) {\n min = state.lastIntValue\n if (state.eat(0x2C /* , */) && this.regexp_eatDecimalDigits(state)) {\n max = state.lastIntValue\n }\n if (state.eat(0x7D /* } */)) {\n // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term\n if (max !== -1 && max < min && !noError) {\n state.raise(\"numbers out of order in {} quantifier\")\n }\n return true\n }\n }\n if (state.switchU && !noError) {\n state.raise(\"Incomplete quantifier\")\n }\n state.pos = start\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Atom\npp.regexp_eatAtom = function(state) {\n return (\n this.regexp_eatPatternCharacters(state) ||\n state.eat(0x2E /* . */) ||\n this.regexp_eatReverseSolidusAtomEscape(state) ||\n this.regexp_eatCharacterClass(state) ||\n this.regexp_eatUncapturingGroup(state) ||\n this.regexp_eatCapturingGroup(state)\n )\n}\npp.regexp_eatReverseSolidusAtomEscape = function(state) {\n const start = state.pos\n if (state.eat(0x5C /* \\ */)) {\n if (this.regexp_eatAtomEscape(state)) {\n return true\n }\n state.pos = start\n }\n return false\n}\npp.regexp_eatUncapturingGroup = function(state) {\n const start = state.pos\n if (state.eat(0x28 /* ( */)) {\n if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) {\n this.regexp_disjunction(state)\n if (state.eat(0x29 /* ) */)) {\n return true\n }\n state.raise(\"Unterminated group\")\n }\n state.pos = start\n }\n return false\n}\npp.regexp_eatCapturingGroup = function(state) {\n if (state.eat(0x28 /* ( */)) {\n if (this.options.ecmaVersion >= 9) {\n this.regexp_groupSpecifier(state)\n } else if (state.current() === 0x3F /* ? */) {\n state.raise(\"Invalid group\")\n }\n this.regexp_disjunction(state)\n if (state.eat(0x29 /* ) */)) {\n state.numCapturingParens += 1\n return true\n }\n state.raise(\"Unterminated group\")\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom\npp.regexp_eatExtendedAtom = function(state) {\n return (\n state.eat(0x2E /* . */) ||\n this.regexp_eatReverseSolidusAtomEscape(state) ||\n this.regexp_eatCharacterClass(state) ||\n this.regexp_eatUncapturingGroup(state) ||\n this.regexp_eatCapturingGroup(state) ||\n this.regexp_eatInvalidBracedQuantifier(state) ||\n this.regexp_eatExtendedPatternCharacter(state)\n )\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier\npp.regexp_eatInvalidBracedQuantifier = function(state) {\n if (this.regexp_eatBracedQuantifier(state, true)) {\n state.raise(\"Nothing to repeat\")\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter\npp.regexp_eatSyntaxCharacter = function(state) {\n const ch = state.current()\n if (isSyntaxCharacter(ch)) {\n state.lastIntValue = ch\n state.advance()\n return true\n }\n return false\n}\nfunction isSyntaxCharacter(ch) {\n return (\n ch === 0x24 /* $ */ ||\n ch >= 0x28 /* ( */ && ch <= 0x2B /* + */ ||\n ch === 0x2E /* . */ ||\n ch === 0x3F /* ? */ ||\n ch >= 0x5B /* [ */ && ch <= 0x5E /* ^ */ ||\n ch >= 0x7B /* { */ && ch <= 0x7D /* } */\n )\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter\n// But eat eager.\npp.regexp_eatPatternCharacters = function(state) {\n const start = state.pos\n let ch = 0\n while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {\n state.advance()\n }\n return state.pos !== start\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter\npp.regexp_eatExtendedPatternCharacter = function(state) {\n const ch = state.current()\n if (\n ch !== -1 &&\n ch !== 0x24 /* $ */ &&\n !(ch >= 0x28 /* ( */ && ch <= 0x2B /* + */) &&\n ch !== 0x2E /* . */ &&\n ch !== 0x3F /* ? */ &&\n ch !== 0x5B /* [ */ &&\n ch !== 0x5E /* ^ */ &&\n ch !== 0x7C /* | */\n ) {\n state.advance()\n return true\n }\n return false\n}\n\n// GroupSpecifier[U] ::\n// [empty]\n// `?` GroupName[?U]\npp.regexp_groupSpecifier = function(state) {\n if (state.eat(0x3F /* ? */)) {\n if (this.regexp_eatGroupName(state)) {\n if (state.groupNames.indexOf(state.lastStringValue) !== -1) {\n state.raise(\"Duplicate capture group name\")\n }\n state.groupNames.push(state.lastStringValue)\n return\n }\n state.raise(\"Invalid group\")\n }\n}\n\n// GroupName[U] ::\n// `<` RegExpIdentifierName[?U] `>`\n// Note: this updates `state.lastStringValue` property with the eaten name.\npp.regexp_eatGroupName = function(state) {\n state.lastStringValue = \"\"\n if (state.eat(0x3C /* < */)) {\n if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) {\n return true\n }\n state.raise(\"Invalid capture group name\")\n }\n return false\n}\n\n// RegExpIdentifierName[U] ::\n// RegExpIdentifierStart[?U]\n// RegExpIdentifierName[?U] RegExpIdentifierPart[?U]\n// Note: this updates `state.lastStringValue` property with the eaten name.\npp.regexp_eatRegExpIdentifierName = function(state) {\n state.lastStringValue = \"\"\n if (this.regexp_eatRegExpIdentifierStart(state)) {\n state.lastStringValue += codePointToString(state.lastIntValue)\n while (this.regexp_eatRegExpIdentifierPart(state)) {\n state.lastStringValue += codePointToString(state.lastIntValue)\n }\n return true\n }\n return false\n}\n\n// RegExpIdentifierStart[U] ::\n// UnicodeIDStart\n// `$`\n// `_`\n// `\\` RegExpUnicodeEscapeSequence[?U]\npp.regexp_eatRegExpIdentifierStart = function(state) {\n const start = state.pos\n let ch = state.current()\n state.advance()\n\n if (ch === 0x5C /* \\ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) {\n ch = state.lastIntValue\n }\n if (isRegExpIdentifierStart(ch)) {\n state.lastIntValue = ch\n return true\n }\n\n state.pos = start\n return false\n}\nfunction isRegExpIdentifierStart(ch) {\n return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */\n}\n\n// RegExpIdentifierPart[U] ::\n// UnicodeIDContinue\n// `$`\n// `_`\n// `\\` RegExpUnicodeEscapeSequence[?U]\n// \n// \npp.regexp_eatRegExpIdentifierPart = function(state) {\n const start = state.pos\n let ch = state.current()\n state.advance()\n\n if (ch === 0x5C /* \\ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) {\n ch = state.lastIntValue\n }\n if (isRegExpIdentifierPart(ch)) {\n state.lastIntValue = ch\n return true\n }\n\n state.pos = start\n return false\n}\nfunction isRegExpIdentifierPart(ch) {\n return isIdentifierChar(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ || ch === 0x200C /* */ || ch === 0x200D /* */\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape\npp.regexp_eatAtomEscape = function(state) {\n if (\n this.regexp_eatBackReference(state) ||\n this.regexp_eatCharacterClassEscape(state) ||\n this.regexp_eatCharacterEscape(state) ||\n (state.switchN && this.regexp_eatKGroupName(state))\n ) {\n return true\n }\n if (state.switchU) {\n // Make the same message as V8.\n if (state.current() === 0x63 /* c */) {\n state.raise(\"Invalid unicode escape\")\n }\n state.raise(\"Invalid escape\")\n }\n return false\n}\npp.regexp_eatBackReference = function(state) {\n const start = state.pos\n if (this.regexp_eatDecimalEscape(state)) {\n const n = state.lastIntValue\n if (state.switchU) {\n // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape\n if (n > state.maxBackReference) {\n state.maxBackReference = n\n }\n return true\n }\n if (n <= state.numCapturingParens) {\n return true\n }\n state.pos = start\n }\n return false\n}\npp.regexp_eatKGroupName = function(state) {\n if (state.eat(0x6B /* k */)) {\n if (this.regexp_eatGroupName(state)) {\n state.backReferenceNames.push(state.lastStringValue)\n return true\n }\n state.raise(\"Invalid named reference\")\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape\npp.regexp_eatCharacterEscape = function(state) {\n return (\n this.regexp_eatControlEscape(state) ||\n this.regexp_eatCControlLetter(state) ||\n this.regexp_eatZero(state) ||\n this.regexp_eatHexEscapeSequence(state) ||\n this.regexp_eatRegExpUnicodeEscapeSequence(state) ||\n (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) ||\n this.regexp_eatIdentityEscape(state)\n )\n}\npp.regexp_eatCControlLetter = function(state) {\n const start = state.pos\n if (state.eat(0x63 /* c */)) {\n if (this.regexp_eatControlLetter(state)) {\n return true\n }\n state.pos = start\n }\n return false\n}\npp.regexp_eatZero = function(state) {\n if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) {\n state.lastIntValue = 0\n state.advance()\n return true\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape\npp.regexp_eatControlEscape = function(state) {\n const ch = state.current()\n if (ch === 0x74 /* t */) {\n state.lastIntValue = 0x09 /* \\t */\n state.advance()\n return true\n }\n if (ch === 0x6E /* n */) {\n state.lastIntValue = 0x0A /* \\n */\n state.advance()\n return true\n }\n if (ch === 0x76 /* v */) {\n state.lastIntValue = 0x0B /* \\v */\n state.advance()\n return true\n }\n if (ch === 0x66 /* f */) {\n state.lastIntValue = 0x0C /* \\f */\n state.advance()\n return true\n }\n if (ch === 0x72 /* r */) {\n state.lastIntValue = 0x0D /* \\r */\n state.advance()\n return true\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter\npp.regexp_eatControlLetter = function(state) {\n const ch = state.current()\n if (isControlLetter(ch)) {\n state.lastIntValue = ch % 0x20\n state.advance()\n return true\n }\n return false\n}\nfunction isControlLetter(ch) {\n return (\n (ch >= 0x41 /* A */ && ch <= 0x5A /* Z */) ||\n (ch >= 0x61 /* a */ && ch <= 0x7A /* z */)\n )\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence\npp.regexp_eatRegExpUnicodeEscapeSequence = function(state) {\n const start = state.pos\n\n if (state.eat(0x75 /* u */)) {\n if (this.regexp_eatFixedHexDigits(state, 4)) {\n const lead = state.lastIntValue\n if (state.switchU && lead >= 0xD800 && lead <= 0xDBFF) {\n const leadSurrogateEnd = state.pos\n if (state.eat(0x5C /* \\ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) {\n const trail = state.lastIntValue\n if (trail >= 0xDC00 && trail <= 0xDFFF) {\n state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000\n return true\n }\n }\n state.pos = leadSurrogateEnd\n state.lastIntValue = lead\n }\n return true\n }\n if (\n state.switchU &&\n state.eat(0x7B /* { */) &&\n this.regexp_eatHexDigits(state) &&\n state.eat(0x7D /* } */) &&\n isValidUnicode(state.lastIntValue)\n ) {\n return true\n }\n if (state.switchU) {\n state.raise(\"Invalid unicode escape\")\n }\n state.pos = start\n }\n\n return false\n}\nfunction isValidUnicode(ch) {\n return ch >= 0 && ch <= 0x10FFFF\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape\npp.regexp_eatIdentityEscape = function(state) {\n if (state.switchU) {\n if (this.regexp_eatSyntaxCharacter(state)) {\n return true\n }\n if (state.eat(0x2F /* / */)) {\n state.lastIntValue = 0x2F /* / */\n return true\n }\n return false\n }\n\n const ch = state.current()\n if (ch !== 0x63 /* c */ && (!state.switchN || ch !== 0x6B /* k */)) {\n state.lastIntValue = ch\n state.advance()\n return true\n }\n\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape\npp.regexp_eatDecimalEscape = function(state) {\n state.lastIntValue = 0\n let ch = state.current()\n if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) {\n do {\n state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */)\n state.advance()\n } while ((ch = state.current()) >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */)\n return true\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape\npp.regexp_eatCharacterClassEscape = function(state) {\n const ch = state.current()\n\n if (isCharacterClassEscape(ch)) {\n state.lastIntValue = -1\n state.advance()\n return true\n }\n\n if (\n state.switchU &&\n this.options.ecmaVersion >= 9 &&\n (ch === 0x50 /* P */ || ch === 0x70 /* p */)\n ) {\n state.lastIntValue = -1\n state.advance()\n if (\n state.eat(0x7B /* { */) &&\n this.regexp_eatUnicodePropertyValueExpression(state) &&\n state.eat(0x7D /* } */)\n ) {\n return true\n }\n state.raise(\"Invalid property name\")\n }\n\n return false\n}\nfunction isCharacterClassEscape(ch) {\n return (\n ch === 0x64 /* d */ ||\n ch === 0x44 /* D */ ||\n ch === 0x73 /* s */ ||\n ch === 0x53 /* S */ ||\n ch === 0x77 /* w */ ||\n ch === 0x57 /* W */\n )\n}\n\n// UnicodePropertyValueExpression ::\n// UnicodePropertyName `=` UnicodePropertyValue\n// LoneUnicodePropertyNameOrValue\npp.regexp_eatUnicodePropertyValueExpression = function(state) {\n const start = state.pos\n\n // UnicodePropertyName `=` UnicodePropertyValue\n if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D /* = */)) {\n const name = state.lastStringValue\n if (this.regexp_eatUnicodePropertyValue(state)) {\n const value = state.lastStringValue\n this.regexp_validateUnicodePropertyNameAndValue(state, name, value)\n return true\n }\n }\n state.pos = start\n\n // LoneUnicodePropertyNameOrValue\n if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {\n const nameOrValue = state.lastStringValue\n this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue)\n return true\n }\n return false\n}\npp.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {\n if (!UNICODE_PROPERTY_VALUES.hasOwnProperty(name) || UNICODE_PROPERTY_VALUES[name].indexOf(value) === -1) {\n state.raise(\"Invalid property name\")\n }\n}\npp.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {\n if (UNICODE_PROPERTY_VALUES.$LONE.indexOf(nameOrValue) === -1) {\n state.raise(\"Invalid property name\")\n }\n}\n\n// UnicodePropertyName ::\n// UnicodePropertyNameCharacters\npp.regexp_eatUnicodePropertyName = function(state) {\n let ch = 0\n state.lastStringValue = \"\"\n while (isUnicodePropertyNameCharacter(ch = state.current())) {\n state.lastStringValue += codePointToString(ch)\n state.advance()\n }\n return state.lastStringValue !== \"\"\n}\nfunction isUnicodePropertyNameCharacter(ch) {\n return isControlLetter(ch) || ch === 0x5F /* _ */\n}\n\n// UnicodePropertyValue ::\n// UnicodePropertyValueCharacters\npp.regexp_eatUnicodePropertyValue = function(state) {\n let ch = 0\n state.lastStringValue = \"\"\n while (isUnicodePropertyValueCharacter(ch = state.current())) {\n state.lastStringValue += codePointToString(ch)\n state.advance()\n }\n return state.lastStringValue !== \"\"\n}\nfunction isUnicodePropertyValueCharacter(ch) {\n return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch)\n}\n\n// LoneUnicodePropertyNameOrValue ::\n// UnicodePropertyValueCharacters\npp.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {\n return this.regexp_eatUnicodePropertyValue(state)\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass\npp.regexp_eatCharacterClass = function(state) {\n if (state.eat(0x5B /* [ */)) {\n state.eat(0x5E /* ^ */)\n this.regexp_classRanges(state)\n if (state.eat(0x5D /* [ */)) {\n return true\n }\n // Unreachable since it threw \"unterminated regular expression\" error before.\n state.raise(\"Unterminated character class\")\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges\n// https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges\n// https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash\npp.regexp_classRanges = function(state) {\n while (this.regexp_eatClassAtom(state)) {\n const left = state.lastIntValue\n if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) {\n const right = state.lastIntValue\n if (state.switchU && (left === -1 || right === -1)) {\n state.raise(\"Invalid character class\")\n }\n if (left !== -1 && right !== -1 && left > right) {\n state.raise(\"Range out of order in character class\")\n }\n }\n }\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom\n// https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash\npp.regexp_eatClassAtom = function(state) {\n const start = state.pos\n\n if (state.eat(0x5C /* \\ */)) {\n if (this.regexp_eatClassEscape(state)) {\n return true\n }\n if (state.switchU) {\n // Make the same message as V8.\n const ch = state.current()\n if (ch === 0x63 /* c */ || isOctalDigit(ch)) {\n state.raise(\"Invalid class escape\")\n }\n state.raise(\"Invalid escape\")\n }\n state.pos = start\n }\n\n const ch = state.current()\n if (ch !== 0x5D /* [ */) {\n state.lastIntValue = ch\n state.advance()\n return true\n }\n\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape\npp.regexp_eatClassEscape = function(state) {\n const start = state.pos\n\n if (state.eat(0x62 /* b */)) {\n state.lastIntValue = 0x08 /* */\n return true\n }\n\n if (state.switchU && state.eat(0x2D /* - */)) {\n state.lastIntValue = 0x2D /* - */\n return true\n }\n\n if (!state.switchU && state.eat(0x63 /* c */)) {\n if (this.regexp_eatClassControlLetter(state)) {\n return true\n }\n state.pos = start\n }\n\n return (\n this.regexp_eatCharacterClassEscape(state) ||\n this.regexp_eatCharacterEscape(state)\n )\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter\npp.regexp_eatClassControlLetter = function(state) {\n const ch = state.current()\n if (isDecimalDigit(ch) || ch === 0x5F /* _ */) {\n state.lastIntValue = ch % 0x20\n state.advance()\n return true\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence\npp.regexp_eatHexEscapeSequence = function(state) {\n const start = state.pos\n if (state.eat(0x78 /* x */)) {\n if (this.regexp_eatFixedHexDigits(state, 2)) {\n return true\n }\n if (state.switchU) {\n state.raise(\"Invalid escape\")\n }\n state.pos = start\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits\npp.regexp_eatDecimalDigits = function(state) {\n const start = state.pos\n let ch = 0\n state.lastIntValue = 0\n while (isDecimalDigit(ch = state.current())) {\n state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */)\n state.advance()\n }\n return state.pos !== start\n}\nfunction isDecimalDigit(ch) {\n return ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits\npp.regexp_eatHexDigits = function(state) {\n const start = state.pos\n let ch = 0\n state.lastIntValue = 0\n while (isHexDigit(ch = state.current())) {\n state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch)\n state.advance()\n }\n return state.pos !== start\n}\nfunction isHexDigit(ch) {\n return (\n (ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) ||\n (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) ||\n (ch >= 0x61 /* a */ && ch <= 0x66 /* f */)\n )\n}\nfunction hexToInt(ch) {\n if (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) {\n return 10 + (ch - 0x41 /* A */)\n }\n if (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) {\n return 10 + (ch - 0x61 /* a */)\n }\n return ch - 0x30 /* 0 */\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence\n// Allows only 0-377(octal) i.e. 0-255(decimal).\npp.regexp_eatLegacyOctalEscapeSequence = function(state) {\n if (this.regexp_eatOctalDigit(state)) {\n const n1 = state.lastIntValue\n if (this.regexp_eatOctalDigit(state)) {\n const n2 = state.lastIntValue\n if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {\n state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue\n } else {\n state.lastIntValue = n1 * 8 + n2\n }\n } else {\n state.lastIntValue = n1\n }\n return true\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit\npp.regexp_eatOctalDigit = function(state) {\n const ch = state.current()\n if (isOctalDigit(ch)) {\n state.lastIntValue = ch - 0x30 /* 0 */\n state.advance()\n return true\n }\n state.lastIntValue = 0\n return false\n}\nfunction isOctalDigit(ch) {\n return ch >= 0x30 /* 0 */ && ch <= 0x37 /* 7 */\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits\n// https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit\n// And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence\npp.regexp_eatFixedHexDigits = function(state, length) {\n const start = state.pos\n state.lastIntValue = 0\n for (let i = 0; i < length; ++i) {\n const ch = state.current()\n if (!isHexDigit(ch)) {\n state.pos = start\n return false\n }\n state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch)\n state.advance()\n }\n return true\n}\n","import {isIdentifierStart, isIdentifierChar} from \"./identifier\"\nimport {types as tt, keywords as keywordTypes} from \"./tokentype\"\nimport {Parser} from \"./state\"\nimport {SourceLocation} from \"./locutil\"\nimport {RegExpValidationState} from \"./regexp\"\nimport {lineBreak, lineBreakG, isNewLine, nonASCIIwhitespace} from \"./whitespace\"\n\n// Object type used to represent tokens. Note that normally, tokens\n// simply exist as properties on the parser object. This is only\n// used for the onToken callback and the external tokenizer.\n\nexport class Token {\n constructor(p) {\n this.type = p.type\n this.value = p.value\n this.start = p.start\n this.end = p.end\n if (p.options.locations)\n this.loc = new SourceLocation(p, p.startLoc, p.endLoc)\n if (p.options.ranges)\n this.range = [p.start, p.end]\n }\n}\n\n// ## Tokenizer\n\nconst pp = Parser.prototype\n\n// Move to the next token\n\npp.next = function() {\n if (this.options.onToken)\n this.options.onToken(new Token(this))\n\n this.lastTokEnd = this.end\n this.lastTokStart = this.start\n this.lastTokEndLoc = this.endLoc\n this.lastTokStartLoc = this.startLoc\n this.nextToken()\n}\n\npp.getToken = function() {\n this.next()\n return new Token(this)\n}\n\n// If we're in an ES6 environment, make parsers iterable\nif (typeof Symbol !== \"undefined\")\n pp[Symbol.iterator] = function() {\n return {\n next: () => {\n let token = this.getToken()\n return {\n done: token.type === tt.eof,\n value: token\n }\n }\n }\n }\n\n// Toggle strict mode. Re-reads the next number or string to please\n// pedantic tests (`\"use strict\"; 010;` should fail).\n\npp.curContext = function() {\n return this.context[this.context.length - 1]\n}\n\n// Read a single token, updating the parser object's token-related\n// properties.\n\npp.nextToken = function() {\n let curContext = this.curContext()\n if (!curContext || !curContext.preserveSpace) this.skipSpace()\n\n this.start = this.pos\n if (this.options.locations) this.startLoc = this.curPosition()\n if (this.pos >= this.input.length) return this.finishToken(tt.eof)\n\n if (curContext.override) return curContext.override(this)\n else this.readToken(this.fullCharCodeAtPos())\n}\n\npp.readToken = function(code) {\n // Identifier or keyword. '\\uXXXX' sequences are allowed in\n // identifiers, so '\\' also dispatches to that.\n if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\\' */)\n return this.readWord()\n\n return this.getTokenFromCode(code)\n}\n\npp.fullCharCodeAtPos = function() {\n let code = this.input.charCodeAt(this.pos)\n if (code <= 0xd7ff || code >= 0xe000) return code\n let next = this.input.charCodeAt(this.pos + 1)\n return (code << 10) + next - 0x35fdc00\n}\n\npp.skipBlockComment = function() {\n let startLoc = this.options.onComment && this.curPosition()\n let start = this.pos, end = this.input.indexOf(\"*/\", this.pos += 2)\n if (end === -1) this.raise(this.pos - 2, \"Unterminated comment\")\n this.pos = end + 2\n if (this.options.locations) {\n lineBreakG.lastIndex = start\n let match\n while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {\n ++this.curLine\n this.lineStart = match.index + match[0].length\n }\n }\n if (this.options.onComment)\n this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos,\n startLoc, this.curPosition())\n}\n\npp.skipLineComment = function(startSkip) {\n let start = this.pos\n let startLoc = this.options.onComment && this.curPosition()\n let ch = this.input.charCodeAt(this.pos += startSkip)\n while (this.pos < this.input.length && !isNewLine(ch)) {\n ch = this.input.charCodeAt(++this.pos)\n }\n if (this.options.onComment)\n this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,\n startLoc, this.curPosition())\n}\n\n// Called at the start of the parse and after every token. Skips\n// whitespace and comments, and.\n\npp.skipSpace = function() {\n loop: while (this.pos < this.input.length) {\n let ch = this.input.charCodeAt(this.pos)\n switch (ch) {\n case 32: case 160: // ' '\n ++this.pos\n break\n case 13:\n if (this.input.charCodeAt(this.pos + 1) === 10) {\n ++this.pos\n }\n case 10: case 8232: case 8233:\n ++this.pos\n if (this.options.locations) {\n ++this.curLine\n this.lineStart = this.pos\n }\n break\n case 47: // '/'\n switch (this.input.charCodeAt(this.pos + 1)) {\n case 42: // '*'\n this.skipBlockComment()\n break\n case 47:\n this.skipLineComment(2)\n break\n default:\n break loop\n }\n break\n default:\n if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {\n ++this.pos\n } else {\n break loop\n }\n }\n }\n}\n\n// Called at the end of every token. Sets `end`, `val`, and\n// maintains `context` and `exprAllowed`, and skips the space after\n// the token, so that the next one's `start` will point at the\n// right position.\n\npp.finishToken = function(type, val) {\n this.end = this.pos\n if (this.options.locations) this.endLoc = this.curPosition()\n let prevType = this.type\n this.type = type\n this.value = val\n\n this.updateContext(prevType)\n}\n\n// ### Token reading\n\n// This is the function that is called to fetch the next token. It\n// is somewhat obscure, because it works in character codes rather\n// than characters, and because operator parsing has been inlined\n// into it.\n//\n// All in the name of speed.\n//\npp.readToken_dot = function() {\n let next = this.input.charCodeAt(this.pos + 1)\n if (next >= 48 && next <= 57) return this.readNumber(true)\n let next2 = this.input.charCodeAt(this.pos + 2)\n if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'\n this.pos += 3\n return this.finishToken(tt.ellipsis)\n } else {\n ++this.pos\n return this.finishToken(tt.dot)\n }\n}\n\npp.readToken_slash = function() { // '/'\n let next = this.input.charCodeAt(this.pos + 1)\n if (this.exprAllowed) { ++this.pos; return this.readRegexp() }\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(tt.slash, 1)\n}\n\npp.readToken_mult_modulo_exp = function(code) { // '%*'\n let next = this.input.charCodeAt(this.pos + 1)\n let size = 1\n let tokentype = code === 42 ? tt.star : tt.modulo\n\n // exponentiation operator ** and **=\n if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {\n ++size\n tokentype = tt.starstar\n next = this.input.charCodeAt(this.pos + 2)\n }\n\n if (next === 61) return this.finishOp(tt.assign, size + 1)\n return this.finishOp(tokentype, size)\n}\n\npp.readToken_pipe_amp = function(code) { // '|&'\n let next = this.input.charCodeAt(this.pos + 1)\n if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2)\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1)\n}\n\npp.readToken_caret = function() { // '^'\n let next = this.input.charCodeAt(this.pos + 1)\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(tt.bitwiseXOR, 1)\n}\n\npp.readToken_plus_min = function(code) { // '+-'\n let next = this.input.charCodeAt(this.pos + 1)\n if (next === code) {\n if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 &&\n (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {\n // A `-->` line comment\n this.skipLineComment(3)\n this.skipSpace()\n return this.nextToken()\n }\n return this.finishOp(tt.incDec, 2)\n }\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(tt.plusMin, 1)\n}\n\npp.readToken_lt_gt = function(code) { // '<>'\n let next = this.input.charCodeAt(this.pos + 1)\n let size = 1\n if (next === code) {\n size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2\n if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1)\n return this.finishOp(tt.bitShift, size)\n }\n if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&\n this.input.charCodeAt(this.pos + 3) === 45) {\n // `` line comment\n this.skipLineComment(3)\n this.skipSpace()\n return this.nextToken()\n }\n return this.finishOp(tt.incDec, 2)\n }\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(tt.plusMin, 1)\n}\n\npp.readToken_lt_gt = function(code) { // '<>'\n let next = this.input.charCodeAt(this.pos + 1)\n let size = 1\n if (next === code) {\n size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2\n if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1)\n return this.finishOp(tt.bitShift, size)\n }\n if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&\n this.input.charCodeAt(this.pos + 3) === 45) {\n // ` diff --git a/doc/api/assert.md b/doc/api/assert.md index 4800bed4e8239d..50519b831c9a2c 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -418,10 +418,10 @@ the function does not return a promise, `assert.doesNotReject()` will return a rejected `Promise` with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases the error handler is skipped. -Please note: Using `assert.doesNotReject()` is actually not useful because there -is little benefit by catching a rejection and then rejecting it again. Instead, -consider adding a comment next to the specific code path that should not reject -and keep error messages as expressive as possible. +Using `assert.doesNotReject()` is actually not useful because there is little +benefit in catching a rejection and then rejecting it again. Instead, consider +adding a comment next to the specific code path that should not reject and keep +error messages as expressive as possible. If specified, `error` can be a [`Class`][], [`RegExp`][] or a validation function. See [`assert.throws()`][] for more details. @@ -464,8 +464,8 @@ changes: Asserts that the function `fn` does not throw an error. -Please note: Using `assert.doesNotThrow()` is actually not useful because there -is no benefit by catching an error and then rethrowing it. Instead, consider +Using `assert.doesNotThrow()` is actually not useful because there +is no benefit in catching an error and then rethrowing it. Instead, consider adding a comment next to the specific code path that should not throw and keep error messages as expressive as possible. diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 34b2f521e12ae0..23715b2dd1080f 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -1038,9 +1038,9 @@ child process may not actually terminate the process. See kill(2) for reference. -Also note: on Linux, child processes of child processes will not be terminated +On Linux, child processes of child processes will not be terminated when attempting to kill their parent. This is likely to happen when running a -new process in a shell or with use of the `shell` option of `ChildProcess`: +new process in a shell or with the use of the `shell` option of `ChildProcess`: ```js 'use strict'; diff --git a/doc/api/crypto.md b/doc/api/crypto.md index de38522898b82c..4dbdc101018a96 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -848,7 +848,7 @@ const crypto = require('crypto'); const alice = crypto.createECDH('secp256k1'); const bob = crypto.createECDH('secp256k1'); -// Note: This is a shortcut way to specify one of Alice's previous private +// This is a shortcut way of specifying one of Alice's previous private // keys. It would be unwise to use such a predictable private key in a real // application. alice.setPrivateKey( diff --git a/doc/api/dgram.md b/doc/api/dgram.md index 6541959d3adc27..7db8cdf3650342 100644 --- a/doc/api/dgram.md +++ b/doc/api/dgram.md @@ -413,7 +413,7 @@ added: v8.6.0 * `multicastInterface` {string} -*Note: All references to scope in this section are referring to +*All references to scope in this section are referring to [IPv6 Zone Indices][], which are defined by [RFC 4007][]. In string form, an IP with a scope index is written as `'IP%scope'` where scope is an interface name or interface number.* diff --git a/doc/api/domain.md b/doc/api/domain.md index 3cd021f9d43ad8..eec763600e228f 100644 --- a/doc/api/domain.md +++ b/doc/api/domain.md @@ -122,7 +122,7 @@ if (cluster.isMaster) { d.on('error', (er) => { console.error(`error ${er.stack}`); - // Note: We're in dangerous territory! + // We're in dangerous territory! // By definition, something unexpected occurred, // which we probably didn't want. // Anything can happen now! Be very careful! diff --git a/doc/api/path.md b/doc/api/path.md index c04bff0c476f46..a5cd310690e5cc 100644 --- a/doc/api/path.md +++ b/doc/api/path.md @@ -54,7 +54,7 @@ path.posix.basename('/tmp/myfile.html'); // Returns: 'myfile.html' ``` -*Note:* On Windows Node.js follows the concept of per-drive working directory. +On Windows Node.js follows the concept of per-drive working directory. This behavior can be observed when using a drive path without a backslash. For example, `path.resolve('c:\\')` can potentially return a different result than `path.resolve('c:')`. For more information, see diff --git a/doc/api/vm.md b/doc/api/vm.md index f05a767450af52..543f1642f0ff62 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -7,7 +7,7 @@ The `vm` module provides APIs for compiling and running code within V8 Virtual -Machine contexts. **Note that the `vm` module is not a security mechanism. Do +Machine contexts. **The `vm` module is not a security mechanism. Do not use it to run untrusted code**. The term "sandbox" is used throughout these docs simply to refer to a separate context, and does not confer any security guarantees. diff --git a/doc/guides/backporting-to-release-lines.md b/doc/guides/backporting-to-release-lines.md index 150a1248b146b9..5b531639e77de5 100644 --- a/doc/guides/backporting-to-release-lines.md +++ b/doc/guides/backporting-to-release-lines.md @@ -6,7 +6,7 @@ Each release line has a staging branch that the releaser will use as a scratch pad while preparing a release. The branch name is formatted as follows: `vN.x-staging` where `N` is the major release number. -*Note*: For the active staging branches see the [Release Schedule][]. +For the active staging branches see the [Release Schedule][]. ## What needs to be backported? diff --git a/doc/guides/maintaining-V8.md b/doc/guides/maintaining-V8.md index 4606b1897a7f40..ccc3257c7a90cc 100644 --- a/doc/guides/maintaining-V8.md +++ b/doc/guides/maintaining-V8.md @@ -228,7 +228,7 @@ to be cherry-picked in the Node.js repository and V8-CI must test the change. * Open a cherry-pick PR on `nodejs/node` targeting the *vY.x-staging* branch and notify the `@nodejs/v8` team. * Run the Node.js [V8 CI] in addition to the [Node.js CI]. - Note: The CI uses the `test-v8` target in the `Makefile`, which uses + The CI uses the `test-v8` target in the `Makefile`, which uses `tools/make-v8.sh` to reconstruct a git tree in the `deps/v8` directory to run V8 tests. diff --git a/doc/guides/maintaining-the-build-files.md b/doc/guides/maintaining-the-build-files.md index f3f7bbf5e2c0fd..2f89362b8ff23f 100644 --- a/doc/guides/maintaining-the-build-files.md +++ b/doc/guides/maintaining-the-build-files.md @@ -11,7 +11,7 @@ There are three main build files that may be directly run when building Node.js: - `configure`: A Python 2 script that detects system capabilities and runs [GYP][]. It generates `config.gypi` which includes parameters used by GYP to create platform-dependent build files. Its output is usually in one of these - formats: Makefile, MSbuild, ninja, or XCode project files. (Note: the main + formats: Makefile, MSbuild, ninja, or XCode project files (the main Makefile mentioned below is maintained separately by humans). For a detailed guide on this script, see [configure](#configure). - `vcbuild.bat`: A Windows Batch Script that locates build tools, provides a diff --git a/doc/guides/using-internal-errors.md b/doc/guides/using-internal-errors.md index d22fc68e0f34c4..77eabb4ad48dec 100644 --- a/doc/guides/using-internal-errors.md +++ b/doc/guides/using-internal-errors.md @@ -14,7 +14,7 @@ in the ecosystem. For that reason, Node.js has considered error message changes to be breaking changes. By providing a permanent identifier for a specific error, we reduce the need for userland code to inspect error messages. -*Note*: Switching an existing error to use the `internal/errors` module must be +Switching an existing error to use the `internal/errors` module must be considered a `semver-major` change. ## Using internal/errors.js diff --git a/doc/node.1 b/doc/node.1 index 4c97240ee716a6..40d661b0bde540 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -227,16 +227,6 @@ and . .It Fl -v8-options Print V8 command-line options. -.Pp -Note: V8 options allow words to be separated by both dashes -.Sy ( - ) -or underscores -.Sy ( _ ) . -.Pp -For example, -.Fl -stack-trace-limit -is equivalent to -.Fl -stack_trace_limit . . .It Fl -v8-pool-size Ns = Ns Ar num Set V8's thread pool size which will be used to allocate background jobs. diff --git a/doc/releases.md b/doc/releases.md index edbe255528ff7c..5781a9d5fd490f 100644 --- a/doc/releases.md +++ b/doc/releases.md @@ -182,7 +182,7 @@ and also if there are non-trivial API changes. The rules are not yet strictly defined, so if in doubt, please confer with someone that will have a more informed perspective, such as a member of the NAN team. -*Note*: It is current TSC policy to bump major version when ABI changes. If you +It is current TSC policy to bump major version when ABI changes. If you see a need to bump `NODE_MODULE_VERSION` then you should consult the TSC. Commits may need to be reverted or a major version bump may need to happen. @@ -263,7 +263,7 @@ doc/api/*.md`, and substitute this node version with `sed -i "s/REPLACEME/$VERSION/g" doc/api/*.md` or `perl -pi -e "s/REPLACEME/$VERSION/g" doc/api/*.md`. -*Note*: `$VERSION` should be prefixed with a `v`. +`$VERSION` should be prefixed with a `v`. If this release includes any new deprecations it is necessary to ensure that those are assigned a proper static deprecation code. These are listed in the @@ -507,7 +507,7 @@ release, you should re-run `tools/release.sh` after the ARM builds have finished. That will move the ARM artifacts into the correct location. You will be prompted to re-sign SHASUMS256.txt. -*Note*: It is possible to only sign a release by running `./tools/release.sh -s +It is possible to only sign a release by running `./tools/release.sh -s vX.Y.Z`. ### 14. Check the Release From ddfb22fd96f1b844f6949c49a943a9a421a508ad Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 27 Oct 2018 20:39:13 -0700 Subject: [PATCH 294/328] doc: remove mailing list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We removed the mailing list from the README and other places quite some time ago. Core devs don't monitor it much. However, it is still linked in a couple places in the docs directory. Remove those links. PR-URL: https://github.com/nodejs/node/pull/23932 Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Refael Ackermann Reviewed-By: Vse Mozhet Byt Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell --- doc/api/index.md | 1 - doc/node.1 | 4 ---- 2 files changed, 5 deletions(-) diff --git a/doc/api/index.md b/doc/api/index.md index 5ba0da6a7fb5aa..4262191327ce60 100644 --- a/doc/api/index.md +++ b/doc/api/index.md @@ -61,4 +61,3 @@
* [GitHub Repo & Issue Tracker](https://github.com/nodejs/node) -* [Mailing List](https://groups.google.com/forum/#!forum/nodejs) diff --git a/doc/node.1 b/doc/node.1 index 40d661b0bde540..d538273409ad71 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -389,10 +389,6 @@ GitHub repository & Issue Tracker: .Sy https://github.com/nodejs/node . .Pp -Mailing list: -.Sy http://groups.google.com/group/nodejs -. -.Pp IRC (general questions): .Sy "chat.freenode.net #node.js" (unofficial) From 3c46c0367819ddce7c23da0f35b7f4ac51913cdd Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 26 Oct 2018 15:09:16 -0700 Subject: [PATCH 295/328] doc: add documentation for http.IncomingMessage$complete Fixes: https://github.com/nodejs/node/issues/8102 PR-URL: https://github.com/nodejs/node/pull/23914 Reviewed-By: Luigi Pinca Reviewed-By: Vse Mozhet Byt Reviewed-By: Trivikram Kamat --- doc/api/http.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/doc/api/http.md b/doc/api/http.md index 7d1fb9788d9b1d..562830ee589385 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -1496,6 +1496,34 @@ added: v10.1.0 The `message.aborted` property will be `true` if the request has been aborted. +### message.complete + + +* {boolean} + +The `message.complete` property will be `true` if a complete HTTP message has +been received and successfully parsed. + +This property is particularly useful as a means of determining if a client or +server fully transmitted a message before a connection was terminated: + +```js +const req = http.request({ + host: '127.0.0.1', + port: 8080, + method: 'POST' +}, (res) => { + res.resume(); + res.on('end', () => { + if (!res.complete) + console.error( + 'The connection was terminated while the message was still being sent'); + }); +}); +``` + ### message.destroy([error]) * NOT OK: Javascript, Google's v8 +* Use _Node.js_ and not _Node_, _NodeJS_, or similar variants. + * When referring to the executable, _`node`_ is acceptable. See also API documentation structure overview in [doctools README][]. From c32cf17907769c6a9793af226f7a45ff059d6b2c Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Mon, 22 Oct 2018 15:07:00 -0400 Subject: [PATCH 303/328] src,win: informative stack traces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refresh `Win32SymbolDebuggingContext::LookupSymbol` to use more APIs PR-URL: https://github.com/nodejs/node/pull/23822 Refs: https://docs.microsoft.com/en-us/windows/desktop/Debug/retrieving-symbol-information-by-address Refs: https://docs.microsoft.com/en-us/windows/desktop/Debug/retrieving-undecorated-symbol-names Reviewed-By: Tobias Nießen --- src/debug_utils.cc | 139 +++++++++++++++++++++++++++++++++++---------- src/debug_utils.h | 14 ++++- 2 files changed, 123 insertions(+), 30 deletions(-) diff --git a/src/debug_utils.cc b/src/debug_utils.cc index a24c51de39cf2d..77ea219bfc880a 100644 --- a/src/debug_utils.cc +++ b/src/debug_utils.cc @@ -100,35 +100,104 @@ class Win32SymbolDebuggingContext final : public NativeSymbolDebuggingContext { USE(SymInitialize(current_process_, nullptr, true)); } - ~Win32SymbolDebuggingContext() { + ~Win32SymbolDebuggingContext() override { USE(SymCleanup(current_process_)); } - SymbolInfo LookupSymbol(void* address) override { - // Ref: https://msdn.microsoft.com/en-en/library/windows/desktop/ms680578(v=vs.85).aspx - char info_buf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME]; - SYMBOL_INFO* info = reinterpret_cast(info_buf); - char demangled[MAX_SYM_NAME]; + using NameAndDisplacement = std::pair; + NameAndDisplacement WrappedSymFromAddr(DWORD64 dwAddress) const { + // Refs: https://docs.microsoft.com/en-us/windows/desktop/Debug/retrieving-symbol-information-by-address + // Patches: + // Use `fprintf(stderr, ` instead of `printf` + // `sym.filename = pSymbol->Name` on success + // `current_process_` instead of `hProcess. + DWORD64 dwDisplacement = 0; + // Patch: made into arg - DWORD64 dwAddress = SOME_ADDRESS; + + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)]; + const auto pSymbol = reinterpret_cast(buffer); + + pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO); + pSymbol->MaxNameLen = MAX_SYM_NAME; + + if (SymFromAddr(current_process_, dwAddress, &dwDisplacement, pSymbol)) { + // SymFromAddr returned success + return NameAndDisplacement(pSymbol->Name, dwDisplacement); + } else { + // SymFromAddr failed + const DWORD error = GetLastError(); // "eat" the error anyway +#ifdef DEBUG + fprintf(stderr, "SymFromAddr returned error : %lu\n", error); +#endif + } + // End MSDN code - info->MaxNameLen = MAX_SYM_NAME; - info->SizeOfStruct = sizeof(SYMBOL_INFO); + return NameAndDisplacement(); + } - SymbolInfo ret; - const bool have_info = SymFromAddr(current_process_, - reinterpret_cast(address), - nullptr, - info); - if (have_info && strlen(info->Name) == 0) { - if (UnDecorateSymbolName(info->Name, - demangled, - sizeof(demangled), - UNDNAME_COMPLETE)) { - ret.name = demangled; - } else { - ret.name = info->Name; - } + SymbolInfo WrappedGetLine(DWORD64 dwAddress) const { + SymbolInfo sym{}; + + // Refs: https://docs.microsoft.com/en-us/windows/desktop/Debug/retrieving-symbol-information-by-address + // Patches: + // Use `fprintf(stderr, ` instead of `printf`. + // Assign values to `sym` on success. + // `current_process_` instead of `hProcess. + + // Patch: made into arg - DWORD64 dwAddress; + DWORD dwDisplacement; + IMAGEHLP_LINE64 line; + + SymSetOptions(SYMOPT_LOAD_LINES); + + line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); + // Patch: made into arg - dwAddress = 0x1000000; + + if (SymGetLineFromAddr64(current_process_, dwAddress, + &dwDisplacement, &line)) { + // SymGetLineFromAddr64 returned success + sym.filename = line.FileName; + sym.line = line.LineNumber; + } else { + // SymGetLineFromAddr64 failed + const DWORD error = GetLastError(); // "eat" the error anyway +#ifdef DEBUG + fprintf(stderr, "SymGetLineFromAddr64 returned error : %lu\n", error); +#endif + } + // End MSDN code + + return sym; + } + + // Fills the SymbolInfo::name of the io/out argument `sym` + std::string WrappedUnDecorateSymbolName(const char* name) const { + // Refs: https://docs.microsoft.com/en-us/windows/desktop/Debug/retrieving-undecorated-symbol-names + // Patches: + // Use `fprintf(stderr, ` instead of `printf`. + // return `szUndName` instead of `printf` on success + char szUndName[MAX_SYM_NAME]; + if (UnDecorateSymbolName(name, szUndName, sizeof(szUndName), + UNDNAME_COMPLETE)) { + // UnDecorateSymbolName returned success + return szUndName; + } else { + // UnDecorateSymbolName failed + const DWORD error = GetLastError(); // "eat" the error anyway +#ifdef DEBUG + fprintf(stderr, "UnDecorateSymbolName returned error %lu\n", error); +#endif } + return nullptr; + } + SymbolInfo LookupSymbol(void* address) override { + const DWORD64 dw_address = reinterpret_cast(address); + SymbolInfo ret = WrappedGetLine(dw_address); + std::tie(ret.name, ret.dis) = WrappedSymFromAddr(dw_address); + if (!ret.name.empty()) { + ret.name = WrappedUnDecorateSymbolName(ret.name.c_str()); + } return ret; } @@ -145,6 +214,13 @@ class Win32SymbolDebuggingContext final : public NativeSymbolDebuggingContext { return CaptureStackBackTrace(0, count, frames, nullptr); } + Win32SymbolDebuggingContext(const Win32SymbolDebuggingContext&) = delete; + Win32SymbolDebuggingContext(Win32SymbolDebuggingContext&&) = delete; + Win32SymbolDebuggingContext operator=(const Win32SymbolDebuggingContext&) + = delete; + Win32SymbolDebuggingContext operator=(Win32SymbolDebuggingContext&&) + = delete; + private: HANDLE current_process_; }; @@ -158,13 +234,18 @@ NativeSymbolDebuggingContext::New() { #endif // __POSIX__ std::string NativeSymbolDebuggingContext::SymbolInfo::Display() const { - std::string ret = name; + std::ostringstream oss; + oss << name; + if (dis != 0) { + oss << "+" << dis; + } if (!filename.empty()) { - ret += " ["; - ret += filename; - ret += ']'; + oss << " [" << filename << ']'; + } + if (line != 0) { + oss << ":L" << line; } - return ret; + return oss.str(); } void DumpBacktrace(FILE* fp) { @@ -173,8 +254,8 @@ void DumpBacktrace(FILE* fp) { const int size = sym_ctx->GetStackTrace(frames, arraysize(frames)); for (int i = 1; i < size; i += 1) { void* frame = frames[i]; - fprintf(fp, "%2d: %p %s\n", - i, frame, sym_ctx->LookupSymbol(frame).Display().c_str()); + NativeSymbolDebuggingContext::SymbolInfo s = sym_ctx->LookupSymbol(frame); + fprintf(fp, "%2d: %p %s\n", i, frame, s.Display().c_str()); } } diff --git a/src/debug_utils.h b/src/debug_utils.h index 2fd9e7dab7f8f4..c6c8e03b51fd64 100644 --- a/src/debug_utils.h +++ b/src/debug_utils.h @@ -6,6 +6,7 @@ #include "async_wrap.h" #include "env.h" #include +#include // Use FORCE_INLINE on functions that have a debug-category-enabled check first // and then ideally only a single function call following it, to maintain @@ -93,14 +94,25 @@ class NativeSymbolDebuggingContext { public: std::string name; std::string filename; + size_t line = 0; + size_t dis = 0; std::string Display() const; }; + NativeSymbolDebuggingContext() = default; virtual ~NativeSymbolDebuggingContext() {} - virtual SymbolInfo LookupSymbol(void* address) { return { "", "" }; } + + virtual SymbolInfo LookupSymbol(void* address) { return {}; } virtual bool IsMapped(void* address) { return false; } virtual int GetStackTrace(void** frames, int count) { return 0; } + + NativeSymbolDebuggingContext(const NativeSymbolDebuggingContext&) = delete; + NativeSymbolDebuggingContext(NativeSymbolDebuggingContext&&) = delete; + NativeSymbolDebuggingContext operator=(NativeSymbolDebuggingContext&) + = delete; + NativeSymbolDebuggingContext operator=(NativeSymbolDebuggingContext&&) + = delete; }; // Variant of `uv_loop_close` that tries to be as helpful as possible From dd82014f600c8c556488017c21e4620cb486d430 Mon Sep 17 00:00:00 2001 From: ZYSzys <17367077526@163.com> Date: Fri, 26 Oct 2018 23:24:01 +0800 Subject: [PATCH 304/328] lib: remove useless cwd in posix.resolve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23902 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat Reviewed-By: Tobias Nießen Reviewed-By: James M Snell --- lib/path.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/path.js b/lib/path.js index c8d92f14af04de..798682ca0f1a6b 100644 --- a/lib/path.js +++ b/lib/path.js @@ -1073,16 +1073,13 @@ const posix = { resolve: function resolve() { var resolvedPath = ''; var resolvedAbsolute = false; - var cwd; for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { var path; if (i >= 0) path = arguments[i]; else { - if (cwd === undefined) - cwd = process.cwd(); - path = cwd; + path = process.cwd(); } assertPath(path); From 7374c0c5e115f01f9a9853ea186d1002bd5cd19f Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 24 Oct 2018 21:15:22 +0800 Subject: [PATCH 305/328] lib: fix code cache generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit e7f710c1 broke the code cache generation since internalBinding is now passed in through the wrapper and cannot be redeclared. This patch fixes that. Refs: https://github.com/nodejs/node/issues/21563 PR-URL: https://github.com/nodejs/node/pull/23855 Reviewed-By: Michaël Zasso Reviewed-By: Refael Ackermann Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- lib/internal/bootstrap/cache.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/internal/bootstrap/cache.js b/lib/internal/bootstrap/cache.js index 41fe1e3a914ba0..6181228b033228 100644 --- a/lib/internal/bootstrap/cache.js +++ b/lib/internal/bootstrap/cache.js @@ -6,8 +6,9 @@ // cannot be tampered with even with --expose-internals const { - NativeModule, internalBinding + NativeModule } = require('internal/bootstrap/loaders'); +const { hasTracing } = process.binding('config'); function getCodeCache(id) { const cached = NativeModule.getCached(id); @@ -42,6 +43,16 @@ const cannotUseCache = [ 'internal/bootstrap/node' ].concat(depsModule); +// Skip modules that cannot be required when they are not +// built into the binary. +if (process.config.variables.v8_enable_inspector !== 1) { + cannotUseCache.push('inspector'); + cannotUseCache.push('internal/util/inspector'); +} +if (!hasTracing) { + cannotUseCache.push('trace_events'); +} + module.exports = { cachableBuiltins: Object.keys(NativeModule._source).filter( (key) => !cannotUseCache.includes(key) From ff59c1c97e7657a8960d489587c3fc01e6593ac7 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 24 Oct 2018 23:24:31 +0800 Subject: [PATCH 306/328] test: run code cache test by default and test generator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add the code cache tests to the default test suite, and test the bookkeeping when the binary is not built with the code cache. - Test the code cache generator to make sure we do not accidentally break it - until we enable code cache in the CI. Refs: https://github.com/nodejs/node/issues/21563 PR-URL: https://github.com/nodejs/node/pull/23855 Reviewed-By: Michaël Zasso Reviewed-By: Refael Ackermann Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/code-cache/test-code-cache-generator.js | 58 ++++++++++++++++++++ test/code-cache/test-code-cache.js | 46 ++++++++++------ tools/test.py | 1 - 3 files changed, 88 insertions(+), 17 deletions(-) create mode 100644 test/code-cache/test-code-cache-generator.js diff --git a/test/code-cache/test-code-cache-generator.js b/test/code-cache/test-code-cache-generator.js new file mode 100644 index 00000000000000..972d89629c0a23 --- /dev/null +++ b/test/code-cache/test-code-cache-generator.js @@ -0,0 +1,58 @@ +'use strict'; + +// This test verifies that the binary is compiled with code cache and the +// cache is used when built in modules are compiled. + +const common = require('../common'); + +const tmpdir = require('../common/tmpdir'); +const { spawnSync } = require('child_process'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); +const readline = require('readline'); + +const generator = path.join( + __dirname, '..', '..', 'tools', 'generate_code_cache.js' +); +tmpdir.refresh(); +const dest = path.join(tmpdir.path, 'cache.cc'); + +// Run tools/generate_code_cache.js +const child = spawnSync( + process.execPath, + ['--expose-internals', generator, dest] +); +assert.ifError(child.error); +if (child.status !== 0) { + console.log(child.stderr.toString()); + assert.strictEqual(child.status, 0); +} + +// Verifies that: +// - node::DefineCodeCache() +// - node::DefineCodeCacheHash() +// are defined in the generated code. +// See src/node_code_cache_stub.cc for explanations. + +const rl = readline.createInterface({ + input: fs.createReadStream(dest), + crlfDelay: Infinity +}); + +let hasCacheDef = false; +let hasHashDef = false; + +rl.on('line', common.mustCallAtLeast((line) => { + if (line.includes('DefineCodeCache(')) { + hasCacheDef = true; + } + if (line.includes('DefineCodeCacheHash(')) { + hasHashDef = true; + } +}, 2)); + +rl.on('close', common.mustCall(() => { + assert.ok(hasCacheDef); + assert.ok(hasHashDef); +})); diff --git a/test/code-cache/test-code-cache.js b/test/code-cache/test-code-cache.js index b05e764e8ad290..c1bfa80f4342f3 100644 --- a/test/code-cache/test-code-cache.js +++ b/test/code-cache/test-code-cache.js @@ -1,8 +1,9 @@ 'use strict'; // Flags: --expose-internals -// This test verifies that the binary is compiled with code cache and the -// cache is used when built in modules are compiled. +// This test verifies that if the binary is compiled with code cache, +// and the cache is used when built in modules are compiled. +// Otherwise, verifies that no cache is used when compiling builtins. require('../common'); const assert = require('assert'); @@ -18,23 +19,36 @@ const { compiledWithoutCache } = require('internal/bootstrap/cache'); -assert.strictEqual( - typeof process.config.variables.node_code_cache_path, - 'string' -); - -assert.deepStrictEqual(compiledWithoutCache, []); - const loadedModules = process.moduleLoadList .filter((m) => m.startsWith('NativeModule')) .map((m) => m.replace('NativeModule ', '')); -for (const key of loadedModules) { - assert(compiledWithCache.includes(key), - `"${key}" should've been compiled with code cache`); -} +// The binary is not configured with code cache, verifies that the builtins +// are all compiled without cache and we are doing the bookkeeping right. +if (process.config.variables.node_code_cache_path === undefined) { + assert.deepStrictEqual(compiledWithCache, []); + assert.notStrictEqual(compiledWithoutCache.length, 0); + + for (const key of loadedModules) { + assert(compiledWithoutCache.includes(key), + `"${key}" should not have been compiled with code cache`); + } -for (const key of cachableBuiltins) { - assert(isUint8Array(codeCache[key]) && codeCache[key].length > 0, - `Code cache for "${key}" should've been generated`); +} else { + // The binary is configured with code cache. + assert.strictEqual( + typeof process.config.variables.node_code_cache_path, + 'string' + ); + assert.deepStrictEqual(compiledWithoutCache, []); + + for (const key of loadedModules) { + assert(compiledWithCache.includes(key), + `"${key}" should've been compiled with code cache`); + } + + for (const key of cachableBuiltins) { + assert(isUint8Array(codeCache[key]) && codeCache[key].length > 0, + `Code cache for "${key}" should've been generated`); + } } diff --git a/tools/test.py b/tools/test.py index 3d0ba43beca8b5..cd361196653043 100755 --- a/tools/test.py +++ b/tools/test.py @@ -1498,7 +1498,6 @@ def PrintCrashed(code): IGNORED_SUITES = [ 'addons', 'addons-napi', - 'code-cache', 'doctool', 'internet', 'pummel', From 592f5bd49cd57b114c48446238d78afc7e7bb664 Mon Sep 17 00:00:00 2001 From: Ouyang Yadong Date: Thu, 25 Oct 2018 14:05:41 +0800 Subject: [PATCH 307/328] src: use "constants" string instead of creating new one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using the same "constants" string in c++. PR-URL: https://github.com/nodejs/node/pull/23894 Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig Reviewed-By: Richard Lau Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat Reviewed-By: Сковорода Никита Андреевич --- src/node_http2.cc | 2 +- src/pipe_wrap.cc | 2 +- src/tcp_wrap.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/node_http2.cc b/src/node_http2.cc index 7e5e49f47e4f82..0b97e524b3dbc3 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -3114,7 +3114,7 @@ HTTP_STATUS_CODES(V) env->SetMethod(target, "packSettings", PackSettings); target->Set(context, - FIXED_ONE_BYTE_STRING(isolate, "constants"), + env->constants_string(), constants).FromJust(); target->Set(context, FIXED_ONE_BYTE_STRING(isolate, "nameForErrorCode"), diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 90ba87b2d55d09..7f7e2250439763 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -109,7 +109,7 @@ void PipeWrap::Initialize(Local target, NODE_DEFINE_CONSTANT(constants, UV_READABLE); NODE_DEFINE_CONSTANT(constants, UV_WRITABLE); target->Set(context, - FIXED_ONE_BYTE_STRING(env->isolate(), "constants"), + env->constants_string(), constants).FromJust(); } diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index f653297fc0ac8b..a6cc01f1288928 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -124,7 +124,7 @@ void TCPWrap::Initialize(Local target, NODE_DEFINE_CONSTANT(constants, SOCKET); NODE_DEFINE_CONSTANT(constants, SERVER); target->Set(context, - FIXED_ONE_BYTE_STRING(env->isolate(), "constants"), + env->constants_string(), constants).FromJust(); } From 51947a515d3977dab388801888beb43591edac2c Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Tue, 16 Oct 2018 18:25:44 -0400 Subject: [PATCH 308/328] build: configure default v8_optimized_debug Under the assumption that debugging is more often focused on node core source. This setting compiles V8 with only partial optimizations, DCHECKS, and debug symbols, so it is still very much debuggable, but it is much faster. It does disable SLOW_DCHECKS, but at the advice of the V8 team, those are more important for deep V8 debugging. Override is configurable with `./configure --v8-non-optimized-debug`. PR-URL: https://github.com/nodejs/node/pull/23704 Reviewed-By: Joyee Cheung Reviewed-By: Ujjwal Sharma --- common.gypi | 3 --- configure.py | 8 +++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/common.gypi b/common.gypi index f0315b198a85a0..b07b854be6217f 100644 --- a/common.gypi +++ b/common.gypi @@ -28,9 +28,6 @@ 'openssl_fips%': '', - # Default to -O0 for debug builds. - 'v8_optimized_debug%': 0, - # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. 'v8_embedder_string': '-node.44', diff --git a/configure.py b/configure.py index a5075bd9d8a60b..bf9a10d6474805 100755 --- a/configure.py +++ b/configure.py @@ -576,6 +576,12 @@ default=True, help='get more output from this script') +parser.add_option('--v8-non-optimized-debug', + action='store_true', + dest='v8_non_optimized_debug', + default=False, + help='compile V8 with minimal optimizations and with runtime checks') + # Create compile_commands.json in out/Debug and out/Release. parser.add_option('-C', action='store_true', @@ -1156,7 +1162,7 @@ def configure_library(lib, output): def configure_v8(o): o['variables']['v8_enable_gdbjit'] = 1 if options.gdb else 0 o['variables']['v8_no_strict_aliasing'] = 1 # Work around compiler bugs. - o['variables']['v8_optimized_debug'] = 0 # Compile with -O0 in debug builds. + o['variables']['v8_optimized_debug'] = 0 if options.v8_non_optimized_debug else 1 o['variables']['v8_random_seed'] = 0 # Use a random seed for hash tables. o['variables']['v8_promise_internal_field_count'] = 1 # Add internal field to promises for async hooks. o['variables']['v8_use_snapshot'] = 'false' if options.without_snapshot else 'true' From 67f5d3052d2d8e451bf3801cab1ab0da1ee719f6 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Mon, 15 Oct 2018 18:32:11 -0400 Subject: [PATCH 309/328] deps,v8: fix gypfile bug PR-URL: https://github.com/nodejs/node/pull/23704 Reviewed-By: Joyee Cheung Reviewed-By: Ujjwal Sharma --- common.gypi | 2 +- deps/v8/gypfiles/toolchain.gypi | 258 ++++++++++++++------------------ deps/v8/gypfiles/v8.gyp | 21 +-- 3 files changed, 115 insertions(+), 166 deletions(-) diff --git a/common.gypi b/common.gypi index b07b854be6217f..e73d215a982f72 100644 --- a/common.gypi +++ b/common.gypi @@ -30,7 +30,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.44', + 'v8_embedder_string': '-node.45', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/gypfiles/toolchain.gypi b/deps/v8/gypfiles/toolchain.gypi index ea8f1c2f00da56..4860c5b7724e20 100644 --- a/deps/v8/gypfiles/toolchain.gypi +++ b/deps/v8/gypfiles/toolchain.gypi @@ -1134,121 +1134,7 @@ }], ], # conditions 'configurations': { - # Abstract configuration for v8_optimized_debug == 0. - 'DebugBase0': { - 'abstract': 1, - 'msvs_settings': { - 'VCCLCompilerTool': { - 'Optimization': '0', - 'conditions': [ - ['component=="shared_library" or force_dynamic_crt==1', { - 'RuntimeLibrary': '3', # /MDd - }, { - 'RuntimeLibrary': '1', # /MTd - }], - ], - }, - 'VCLinkerTool': { - 'LinkIncremental': '2', - }, - }, - 'variables': { - 'v8_enable_slow_dchecks%': 1, - }, - 'conditions': [ - ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \ - OS=="qnx" or OS=="aix"', { - 'cflags!': [ - '-O3', - '-O2', - '-O1', - '-Os', - ], - 'cflags': [ - '-fdata-sections', - '-ffunction-sections', - ], - }], - ['OS=="mac"', { - 'xcode_settings': { - 'GCC_OPTIMIZATION_LEVEL': '0', # -O0 - }, - }], - ['v8_enable_slow_dchecks==1', { - 'defines': [ - 'ENABLE_SLOW_DCHECKS', - ], - }], - ], - }, # DebugBase0 - # Abstract configuration for v8_optimized_debug == 1. - 'DebugBase1': { - 'abstract': 1, - 'msvs_settings': { - 'VCCLCompilerTool': { - 'Optimization': '2', - 'InlineFunctionExpansion': '2', - 'EnableIntrinsicFunctions': 'true', - 'FavorSizeOrSpeed': '0', - 'StringPooling': 'true', - 'BasicRuntimeChecks': '0', - 'conditions': [ - ['component=="shared_library" or force_dynamic_crt==1', { - 'RuntimeLibrary': '3', #/MDd - }, { - 'RuntimeLibrary': '1', #/MTd - }], - ], - }, - 'VCLinkerTool': { - 'LinkIncremental': '1', - 'OptimizeReferences': '2', - 'EnableCOMDATFolding': '2', - }, - }, - 'variables': { - 'v8_enable_slow_dchecks%': 0, - }, - 'conditions': [ - ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \ - OS=="qnx" or OS=="aix"', { - 'cflags!': [ - '-O0', - '-O1', - '-Os', - ], - 'cflags': [ - '-fdata-sections', - '-ffunction-sections', - ], - 'conditions': [ - # Don't use -O3 with sanitizers. - ['asan==0 and msan==0 and lsan==0 \ - and tsan==0 and ubsan==0 and ubsan_vptr==0', { - 'cflags': ['-O3'], - 'cflags!': ['-O2'], - }, { - 'cflags': ['-O2'], - 'cflags!': ['-O3'], - }], - ], - }], - ['OS=="mac"', { - 'xcode_settings': { - 'GCC_OPTIMIZATION_LEVEL': '3', # -O3 - 'GCC_STRICT_ALIASING': 'YES', - }, - }], - ['v8_enable_slow_dchecks==1', { - 'defines': [ - 'ENABLE_SLOW_DCHECKS', - ], - }], - ], - }, # DebugBase1 - # Common settings for the Debug configuration. - 'DebugBaseCommon': { - 'abstract': 1, + 'Debug': { 'defines': [ 'ENABLE_DISASSEMBLER', 'V8_ENABLE_CHECKS', @@ -1311,27 +1197,126 @@ }], ], }], - ], - }, # DebugBaseCommon - 'Debug': { - 'inherit_from': ['DebugBaseCommon'], - 'conditions': [ ['v8_optimized_debug==0', { - 'inherit_from': ['DebugBase0'], + 'msvs_settings': { + 'VCCLCompilerTool': { + 'Optimization': '0', + 'conditions': [ + ['component=="shared_library" or force_dynamic_crt==1', { + 'RuntimeLibrary': '3', # /MDd + }, { + 'RuntimeLibrary': '1', # /MTd + }], + ], + }, + 'VCLinkerTool': { + 'LinkIncremental': '2', + }, + }, + 'variables': { + 'v8_enable_slow_dchecks%': 1, + }, + 'conditions': [ + ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \ + OS=="qnx" or OS=="aix"', { + 'cflags!': [ + '-O3', + '-O2', + '-O1', + '-Os', + ], + 'cflags': [ + '-fdata-sections', + '-ffunction-sections', + ], + }], + ['OS=="mac"', { + 'xcode_settings': { + 'GCC_OPTIMIZATION_LEVEL': '0', # -O0 + }, + }], + ['v8_enable_slow_dchecks==1', { + 'defines': [ + 'ENABLE_SLOW_DCHECKS', + ], + }], + ], }, { - 'inherit_from': ['DebugBase1'], + 'msvs_settings': { + 'VCCLCompilerTool': { + 'Optimization': '2', + 'InlineFunctionExpansion': '2', + 'EnableIntrinsicFunctions': 'true', + 'FavorSizeOrSpeed': '0', + 'StringPooling': 'true', + 'BasicRuntimeChecks': '0', + 'conditions': [ + ['component=="shared_library" or force_dynamic_crt==1', { + 'RuntimeLibrary': '3', #/MDd + }, { + 'RuntimeLibrary': '1', #/MTd + }], + ], + }, + 'VCLinkerTool': { + 'LinkIncremental': '1', + 'OptimizeReferences': '2', + 'EnableCOMDATFolding': '2', + }, + }, + 'variables': { + 'v8_enable_slow_dchecks%': 0, + }, + 'conditions': [ + ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \ + OS=="qnx" or OS=="aix"', { + 'cflags!': [ + '-O0', + '-O1', + '-Os', + ], + 'cflags': [ + '-fdata-sections', + '-ffunction-sections', + ], + 'conditions': [ + # Don't use -O3 with sanitizers. + ['asan==0 and msan==0 and lsan==0 \ + and tsan==0 and ubsan==0 and ubsan_vptr==0', { + 'cflags': ['-O3'], + 'cflags!': ['-O2'], + }, { + 'cflags': ['-O2'], + 'cflags!': ['-O3'], + }], + ], + }], + ['OS=="mac"', { + 'xcode_settings': { + 'GCC_OPTIMIZATION_LEVEL': '3', # -O3 + 'GCC_STRICT_ALIASING': 'YES', + }, + }], + ['v8_enable_slow_dchecks==1', { + 'defines': [ + 'ENABLE_SLOW_DCHECKS', + ], + }], + ], }], # Temporary refs: https://github.com/nodejs/node/pull/23801 ['v8_enable_handle_zapping==1', { 'defines': ['ENABLE_HANDLE_ZAPPING',], }], ], - }, # Debug - 'ReleaseBase': { - 'abstract': 1, + + }, # DebugBaseCommon + 'Release': { 'variables': { 'v8_enable_slow_dchecks%': 0, }, + # Temporary refs: https://github.com/nodejs/node/pull/23801 + 'defines!': ['ENABLE_HANDLE_ZAPPING',], 'conditions': [ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" \ or OS=="aix"', { @@ -1407,29 +1392,6 @@ }], ], # conditions }, # Release - 'Release': { - 'inherit_from': ['ReleaseBase'], - # Temporary refs: https://github.com/nodejs/node/pull/23801 - 'defines!': ['ENABLE_HANDLE_ZAPPING',], - }, # Debug - 'conditions': [ - [ 'OS=="win"', { - # TODO(bradnelson): add a gyp mechanism to make this more graceful. - 'Debug_x64': { - 'inherit_from': ['DebugBaseCommon'], - 'conditions': [ - ['v8_optimized_debug==0', { - 'inherit_from': ['DebugBase0'], - }, { - 'inherit_from': ['DebugBase1'], - }], - ], - }, - 'Release_x64': { - 'inherit_from': ['ReleaseBase'], - }, - }], - ], }, # configurations 'msvs_disabled_warnings': [ 4245, # Conversion with signed/unsigned mismatch. diff --git a/deps/v8/gypfiles/v8.gyp b/deps/v8/gypfiles/v8.gyp index 8c78f022551e66..e18429b6d2ffdf 100644 --- a/deps/v8/gypfiles/v8.gyp +++ b/deps/v8/gypfiles/v8.gyp @@ -2461,23 +2461,10 @@ '../third_party/antlr4/runtime/Cpp/runtime/src', '../src/torque', ], - # This is defined trough `configurations` for GYP+ninja compatibility - 'configurations': { - 'Debug': { - 'msvs_settings': { - 'VCCLCompilerTool': { - 'RuntimeTypeInfo': 'true', - 'ExceptionHandling': 1, - }, - } - }, - 'Release': { - 'msvs_settings': { - 'VCCLCompilerTool': { - 'RuntimeTypeInfo': 'true', - 'ExceptionHandling': 1, - }, - } + 'msvs_settings': { + 'VCCLCompilerTool': { + 'RuntimeTypeInfo': 'true', + 'ExceptionHandling': 1, }, }, 'sources': [ From bd73da00f2258bf658e043b12bd3e27e21286166 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Mon, 29 Oct 2018 14:40:38 -0400 Subject: [PATCH 310/328] build: add -Werror=undefined-inline to clang builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23961 Refs: https://github.com/nodejs/node/pull/23954 Refs: https://github.com/nodejs/node/pull/23910 Refs: https://github.com/nodejs/node/pull/23880 Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig Reviewed-By: Richard Lau Reviewed-By: Joyee Cheung --- node.gypi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/node.gypi b/node.gypi index ab2df8645e4e0e..7836561a84117d 100644 --- a/node.gypi +++ b/node.gypi @@ -32,9 +32,13 @@ '-Wendif-labels', '-W', '-Wno-unused-parameter', + '-Werror=undefined-inline', ], }, 'conditions': [ + ['clang==1', { + 'cflags': [ '-Werror=undefined-inline', ] + }], [ 'node_shared=="false"', { 'msvs_settings': { 'VCManifestTool': { From d25e94b795f886a268d4f08b41f65151a331fa14 Mon Sep 17 00:00:00 2001 From: Suresh Srinivas Date: Mon, 29 Oct 2018 16:47:27 -0700 Subject: [PATCH 311/328] src: fix fully-static & large-pages combination Fixes: https://github.com/nodejs/node/issues/23906 Refs: https://github.com/nodejs/node/pull/22079 This change to ld.implicit.script moves libc static code to .lpstub area and avoids the issue detailed in 23906 Quick performance comparision on web-tooling shows 3% improvement for the combination over fully-static cycles 376,235,487,455 390,007,877,315 instructions 700,341,146,973 714,773,201,182 itlb_misses_walk_completed 20,654,246 28,908,381 itlb_misses_walk_completed_4k 19,884,666 28,865,118 itlb_misses_walk_completed_2m_4m 769,391 43,251 Score 9.13 8.86 PR-URL: https://github.com/nodejs/node/pull/23964 Reviewed-By: Refael Ackermann Reviewed-By: Ben Noordhuis --- src/large_pages/ld.implicit.script | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/large_pages/ld.implicit.script b/src/large_pages/ld.implicit.script index ad7ce1b2e2e5cf..7f12e4bd7df9e5 100644 --- a/src/large_pages/ld.implicit.script +++ b/src/large_pages/ld.implicit.script @@ -1,8 +1,10 @@ SECTIONS { - .lpstub : { *(.lpstub) } + .lpstub : { + *libc.a:*(.text .text.*) + *(.lpstub) + } } PROVIDE (__nodetext = .); PROVIDE (_nodetext = .); PROVIDE (nodetext = .); INSERT BEFORE .text; - From 74f128a3cd2c43352448eb59ea9e9cff33267573 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 29 Oct 2018 10:27:34 +0100 Subject: [PATCH 312/328] build: make benchmark/napi all prereq order-only This commit makes the all prerequisites order-only to prevent this target's rules to be executed every time which is currently the case as the all target is a phony target and will be executed every time. PR-URL: https://github.com/nodejs/node/pull/23951 Reviewed-By: Richard Lau Reviewed-By: Franziska Hinkelmann Reviewed-By: Refael Ackermann --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 88be22fcace3ec..aa8d75242c00f5 100644 --- a/Makefile +++ b/Makefile @@ -308,19 +308,19 @@ test-valgrind: all test-check-deopts: all $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) --check-deopts parallel sequential -benchmark/napi/function_call/build/Release/binding.node: all \ +benchmark/napi/function_call/build/Release/binding.node: \ benchmark/napi/function_call/napi_binding.c \ benchmark/napi/function_call/binding.cc \ - benchmark/napi/function_call/binding.gyp + benchmark/napi/function_call/binding.gyp | all $(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \ --python="$(PYTHON)" \ --directory="$(shell pwd)/benchmark/napi/function_call" \ --nodedir="$(shell pwd)" -benchmark/napi/function_args/build/Release/binding.node: all \ +benchmark/napi/function_args/build/Release/binding.node: \ benchmark/napi/function_args/napi_binding.c \ benchmark/napi/function_args/binding.cc \ - benchmark/napi/function_args/binding.gyp + benchmark/napi/function_args/binding.gyp | all $(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \ --python="$(PYTHON)" \ --directory="$(shell pwd)/benchmark/napi/function_args" \ From a35e8f1666598a3b5ad72ee4dcc17e833bbcc50e Mon Sep 17 00:00:00 2001 From: Ouyang Yadong Date: Wed, 31 Oct 2018 16:53:38 +0800 Subject: [PATCH 313/328] doc: add types and their corresponding return values This commit supplements some types and their corresponding return values in docs, including `AsyncResource`, `DiffieHellman`, `ECDH`, `https.Server`, `repl.REPLServer`. PR-URL: https://github.com/nodejs/node/pull/23998 Reviewed-By: Vse Mozhet Byt Reviewed-By: Luigi Pinca --- doc/api/async_hooks.md | 2 ++ doc/api/crypto.md | 5 ++++- doc/api/https.md | 3 +++ doc/api/repl.md | 1 + doc/api/tls.md | 5 +++++ tools/doc/type-parser.js | 7 +++++++ 6 files changed, 22 insertions(+), 1 deletion(-) diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index 252ded2ca41b2c..f0752a5892c362 100644 --- a/doc/api/async_hooks.md +++ b/doc/api/async_hooks.md @@ -704,6 +704,8 @@ alternative. #### asyncResource.emitDestroy() +* Returns: {AsyncResource} A reference to `asyncResource`. + Call all `destroy` hooks. This should only ever be called once. An error will be thrown if it is called more than once. This **must** be manually called. If the resource is left to be collected by the GC then the `destroy` hooks will diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 4dbdc101018a96..30e0a50f3fde27 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1555,6 +1555,7 @@ changes: * `generator` {number | string | Buffer | TypedArray | DataView} **Default:** `2` * `generatorEncoding` {string} +* Returns: {DiffieHellman} Creates a `DiffieHellman` key exchange object using the supplied `prime` and an optional specific `generator`. @@ -1578,6 +1579,7 @@ added: v0.5.0 * `primeLength` {number} * `generator` {number | string | Buffer | TypedArray | DataView} **Default:** `2` +* Returns: {DiffieHellman} Creates a `DiffieHellman` key exchange object and generates a prime of `primeLength` bits using an optional specific numeric `generator`. @@ -1588,6 +1590,7 @@ If `generator` is not specified, the value `2` is used. added: v0.11.14 --> * `curveName` {string} +* Returns: {ECDH} Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a predefined curve specified by the `curveName` string. Use @@ -1840,7 +1843,7 @@ console.log(curves); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...] added: v0.7.5 --> * `groupName` {string} -* Returns: {Object} +* Returns: {DiffieHellman} Creates a predefined `DiffieHellman` key exchange object. The supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in diff --git a/doc/api/https.md b/doc/api/https.md index e01606042ee557..f6af7d2f1a6931 100644 --- a/doc/api/https.md +++ b/doc/api/https.md @@ -28,6 +28,7 @@ This class is a subclass of `tls.Server` and emits events same as added: v0.1.90 --> * `callback` {Function} +* Returns: {https.Server} See [`server.close()`][`http.close()`] from the HTTP module for details. @@ -49,6 +50,7 @@ added: v0.11.2 --> * `msecs` {number} **Default:** `120000` (2 minutes) * `callback` {Function} +* Returns: {https.Server} See [`http.Server#setTimeout()`][]. @@ -75,6 +77,7 @@ added: v0.3.4 * `options` {Object} Accepts `options` from [`tls.createServer()`][], [`tls.createSecureContext()`][] and [`http.createServer()`][]. * `requestListener` {Function} A listener to be added to the `'request'` event. +* Returns: {https.Server} ```js // curl -k https://localhost:8000/ diff --git a/doc/api/repl.md b/doc/api/repl.md index d010265327e5fa..09fe9ebcbece61 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -499,6 +499,7 @@ changes: * `breakEvalOnSigint` - Stop evaluating the current piece of code when `SIGINT` is received, i.e. `Ctrl+C` is pressed. This cannot be used together with a custom `eval` function. **Default:** `false`. +* Returns: {repl.REPLServer} The `repl.start()` method creates and starts a [`repl.REPLServer`][] instance. diff --git a/doc/api/tls.md b/doc/api/tls.md index d6ead9060182c5..30dfb9c31e01fe 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -378,6 +378,7 @@ added: v0.3.2 * `callback` {Function} A listener callback that will be registered to listen for the server instance's `'close'` event. +* Returns: {tls.Server} The `server.close()` method stops the server from accepting new connections. @@ -911,6 +912,7 @@ changes: * ...: [`tls.createSecureContext()`][] options that are used if the `secureContext` option is missing, otherwise they are ignored. * `callback` {Function} +* Returns: {tls.TLSSocket} The `callback` function, if specified, will be added as a listener for the [`'secureConnect'`][] event. @@ -985,6 +987,7 @@ added: v0.11.3 * `path` {string} Default value for `options.path`. * `options` {Object} See [`tls.connect()`][]. * `callback` {Function} See [`tls.connect()`][]. +* Returns: {tls.TLSSocket} Same as [`tls.connect()`][] except that `path` can be provided as an argument instead of an option. @@ -1000,6 +1003,7 @@ added: v0.11.3 * `host` {string} Default value for `options.host`. * `options` {Object} See [`tls.connect()`][]. * `callback` {Function} See [`tls.connect()`][]. +* Returns: {tls.TLSSocket} Same as [`tls.connect()`][] except that `port` and `host` can be provided as arguments instead of options. @@ -1172,6 +1176,7 @@ changes: * ...: Any [`tls.createSecureContext()`][] option can be provided. For servers, the identity options (`pfx` or `key`/`cert`) are usually required. * `secureConnectionListener` {Function} +* Returns: {tls.Server} Creates a new [`tls.Server`][]. The `secureConnectionListener`, if provided, is automatically set as a listener for the [`'secureConnection'`][] event. diff --git a/tools/doc/type-parser.js b/tools/doc/type-parser.js index b57dc6957a9ae0..49d888e88b9900 100644 --- a/tools/doc/type-parser.js +++ b/tools/doc/type-parser.js @@ -36,6 +36,7 @@ const customTypesMap = { `${jsDocPrefix}Reference/Iteration_protocols#The_iterator_protocol`, 'AsyncHook': 'async_hooks.html#async_hooks_async_hooks_createhook_callbacks', + 'AsyncResource': 'async_hooks.html#async_hooks_class_asyncresource', 'Buffer': 'buffer.html#buffer_class_buffer', @@ -45,6 +46,8 @@ const customTypesMap = { 'Cipher': 'crypto.html#crypto_class_cipher', 'Decipher': 'crypto.html#crypto_class_decipher', + 'DiffieHellman': 'crypto.html#crypto_class_diffiehellman', + 'ECDH': 'crypto.html#crypto_class_ecdh', 'Hash': 'crypto.html#crypto_class_hash', 'Hmac': 'crypto.html#crypto_class_hmac', 'Sign': 'crypto.html#crypto_class_sign', @@ -83,6 +86,8 @@ const customTypesMap = { 'Http2Stream': 'http2.html#http2_class_http2stream', 'ServerHttp2Stream': 'http2.html#http2_class_serverhttp2stream', + 'https.Server': 'https.html#https_class_https_server', + 'module': 'modules.html#modules_the_module_object', 'Handle': 'net.html#net_server_listen_handle_backlog_callback', @@ -101,6 +106,8 @@ const customTypesMap = { 'readline.Interface': 'readline.html#readline_class_interface', + 'repl.REPLServer': 'repl.html#repl_class_replserver', + 'Stream': 'stream.html#stream_stream', 'stream.Duplex': 'stream.html#stream_class_stream_duplex', 'stream.Readable': 'stream.html#stream_class_stream_readable', From a9dcf6f0cef58d7d21205fc18302571f3d39d4e7 Mon Sep 17 00:00:00 2001 From: Jagannath Bhat Date: Tue, 30 Oct 2018 23:01:18 +0530 Subject: [PATCH 314/328] doc: improve BUILDING.md PR-URL: https://github.com/nodejs/node/pull/23976 Reviewed-By: Anna Henningsen Reviewed-By: Denys Otrishko Reviewed-By: Vse Mozhet Byt Reviewed-By: Richard Lau Reviewed-By: James M Snell Reviewed-By: Rich Trott --- BUILDING.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 4beba6ea81715e..efe39e656b383a 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -95,8 +95,8 @@ platforms in production. by Joyent. SmartOS images >= 16.4 are not supported because GCC 4.8 runtime libraries are not available in their pkgsrc repository -2: Tier 1 support for building on Windows is only on 64 bit - hosts. Support is experimental for 32 bit hosts. +2: Tier 1 support for building on Windows is only on 64-bit + hosts. Support is experimental for 32-bit hosts. 3: On Windows, running Node.js in Windows terminal emulators like `mintty` requires the usage of [winpty](https://github.com/rprichard/winpty) @@ -114,7 +114,7 @@ platforms in production. ### Supported toolchains -Depending on host platform, the selection of toolchains may vary. +Depending on the host platform, the selection of toolchains may vary. #### Unix @@ -126,11 +126,11 @@ Depending on host platform, the selection of toolchains may vary. #### Windows -* Visual Studio 2017 with the Windows 10 SDK on a 64 bit host. +* Visual Studio 2017 with the Windows 10 SDK on a 64-bit host. #### OpenSSL asm support -OpenSSL-1.1.0 requires the following asssembler version for use of asm +OpenSSL-1.1.0 requires the following assembler version for use of asm support on x86_64 and ia32. * gas (GNU assembler) version 2.23 or higher @@ -314,7 +314,7 @@ These core dumps are useful for debugging when provided with the corresponding original debug binary and system information. Reading the core dump requires `gdb` built on the same platform the core dump -was captured on (i.e. 64 bit `gdb` for `node` built on a 64 bit system, Linux +was captured on (i.e. 64-bit `gdb` for `node` built on a 64-bit system, Linux `gdb` for `node` built on Linux) otherwise you will get errors like `not in executable format: File format not recognized`. @@ -433,7 +433,7 @@ $ ./configure --without-intl $ pkg-config --modversion icu-i18n && ./configure --with-intl=system-icu ``` -If you are cross compiling, your `pkg-config` must be able to supply a path +If you are cross-compiling, your `pkg-config` must be able to supply a path that works for both your host and target environments. #### Build with a specific ICU: @@ -481,7 +481,7 @@ This version of Node.js does not support FIPS. ## Building Node.js with external core modules It is possible to specify one or more JavaScript text files to be bundled in -the binary as builtin modules when building Node.js. +the binary as built-in modules when building Node.js. ### Unix/macOS From 17c2ddd71d32944a726826245b76d82d851031e0 Mon Sep 17 00:00:00 2001 From: Jagannath Bhat Date: Tue, 30 Oct 2018 23:08:04 +0530 Subject: [PATCH 315/328] doc: improve COLLABORATOR_GUIDE PR-URL: https://github.com/nodejs/node/pull/23977 Reviewed-By: Denys Otrishko Reviewed-By: Vse Mozhet Byt Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat --- COLLABORATOR_GUIDE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/COLLABORATOR_GUIDE.md b/COLLABORATOR_GUIDE.md index 7cfc6388c549b5..fd26ea5f15d0db 100644 --- a/COLLABORATOR_GUIDE.md +++ b/COLLABORATOR_GUIDE.md @@ -497,7 +497,7 @@ This should be done where a pull request: Assign the `tsc-review` label or @-mention the `@nodejs/tsc` GitHub team if you want to elevate an issue to the [TSC][]. -Do not use the GitHub UI on the right hand side to assign to +Do not use the GitHub UI on the right-hand side to assign to `@nodejs/tsc` or request a review from `@nodejs/tsc`. The TSC should serve as the final arbiter where required. @@ -528,7 +528,7 @@ The TSC should serve as the final arbiter where required. you are unsure exactly how to format the commit messages, use the commit log as a reference. See [this commit][commit-example] as an example. -For PRs from first time contributors, be [welcoming](#welcoming-first-time-contributors). +For PRs from first-time contributors, be [welcoming](#welcoming-first-time-contributors). Also, verify that their git settings are to their liking. All commits should be self-contained, meaning every commit should pass all From b89297b618483392ca53d8fde82e10179df008a8 Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Tue, 30 Oct 2018 16:59:53 -0700 Subject: [PATCH 316/328] test: fix test-fs-watch-system-limit On some systems the default inotify limits might be too high for the test to actually fail. Detect and skip the test in such environments. PR-URL: https://github.com/nodejs/node/pull/23986 Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca --- test/sequential/test-fs-watch-system-limit.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/sequential/test-fs-watch-system-limit.js b/test/sequential/test-fs-watch-system-limit.js index e896cbf83b965a..8b9cb62ad0a007 100644 --- a/test/sequential/test-fs-watch-system-limit.js +++ b/test/sequential/test-fs-watch-system-limit.js @@ -2,6 +2,7 @@ const common = require('../common'); const assert = require('assert'); const child_process = require('child_process'); +const fs = require('fs'); const stream = require('stream'); if (!common.isLinux) @@ -9,6 +10,20 @@ if (!common.isLinux) if (!common.enoughTestCpu) common.skip('This test is resource-intensive'); +try { + // Ensure inotify limit is low enough for the test to actually exercise the + // limit with small enough resources. + const limit = Number( + fs.readFileSync('/proc/sys/fs/inotify/max_user_watches', 'utf8')); + if (limit > 16384) + common.skip('inotify limit is quite large'); +} catch (e) { + if (e.code === 'ENOENT') + common.skip('the inotify /proc subsystem does not exist'); + // Fail on other errors. + throw e; +} + const processes = []; const gatherStderr = new stream.PassThrough(); gatherStderr.setEncoding('utf8'); From d1ac8029891b964a527c73b1928f5cadfe3ad6ec Mon Sep 17 00:00:00 2001 From: Shobhit Chittora Date: Mon, 20 Aug 2018 21:32:31 +0530 Subject: [PATCH 317/328] child_process: handle undefined/null for fork() args PR-URL: https://github.com/nodejs/node/pull/22416 Fixes: https://github.com/nodejs/node/issues/20749 Reviewed-By: James M Snell Reviewed-By: Denys Otrishko Reviewed-By: Matheus Marchini --- lib/child_process.js | 5 +++ test/fixtures/child-process-echo-options.js | 1 + .../test-child-process-fork-options.js | 37 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 test/fixtures/child-process-echo-options.js create mode 100644 test/parallel/test-child-process-fork-options.js diff --git a/lib/child_process.js b/lib/child_process.js index bc86ab3797ad17..f08acd76c7953b 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -69,6 +69,11 @@ exports.fork = function fork(modulePath /* , args, options */) { args = arguments[pos++]; } + if (pos < arguments.length && + (arguments[pos] === undefined || arguments[pos] === null)) { + pos++; + } + if (pos < arguments.length && arguments[pos] != null) { if (typeof arguments[pos] !== 'object') { throw new ERR_INVALID_ARG_VALUE(`arguments[${pos}]`, arguments[pos]); diff --git a/test/fixtures/child-process-echo-options.js b/test/fixtures/child-process-echo-options.js new file mode 100644 index 00000000000000..04f3f8dcffe6a9 --- /dev/null +++ b/test/fixtures/child-process-echo-options.js @@ -0,0 +1 @@ +process.send({ env: process.env }); diff --git a/test/parallel/test-child-process-fork-options.js b/test/parallel/test-child-process-fork-options.js new file mode 100644 index 00000000000000..5efb9bdbb49735 --- /dev/null +++ b/test/parallel/test-child-process-fork-options.js @@ -0,0 +1,37 @@ +'use strict'; +const common = require('../common'); +const fixtures = require('../common/fixtures'); + +// This test ensures that fork should parse options +// correctly if args is undefined or null + +const assert = require('assert'); +const { fork } = require('child_process'); + +const expectedEnv = { foo: 'bar' }; + +{ + const cp = fork(fixtures.path('child-process-echo-options.js'), undefined, + { env: Object.assign({}, process.env, expectedEnv) }); + + cp.on('message', common.mustCall(({ env }) => { + assert.strictEqual(env.foo, expectedEnv.foo); + })); + + cp.on('exit', common.mustCall((code) => { + assert.strictEqual(code, 0); + })); +} + +{ + const cp = fork(fixtures.path('child-process-echo-options.js'), null, + { env: Object.assign({}, process.env, expectedEnv) }); + + cp.on('message', common.mustCall(({ env }) => { + assert.strictEqual(env.foo, expectedEnv.foo); + })); + + cp.on('exit', common.mustCall((code) => { + assert.strictEqual(code, 0); + })); +} From a15de4876a0a3c014c491086940bac579d88d805 Mon Sep 17 00:00:00 2001 From: mritunjaygoutam12 Date: Tue, 30 Oct 2018 12:59:02 +0530 Subject: [PATCH 318/328] test: add property for RangeError in test-buffer-copy PR-URL: https://github.com/nodejs/node/pull/23968 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig --- test/parallel/test-buffer-copy.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-buffer-copy.js b/test/parallel/test-buffer-copy.js index f3c351f09aead3..a53570fa2213cf 100644 --- a/test/parallel/test-buffer-copy.js +++ b/test/parallel/test-buffer-copy.js @@ -1,10 +1,17 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const b = Buffer.allocUnsafe(1024); const c = Buffer.allocUnsafe(512); + +const errorProperty = { + code: 'ERR_INDEX_OUT_OF_RANGE', + type: RangeError, + message: 'Index out of range' +}; + let cntr = 0; { @@ -107,9 +114,9 @@ bb.fill('hello crazy world'); b.copy(c, 0, 100, 10); // copy throws at negative sourceStart -assert.throws(function() { - Buffer.allocUnsafe(5).copy(Buffer.allocUnsafe(5), 0, -1); -}, RangeError); +common.expectsError( + () => Buffer.allocUnsafe(5).copy(Buffer.allocUnsafe(5), 0, -1), + errorProperty); { // check sourceEnd resets to targetEnd if former is greater than the latter @@ -122,7 +129,8 @@ assert.throws(function() { } // throw with negative sourceEnd -assert.throws(() => b.copy(c, 0, 0, -1), RangeError); +common.expectsError( + () => b.copy(c, 0, -1), errorProperty); // when sourceStart is greater than sourceEnd, zero copied assert.strictEqual(b.copy(c, 0, 100, 10), 0); From 31eff105e0ff9f57d4ac45017ed5fe2b79beea63 Mon Sep 17 00:00:00 2001 From: Esteban Sotillo Date: Mon, 29 Oct 2018 15:22:43 +0100 Subject: [PATCH 319/328] test: fix strictEqual arguments order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23956 Reviewed-By: Colin Ihrig Reviewed-By: Michaël Zasso Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Franziska Hinkelmann --- test/parallel/test-http2-write-empty-string.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http2-write-empty-string.js b/test/parallel/test-http2-write-empty-string.js index 6e6ce5254ddcfc..ea591176a47251 100644 --- a/test/parallel/test-http2-write-empty-string.js +++ b/test/parallel/test-http2-write-empty-string.js @@ -25,7 +25,7 @@ server.listen(0, common.mustCall(function() { let res = ''; req.on('response', common.mustCall(function(headers) { - assert.strictEqual(200, headers[':status']); + assert.strictEqual(headers[':status'], 200); })); req.on('data', (chunk) => { @@ -33,7 +33,7 @@ server.listen(0, common.mustCall(function() { }); req.on('end', common.mustCall(function() { - assert.strictEqual('1\n2\n3\n', res); + assert.strictEqual(res, '1\n2\n3\n'); client.close(); })); From 203c42002510c12234e6fc63c4cc79457b074d22 Mon Sep 17 00:00:00 2001 From: Jerome Covington Date: Sun, 28 Oct 2018 13:55:59 -0400 Subject: [PATCH 320/328] test: assert that invalidcmd throws error code Update invalidcmd test case in test-child-process-spawn-typeerror to assert on specific expected error code. PR-URL: https://github.com/nodejs/node/pull/23942 Reviewed-By: Refael Ackermann Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott --- test/parallel/test-child-process-spawn-typeerror.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-child-process-spawn-typeerror.js b/test/parallel/test-child-process-spawn-typeerror.js index 31a1867df945f7..82acaf8e088038 100644 --- a/test/parallel/test-child-process-spawn-typeerror.js +++ b/test/parallel/test-child-process-spawn-typeerror.js @@ -33,12 +33,11 @@ const invalidArgValueError = common.expectsError({ code: 'ERR_INVALID_ARG_VALUE', type: TypeError }, 14); const invalidArgTypeError = - common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 12); + common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 13); assert.throws(function() { - const child = spawn(invalidcmd, 'this is not an array'); - child.on('error', common.mustNotCall()); -}, TypeError); + spawn(invalidcmd, 'this is not an array'); +}, invalidArgTypeError); // Verify that valid argument combinations do not throw. spawn(cmd); From e973b5df74e72b4aefd819a7a6efbfcf48793770 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Tue, 30 Oct 2018 14:34:20 -0400 Subject: [PATCH 321/328] tools: update alternative docs versions Add `11.x` and mark `10.x` as `lts`. PR-URL: https://github.com/nodejs/node/pull/23980 Reviewed-By: Refael Ackermann Reviewed-By: Vse Mozhet Byt Reviewed-By: Trivikram Kamat Reviewed-By: Luigi Pinca --- tools/doc/html.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/doc/html.js b/tools/doc/html.js index fd74563dd7fc97..9c9c355574d4e5 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -404,7 +404,8 @@ function altDocs(filename, docCreated) { const [, docCreatedMajor, docCreatedMinor] = docCreated.map(Number); const host = 'https://nodejs.org'; const versions = [ - { num: '10.x' }, + { num: '11.x' }, + { num: '10.x', lts: true }, { num: '9.x' }, { num: '8.x', lts: true }, { num: '7.x' }, From 5c6d49b48660d4afbcfd9c53284d02d6ebdbc56a Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 30 Oct 2018 23:14:11 -0700 Subject: [PATCH 322/328] doc: revise CHANGELOG.md text Make the text shorter and clearer. PR-URL: https://github.com/nodejs/node/pull/23988 Reviewed-By: Trivikram Kamat Reviewed-By: Vse Mozhet Byt Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- CHANGELOG.md | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab99af5f92621a..1339239e62c4f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,5 @@ # Node.js Changelog - - -To make the changelog easier to both use and manage, it has been split into -multiple files organized according to significant major and minor Node.js -release lines. - Select a Node.js version below to view the changelog history: * [Node.js 10](doc/changelogs/CHANGELOG_V10.md) — **Long Term Support** @@ -117,10 +111,9 @@ release. ### Notes -* Release streams marked with `LTS` are currently covered by the - [Node.js Long Term Support plan](https://github.com/nodejs/Release). -* Release versions displayed in **bold** text represent the most - recent actively supported release. +* The [Node.js Long Term Support plan](https://github.com/nodejs/Release) covers + LTS releases. +* Release versions in **bold** text are the most recent supported releases. ---- ---- From 8f782fbe272d84f7219f6b7044dccad49d1060a3 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 30 Oct 2018 23:22:04 -0700 Subject: [PATCH 323/328] doc: simplify CODE_OF_CONDUCT.md PR-URL: https://github.com/nodejs/node/pull/23989 Reviewed-By: Refael Ackermann Reviewed-By: Richard Lau Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Vse Mozhet Byt Reviewed-By: Michael Dawson Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- CODE_OF_CONDUCT.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 5a935352a1f9f0..4c211405596cb4 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,8 +1,4 @@ # Code of Conduct -The Node.js Code of Conduct document has moved to -https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md. Please update -links to this document accordingly. - -The Node.js Moderation policy can be found at -https://github.com/nodejs/admin/blob/master/Moderation-Policy.md +* [Node.js Code of Conduct](https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md) +* [Node.js Moderation Policy](https://github.com/nodejs/admin/blob/master/Moderation-Policy.md) From 514b53760413d59943e7c6a8bdad9bc0a919687f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 30 Oct 2018 23:41:03 -0700 Subject: [PATCH 324/328] doc: revise COLLABORATOR_GUIDE.md Simplify text/content. PR-URL: https://github.com/nodejs/node/pull/23990 Reviewed-By: Ben Noordhuis Reviewed-By: Richard Lau Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig Reviewed-By: Vse Mozhet Byt Reviewed-By: Michael Dawson Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- COLLABORATOR_GUIDE.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/COLLABORATOR_GUIDE.md b/COLLABORATOR_GUIDE.md index fd26ea5f15d0db..7fa6fee197aabc 100644 --- a/COLLABORATOR_GUIDE.md +++ b/COLLABORATOR_GUIDE.md @@ -28,7 +28,7 @@ - [Using `git-node`](#using-git-node) - [Technical HOWTO](#technical-howto) - [Troubleshooting](#troubleshooting) - - [I Just Made a Mistake](#i-just-made-a-mistake) + - [I Made a Mistake](#i-made-a-mistake) - [Long Term Support](#long-term-support) - [What is LTS?](#what-is-lts) - [How does LTS work?](#how-does-lts-work) @@ -38,13 +38,10 @@ - [How is an LTS release cut?](#how-is-an-lts-release-cut) * [Who to CC in the issue tracker](#who-to-cc-in-the-issue-tracker) -This document contains information for Collaborators of the Node.js -project regarding managing the project's code, documentation, and issue tracker. - -Collaborators should be familiar with the guidelines for new -contributors in [CONTRIBUTING.md](./CONTRIBUTING.md) and also -understand the project governance model as outlined in -[GOVERNANCE.md](./GOVERNANCE.md). +This document explains how Collaborators manage the Node.js project. +Collaborators should understand the +[guidelines for new contributors](CONTRIBUTING.md) and the +[project governance model](GOVERNANCE.md). ## Issues and Pull Requests @@ -747,7 +744,7 @@ make -j4 test git push upstream master ``` -### I Just Made a Mistake +### I Made a Mistake * Ping a TSC member. * `#node-dev` on freenode From 435e7b467306c59e553d29ef148824a865517914 Mon Sep 17 00:00:00 2001 From: Jagannath Bhat Date: Tue, 30 Oct 2018 23:12:09 +0530 Subject: [PATCH 325/328] doc: address bits of proof reading work PR-URL: https://github.com/nodejs/node/pull/23978 Reviewed-By: Anna Henningsen Reviewed-By: Vse Mozhet Byt Reviewed-By: James M Snell Reviewed-By: Rich Trott --- GOVERNANCE.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GOVERNANCE.md b/GOVERNANCE.md index 40ef6e7bbe5fcb..da6706e87f0d8c 100644 --- a/GOVERNANCE.md +++ b/GOVERNANCE.md @@ -45,7 +45,7 @@ be accepted unless: * Discussions and/or additional changes result in no Collaborators objecting to the change. Previously-objecting Collaborators do not necessarily have to - sign-off on the change, but they should not be opposed to it. + sign off on the change, but they should not be opposed to it. * The change is escalated to the TSC and the TSC votes to approve the change. This should only happen if disagreements between Collaborators cannot be resolved through discussion. @@ -123,7 +123,7 @@ The meeting chair is responsible for ensuring that minutes are taken and that a pull request with the minutes is submitted after the meeting. Due to the challenges of scheduling a global meeting with participants in -several timezones, the TSC will seek to resolve as many agenda items as possible +several time zones, the TSC will seek to resolve as many agenda items as possible outside of meetings using [the TSC issue tracker](https://github.com/nodejs/TSC/issues). The process in the issue tracker is: @@ -196,7 +196,7 @@ completed within a month after the nomination is accepted. ## Consensus Seeking Process -The TSC follows a [Consensus Seeking][] decision making model as described by +The TSC follows a [Consensus Seeking][] decision-making model as described by the [TSC Charter][]. [collaborators-discussions]: https://github.com/orgs/nodejs/teams/collaborators/discussions From a66d8774ac3c22c3d06fb16e65418bd7a6d0b841 Mon Sep 17 00:00:00 2001 From: Ivan Filenko Date: Fri, 2 Nov 2018 00:15:48 +0300 Subject: [PATCH 326/328] doc: fix dublication in net.createServer() docs PR-URL: https://github.com/nodejs/node/pull/24026 Reviewed-By: Vse Mozhet Byt Reviewed-By: Luigi Pinca --- doc/api/net.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/api/net.md b/doc/api/net.md index eb48ab8d00c87f..a8cd321dca968d 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -886,6 +886,7 @@ added: v0.7.0 --> * `options` {Object} * `connectListener` {Function} + Alias to [`net.createConnection(options[, connectListener])`][`net.createConnection(options)`]. @@ -1028,10 +1029,6 @@ then returns the `net.Socket` that starts the connection. -* `options` {Object} -* `connectionListener` {Function} - -Creates a new TCP or [IPC][] server. * `options` {Object} * `allowHalfOpen` {boolean} Indicates whether half-opened TCP @@ -1042,6 +1039,8 @@ Creates a new TCP or [IPC][] server. [`'connection'`][] event. * Returns: {net.Server} +Creates a new TCP or [IPC][] server. + If `allowHalfOpen` is set to `true`, when the other end of the socket sends a FIN packet, the server will only send a FIN packet back when [`socket.end()`][] is explicitly called, until then the connection is From e66c09e459ef969a3d309c894b00b366e8032e1a Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Wed, 21 Nov 2018 10:51:56 -0500 Subject: [PATCH 327/328] deps: cherry-pick 2987946 from upstream V8 Original commit message: Stop manual unescaping of script source data when preprocessing logs. It appears that the fields are already being unescaped elsewhere, perhaps by the JSON writer. So if we unescape when adding the source filename and contents, unescaping will happen again later and plain backslashes will be interpreted as escape codes. Bug: v8:6240 Change-Id: Ic66b9017ae685d6dd12944ee8d254991e26fbd32 Reviewed-on: https://chromium-review.googlesource.com/1186625 Reviewed-by: Jaroslav Sevcik Commit-Queue: Bret Sepulveda Cr-Commit-Position: refs/heads/master@{#55401} Refs: https://github.com/v8/v8/commit/29879461ceb4bc9b84b0ec38e4dd192fbf884dc2 PR-URL: https://github.com/nodejs/node/pull/24555 Fixes: https://github.com/nodejs/node/issues/20891 Reviewed-By: Richard Lau Reviewed-By: Bartosz Sosnowski --- common.gypi | 2 +- deps/v8/tools/profile.js | 27 ++------------------------- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/common.gypi b/common.gypi index e73d215a982f72..a04c1df94b539f 100644 --- a/common.gypi +++ b/common.gypi @@ -30,7 +30,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.45', + 'v8_embedder_string': '-node.46', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/tools/profile.js b/deps/v8/tools/profile.js index cddadaaf53121a..74b4b3bf663f66 100644 --- a/deps/v8/tools/profile.js +++ b/deps/v8/tools/profile.js @@ -1002,33 +1002,10 @@ JsonProfile.prototype.addSourcePositions = function( }; }; -function unescapeString(s) { - s = s.split("\\"); - for (var i = 1; i < s.length; i++) { - if (s[i] === "") { - // Double backslash. - s[i] = "\\"; - } else if (i > 0 && s[i].startsWith("x")) { - // Escaped Ascii character. - s[i] = String.fromCharCode(parseInt(s[i].substring(1, 3), 16)) + - s[i].substring(3); - } else if (i > 0 && s[i].startsWith("u")) { - // Escaped unicode character. - s[i] = String.fromCharCode(parseInt(s[i].substring(1, 5), 16)) + - s[i].substring(5); - } else { - if (i > 0 && s[i - 1] !== "\\") { - printErr("Malformed source string"); - } - } - } - return s.join(""); -} - JsonProfile.prototype.addScriptSource = function(script, url, source) { this.scripts_[script] = { - name : unescapeString(url), - source : unescapeString(source) + name : url, + source : source }; }; From 4088d6e5420adff8abedc949457a991cbd087c66 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 27 Nov 2018 08:32:44 -0800 Subject: [PATCH 328/328] 2018-11-27, Version 10.13.1 'Dubnium' (LTS) Notable changes: * Coming Soon PR-URL: https://github.com/nodejs/node/pull/24675 --- CHANGELOG.md | 3 +- doc/changelogs/CHANGELOG_V10.md | 337 ++++++++++++++++++++++++++++++++ src/node_version.h | 4 +- 3 files changed, 341 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1339239e62c4f8..016970772e6feb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,8 @@ release.
-10.13.0
+10.13.1
+10.13.0
10.12.0
10.11.0
10.10.0
diff --git a/doc/changelogs/CHANGELOG_V10.md b/doc/changelogs/CHANGELOG_V10.md index 153f6eb46c9382..f46047f0cb2584 100644 --- a/doc/changelogs/CHANGELOG_V10.md +++ b/doc/changelogs/CHANGELOG_V10.md @@ -44,6 +44,343 @@ * [io.js](CHANGELOG_IOJS.md) * [Archive](CHANGELOG_ARCHIVE.md) + +## 2018-11-27, Version 10.13.1 'Dubnium' (LTS), @codebytere + +### Notable Changes + +Coming soon. + +### Commits + +* [[`8345a8227d`](https://github.com/nodejs/node/commit/8345a8227d)] - **async_hooks**: add missing async\_hooks destroys in AsyncReset (Bastian Krol) [#23272](https://github.com/nodejs/node/pull/23272) +* [[`9e92b8124d`](https://github.com/nodejs/node/commit/9e92b8124d)] - **benchmark**: fix bench-mkdirp to use recursive option (Klaus Meinhardt) [#23699](https://github.com/nodejs/node/pull/23699) +* [[`d13bb2c2eb`](https://github.com/nodejs/node/commit/d13bb2c2eb)] - **benchmark**: coerce PORT to number (Ali Ijaz Sheikh) [#23721](https://github.com/nodejs/node/pull/23721) +* [[`99d39f9cf0`](https://github.com/nodejs/node/commit/99d39f9cf0)] - **benchmark**: added a test benchmark for worker (Muzafar Umarov) [#23475](https://github.com/nodejs/node/pull/23475) +* [[`c39b910f6e`](https://github.com/nodejs/node/commit/c39b910f6e)] - **bootstrapper**: move internalBinding to NativeModule (Gus Caplan) [#23025](https://github.com/nodejs/node/pull/23025) +* [[`74f128a3cd`](https://github.com/nodejs/node/commit/74f128a3cd)] - **build**: make benchmark/napi all prereq order-only (Daniel Bevenius) [#23951](https://github.com/nodejs/node/pull/23951) +* [[`bd73da00f2`](https://github.com/nodejs/node/commit/bd73da00f2)] - **build**: add -Werror=undefined-inline to clang builds (Refael Ackermann) [#23961](https://github.com/nodejs/node/pull/23961) +* [[`51947a515d`](https://github.com/nodejs/node/commit/51947a515d)] - **build**: configure default v8\_optimized\_debug (Refael Ackermann) [#23704](https://github.com/nodejs/node/pull/23704) +* [[`aed45d7ce9`](https://github.com/nodejs/node/commit/aed45d7ce9)] - **build**: add lint-py which uses flake8 (cclauss) [#21952](https://github.com/nodejs/node/pull/21952) +* [[`9844188025`](https://github.com/nodejs/node/commit/9844188025)] - **build**: allow for overwriting of use\_openssl\_def (Shelley Vohr) [#23763](https://github.com/nodejs/node/pull/23763) +* [[`a5530159c1`](https://github.com/nodejs/node/commit/a5530159c1)] - **build**: fix coverage generation (Michael Dawson) [#23769](https://github.com/nodejs/node/pull/23769) +* [[`abd46ee1b5`](https://github.com/nodejs/node/commit/abd46ee1b5)] - **build**: fix `./configure --enable-d8` (Ben Noordhuis) [#23656](https://github.com/nodejs/node/pull/23656) +* [[`715768e1e1`](https://github.com/nodejs/node/commit/715768e1e1)] - **build**: add .DS\_store to .gitgnore (Marcos Frony) [#23554](https://github.com/nodejs/node/pull/23554) +* [[`8f58eed775`](https://github.com/nodejs/node/commit/8f58eed775)] - **build,meta**: switch to gcc-4.9 on travis (Refael Ackermann) [#23778](https://github.com/nodejs/node/pull/23778) +* [[`d1ac802989`](https://github.com/nodejs/node/commit/d1ac802989)] - **child_process**: handle undefined/null for fork() args (Shobhit Chittora) [#22416](https://github.com/nodejs/node/pull/22416) +* [[`d62d6666d4`](https://github.com/nodejs/node/commit/d62d6666d4)] - **crypto**: add SET\_INTEGER\_CONSANT macro (Daniel Bevenius) [#23687](https://github.com/nodejs/node/pull/23687) +* [[`cbc54d4f5d`](https://github.com/nodejs/node/commit/cbc54d4f5d)] - **crypto**: strip unwanted space from openssl version (Sam Roberts) [#23678](https://github.com/nodejs/node/pull/23678) +* [[`f216699ab4`](https://github.com/nodejs/node/commit/f216699ab4)] - **crypto**: remove DiffieHellman.initialised\_ (Tobias Nießen) [#23717](https://github.com/nodejs/node/pull/23717) +* [[`3ca41dce5c`](https://github.com/nodejs/node/commit/3ca41dce5c)] - **crypto**: simplify internal state handling (Tobias Nießen) [#23648](https://github.com/nodejs/node/pull/23648) +* [[`4ba897750d`](https://github.com/nodejs/node/commit/4ba897750d)] - **crypto**: simplify error handling in ECDH::New (Tobias Nießen) [#23647](https://github.com/nodejs/node/pull/23647) +* [[`86a5690e38`](https://github.com/nodejs/node/commit/86a5690e38)] - **crypto**: move field initialization to class (Diana Holland) [#23610](https://github.com/nodejs/node/pull/23610) +* [[`a3540914c9`](https://github.com/nodejs/node/commit/a3540914c9)] - **crypto**: fix length argument to snprintf() (Ben Noordhuis) [#23622](https://github.com/nodejs/node/pull/23622) +* [[`e66c09e459`](https://github.com/nodejs/node/commit/e66c09e459)] - **deps**: cherry-pick 2987946 from upstream V8 (Refael Ackermann) [#24555](https://github.com/nodejs/node/pull/24555) +* [[`b2fbefb037`](https://github.com/nodejs/node/commit/b2fbefb037)] - **deps**: icu: apply workaround patch (Steven R. Loomis) [#23764](https://github.com/nodejs/node/pull/23764) +* [[`20430ae487`](https://github.com/nodejs/node/commit/20430ae487)] - **deps**: V8: Add virtual dtor to avoid aix gcc error (Vasili Skurydzin) [#23695](https://github.com/nodejs/node/pull/23695) +* [[`d3fb599b61`](https://github.com/nodejs/node/commit/d3fb599b61)] - **deps**: cherry-pick 67b5499 from V8 upstream (Vasili Skurydzin) [#23695](https://github.com/nodejs/node/pull/23695) +* [[`f2d3bade81`](https://github.com/nodejs/node/commit/f2d3bade81)] - **deps**: cherry-pick d2e0166 from V8 upstream (Vasili Skurydzin) [#23695](https://github.com/nodejs/node/pull/23695) +* [[`a4d67c95b6`](https://github.com/nodejs/node/commit/a4d67c95b6)] - **deps**: cherry-pick a51f429 from V8 upstream (Vasili Skurydzin) [#23695](https://github.com/nodejs/node/pull/23695) +* [[`01544e1224`](https://github.com/nodejs/node/commit/01544e1224)] - **deps**: cherry-pick abab9fb from V8 upstream (Vasili Skurydzin) [#23695](https://github.com/nodejs/node/pull/23695) +* [[`d4c8d778e8`](https://github.com/nodejs/node/commit/d4c8d778e8)] - **deps**: cherry-pick d9e7832 from V8 upstream (Vasili Skurydzin) [#23695](https://github.com/nodejs/node/pull/23695) +* [[`1e9b4a2a09`](https://github.com/nodejs/node/commit/1e9b4a2a09)] - **deps**: backport 525b396195 from upstream V8 (Peter Marshall) [#23827](https://github.com/nodejs/node/pull/23827) +* [[`2290c315a2`](https://github.com/nodejs/node/commit/2290c315a2)] - **deps**: partially revert 'increase V8 deprecation levels' (Peter Marshall) [#24195](https://github.com/nodejs/node/pull/24195) +* [[`44279e03fc`](https://github.com/nodejs/node/commit/44279e03fc)] - **deps**: add missing ares\_android.h file (cjihrig) [#23682](https://github.com/nodejs/node/pull/23682) +* [[`67f5d3052d`](https://github.com/nodejs/node/commit/67f5d3052d)] - **deps,v8**: fix gypfile bug (Refael Ackermann) [#23704](https://github.com/nodejs/node/pull/23704) +* [[`b2252ea81d`](https://github.com/nodejs/node/commit/b2252ea81d)] - **dns**: fix inconsistent (hostname vs host) (Ulises Gascón) [#23572](https://github.com/nodejs/node/pull/23572) +* [[`a66d8774ac`](https://github.com/nodejs/node/commit/a66d8774ac)] - **doc**: fix dublication in net.createServer() docs (Ivan Filenko) [#24026](https://github.com/nodejs/node/pull/24026) +* [[`435e7b4673`](https://github.com/nodejs/node/commit/435e7b4673)] - **doc**: address bits of proof reading work (Jagannath Bhat) [#23978](https://github.com/nodejs/node/pull/23978) +* [[`514b537604`](https://github.com/nodejs/node/commit/514b537604)] - **doc**: revise COLLABORATOR\_GUIDE.md (Rich Trott) [#23990](https://github.com/nodejs/node/pull/23990) +* [[`8f782fbe27`](https://github.com/nodejs/node/commit/8f782fbe27)] - **doc**: simplify CODE\_OF\_CONDUCT.md (Rich Trott) [#23989](https://github.com/nodejs/node/pull/23989) +* [[`5c6d49b486`](https://github.com/nodejs/node/commit/5c6d49b486)] - **doc**: revise CHANGELOG.md text (Rich Trott) [#23988](https://github.com/nodejs/node/pull/23988) +* [[`17c2ddd71d`](https://github.com/nodejs/node/commit/17c2ddd71d)] - **doc**: improve COLLABORATOR\_GUIDE (Jagannath Bhat) [#23977](https://github.com/nodejs/node/pull/23977) +* [[`a9dcf6f0ce`](https://github.com/nodejs/node/commit/a9dcf6f0ce)] - **doc**: improve BUILDING.md (Jagannath Bhat) [#23976](https://github.com/nodejs/node/pull/23976) +* [[`a35e8f1666`](https://github.com/nodejs/node/commit/a35e8f1666)] - **doc**: add types and their corresponding return values (Ouyang Yadong) [#23998](https://github.com/nodejs/node/pull/23998) +* [[`4a52fc0fea`](https://github.com/nodejs/node/commit/4a52fc0fea)] - **doc**: add branding to style guide (Rich Trott) [#23967](https://github.com/nodejs/node/pull/23967) +* [[`803070b7f1`](https://github.com/nodejs/node/commit/803070b7f1)] - **doc**: use Node.js instead of Node (Rich Trott) [#23967](https://github.com/nodejs/node/pull/23967) +* [[`f6abca9d62`](https://github.com/nodejs/node/commit/f6abca9d62)] - **doc**: revise BUILDING.md (Rich Trott) [#23966](https://github.com/nodejs/node/pull/23966) +* [[`8180b0b5b3`](https://github.com/nodejs/node/commit/8180b0b5b3)] - **doc**: clarify fd behaviour with {read,write}File (Sakthipriyan Vairamani (thefourtheye)) [#23706](https://github.com/nodejs/node/pull/23706) +* [[`1c9ae77c40`](https://github.com/nodejs/node/commit/1c9ae77c40)] - **doc**: fix typographical issues (Denis McDonald) [#23970](https://github.com/nodejs/node/pull/23970) +* [[`d19a3d6ee3`](https://github.com/nodejs/node/commit/d19a3d6ee3)] - **doc**: document HPE\_HEADER\_OVERFLOW error (Sam Roberts) [#23963](https://github.com/nodejs/node/pull/23963) +* [[`3c46c03678`](https://github.com/nodejs/node/commit/3c46c03678)] - **doc**: add documentation for http.IncomingMessage$complete (James M Snell) [#23914](https://github.com/nodejs/node/pull/23914) +* [[`ddfb22fd96`](https://github.com/nodejs/node/commit/ddfb22fd96)] - **doc**: remove mailing list (Rich Trott) [#23932](https://github.com/nodejs/node/pull/23932) +* [[`5072fcb899`](https://github.com/nodejs/node/commit/5072fcb899)] - **doc**: remove notice of dashes in V8 options (Denys Otrishko) [#23903](https://github.com/nodejs/node/pull/23903) +* [[`839f026ded`](https://github.com/nodejs/node/commit/839f026ded)] - **doc**: rename README section for Release Keys (Rich Trott) [#23927](https://github.com/nodejs/node/pull/23927) +* [[`565f4ca950`](https://github.com/nodejs/node/commit/565f4ca950)] - **doc**: add note about ABI compatibility (Myles Borins) [#22237](https://github.com/nodejs/node/pull/22237) +* [[`64c683bcdc`](https://github.com/nodejs/node/commit/64c683bcdc)] - **doc**: add optional callback to socket.end() (Ajido) [#23937](https://github.com/nodejs/node/pull/23937) +* [[`c0649c83b3`](https://github.com/nodejs/node/commit/c0649c83b3)] - **doc**: make example more clarified in cluster.md (ZYSzys) [#23931](https://github.com/nodejs/node/pull/23931) +* [[`fa9d2861ed`](https://github.com/nodejs/node/commit/fa9d2861ed)] - **doc**: simplify valid security issue descriptions (Rich Trott) [#23881](https://github.com/nodejs/node/pull/23881) +* [[`28ee410c9d`](https://github.com/nodejs/node/commit/28ee410c9d)] - **doc**: simplify path.basename() on POSIX and Windows (ZYSzys) [#23864](https://github.com/nodejs/node/pull/23864) +* [[`09faedfcf5`](https://github.com/nodejs/node/commit/09faedfcf5)] - **doc**: document nullptr comparisons in style guide (Anna Henningsen) [#23805](https://github.com/nodejs/node/pull/23805) +* [[`9a09f8af90`](https://github.com/nodejs/node/commit/9a09f8af90)] - **doc**: remove problematic example from README (Rich Trott) [#23817](https://github.com/nodejs/node/pull/23817) +* [[`8a6086c682`](https://github.com/nodejs/node/commit/8a6086c682)] - **doc**: use Cookie in request.setHeader() examples (Luigi Pinca) [#23707](https://github.com/nodejs/node/pull/23707) +* [[`f5c68dc363`](https://github.com/nodejs/node/commit/f5c68dc363)] - **doc**: NODE\_EXTRA\_CA\_CERTS is ignored if setuid root (Ben Noordhuis) [#23770](https://github.com/nodejs/node/pull/23770) +* [[`e711e45191`](https://github.com/nodejs/node/commit/e711e45191)] - **doc**: add review suggestions to require() (erickwendel) [#23605](https://github.com/nodejs/node/pull/23605) +* [[`f1c2fb3ae2`](https://github.com/nodejs/node/commit/f1c2fb3ae2)] - **doc**: document and warn if the ICU version is too old (Steven R. Loomis) [#23766](https://github.com/nodejs/node/pull/23766) +* [[`c77d127dfe`](https://github.com/nodejs/node/commit/c77d127dfe)] - **doc**: move @phillipj to emeriti (Phillip Johnsen) [#23790](https://github.com/nodejs/node/pull/23790) +* [[`9982c09469`](https://github.com/nodejs/node/commit/9982c09469)] - **doc**: add note about removeListener order (James M Snell) [#23762](https://github.com/nodejs/node/pull/23762) +* [[`bd0e0d2105`](https://github.com/nodejs/node/commit/bd0e0d2105)] - **doc**: document ACL limitation for fs.access on Windows (James M Snell) [#23772](https://github.com/nodejs/node/pull/23772) +* [[`64f9a3c138`](https://github.com/nodejs/node/commit/64f9a3c138)] - **doc**: document that addMembership must be called once in a cluster (James M Snell) [#23746](https://github.com/nodejs/node/pull/23746) +* [[`30bcddcaeb`](https://github.com/nodejs/node/commit/30bcddcaeb)] - **doc**: add missing YAML labels (Vse Mozhet Byt) [#23810](https://github.com/nodejs/node/pull/23810) +* [[`f8bd7c0f02`](https://github.com/nodejs/node/commit/f8bd7c0f02)] - **doc**: remove reference to sslv3 in tls.md (James M Snell) [#23745](https://github.com/nodejs/node/pull/23745) +* [[`da65cb61e5`](https://github.com/nodejs/node/commit/da65cb61e5)] - **doc**: revise security-reporting example text (Rich Trott) [#23759](https://github.com/nodejs/node/pull/23759) +* [[`30b1a4a61f`](https://github.com/nodejs/node/commit/30b1a4a61f)] - **doc**: formalize non-const reference usage in C++ style guide (Anna Henningsen) [#23155](https://github.com/nodejs/node/pull/23155) +* [[`523db5f5a9`](https://github.com/nodejs/node/commit/523db5f5a9)] - **doc**: fix headings for CHANGELOG\_v10.md (Myles Borins) [#23973](https://github.com/nodejs/node/pull/23973) +* [[`4c9d993d8c`](https://github.com/nodejs/node/commit/4c9d993d8c)] - **doc**: add missing deprecation labels (James M Snell) [#23761](https://github.com/nodejs/node/pull/23761) +* [[`f318d163a5`](https://github.com/nodejs/node/commit/f318d163a5)] - **doc**: document use of buffer.swap16() for utf16be (James M Snell) [#23747](https://github.com/nodejs/node/pull/23747) +* [[`d862f1e894`](https://github.com/nodejs/node/commit/d862f1e894)] - **doc**: add Backport-PR-URL info in backport guide (Ali Ijaz Sheikh) [#23701](https://github.com/nodejs/node/pull/23701) +* [[`8cd83c50b8`](https://github.com/nodejs/node/commit/8cd83c50b8)] - **doc**: improve README.md (Rich Trott) [#23705](https://github.com/nodejs/node/pull/23705) +* [[`e856fa2155`](https://github.com/nodejs/node/commit/e856fa2155)] - **doc**: simplify security reporting text (Rich Trott) [#23686](https://github.com/nodejs/node/pull/23686) +* [[`3e4032a333`](https://github.com/nodejs/node/commit/3e4032a333)] - **doc**: cleanup and references in C++ guide (Refael Ackermann) [#23650](https://github.com/nodejs/node/pull/23650) +* [[`00c028fb1d`](https://github.com/nodejs/node/commit/00c028fb1d)] - **doc**: fix url example to match behavior (Сковорода Никита Андреевич) [#23359](https://github.com/nodejs/node/pull/23359) +* [[`272d4faadf`](https://github.com/nodejs/node/commit/272d4faadf)] - **doc**: use reserved domains for examples in url.md (Сковорода Никита Андреевич) [#23359](https://github.com/nodejs/node/pull/23359) +* [[`43d4977c96`](https://github.com/nodejs/node/commit/43d4977c96)] - **doc**: fix pr-url in repl.md (Сковорода Никита Андреевич) [#23359](https://github.com/nodejs/node/pull/23359) +* [[`5ee0d90b6e`](https://github.com/nodejs/node/commit/5ee0d90b6e)] - **doc**: wrap links in \<\> (Сковорода Никита Андреевич) [#23359](https://github.com/nodejs/node/pull/23359) +* [[`45fbcbb68d`](https://github.com/nodejs/node/commit/45fbcbb68d)] - **doc**: edit BUILDING.md (Rich Trott) [#23435](https://github.com/nodejs/node/pull/23435) +* [[`1266878cbe`](https://github.com/nodejs/node/commit/1266878cbe)] - **doc**: describe SNI host name format (Sam Roberts) [#23357](https://github.com/nodejs/node/pull/23357) +* [[`4e1a54f309`](https://github.com/nodejs/node/commit/4e1a54f309)] - **doc**: revise security-reporting text in README (Rich Trott) [#23407](https://github.com/nodejs/node/pull/23407) +* [[`39c59be38a`](https://github.com/nodejs/node/commit/39c59be38a)] - **doc**: rewrite consensus seeking in guide (Rich Trott) [#23349](https://github.com/nodejs/node/pull/23349) +* [[`f63bf3fe0e`](https://github.com/nodejs/node/commit/f63bf3fe0e)] - **doc**: edit for minor fixes to prcoess.md (Rich Trott) [#23347](https://github.com/nodejs/node/pull/23347) +* [[`6603592ab4`](https://github.com/nodejs/node/commit/6603592ab4)] - **doc**: remove personal pronoun from worker\_threads (Rich Trott) [#23347](https://github.com/nodejs/node/pull/23347) +* [[`ab90013836`](https://github.com/nodejs/node/commit/ab90013836)] - **doc**: remove personal pronoun from domain.md (Rich Trott) [#23347](https://github.com/nodejs/node/pull/23347) +* [[`1e119eb6ae`](https://github.com/nodejs/node/commit/1e119eb6ae)] - **doc**: remove style instruction that is not followed (Rich Trott) [#23346](https://github.com/nodejs/node/pull/23346) +* [[`6196884390`](https://github.com/nodejs/node/commit/6196884390)] - **doc**: add WebAssembly to globals (Steven) [#23339](https://github.com/nodejs/node/pull/23339) +* [[`26f4221fc0`](https://github.com/nodejs/node/commit/26f4221fc0)] - **doc,meta**: assign PR semantics (Refael Ackermann) [#23292](https://github.com/nodejs/node/pull/23292) +* [[`b7d6c1ae96`](https://github.com/nodejs/node/commit/b7d6c1ae96)] - **doc,meta**: refresh wording in colab guide (Refael Ackermann) [#23292](https://github.com/nodejs/node/pull/23292) +* [[`2f51e49570`](https://github.com/nodejs/node/commit/2f51e49570)] - **doc,meta**: add references to outside C++ guides (Refael Ackermann) [#23317](https://github.com/nodejs/node/pull/23317) +* [[`d4f0366a7d`](https://github.com/nodejs/node/commit/d4f0366a7d)] - **http**: reduce duplicated code for cleaning parser (Weijia Wang) [#23351](https://github.com/nodejs/node/pull/23351) +* [[`9f4be5d1cb`](https://github.com/nodejs/node/commit/9f4be5d1cb)] - **http2**: make Http2Settings constructors delegate (Daniel Bevenius) [#23326](https://github.com/nodejs/node/pull/23326) +* [[`7374c0c5e1`](https://github.com/nodejs/node/commit/7374c0c5e1)] - **lib**: fix code cache generation (Joyee Cheung) [#23855](https://github.com/nodejs/node/pull/23855) +* [[`dd82014f60`](https://github.com/nodejs/node/commit/dd82014f60)] - **lib**: remove useless cwd in posix.resolve (ZYSzys) [#23902](https://github.com/nodejs/node/pull/23902) +* [[`c601fdef12`](https://github.com/nodejs/node/commit/c601fdef12)] - **lib**: migrate from process.binding('config') to getOptions() (Vladimir Ilic) [#23588](https://github.com/nodejs/node/pull/23588) +* [[`9b89e9c250`](https://github.com/nodejs/node/commit/9b89e9c250)] - **lib**: migrate process.binding to internalBinding (surreal8) [#23517](https://github.com/nodejs/node/pull/23517) +* [[`100ed74216`](https://github.com/nodejs/node/commit/100ed74216)] - **lib**: migrate process.binding to getOptions (Randy Wressell) [#23522](https://github.com/nodejs/node/pull/23522) +* [[`6eea5dc6e8`](https://github.com/nodejs/node/commit/6eea5dc6e8)] - **lib**: migrate process.binding('config') to getOptions() (Jonny Kalambay) [#23526](https://github.com/nodejs/node/pull/23526) +* [[`5a0b9faab8`](https://github.com/nodejs/node/commit/5a0b9faab8)] - **lib**: removed unused variable (Long Nguyen) [#23497](https://github.com/nodejs/node/pull/23497) +* [[`c634698d5c`](https://github.com/nodejs/node/commit/c634698d5c)] - **lib**: switch to internalBinding for cjs loader (Steven Scott) [#23492](https://github.com/nodejs/node/pull/23492) +* [[`26f356f7ab`](https://github.com/nodejs/node/commit/26f356f7ab)] - **lib**: migrate from process.binding to internalBinding (Andres Monge) [#23586](https://github.com/nodejs/node/pull/23586) +* [[`6acc89172f`](https://github.com/nodejs/node/commit/6acc89172f)] - **lib**: migrate to getOptions in loaders.js (David Xue) [#23455](https://github.com/nodejs/node/pull/23455) +* [[`00698cc4e5`](https://github.com/nodejs/node/commit/00698cc4e5)] - **lib**: remove an unused variable (Claire Liu) [#23482](https://github.com/nodejs/node/pull/23482) +* [[`63988f6cfd`](https://github.com/nodejs/node/commit/63988f6cfd)] - **lib**: remove unused 'e' from catch (Matt Holmes) [#23458](https://github.com/nodejs/node/pull/23458) +* [[`8016d35ea3`](https://github.com/nodejs/node/commit/8016d35ea3)] - **lib**: http server, friendly error messages (Sagi Tsofan) [#22995](https://github.com/nodejs/node/pull/22995) +* [[`8ec2c51bc9`](https://github.com/nodejs/node/commit/8ec2c51bc9)] - **meta**: clarify fast-track approval (James M Snell) [#23744](https://github.com/nodejs/node/pull/23744) +* [[`4f8e4f065c`](https://github.com/nodejs/node/commit/4f8e4f065c)] - **module**: removed unused variable (Martin Omander) [#23624](https://github.com/nodejs/node/pull/23624) +* [[`9b951601e2`](https://github.com/nodejs/node/commit/9b951601e2)] - **n-api**: make per-`Context`-ness of `napi\_env` explicit (Anna Henningsen) [#23689](https://github.com/nodejs/node/pull/23689) +* [[`ac73050fc8`](https://github.com/nodejs/node/commit/ac73050fc8)] - **os**: fix memory leak in `userInfo()` (Anna Henningsen) [#23893](https://github.com/nodejs/node/pull/23893) +* [[`5e1b9c3c91`](https://github.com/nodejs/node/commit/5e1b9c3c91)] - **readline**: assert without the use of event listener (Lian Li) [#23472](https://github.com/nodejs/node/pull/23472) +* [[`d1c0827294`](https://github.com/nodejs/node/commit/d1c0827294)] - **repl**: migrate from process.binding('config') to getOptions() (Jose Bucio) [#23684](https://github.com/nodejs/node/pull/23684) +* [[`9dfc13efa0`](https://github.com/nodejs/node/commit/9dfc13efa0)] - **repl**: remove unused variable from try catch (mmisiarek) [#23452](https://github.com/nodejs/node/pull/23452) +* [[`18060f2d12`](https://github.com/nodejs/node/commit/18060f2d12)] - **repl**: remove unused variable e from try catch (Khalid Adil) [#23449](https://github.com/nodejs/node/pull/23449) +* [[`d25e94b795`](https://github.com/nodejs/node/commit/d25e94b795)] - **src**: fix fully-static & large-pages combination (Suresh Srinivas) [#23964](https://github.com/nodejs/node/pull/23964) +* [[`592f5bd49c`](https://github.com/nodejs/node/commit/592f5bd49c)] - **src**: use "constants" string instead of creating new one (Ouyang Yadong) [#23894](https://github.com/nodejs/node/pull/23894) +* [[`98649dc17f`](https://github.com/nodejs/node/commit/98649dc17f)] - **src**: reduce duplication in tcp\_wrap Connect (Daniel Bevenius) [#23753](https://github.com/nodejs/node/pull/23753) +* [[`d316f64e9e`](https://github.com/nodejs/node/commit/d316f64e9e)] - **src**: refactor deprecated v8::String::NewFromTwoByte call (Romain Lanz) [#23803](https://github.com/nodejs/node/pull/23803) +* [[`2e3e68aac1`](https://github.com/nodejs/node/commit/2e3e68aac1)] - **src**: refactor deprecated v8::Function::Call call (Romain Lanz) [#23804](https://github.com/nodejs/node/pull/23804) +* [[`9a7554a85b`](https://github.com/nodejs/node/commit/9a7554a85b)] - **src**: fix CreatePlatform header param mismatch (Shelley Vohr) [#23947](https://github.com/nodejs/node/pull/23947) +* [[`de2340dccd`](https://github.com/nodejs/node/commit/de2340dccd)] - **src**: trace\_event: secondary storage for metadata (Ali Ijaz Sheikh) [#20900](https://github.com/nodejs/node/pull/20900) +* [[`d1102f81dc`](https://github.com/nodejs/node/commit/d1102f81dc)] - **src**: initial large page (2M) support (Suresh Srinivas) [#22079](https://github.com/nodejs/node/pull/22079) +* [[`850b54f4fd`](https://github.com/nodejs/node/commit/850b54f4fd)] - **src**: changed stdio\_pipes\_ to std::vector (Steven Auger) [#23615](https://github.com/nodejs/node/pull/23615) +* [[`f5cadf6c12`](https://github.com/nodejs/node/commit/f5cadf6c12)] - **src**: update v8::Object::GetPropertyNames() usage (cjihrig) [#23660](https://github.com/nodejs/node/pull/23660) +* [[`ea9c44d6f8`](https://github.com/nodejs/node/commit/ea9c44d6f8)] - **src**: remove OCB support ifdef OPENSSL\_NO\_OCB (Shelley Vohr) [#23635](https://github.com/nodejs/node/pull/23635) +* [[`dd91c1d20c`](https://github.com/nodejs/node/commit/dd91c1d20c)] - **src**: change macro to fn (Gino Notto) [#23603](https://github.com/nodejs/node/pull/23603) +* [[`db44a1a5a8`](https://github.com/nodejs/node/commit/db44a1a5a8)] - **src**: add default initializer in tls\_wrap (Richard Hoehn) [#23567](https://github.com/nodejs/node/pull/23567) +* [[`b55fed075c`](https://github.com/nodejs/node/commit/b55fed075c)] - **src**: use MallocedBuffer abstraction for buffers (Cody Hazelwood) [#23543](https://github.com/nodejs/node/pull/23543) +* [[`90cbeae6d9`](https://github.com/nodejs/node/commit/90cbeae6d9)] - **src**: use default initializers over settings fields on the constructor (Andrew J D McCann) [#23532](https://github.com/nodejs/node/pull/23532) +* [[`fa7d0ce486`](https://github.com/nodejs/node/commit/fa7d0ce486)] - **src**: remove unused UVHandle methods (MarianneDr) [#23535](https://github.com/nodejs/node/pull/23535) +* [[`25d7c0213c`](https://github.com/nodejs/node/commit/25d7c0213c)] - **src**: ready background workers before bootstrap (Ali Ijaz Sheikh) [#23233](https://github.com/nodejs/node/pull/23233) +* [[`264d1298b7`](https://github.com/nodejs/node/commit/264d1298b7)] - **src**: move default assignment of async\_id\_ in async\_wrap.h (David Corona) [#23495](https://github.com/nodejs/node/pull/23495) +* [[`8cd41aa742`](https://github.com/nodejs/node/commit/8cd41aa742)] - **src**: fix bug in MallocedBuffer constructor (Tobias Nießen) [#23434](https://github.com/nodejs/node/pull/23434) +* [[`8e198f0494`](https://github.com/nodejs/node/commit/8e198f0494)] - **src**: improve SSL version extraction logic (Gireesh Punathil) [#23050](https://github.com/nodejs/node/pull/23050) +* [[`cdb6da9478`](https://github.com/nodejs/node/commit/cdb6da9478)] - **src**: revert removal of SecureContext `\_external` getter (Vitaly Dyatlov) [#21711](https://github.com/nodejs/node/pull/21711) +* [[`2564abfc99`](https://github.com/nodejs/node/commit/2564abfc99)] - **src**: remove unused limits header from util-inl.h (Daniel Bevenius) [#23353](https://github.com/nodejs/node/pull/23353) +* [[`168885f9c6`](https://github.com/nodejs/node/commit/168885f9c6)] - **src**: replace NO\_RETURN with \[\[noreturn\]\] (Refael Ackermann) [#23337](https://github.com/nodejs/node/pull/23337) +* [[`0b39975cd4`](https://github.com/nodejs/node/commit/0b39975cd4)] - **src**: fix usage of deprecated v8::Date::New (Michaël Zasso) [#23288](https://github.com/nodejs/node/pull/23288) +* [[`c32cf17907`](https://github.com/nodejs/node/commit/c32cf17907)] - **src,win**: informative stack traces (Refael Ackermann) [#23822](https://github.com/nodejs/node/pull/23822) +* [[`1484eeb456`](https://github.com/nodejs/node/commit/1484eeb456)] - **stream**: do not error async iterators on destroy(null) (Matteo Collina) [#23901](https://github.com/nodejs/node/pull/23901) +* [[`5ea25c2a97`](https://github.com/nodejs/node/commit/5ea25c2a97)] - **stream**: ended streams should resolve the async iteration (Matteo Collina) [#23901](https://github.com/nodejs/node/pull/23901) +* [[`dbd37ab256`](https://github.com/nodejs/node/commit/dbd37ab256)] - **stream**: async iteration should work with destroyed stream (Matteo Collina) [#23785](https://github.com/nodejs/node/pull/23785) +* [[`203c420025`](https://github.com/nodejs/node/commit/203c420025)] - **test**: assert that invalidcmd throws error code (Jerome Covington) [#23942](https://github.com/nodejs/node/pull/23942) +* [[`31eff105e0`](https://github.com/nodejs/node/commit/31eff105e0)] - **test**: fix strictEqual arguments order (Esteban Sotillo) [#23956](https://github.com/nodejs/node/pull/23956) +* [[`a15de4876a`](https://github.com/nodejs/node/commit/a15de4876a)] - **test**: add property for RangeError in test-buffer-copy (mritunjaygoutam12) [#23968](https://github.com/nodejs/node/pull/23968) +* [[`b89297b618`](https://github.com/nodejs/node/commit/b89297b618)] - **test**: fix test-fs-watch-system-limit (Ali Ijaz Sheikh) [#23986](https://github.com/nodejs/node/pull/23986) +* [[`ff59c1c97e`](https://github.com/nodejs/node/commit/ff59c1c97e)] - **test**: run code cache test by default and test generator (Joyee Cheung) [#23855](https://github.com/nodejs/node/pull/23855) +* [[`5fb583240e`](https://github.com/nodejs/node/commit/5fb583240e)] - **test**: fix regression when compiled with FIPS (Adam Majer) [#23871](https://github.com/nodejs/node/pull/23871) +* [[`1c6820b9e1`](https://github.com/nodejs/node/commit/1c6820b9e1)] - **test**: fix strictEqual() argument order (Loic) [#23829](https://github.com/nodejs/node/pull/23829) +* [[`f30f11bd5d`](https://github.com/nodejs/node/commit/f30f11bd5d)] - **test**: verify `performance.timerify()` works w/ non-Node Contexts (Anna Henningsen) [#23784](https://github.com/nodejs/node/pull/23784) +* [[`9e9bb85b6c`](https://github.com/nodejs/node/commit/9e9bb85b6c)] - **test**: add test-benchmark-napi (Emily Marigold Klassen) [#23585](https://github.com/nodejs/node/pull/23585) +* [[`60f1a5aae8`](https://github.com/nodejs/node/commit/60f1a5aae8)] - **test**: increase coverage of internal/stream/end-of-stream (Tyler Vann-Campbell) [#23751](https://github.com/nodejs/node/pull/23751) +* [[`01c1ee6730`](https://github.com/nodejs/node/commit/01c1ee6730)] - **test**: fix strictEqual() arguments order (Nolan Rigo) [#23800](https://github.com/nodejs/node/pull/23800) +* [[`79be83dde9`](https://github.com/nodejs/node/commit/79be83dde9)] - **test**: fix invalid modulesLength for DSA keygen (Adam Majer) [#23732](https://github.com/nodejs/node/pull/23732) +* [[`cdf89339e4`](https://github.com/nodejs/node/commit/cdf89339e4)] - **test**: fix test-require-symlink on Windows (Bartosz Sosnowski) [#23691](https://github.com/nodejs/node/pull/23691) +* [[`fd12699f7d`](https://github.com/nodejs/node/commit/fd12699f7d)] - **test**: fix strictEqual() argument order (Romain Lanz) [#23768](https://github.com/nodejs/node/pull/23768) +* [[`6ee9273e9e`](https://github.com/nodejs/node/commit/6ee9273e9e)] - **test**: fix strictEqual() arguments order (Thomas GENTILHOMME) [#23771](https://github.com/nodejs/node/pull/23771) +* [[`4116788f76`](https://github.com/nodejs/node/commit/4116788f76)] - **test**: fix assertion arguments order (Elian Gutierrez) [#23787](https://github.com/nodejs/node/pull/23787) +* [[`4673848025`](https://github.com/nodejs/node/commit/4673848025)] - **test**: add blocks and comments to fs-promises tests (Ian Sutherland) [#23627](https://github.com/nodejs/node/pull/23627) +* [[`9ad176ab50`](https://github.com/nodejs/node/commit/9ad176ab50)] - **test**: add a test for `tls.Socket` with `allowHalfOpen` (Ouyang Yadong) [#23866](https://github.com/nodejs/node/pull/23866) +* [[`874371df89`](https://github.com/nodejs/node/commit/874371df89)] - **test**: increase coverage for readfile with withFileTypes (christian-bromann) [#23557](https://github.com/nodejs/node/pull/23557) +* [[`ce03acac71`](https://github.com/nodejs/node/commit/ce03acac71)] - **test**: skip failing tests for osx mojave (jn99) [#23550](https://github.com/nodejs/node/pull/23550) +* [[`8552bb4065`](https://github.com/nodejs/node/commit/8552bb4065)] - **test**: enable trace-events tests for workers (Richard Lau) [#23698](https://github.com/nodejs/node/pull/23698) +* [[`8e7a12f450`](https://github.com/nodejs/node/commit/8e7a12f450)] - **test**: improve test coverage for fs module (garrik.leonardo@gmail.com) [#23601](https://github.com/nodejs/node/pull/23601) +* [[`0b7aa275a9`](https://github.com/nodejs/node/commit/0b7aa275a9)] - **test**: fix argument order in assertion (Illescas, Ricardo) [#23581](https://github.com/nodejs/node/pull/23581) +* [[`4e019f05bc`](https://github.com/nodejs/node/commit/4e019f05bc)] - **test**: reversed params in assert.strictEqual() (Dusan Radovanovic) [#23591](https://github.com/nodejs/node/pull/23591) +* [[`ff9232db35`](https://github.com/nodejs/node/commit/ff9232db35)] - **test**: correct order of args in buffer compare (James Irwin) [#23521](https://github.com/nodejs/node/pull/23521) +* [[`11eabba0fb`](https://github.com/nodejs/node/commit/11eabba0fb)] - **test**: check codes of thrown errors (Nancy Truong) [#23519](https://github.com/nodejs/node/pull/23519) +* [[`79d7733c59`](https://github.com/nodejs/node/commit/79d7733c59)] - **test**: fix strictEqual arguments order (Jonathan Samines) [#23486](https://github.com/nodejs/node/pull/23486) +* [[`642b1686be`](https://github.com/nodejs/node/commit/642b1686be)] - **test**: add test coverage for fs.truncate (christian-bromann) [#23620](https://github.com/nodejs/node/pull/23620) +* [[`f82611a27e`](https://github.com/nodejs/node/commit/f82611a27e)] - **test**: use smaller keys for a faster keygen test (Sam Roberts) [#23430](https://github.com/nodejs/node/pull/23430) +* [[`e8ca33025a`](https://github.com/nodejs/node/commit/e8ca33025a)] - **test**: increased code coverage for slowCases (Jared Haines) [#23592](https://github.com/nodejs/node/pull/23592) +* [[`002c35cd42`](https://github.com/nodejs/node/commit/002c35cd42)] - **test**: assertions arguments match docs (Amanuel Ghebreweldi) [#23594](https://github.com/nodejs/node/pull/23594) +* [[`3d703042c1`](https://github.com/nodejs/node/commit/3d703042c1)] - **test**: fix assert.strictEqual() argument order (Derek) [#23598](https://github.com/nodejs/node/pull/23598) +* [[`25b166a5cb`](https://github.com/nodejs/node/commit/25b166a5cb)] - **test**: fix assert parameter order in test-https-localaddress.js (Ian Sutherland) [#23599](https://github.com/nodejs/node/pull/23599) +* [[`e98d8f427c`](https://github.com/nodejs/node/commit/e98d8f427c)] - **test**: change order of assert.strictEquals arguments (Chuck Theobald) [#23600](https://github.com/nodejs/node/pull/23600) +* [[`8d39cf6323`](https://github.com/nodejs/node/commit/8d39cf6323)] - **test**: fix assert equal order of arguments (David Jiang) [#23602](https://github.com/nodejs/node/pull/23602) +* [[`af6528ab85`](https://github.com/nodejs/node/commit/af6528ab85)] - **test**: fix order of assert args in client response domain test (Emily Kolar) [#23604](https://github.com/nodejs/node/pull/23604) +* [[`984fac4a53`](https://github.com/nodejs/node/commit/984fac4a53)] - **test**: re-order strictEqual paramater calls (Paul Tichonczuk) [#23607](https://github.com/nodejs/node/pull/23607) +* [[`37e1101a0f`](https://github.com/nodejs/node/commit/37e1101a0f)] - **test**: fix assertions args order (Milton Sosa) [#23608](https://github.com/nodejs/node/pull/23608) +* [[`0c9a866541`](https://github.com/nodejs/node/commit/0c9a866541)] - **test**: fix parameters in test-repl.js (Israel Ortiz) [#23609](https://github.com/nodejs/node/pull/23609) +* [[`d370c5e8c1`](https://github.com/nodejs/node/commit/d370c5e8c1)] - **test**: reverse arguments in assert.strictEqual (Vsevolod Geraskin) [#23613](https://github.com/nodejs/node/pull/23613) +* [[`4d9059b1df`](https://github.com/nodejs/node/commit/4d9059b1df)] - **test**: update assertion parameter order (Sean Healy) [#23614](https://github.com/nodejs/node/pull/23614) +* [[`6d80af3112`](https://github.com/nodejs/node/commit/6d80af3112)] - **test**: fix backward assertion arguments (Stéphane Vasseur) [#23616](https://github.com/nodejs/node/pull/23616) +* [[`202d38c484`](https://github.com/nodejs/node/commit/202d38c484)] - **test**: reversed 1st and 2nd arguments for assert.strictEqual() (vchoubey08) [#23617](https://github.com/nodejs/node/pull/23617) +* [[`9fb6cf01f9`](https://github.com/nodejs/node/commit/9fb6cf01f9)] - **test**: correct assertion argument order (Jeff Marvin) [#23618](https://github.com/nodejs/node/pull/23618) +* [[`64268d005a`](https://github.com/nodejs/node/commit/64268d005a)] - **test**: fix assertion order (erickwendel) [#23626](https://github.com/nodejs/node/pull/23626) +* [[`4874ce2106`](https://github.com/nodejs/node/commit/4874ce2106)] - **test**: updated assert test values to doc standards (keeysnc) [#23593](https://github.com/nodejs/node/pull/23593) +* [[`57b4fc16c3`](https://github.com/nodejs/node/commit/57b4fc16c3)] - **test**: switch order of assertion arguments (Mel) [#23563](https://github.com/nodejs/node/pull/23563) +* [[`e0b4dab586`](https://github.com/nodejs/node/commit/e0b4dab586)] - **test**: fix assert.strictEqual() argument order (Savio Resende) [#23564](https://github.com/nodejs/node/pull/23564) +* [[`0fcbe2c8ba`](https://github.com/nodejs/node/commit/0fcbe2c8ba)] - **test**: fix parameter order of assertions (Pete Lombardo) [#23565](https://github.com/nodejs/node/pull/23565) +* [[`7c7f8068be`](https://github.com/nodejs/node/commit/7c7f8068be)] - **test**: fix assert value order (Ethan Weber) [#23566](https://github.com/nodejs/node/pull/23566) +* [[`ef2777db40`](https://github.com/nodejs/node/commit/ef2777db40)] - **test**: fix strictEqual order for timers test (Saleh Abdel Motaal) [#23568](https://github.com/nodejs/node/pull/23568) +* [[`2cb4789a68`](https://github.com/nodejs/node/commit/2cb4789a68)] - **test**: corrected assertion arguments order (francois) [#23569](https://github.com/nodejs/node/pull/23569) +* [[`110606daa5`](https://github.com/nodejs/node/commit/110606daa5)] - **test**: fix strictEqual input parameters order (AlixAng) [#23570](https://github.com/nodejs/node/pull/23570) +* [[`bcf24e7a4d`](https://github.com/nodejs/node/commit/bcf24e7a4d)] - **test**: fix order of arguments passed to strictEqual (Joe Shindelar) [#23571](https://github.com/nodejs/node/pull/23571) +* [[`2a3ba01b08`](https://github.com/nodejs/node/commit/2a3ba01b08)] - **test**: fix arguments ordering for assertions to match the docs (Liran Tal) [#23575](https://github.com/nodejs/node/pull/23575) +* [[`b68ee2238f`](https://github.com/nodejs/node/commit/b68ee2238f)] - **test**: fixed strictEqual arguments order (Ruy Adorno) [#23576](https://github.com/nodejs/node/pull/23576) +* [[`2ea96196fe`](https://github.com/nodejs/node/commit/2ea96196fe)] - **test**: add crypto.scrypt test case with different encoding (Yitong) [#23578](https://github.com/nodejs/node/pull/23578) +* [[`6ec5b4a84d`](https://github.com/nodejs/node/commit/6ec5b4a84d)] - **test**: reversed actual and expected values for .strictEqual() (Salman Shakeel) [#23579](https://github.com/nodejs/node/pull/23579) +* [[`70ba0f97a0`](https://github.com/nodejs/node/commit/70ba0f97a0)] - **test**: increased code coverage for proxySessionHandler (Justin Lee) [#23583](https://github.com/nodejs/node/pull/23583) +* [[`18ea8cfbdd`](https://github.com/nodejs/node/commit/18ea8cfbdd)] - **test**: fix assertion arguments order (seantcoyote) [#23584](https://github.com/nodejs/node/pull/23584) +* [[`c9ba20aeca`](https://github.com/nodejs/node/commit/c9ba20aeca)] - **test**: fix assert.strictEqual() parameter order in test-path-maklong.js (blakehall) [#23587](https://github.com/nodejs/node/pull/23587) +* [[`8b38c2e1c0`](https://github.com/nodejs/node/commit/8b38c2e1c0)] - **test**: fix argument order in assertions (Illescas, Ricardo) [#23589](https://github.com/nodejs/node/pull/23589) +* [[`9439e3e973`](https://github.com/nodejs/node/commit/9439e3e973)] - **test**: fix order of parameters to assert.strictEqual (Jason Nutter) [#23590](https://github.com/nodejs/node/pull/23590) +* [[`760b5715d9`](https://github.com/nodejs/node/commit/760b5715d9)] - **test**: removed unused variable in fs-watch-file-slow (Maki Toda) [#23548](https://github.com/nodejs/node/pull/23548) +* [[`04769c4573`](https://github.com/nodejs/node/commit/04769c4573)] - **test**: update strictEqual arguments order (Clinton Pahl) [#23552](https://github.com/nodejs/node/pull/23552) +* [[`042e97428f`](https://github.com/nodejs/node/commit/042e97428f)] - **test**: removed unused error variable in try catch (Murtaza H) [#23553](https://github.com/nodejs/node/pull/23553) +* [[`fc2f104efe`](https://github.com/nodejs/node/commit/fc2f104efe)] - **test**: reverse order of args in reconnect-error assert (Jackelin Herrera) [#23555](https://github.com/nodejs/node/pull/23555) +* [[`abf19da10f`](https://github.com/nodejs/node/commit/abf19da10f)] - **test**: added async-hook benchmark (peter) [#23556](https://github.com/nodejs/node/pull/23556) +* [[`0569bfeab1`](https://github.com/nodejs/node/commit/0569bfeab1)] - **test**: fix order of assert arguments in vm-new-script-this-context (Victor Poriazov) [#23558](https://github.com/nodejs/node/pull/23558) +* [[`fc05ca56e7`](https://github.com/nodejs/node/commit/fc05ca56e7)] - **test**: modernize test-crypto-domain (naris93) [#23559](https://github.com/nodejs/node/pull/23559) +* [[`77f2100469`](https://github.com/nodejs/node/commit/77f2100469)] - **test**: fix strictEqual assertion order on readline tests (Joe Grosspietsch) [#23561](https://github.com/nodejs/node/pull/23561) +* [[`8d583a7b40`](https://github.com/nodejs/node/commit/8d583a7b40)] - **test**: switch strictEqual parameters - actual first before expected (Chris Bautista) [#23537](https://github.com/nodejs/node/pull/23537) +* [[`a410488994`](https://github.com/nodejs/node/commit/a410488994)] - **test**: assert.strictEqual parameters ordered correctly (Justin denBroeder) [#23538](https://github.com/nodejs/node/pull/23538) +* [[`5bf919e818`](https://github.com/nodejs/node/commit/5bf919e818)] - **test**: fix assert.strictEqual() arguments order (Ivan Lukasevych) [#23539](https://github.com/nodejs/node/pull/23539) +* [[`21a46ef123`](https://github.com/nodejs/node/commit/21a46ef123)] - **test**: reverse the order of assertion statement arguments in pingpong test (Allan Zheng) [#23540](https://github.com/nodejs/node/pull/23540) +* [[`e5500f823d`](https://github.com/nodejs/node/commit/e5500f823d)] - **test**: added test for generateKeyPair (David Xue) [#23541](https://github.com/nodejs/node/pull/23541) +* [[`adc89e30cf`](https://github.com/nodejs/node/commit/adc89e30cf)] - **test**: swap expected and actual arguments in assert.strictEqual() (Erin Bush) [#23542](https://github.com/nodejs/node/pull/23542) +* [[`6e5a5ff654`](https://github.com/nodejs/node/commit/6e5a5ff654)] - **test**: fix assertions argument order (KelvinLawHF1) [#23544](https://github.com/nodejs/node/pull/23544) +* [[`02b0688003`](https://github.com/nodejs/node/commit/02b0688003)] - **test**: fix assertion argument order (Carl Richmond) [#23545](https://github.com/nodejs/node/pull/23545) +* [[`4c27cf0a41`](https://github.com/nodejs/node/commit/4c27cf0a41)] - **test**: refactor callback functions to arrow functions (Sean Healy) [#23546](https://github.com/nodejs/node/pull/23546) +* [[`1e8ce06732`](https://github.com/nodejs/node/commit/1e8ce06732)] - **test**: updating assertion and expect order in test-tls-client-verify.js (Eli Itah) [#23547](https://github.com/nodejs/node/pull/23547) +* [[`efdbc2d846`](https://github.com/nodejs/node/commit/efdbc2d846)] - **test**: use correct argument order for assert.strictEqual() (Oktavianus Ludiro) [#23527](https://github.com/nodejs/node/pull/23527) +* [[`5d7c15bc6d`](https://github.com/nodejs/node/commit/5d7c15bc6d)] - **test**: corrected the order of arguments in assert.strictEqual() (Diana Lee) [#23528](https://github.com/nodejs/node/pull/23528) +* [[`8e69895603`](https://github.com/nodejs/node/commit/8e69895603)] - **test**: fix assert.strictEqual() argument order (ssamuels0916) [#23529](https://github.com/nodejs/node/pull/23529) +* [[`93af93ae9f`](https://github.com/nodejs/node/commit/93af93ae9f)] - **test**: fix strictEqual assertion argument in test-tls-ecdh-auto (jaxyz) [#23530](https://github.com/nodejs/node/pull/23530) +* [[`0895576d10`](https://github.com/nodejs/node/commit/0895576d10)] - **test**: correct labelling of asserts errors (nofwayy) [#23531](https://github.com/nodejs/node/pull/23531) +* [[`474b401794`](https://github.com/nodejs/node/commit/474b401794)] - **test**: reorder asserts arguments (Marcos Frony) [#23534](https://github.com/nodejs/node/pull/23534) +* [[`de8ffbad80`](https://github.com/nodejs/node/commit/de8ffbad80)] - **test**: updating assertion on test so it fits the new method signature (garrik.leonardo@gmail.com) [#23536](https://github.com/nodejs/node/pull/23536) +* [[`7cd9161ea4`](https://github.com/nodejs/node/commit/7cd9161ea4)] - **test**: refactor functions to es6 (Michael Chen) [#23510](https://github.com/nodejs/node/pull/23510) +* [[`22a4ec1d70`](https://github.com/nodejs/node/commit/22a4ec1d70)] - **test**: replaced functions with arrow functions (edgarzapeka) [#23511](https://github.com/nodejs/node/pull/23511) +* [[`a0985281ee`](https://github.com/nodejs/node/commit/a0985281ee)] - **test**: corret assertion arg order in test-regress-GH-892.js (Elvis-Philip N) [#23513](https://github.com/nodejs/node/pull/23513) +* [[`608d5fa8f0`](https://github.com/nodejs/node/commit/608d5fa8f0)] - **test**: fix test-dgram-pingpong assertion arg order (David Ward) [#23514](https://github.com/nodejs/node/pull/23514) +* [[`0d6d6f63cd`](https://github.com/nodejs/node/commit/0d6d6f63cd)] - **test**: fix assert.strictEqual() argument order (Ben Schaaf) [#23515](https://github.com/nodejs/node/pull/23515) +* [[`161cbbb97a`](https://github.com/nodejs/node/commit/161cbbb97a)] - **test**: fix assert.strictEqual arg order in test-tls-ecdh-multiple.js (Takdeer Sodhan) [#23516](https://github.com/nodejs/node/pull/23516) +* [[`ad83caf7fa`](https://github.com/nodejs/node/commit/ad83caf7fa)] - **test**: use the correct parameter order on assert.strictEqual() (Tyler Vann-Campbell) [#23520](https://github.com/nodejs/node/pull/23520) +* [[`b7d4404e87`](https://github.com/nodejs/node/commit/b7d4404e87)] - **test**: fix assert order in test-vm-context (Lee Gray) [#23523](https://github.com/nodejs/node/pull/23523) +* [[`9dc11e3354`](https://github.com/nodejs/node/commit/9dc11e3354)] - **test**: switch arguments of assert() (Arne Schramm) [#23524](https://github.com/nodejs/node/pull/23524) +* [[`4f116a7009`](https://github.com/nodejs/node/commit/4f116a7009)] - **test**: swap assert argument order in test-vm-create-and-run-in-context.js (Pascal Lambert) [#23525](https://github.com/nodejs/node/pull/23525) +* [[`ff5345cf5c`](https://github.com/nodejs/node/commit/ff5345cf5c)] - **test**: fix order of assert.strictEqual() args to actual, expected (Joshua Belcher) [#23501](https://github.com/nodejs/node/pull/23501) +* [[`f5fd8a2168`](https://github.com/nodejs/node/commit/f5fd8a2168)] - **test**: fixed incorrect variable order in assert.strictEqual() (Daniyal Mokhammad) [#23502](https://github.com/nodejs/node/pull/23502) +* [[`66c82adb0e`](https://github.com/nodejs/node/commit/66c82adb0e)] - **test**: properly order test assertion variables (David Scott) [#23503](https://github.com/nodejs/node/pull/23503) +* [[`28b6129a7b`](https://github.com/nodejs/node/commit/28b6129a7b)] - **test**: modernize test-child-process-flush-stdio (Viacheslav Liakhov) [#23504](https://github.com/nodejs/node/pull/23504) +* [[`23d6932c61`](https://github.com/nodejs/node/commit/23d6932c61)] - **test**: put expected assert value in correct place (Jean-Francois Arseneau) [#23505](https://github.com/nodejs/node/pull/23505) +* [[`d590aa858d`](https://github.com/nodejs/node/commit/d590aa858d)] - **test**: fix argument order in assertions (Illescas, Ricardo) [#23506](https://github.com/nodejs/node/pull/23506) +* [[`119fc3abdd`](https://github.com/nodejs/node/commit/119fc3abdd)] - **test**: fix assertions args order in test/parallel/test-fs-chmod.js (Milton Sosa) [#23507](https://github.com/nodejs/node/pull/23507) +* [[`6f590be539`](https://github.com/nodejs/node/commit/6f590be539)] - **test**: fix strictEqual assertion arguments (Alejandro Oviedo Garcia) [#23508](https://github.com/nodejs/node/pull/23508) +* [[`d156d093ff`](https://github.com/nodejs/node/commit/d156d093ff)] - **test**: fix ordering of assertion values (Andrew MacCuaig) +* [[`fd5290e68c`](https://github.com/nodejs/node/commit/fd5290e68c)] - **test**: update function keywords to fat arrows (Robert Monks) [#23493](https://github.com/nodejs/node/pull/23493) +* [[`e9f17464a8`](https://github.com/nodejs/node/commit/e9f17464a8)] - **test**: reversed arguments in strictqual to reflect documentation (scabhi) [#23494](https://github.com/nodejs/node/pull/23494) +* [[`f1fb2bea5e`](https://github.com/nodejs/node/commit/f1fb2bea5e)] - **test**: modernized test to use arrow functions (Greg Goforth) [#23496](https://github.com/nodejs/node/pull/23496) +* [[`627e3ad241`](https://github.com/nodejs/node/commit/627e3ad241)] - **test**: use arrow functions in test-exception-handler (Jenna Zeigen) [#23498](https://github.com/nodejs/node/pull/23498) +* [[`13afb68e8a`](https://github.com/nodejs/node/commit/13afb68e8a)] - **test**: fix argument order in asserts (@CAYdenberg) [#23499](https://github.com/nodejs/node/pull/23499) +* [[`e0a3e238bb`](https://github.com/nodejs/node/commit/e0a3e238bb)] - **test**: modernizing test-dgram-listen-after-bind with arrow functions (chrisforrette) [#23500](https://github.com/nodejs/node/pull/23500) +* [[`01d599cffe`](https://github.com/nodejs/node/commit/01d599cffe)] - **test**: fix strictEqual argument order (Felix Schlenkrich) [#23490](https://github.com/nodejs/node/pull/23490) +* [[`58aaa61363`](https://github.com/nodejs/node/commit/58aaa61363)] - **test**: rename process.argv\[0\] to process.execPath, rename ex to err (Kayla Altepeter) [#23488](https://github.com/nodejs/node/pull/23488) +* [[`7e56801ddd`](https://github.com/nodejs/node/commit/7e56801ddd)] - **test**: fix assertion argument order (Carl Richmond) [#23489](https://github.com/nodejs/node/pull/23489) +* [[`16175c1b89`](https://github.com/nodejs/node/commit/16175c1b89)] - **test**: fix assertion order test-tls-server-verify (Carolina Pinzon) [#23549](https://github.com/nodejs/node/pull/23549) +* [[`ac0a03a278`](https://github.com/nodejs/node/commit/ac0a03a278)] - **test**: fix assertion order (Chris Nguyen) [#23533](https://github.com/nodejs/node/pull/23533) +* [[`bf20cf8ba2`](https://github.com/nodejs/node/commit/bf20cf8ba2)] - **test**: change to arrow functions in send-bad-arguments (Anna Zhao) [#23483](https://github.com/nodejs/node/pull/23483) +* [[`b29b836d04`](https://github.com/nodejs/node/commit/b29b836d04)] - **test**: removed unused variable (Michal Hynek) [#23481](https://github.com/nodejs/node/pull/23481) +* [[`b083715671`](https://github.com/nodejs/node/commit/b083715671)] - **test**: fix argument order for assert.strictEqual (Stacey) [#23485](https://github.com/nodejs/node/pull/23485) +* [[`d6dabc79c5`](https://github.com/nodejs/node/commit/d6dabc79c5)] - **test**: fix assert.strictEqual params order (Rock Hu) [#23480](https://github.com/nodejs/node/pull/23480) +* [[`87367eccbb`](https://github.com/nodejs/node/commit/87367eccbb)] - **test**: removed mustCallAsync from common and added inside testcase (Quinn Langille) [#23467](https://github.com/nodejs/node/pull/23467) +* [[`46f944f700`](https://github.com/nodejs/node/commit/46f944f700)] - **test**: remove unused "e" from catch in http2 test (Stephen Heitman) [#23476](https://github.com/nodejs/node/pull/23476) +* [[`adff51fc11`](https://github.com/nodejs/node/commit/adff51fc11)] - **test**: remove unused variable from catch (Paige Kato) [#23477](https://github.com/nodejs/node/pull/23477) +* [[`d7609a7a07`](https://github.com/nodejs/node/commit/d7609a7a07)] - **test**: inline common module boolean (ashleysimpson) [#23479](https://github.com/nodejs/node/pull/23479) +* [[`c73a6a05d1`](https://github.com/nodejs/node/commit/c73a6a05d1)] - **test**: swap the order arguments are passed to assert (Dylson Valente Neto) [#23580](https://github.com/nodejs/node/pull/23580) +* [[`da17d97d82`](https://github.com/nodejs/node/commit/da17d97d82)] - **test**: flip assertion arguments for make-callback/test.js (Tim Cheung) [#23470](https://github.com/nodejs/node/pull/23470) +* [[`b436ccc3b2`](https://github.com/nodejs/node/commit/b436ccc3b2)] - **test**: replace function with arrow function (Yitong) [#23474](https://github.com/nodejs/node/pull/23474) +* [[`a6787a7f2b`](https://github.com/nodejs/node/commit/a6787a7f2b)] - **test**: swap actual and expected in assertions (Yitong) [#23474](https://github.com/nodejs/node/pull/23474) +* [[`148d4e4b8e`](https://github.com/nodejs/node/commit/148d4e4b8e)] - **test**: correctly order assertion arguments (Emily Kolar) [#23473](https://github.com/nodejs/node/pull/23473) +* [[`75d4bf2348`](https://github.com/nodejs/node/commit/75d4bf2348)] - **test**: mark `test-http2-session-timeout` as flake on ARM (Refael Ackermann) [#23639](https://github.com/nodejs/node/pull/23639) +* [[`65ea85f4a3`](https://github.com/nodejs/node/commit/65ea85f4a3)] - **test**: update test-cluster-worker-events to use arrow functions (S. Everett Abbott) [#23469](https://github.com/nodejs/node/pull/23469) +* [[`1a39a56f6c`](https://github.com/nodejs/node/commit/1a39a56f6c)] - **test**: correct order for assert.strictEqual for inspector-helper test (Maggie Nolan) [#23468](https://github.com/nodejs/node/pull/23468) +* [[`f8e7112b91`](https://github.com/nodejs/node/commit/f8e7112b91)] - **test**: fix incorrect expectation order (Amie) [#23466](https://github.com/nodejs/node/pull/23466) +* [[`77ef4970f6`](https://github.com/nodejs/node/commit/77ef4970f6)] - **test**: remove unused e variable in catch statement (Denny Scott) [#23465](https://github.com/nodejs/node/pull/23465) +* [[`ed9f8acc79`](https://github.com/nodejs/node/commit/ed9f8acc79)] - **test**: correct assert test (Richard Markins) [#23463](https://github.com/nodejs/node/pull/23463) +* [[`eac6ba94f1`](https://github.com/nodejs/node/commit/eac6ba94f1)] - **test**: fix incorrect ordering of args in assert.strictEqual() (mdaum) [#23461](https://github.com/nodejs/node/pull/23461) +* [[`8766d27598`](https://github.com/nodejs/node/commit/8766d27598)] - **test**: swap assert.strictEqual args to actual, expected (epeden) [#23459](https://github.com/nodejs/node/pull/23459) +* [[`2f920ce497`](https://github.com/nodejs/node/commit/2f920ce497)] - **test**: fix assert.strictEqual argument order (andy addington) [#23457](https://github.com/nodejs/node/pull/23457) +* [[`58a5b76a58`](https://github.com/nodejs/node/commit/58a5b76a58)] - **test**: strictEqual correct order for http-information-processing test (Ivan Sieder) [#23456](https://github.com/nodejs/node/pull/23456) +* [[`e5a2fa2dcb`](https://github.com/nodejs/node/commit/e5a2fa2dcb)] - **test**: fix http local address test assertion (Danu Widatama) [#23451](https://github.com/nodejs/node/pull/23451) +* [[`8a9b2b6168`](https://github.com/nodejs/node/commit/8a9b2b6168)] - **test**: fix order of values in test assertions (Jared Haines) [#23450](https://github.com/nodejs/node/pull/23450) +* [[`31a96600fb`](https://github.com/nodejs/node/commit/31a96600fb)] - **test**: fix `assert.strictEqual` arguments in test/parallel/test-c-ares.js (jungkumseok) [#23448](https://github.com/nodejs/node/pull/23448) +* [[`b3e43a6393`](https://github.com/nodejs/node/commit/b3e43a6393)] - **test**: fix parameter order passed to strictEqual (Shannon) [#23577](https://github.com/nodejs/node/pull/23577) +* [[`484dccbd44`](https://github.com/nodejs/node/commit/484dccbd44)] - **test**: adding test coverage for SourceTextModule.evaluate (Kayla Altepeter) [#23595](https://github.com/nodejs/node/pull/23595) +* [[`2d3292225f`](https://github.com/nodejs/node/commit/2d3292225f)] - **test**: rename common.ddCommand() (Rich Trott) [#23411](https://github.com/nodejs/node/pull/23411) +* [[`2f84a189c7`](https://github.com/nodejs/node/commit/2f84a189c7)] - **test**: refactor common.ddCommand() (Rich Trott) [#23411](https://github.com/nodejs/node/pull/23411) +* [[`65ae332098`](https://github.com/nodejs/node/commit/65ae332098)] - **test**: move some gc tests back to parallel/, unmark flaky (Anna Henningsen) [#23356](https://github.com/nodejs/node/pull/23356) +* [[`21c3822719`](https://github.com/nodejs/node/commit/21c3822719)] - **test**: improve test-gc-http-client-onerror (Denys Otrishko) [#23196](https://github.com/nodejs/node/pull/23196) +* [[`693a50e494`](https://github.com/nodejs/node/commit/693a50e494)] - **test**: improve test-gc-http-client-connaborted (Denys Otrishko) [#23193](https://github.com/nodejs/node/pull/23193) +* [[`6fa033c5b1`](https://github.com/nodejs/node/commit/6fa033c5b1)] - **test**: fix assert.strictEqual argument order (et4891) [#23518](https://github.com/nodejs/node/pull/23518) +* [[`305c1e15fd`](https://github.com/nodejs/node/commit/305c1e15fd)] - **test**: fixing assertion value order (Joe Sepi) [#23574](https://github.com/nodejs/node/pull/23574) +* [[`3024e3abed`](https://github.com/nodejs/node/commit/3024e3abed)] - **test**: separate WPT console test from other test (Rich Trott) [#23340](https://github.com/nodejs/node/pull/23340) +* [[`75a849aadf`](https://github.com/nodejs/node/commit/75a849aadf)] - **test**: add WPT console-label-conversion test (Rich Trott) [#23340](https://github.com/nodejs/node/pull/23340) +* [[`a1fef95500`](https://github.com/nodejs/node/commit/a1fef95500)] - **test**: rename WPT console test (Rich Trott) [#23340](https://github.com/nodejs/node/pull/23340) +* [[`27dd4dee0d`](https://github.com/nodejs/node/commit/27dd4dee0d)] - **test**: add logging to test-worker-memory (Rich Trott) [#23418](https://github.com/nodejs/node/pull/23418) +* [[`e865418138`](https://github.com/nodejs/node/commit/e865418138)] - **test**: add test for a vm indexed property (conectado) [#23318](https://github.com/nodejs/node/pull/23318) +* [[`dad3d7468b`](https://github.com/nodejs/node/commit/dad3d7468b)] - **test**: fix compiler warning in doc/api/addons.md (Daniel Bevenius) [#23323](https://github.com/nodejs/node/pull/23323) +* [[`9aec3e6863`](https://github.com/nodejs/node/commit/9aec3e6863)] - **tls**: close StreamWrap and its stream correctly (Ouyang Yadong) [#23654](https://github.com/nodejs/node/pull/23654) +* [[`81dc2419f4`](https://github.com/nodejs/node/commit/81dc2419f4)] - **tls**: prevent multiple connection errors (cjihrig) [#23636](https://github.com/nodejs/node/pull/23636) +* [[`1afd2071ee`](https://github.com/nodejs/node/commit/1afd2071ee)] - **tls**: make StreamWrap work correctly in "drain" callback (Ouyang Yadong) [#23294](https://github.com/nodejs/node/pull/23294) +* [[`e973b5df74`](https://github.com/nodejs/node/commit/e973b5df74)] - **tools**: update alternative docs versions (Richard Lau) [#23980](https://github.com/nodejs/node/pull/23980) +* [[`3249a57f2b`](https://github.com/nodejs/node/commit/3249a57f2b)] - **tools**: update ESLint to 5.8.0 (cjihrig) [#23904](https://github.com/nodejs/node/pull/23904) +* [[`703f40a035`](https://github.com/nodejs/node/commit/703f40a035)] - **tools**: clarify commit message linting (Rich Trott) [#23742](https://github.com/nodejs/node/pull/23742) +* [[`28599e896a`](https://github.com/nodejs/node/commit/28599e896a)] - **tools**: do not lint commit message if var undefined (Rich Trott) [#23725](https://github.com/nodejs/node/pull/23725) +* [[`ac83a14714`](https://github.com/nodejs/node/commit/ac83a14714)] - **tools**: prefer filter to remove empty strings (Sakthipriyan Vairamani (thefourtheye)) [#23727](https://github.com/nodejs/node/pull/23727) +* [[`6af2f9f946`](https://github.com/nodejs/node/commit/6af2f9f946)] - **tools**: update ESLint to 5.7.0 (cjihrig) [#23629](https://github.com/nodejs/node/pull/23629) +* [[`47eb9484ab`](https://github.com/nodejs/node/commit/47eb9484ab)] - **tools**: update node-lint-md-cli-rollup (Rich Trott) [#23358](https://github.com/nodejs/node/pull/23358) +* [[`43446671e1`](https://github.com/nodejs/node/commit/43446671e1)] - **tools,icu**: read full ICU version info from file (Refael Ackermann) [#23269](https://github.com/nodejs/node/pull/23269) +* [[`9e03393ff2`](https://github.com/nodejs/node/commit/9e03393ff2)] - **tools,test**: add list of slow tests (Refael Ackermann) [#23251](https://github.com/nodejs/node/pull/23251) +* [[`148ae30fd7`](https://github.com/nodejs/node/commit/148ae30fd7)] - **tools,test**: cleanup and dedup code (Refael Ackermann) [#23251](https://github.com/nodejs/node/pull/23251) +* [[`808f37c97f`](https://github.com/nodejs/node/commit/808f37c97f)] - **trace_events**: destroy platform before tracing (Ali Ijaz Sheikh) [#22938](https://github.com/nodejs/node/pull/22938) +* [[`3df083c5fb`](https://github.com/nodejs/node/commit/3df083c5fb)] - **util**: handle null prototype on inspect (Anto Aravinth) [#22331](https://github.com/nodejs/node/pull/22331) +* [[`ffadcc1b22`](https://github.com/nodejs/node/commit/ffadcc1b22)] - **vm**: pass parsing\_context to ScriptCompiler::CompileFunctionInContext (Dara Hayes) [#23206](https://github.com/nodejs/node/pull/23206) +* [[`257a5e9c38`](https://github.com/nodejs/node/commit/257a5e9c38)] - **win**: add prompt to tools installation script (João Reis) [#23987](https://github.com/nodejs/node/pull/23987) +* [[`e9a291582d`](https://github.com/nodejs/node/commit/e9a291582d)] - **win**: clarify Boxstarter behavior on install tools (Rob Reynolds) [#23987](https://github.com/nodejs/node/pull/23987) +* [[`469473d550`](https://github.com/nodejs/node/commit/469473d550)] - ***Revert*** "**win,msi**: install tools for native modules" (Refael Ackermann) [#24344](https://github.com/nodejs/node/pull/24344) +* [[`1c17aa1e43`](https://github.com/nodejs/node/commit/1c17aa1e43)] - **worker**: remove delete MessagePort.prototype.hasRef (James Traver) [#23471](https://github.com/nodejs/node/pull/23471) +* [[`179d4c7269`](https://github.com/nodejs/node/commit/179d4c7269)] - **zlib**: refactor zlib internals (Anna Henningsen) [#23360](https://github.com/nodejs/node/pull/23360) +* [[`7fd1b4dd4b`](https://github.com/nodejs/node/commit/7fd1b4dd4b)] - **zlib**: generate error code names in C++ (Anna Henningsen) [#23413](https://github.com/nodejs/node/pull/23413) + ## 2018-10-30, Version 10.13.0 'Dubnium' (LTS), @MylesBorins diff --git a/src/node_version.h b/src/node_version.h index b8cf9aa6d0408a..fbf5dd0b35eda8 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -24,12 +24,12 @@ #define NODE_MAJOR_VERSION 10 #define NODE_MINOR_VERSION 13 -#define NODE_PATCH_VERSION 1 +#define NODE_PATCH_VERSION 2 #define NODE_VERSION_IS_LTS 1 #define NODE_VERSION_LTS_CODENAME "Dubnium" -#define NODE_VERSION_IS_RELEASE 0 +#define NODE_VERSION_IS_RELEASE 1 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)