diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
deleted file mode 100644
index 375a6aa8a24eff..00000000000000
--- a/.github/ISSUE_TEMPLATE.md
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-* **Version**:
-* **Platform**:
-* **Subsystem**:
-
-
diff --git a/.github/ISSUE_TEMPLATE/1-bug-report.md b/.github/ISSUE_TEMPLATE/1-bug-report.md
index 69b9bf63250f7b..2a2e94d411fe2a 100644
--- a/.github/ISSUE_TEMPLATE/1-bug-report.md
+++ b/.github/ISSUE_TEMPLATE/1-bug-report.md
@@ -5,20 +5,47 @@ about: Create a report to help us improve
---
* **Version**:
* **Platform**:
* **Subsystem**:
-
+### What steps will reproduce the bug?
+
+
+
+### How often does it reproduce? Is there a required condition?
+
+### What is the expected behavior?
+
+
+
+### What do you see instead?
+
+
+
+### Additional information
+
+
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index 257e4abbc10aca..356a9f990e4290 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -3,14 +3,20 @@ name: CI
on: [push, pull_request]
jobs:
- build-linux:
+ build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- - name: Use Node.js 13
- uses: actions/setup-node@v1
+ - name: Build
+ run: NODE=$(which node) make doc-only
+ - uses: actions/upload-artifact@v1
with:
- node-version: 13.x
+ name: docs
+ path: out/doc
+ build-linux:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
- name: Environment Information
run: npx envinfo
- name: Build
@@ -19,10 +25,6 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- - name: Use Node.js 13
- uses: actions/setup-node@v1
- with:
- node-version: 13.x
- name: Environment Information
run: npx envinfo
- name: Install deps
@@ -33,10 +35,6 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- - name: Use Node.js 13
- uses: actions/setup-node@v1
- with:
- node-version: 13.x
- name: Environment Information
run: npx envinfo
- name: Build
diff --git a/.gitignore b/.gitignore
index db2597b042b84a..160b96f74a59ab 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,8 +47,8 @@
/config_fips.gypi
# === Rules for MSVS artifacts ===
-/Debug
-/Release
+Debug/
+Release/
*.sln
*.suo
*.vcxproj*
diff --git a/BUILDING.md b/BUILDING.md
index 448b7711b4d4cc..4f24ebe06c0602 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -28,11 +28,12 @@ file a new issue.
* [Running Coverage](#running-coverage)
* [Building the documentation](#building-the-documentation)
* [Building a debug build](#building-a-debug-build)
+ * [Troubleshooting Unix and macOS builds](#troubleshooting-unix-and-macos-builds)
* [Windows](#windows)
* [Prerequisites](#prerequisites)
* [Option 1: Manual install](#option-1-manual-install)
* [Option 2: Automated install with Boxstarter](#option-2-automated-install-with-boxstarter)
- * [Building Node.js](#building-nodejs-1)
+ * [Building Node.js](#building-nodejs-2)
* [Android/Android-based devices (e.g. Firefox OS)](#androidandroid-based-devices-eg-firefox-os)
* [`Intl` (ECMA-402) support](#intl-ecma-402-support)
* [Build with full ICU support (all locales supported by ICU)](#build-with-full-icu-support-all-locales-supported-by-icu)
@@ -44,7 +45,7 @@ file a new issue.
* [Building without Intl support](#building-without-intl-support)
* [Unix/macOS](#unixmacos-2)
* [Windows](#windows-3)
- * [Use existing installed ICU (Unix/macOS only)](#use-existing-installed-icu-unixmacOS-only)
+ * [Use existing installed ICU (Unix/macOS only)](#use-existing-installed-icu-unixmacos-only)
* [Build with a specific ICU](#build-with-a-specific-icu)
* [Unix/macOS](#unixmacos-3)
* [Windows](#windows-4)
@@ -243,6 +244,7 @@ Installation via Linux package manager can be achieved with:
* Fedora: `sudo dnf install python gcc-c++ make`
* CentOS and RHEL: `sudo yum install python gcc-c++ make`
* OpenSUSE: `sudo zypper install python gcc-c++ make`
+* Arch Linux, Manjaro: `sudo pacman -S python gcc make`
FreeBSD and OpenBSD users may also need to install `libexecinfo`.
@@ -488,6 +490,17 @@ $ gdb /opt/node-debug/node core.node.8.1535359906
$ backtrace
```
+#### Troubleshooting Unix and macOS builds
+
+Stale builds can sometimes result in `file not found` errors while building.
+This and some other problems can be resolved with `make distclean`. The
+`distclean` recipe aggressively removes build artifacts. You will need to
+build again (`make -j4`). Since all build artifacts have been removed, this
+rebuild may take a lot more time than previous builds. Additionally,
+`distclean` removes the file that stores the results of `./configure`. If you
+ran `./configure` with non-default options (such as `--debug`), you will need
+to run it again before invoking `make -j4`.
+
### Windows
#### Prerequisites
diff --git a/CHANGELOG.md b/CHANGELOG.md
index de6e21fed04a4b..4c48caa007f9f3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -30,7 +30,8 @@ release.
-13.8.0
+13.9.0
+13.8.0 13.7.0 13.6.0 13.5.0
diff --git a/COLLABORATOR_GUIDE.md b/COLLABORATOR_GUIDE.md
index a42c4c8b35f4fa..7e887d7543f50a 100644
--- a/COLLABORATOR_GUIDE.md
+++ b/COLLABORATOR_GUIDE.md
@@ -13,6 +13,7 @@
* [Waiting for Approvals](#waiting-for-approvals)
* [Testing and CI](#testing-and-ci)
* [Useful CI Jobs](#useful-ci-jobs)
+ * [Starting a CI Job](#starting-a-ci-job)
* [Internal vs. Public API](#internal-vs-public-api)
* [Breaking Changes](#breaking-changes)
* [Breaking Changes and Deprecations](#breaking-changes-and-deprecations)
@@ -191,12 +192,6 @@ everything else. Start a fresh CI if more than seven days have elapsed since
the original failing CI as the compiled binaries for the Windows and ARM
platforms are only kept for seven days.
-Some of the CI Jobs may require `GIT_REMOTE_REF` which is the remote portion
-of Git refspec. To specify the branch this way `refs/heads/BRANCH` is used
-(i.e for `master` -> `refs/heads/master`).
-For pull requests it will look like `refs/pull/PR_NUMBER/head`
-(i.e. for PR#42 -> `refs/pull/42/head`).
-
#### Useful CI Jobs
* [`node-test-pull-request`](https://ci.nodejs.org/job/node-test-pull-request/)
@@ -216,12 +211,37 @@ that the tests are reliable.
runs the standard V8 tests. Run it when updating V8 in Node.js or floating new
patches on V8.
-* [`node-test-commit-custom-suites`](https://ci.nodejs.org/job/node-test-commit-custom-suites/)
+* [`node-test-commit-custom-suites-freestyle`](https://ci.nodejs.org/job/node-test-commit-custom-suites-freestyle/)
enables customization of test suites and parameters. It can execute test suites
not used in other CI test runs (such as tests in the `internet` or `pummel`
directories). It can also make sure tests pass when provided with a flag not
used in other CI test runs (such as `--worker`).
+#### Starting a CI Job
+
+From the CI Job page, click "Build with Parameters" on the left side.
+
+You generally need to enter only one or both of the following options
+in the form:
+
+* `GIT_REMOTE_REF`: Change to the remote portion of git refspec.
+To specify the branch this way, `refs/heads/BRANCH` is used
+(e.g. for `master` -> `refs/heads/master`).
+For pull requests, it will look like `refs/pull/PR_NUMBER/head`
+(e.g. for PR#42 -> `refs/pull/42/head`).
+* `REBASE_ONTO`: Change that to `origin/master` so the pull request gets rebased
+onto master. This can especially be important for pull requests that have been
+open a while.
+
+Look at the list of jobs on the left hand side under "Build History" and copy
+the link to the one you started (which will be the one on top, but click
+through to make sure it says something like "Started 5 seconds ago"
+(top right) and "Started by user ...".
+
+Copy/paste the URL for the job into a comment in the pull request.
+[`node-test-pull-request`](https://ci.nodejs.org/job/node-test-pull-request/)
+is an exception where the GitHub bot will automatically post for you.
+
### Internal vs. Public API
All functionality in the official Node.js documentation is part of the public
diff --git a/README.md b/README.md
index 6100568c1dce83..07d6ad4e7ed039 100644
--- a/README.md
+++ b/README.md
@@ -261,8 +261,6 @@ For information about the governance of the Node.js project, see
**Ruben Bridgewater** <ruben@bridgewater.de> (he/him)
* [bzoz](https://github.com/bzoz) -
**Bartosz Sosnowski** <bartosz@janeasystems.com>
-* [calvinmetcalf](https://github.com/calvinmetcalf) -
-**Calvin Metcalf** <calvin.metcalf@gmail.com>
* [cclauss](https://github.com/cclauss) -
**Christian Clauss** <cclauss@me.com> (he/him)
* [ChALkeR](https://github.com/ChALkeR) -
@@ -353,7 +351,7 @@ For information about the governance of the Node.js project, see
**Denys Otrishko** <shishugi@gmail.com> (he/him)
* [maclover7](https://github.com/maclover7) -
**Jon Moss** <me@jonathanmoss.me> (he/him)
-* [mafintosh](https://github.com/mafintosh)
+* [mafintosh](https://github.com/mafintosh) -
**Mathias Buus** <mathiasbuus@gmail.com> (he/him)
* [mcollina](https://github.com/mcollina) -
**Matteo Collina** <matteo.collina@gmail.com> (he/him)
@@ -375,8 +373,6 @@ For information about the governance of the Node.js project, see
**Ali Ijaz Sheikh** <ofrobots@google.com> (he/him)
* [oyyd](https://github.com/oyyd) -
**Ouyang Yadong** <oyydoibh@gmail.com> (he/him)
-* [princejwesley](https://github.com/princejwesley) -
-**Prince John Wesley** <princejohnwesley@gmail.com>
* [psmarshall](https://github.com/psmarshall) -
**Peter Marshall** <petermarshall@chromium.org> (he/him)
* [Qard](https://github.com/Qard) -
@@ -385,6 +381,8 @@ For information about the governance of the Node.js project, see
**Refael Ackermann (רפאל פלחי)** <refack@gmail.com> (he/him/הוא/אתה)
* [richardlau](https://github.com/richardlau) -
**Richard Lau** <riclau@uk.ibm.com>
+* [ronag](https://github.com/ronag) -
+**Robert Nagy** <ronagy@icloud.com>
* [ronkorving](https://github.com/ronkorving) -
**Ron Korving** <ron@ronkorving.nl>
* [rubys](https://github.com/rubys) -
@@ -392,7 +390,7 @@ For information about the governance of the Node.js project, see
* [rvagg](https://github.com/rvagg) -
**Rod Vagg** <rod@vagg.org>
* [ryzokuken](https://github.com/ryzokuken) -
-**Ujjwal Sharma** <usharma1998@gmail.com> (he/him)
+**Ujjwal Sharma** <ryzokuken@disroot.org> (he/him)
* [saghul](https://github.com/saghul) -
**Saúl Ibarra Corretgé** <saghul@gmail.com>
* [sam-github](https://github.com/sam-github) -
@@ -431,8 +429,6 @@ For information about the governance of the Node.js project, see
**Rich Trott** <rtrott@gmail.com> (he/him)
* [vdeturckheim](https://github.com/vdeturckheim) -
**Vladimir de Turckheim** <vlad2t@hotmail.com> (he/him)
-* [vkurchatkin](https://github.com/vkurchatkin) -
-**Vladimir Kurchatkin** <vladimir.kurchatkin@gmail.com>
* [watilde](https://github.com/watilde) -
**Daijiro Wachi** <daijiro.wachi@gmail.com> (he/him)
* [watson](https://github.com/watson) -
@@ -456,12 +452,14 @@ For information about the governance of the Node.js project, see
**Anna M. Kedzierska** <anna.m.kedzierska@gmail.com>
* [brendanashworth](https://github.com/brendanashworth) -
**Brendan Ashworth** <brendan.ashworth@me.com>
-* [estliberitas](https://github.com/estliberitas) -
-**Alexander Makarenko** <estliberitas@gmail.com>
+* [calvinmetcalf](https://github.com/calvinmetcalf) -
+**Calvin Metcalf** <calvin.metcalf@gmail.com>
* [chrisdickinson](https://github.com/chrisdickinson) -
**Chris Dickinson** <christopher.s.dickinson@gmail.com>
* [DavidCai1993](https://github.com/DavidCai1993) -
**David Cai** <davidcai1993@yahoo.com> (he/him)
+* [estliberitas](https://github.com/estliberitas) -
+**Alexander Makarenko** <estliberitas@gmail.com>
* [firedfox](https://github.com/firedfox) -
**Daniel Wang** <wangyang0123@gmail.com>
* [imran-iq](https://github.com/imran-iq) -
@@ -504,6 +502,8 @@ For information about the governance of the Node.js project, see
**Bert Belder** <bertbelder@gmail.com>
* [pmq20](https://github.com/pmq20) -
**Minqi Pan** <pmq2001@gmail.com>
+* [princejwesley](https://github.com/princejwesley) -
+**Prince John Wesley** <princejohnwesley@gmail.com>
* [rlidwka](https://github.com/rlidwka) -
**Alex Kocharin** <alex@kocharin.ru>
* [rmg](https://github.com/rmg) -
@@ -522,6 +522,8 @@ For information about the governance of the Node.js project, see
**Thorsten Lorenz** <thlorenz@gmx.de>
* [tunniclm](https://github.com/tunniclm) -
**Mike Tunnicliffe** <m.j.tunnicliffe@gmail.com>
+* [vkurchatkin](https://github.com/vkurchatkin) -
+**Vladimir Kurchatkin** <vladimir.kurchatkin@gmail.com>
* [vsemozhetbyt](https://github.com/vsemozhetbyt) -
**Vse Mozhet Byt** <vsemozhetbyt@gmail.com> (he/him)
* [whitlockjc](https://github.com/whitlockjc) -
diff --git a/benchmark/async_hooks/async-resource-vs-destroy.js b/benchmark/async_hooks/async-resource-vs-destroy.js
new file mode 100644
index 00000000000000..4464dd5f93e7de
--- /dev/null
+++ b/benchmark/async_hooks/async-resource-vs-destroy.js
@@ -0,0 +1,151 @@
+'use strict';
+
+const { promisify } = require('util');
+const { readFile } = require('fs');
+const sleep = promisify(setTimeout);
+const read = promisify(readFile);
+const common = require('../common.js');
+const {
+ createHook,
+ executionAsyncResource,
+ executionAsyncId
+} = require('async_hooks');
+const { createServer } = require('http');
+
+// Configuration for the http server
+// there is no need for parameters in this test
+const connections = 500;
+const path = '/';
+
+const bench = common.createBenchmark(main, {
+ type: ['async-resource', 'destroy'],
+ asyncMethod: ['callbacks', 'async'],
+ n: [1e6]
+});
+
+function buildCurrentResource(getServe) {
+ const server = createServer(getServe(getCLS, setCLS));
+ const hook = createHook({ init });
+ const cls = Symbol('cls');
+ hook.enable();
+
+ return {
+ server,
+ close
+ };
+
+ function getCLS() {
+ const resource = executionAsyncResource();
+ if (resource === null || !resource[cls]) {
+ return null;
+ }
+ return resource[cls].state;
+ }
+
+ function setCLS(state) {
+ const resource = executionAsyncResource();
+ if (resource === null) {
+ return;
+ }
+ if (!resource[cls]) {
+ resource[cls] = { state };
+ } else {
+ resource[cls].state = state;
+ }
+ }
+
+ function init(asyncId, type, triggerAsyncId, resource) {
+ var cr = executionAsyncResource();
+ if (cr !== null) {
+ resource[cls] = cr[cls];
+ }
+ }
+
+ function close() {
+ hook.disable();
+ server.close();
+ }
+}
+
+function buildDestroy(getServe) {
+ const transactions = new Map();
+ const server = createServer(getServe(getCLS, setCLS));
+ const hook = createHook({ init, destroy });
+ hook.enable();
+
+ return {
+ server,
+ close
+ };
+
+ function getCLS() {
+ const asyncId = executionAsyncId();
+ return transactions.has(asyncId) ? transactions.get(asyncId) : null;
+ }
+
+ function setCLS(value) {
+ const asyncId = executionAsyncId();
+ transactions.set(asyncId, value);
+ }
+
+ function init(asyncId, type, triggerAsyncId, resource) {
+ transactions.set(asyncId, getCLS());
+ }
+
+ function destroy(asyncId) {
+ transactions.delete(asyncId);
+ }
+
+ function close() {
+ hook.disable();
+ server.close();
+ }
+}
+
+function getServeAwait(getCLS, setCLS) {
+ return async function serve(req, res) {
+ setCLS(Math.random());
+ await sleep(10);
+ await read(__filename);
+ res.setHeader('content-type', 'application/json');
+ res.end(JSON.stringify({ cls: getCLS() }));
+ };
+}
+
+function getServeCallbacks(getCLS, setCLS) {
+ return function serve(req, res) {
+ setCLS(Math.random());
+ setTimeout(() => {
+ readFile(__filename, () => {
+ res.setHeader('content-type', 'application/json');
+ res.end(JSON.stringify({ cls: getCLS() }));
+ });
+ }, 10);
+ };
+}
+
+const types = {
+ 'async-resource': buildCurrentResource,
+ 'destroy': buildDestroy
+};
+
+const asyncMethods = {
+ 'callbacks': getServeCallbacks,
+ 'async': getServeAwait
+};
+
+function main({ type, asyncMethod }) {
+ const { server, close } = types[type](asyncMethods[asyncMethod]);
+
+ server
+ .listen(common.PORT)
+ .on('listening', () => {
+
+ bench.http({
+ path,
+ connections
+ }, () => {
+ close();
+ });
+ });
+}
diff --git a/benchmark/buffers/buffer-concat-fill.js b/benchmark/buffers/buffer-concat-fill.js
new file mode 100644
index 00000000000000..8fb389fe6c8639
--- /dev/null
+++ b/benchmark/buffers/buffer-concat-fill.js
@@ -0,0 +1,23 @@
+'use strict';
+const common = require('../common.js');
+
+const bench = common.createBenchmark(main, {
+ extraSize: [1, 256, 4 * 256],
+ n: [8e5]
+});
+
+function main({ n, extraSize }) {
+ const pieces = 4;
+ const pieceSize = 256;
+
+ const list = Array.from({ length: pieces })
+ .fill(Buffer.allocUnsafe(pieceSize));
+
+ const totalLength = (pieces * pieceSize) + extraSize;
+
+ bench.start();
+ for (let i = 0; i < n; i++) {
+ Buffer.concat(list, totalLength);
+ }
+ bench.end(n);
+}
diff --git a/benchmark/buffers/buffer-from.js b/benchmark/buffers/buffer-from.js
index 1df1b5b362fefa..d0f7d42f5e4369 100644
--- a/benchmark/buffers/buffer-from.js
+++ b/benchmark/buffers/buffer-from.js
@@ -12,37 +12,37 @@ const bench = common.createBenchmark(main, {
'string-utf8',
'string-base64',
'object',
+ 'uint8array',
+ 'uint16array',
],
len: [100, 2048],
n: [8e5]
});
function main({ len, n, source }) {
- const array = new Array(len).fill(42);
- const arrayBuf = new ArrayBuffer(len);
- const str = 'a'.repeat(len);
- const buffer = Buffer.allocUnsafe(len);
- const uint8array = new Uint8Array(len);
- const obj = { length: null }; // Results in a new, empty Buffer
-
let i = 0;
switch (source) {
- case 'array':
+ case 'array': {
+ const array = new Array(len).fill(42);
bench.start();
for (i = 0; i < n; i++) {
Buffer.from(array);
}
bench.end(n);
break;
- case 'arraybuffer':
+ }
+ case 'arraybuffer': {
+ const arrayBuf = new ArrayBuffer(len);
bench.start();
for (i = 0; i < n; i++) {
Buffer.from(arrayBuf);
}
bench.end(n);
break;
- case 'arraybuffer-middle':
+ }
+ case 'arraybuffer-middle': {
+ const arrayBuf = new ArrayBuffer(len);
const offset = ~~(len / 4);
const length = ~~(len / 2);
bench.start();
@@ -51,48 +51,70 @@ function main({ len, n, source }) {
}
bench.end(n);
break;
- case 'buffer':
+ }
+ case 'buffer': {
+ const buffer = Buffer.allocUnsafe(len);
bench.start();
for (i = 0; i < n; i++) {
Buffer.from(buffer);
}
bench.end(n);
break;
- case 'uint8array':
+ }
+ case 'uint8array': {
+ const uint8array = new Uint8Array(len);
bench.start();
for (i = 0; i < n; i++) {
Buffer.from(uint8array);
}
bench.end(n);
break;
- case 'string':
+ }
+ case 'uint16array': {
+ const uint16array = new Uint16Array(len);
+ bench.start();
+ for (i = 0; i < n; i++) {
+ Buffer.from(uint16array);
+ }
+ bench.end(n);
+ break;
+ }
+ case 'string': {
+ const str = 'a'.repeat(len);
bench.start();
for (i = 0; i < n; i++) {
Buffer.from(str);
}
bench.end(n);
break;
- case 'string-utf8':
+ }
+ case 'string-utf8': {
+ const str = 'a'.repeat(len);
bench.start();
for (i = 0; i < n; i++) {
Buffer.from(str, 'utf8');
}
bench.end(n);
break;
- case 'string-base64':
+ }
+ case 'string-base64': {
+ const str = 'a'.repeat(len);
bench.start();
for (i = 0; i < n; i++) {
Buffer.from(str, 'base64');
}
bench.end(n);
break;
- case 'object':
+ }
+ case 'object': {
+ const obj = { length: null }; // Results in a new, empty Buffer
bench.start();
for (i = 0; i < n; i++) {
Buffer.from(obj);
}
bench.end(n);
break;
+ }
default:
assert.fail('Should not get here');
}
diff --git a/benchmark/common.js b/benchmark/common.js
index 6a3be4fc376920..c5791c2bacfd5d 100644
--- a/benchmark/common.js
+++ b/benchmark/common.js
@@ -33,6 +33,7 @@ function Benchmark(fn, configs, options) {
this._time = [0, 0];
// Used to make sure a benchmark only start a timer once
this._started = false;
+ this._ended = false;
// this._run will use fork() to create a new process for each configuration
// combination.
@@ -197,6 +198,9 @@ Benchmark.prototype.end = function(operations) {
if (!this._started) {
throw new Error('called end without start');
}
+ if (this._ended) {
+ throw new Error('called end multiple times');
+ }
if (typeof operations !== 'number') {
throw new Error('called end() without specifying operation count');
}
@@ -210,6 +214,7 @@ Benchmark.prototype.end = function(operations) {
elapsed[1] = 1;
}
+ this._ended = true;
const time = elapsed[0] + elapsed[1] / 1e9;
const rate = operations / time;
this.report(rate, elapsed);
diff --git a/benchmark/crypto/randomBytes.js b/benchmark/crypto/randomBytes.js
new file mode 100644
index 00000000000000..50ad3f08387566
--- /dev/null
+++ b/benchmark/crypto/randomBytes.js
@@ -0,0 +1,16 @@
+'use strict';
+
+const common = require('../common.js');
+const { randomBytes } = require('crypto');
+
+const bench = common.createBenchmark(main, {
+ size: [64, 1024, 8192, 512 * 1024],
+ n: [1e3],
+});
+
+function main({ n, size }) {
+ bench.start();
+ for (let i = 0; i < n; ++i)
+ randomBytes(size);
+ bench.end(n);
+}
diff --git a/benchmark/domain/domain-fn-args.js b/benchmark/domain/domain-fn-args.js
index c889b35442d046..18906a9ce64099 100644
--- a/benchmark/domain/domain-fn-args.js
+++ b/benchmark/domain/domain-fn-args.js
@@ -15,7 +15,7 @@ function main({ n, args }) {
bench.start();
bdomain.enter();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
if (myArguments.length >= 2) {
const args = Array.prototype.slice.call(myArguments, 1);
fn.apply(this, args);
diff --git a/benchmark/es/defaultparams-bench.js b/benchmark/es/defaultparams-bench.js
index c568c12ae03fda..ab9cc45749c996 100644
--- a/benchmark/es/defaultparams-bench.js
+++ b/benchmark/es/defaultparams-bench.js
@@ -22,14 +22,14 @@ function defaultParams(x = 1, y = 2) {
function runOldStyleDefaults(n) {
bench.start();
- for (var i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
oldStyleDefaults();
bench.end(n);
}
function runDefaultParams(n) {
bench.start();
- for (var i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
defaultParams();
bench.end(n);
}
diff --git a/benchmark/es/destructuring-bench.js b/benchmark/es/destructuring-bench.js
index 37f3fd9ad3d601..f1b484bd47e08f 100644
--- a/benchmark/es/destructuring-bench.js
+++ b/benchmark/es/destructuring-bench.js
@@ -9,9 +9,9 @@ const bench = common.createBenchmark(main, {
});
function runSwapManual(n) {
- var x, y, r;
+ let x, y, r;
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
x = 1, y = 2;
r = x;
x = y;
@@ -23,9 +23,9 @@ function runSwapManual(n) {
}
function runSwapDestructured(n) {
- var x, y;
+ let x, y;
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
x = 1, y = 2;
[x, y] = [y, x];
assert.strictEqual(x, 2);
diff --git a/benchmark/es/destructuring-object-bench.js b/benchmark/es/destructuring-object-bench.js
index 0c5615fd1e667b..68dc17073badc2 100644
--- a/benchmark/es/destructuring-object-bench.js
+++ b/benchmark/es/destructuring-object-bench.js
@@ -8,10 +8,9 @@ const bench = common.createBenchmark(main, {
});
function runNormal(n) {
- var i = 0;
const o = { x: 0, y: 1 };
bench.start();
- for (; i < n; i++) {
+ for (let i = 0; i < n; i++) {
/* eslint-disable no-unused-vars */
const x = o.x;
const y = o.y;
@@ -22,10 +21,9 @@ function runNormal(n) {
}
function runDestructured(n) {
- var i = 0;
const o = { x: 0, y: 1 };
bench.start();
- for (; i < n; i++) {
+ for (let i = 0; i < n; i++) {
/* eslint-disable no-unused-vars */
const { x, y, r = 2 } = o;
/* eslint-enable no-unused-vars */
diff --git a/benchmark/es/foreach-bench.js b/benchmark/es/foreach-bench.js
index f424ca7a2552b2..88bfed00fbc27c 100644
--- a/benchmark/es/foreach-bench.js
+++ b/benchmark/es/foreach-bench.js
@@ -10,8 +10,8 @@ const bench = common.createBenchmark(main, {
function useFor(n, items, count) {
bench.start();
- for (var i = 0; i < n; i++) {
- for (var j = 0; j < count; j++) {
+ for (let i = 0; i < n; i++) {
+ for (let j = 0; j < count; j++) {
// eslint-disable-next-line no-unused-vars
const item = items[j];
}
@@ -21,7 +21,7 @@ function useFor(n, items, count) {
function useForOf(n, items) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
// eslint-disable-next-line no-unused-vars
for (const item of items) {}
}
@@ -30,8 +30,8 @@ function useForOf(n, items) {
function useForIn(n, items) {
bench.start();
- for (var i = 0; i < n; i++) {
- for (var j in items) {
+ for (let i = 0; i < n; i++) {
+ for (const j in items) {
// eslint-disable-next-line no-unused-vars
const item = items[j];
}
@@ -41,7 +41,7 @@ function useForIn(n, items) {
function useForEach(n, items) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
items.forEach((item) => {});
}
bench.end(n);
@@ -49,8 +49,8 @@ function useForEach(n, items) {
function main({ n, count, method }) {
const items = new Array(count);
- var fn;
- for (var i = 0; i < count; i++)
+ let fn;
+ for (let i = 0; i < count; i++)
items[i] = i;
switch (method) {
diff --git a/benchmark/es/map-bench.js b/benchmark/es/map-bench.js
index a2f9e2450a1f23..1b3ba4789db073 100644
--- a/benchmark/es/map-bench.js
+++ b/benchmark/es/map-bench.js
@@ -14,7 +14,7 @@ const bench = common.createBenchmark(main, {
function runObject(n) {
const m = {};
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
m[`i${i}`] = i;
m[`s${i}`] = String(i);
assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]);
@@ -27,7 +27,7 @@ function runObject(n) {
function runNullProtoObject(n) {
const m = Object.create(null);
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
m[`i${i}`] = i;
m[`s${i}`] = String(i);
assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]);
@@ -40,7 +40,7 @@ function runNullProtoObject(n) {
function runNullProtoLiteralObject(n) {
const m = { __proto__: null };
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
m[`i${i}`] = i;
m[`s${i}`] = String(i);
assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]);
@@ -56,7 +56,7 @@ StorageObject.prototype = Object.create(null);
function runStorageObject(n) {
const m = new StorageObject();
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
m[`i${i}`] = i;
m[`s${i}`] = String(i);
assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]);
@@ -79,7 +79,7 @@ function fakeMap() {
function runFakeMap(n) {
const m = fakeMap();
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
m.set(`i${i}`, i);
m.set(`s${i}`, String(i));
assert.strictEqual(String(m.get(`i${i}`)), m.get(`s${i}`));
@@ -92,7 +92,7 @@ function runFakeMap(n) {
function runMap(n) {
const m = new Map();
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
m.set(`i${i}`, i);
m.set(`s${i}`, String(i));
assert.strictEqual(String(m.get(`i${i}`)), m.get(`s${i}`));
diff --git a/benchmark/es/restparams-bench.js b/benchmark/es/restparams-bench.js
index d9b4878cb316a0..d568e28744541f 100644
--- a/benchmark/es/restparams-bench.js
+++ b/benchmark/es/restparams-bench.js
@@ -11,7 +11,7 @@ const bench = common.createBenchmark(main, {
function copyArguments() {
const len = arguments.length;
const args = new Array(len);
- for (var i = 0; i < len; i++)
+ for (let i = 0; i < len; i++)
args[i] = arguments[i];
assert.strictEqual(args[0], 1);
assert.strictEqual(args[1], 2);
@@ -34,22 +34,22 @@ function useArguments() {
}
function runCopyArguments(n) {
- for (var i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
copyArguments(1, 2, 'a', 'b');
}
function runRestArguments(n) {
- for (var i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
restArguments(1, 2, 'a', 'b');
}
function runUseArguments(n) {
- for (var i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
useArguments(1, 2, 'a', 'b');
}
function main({ n, method }) {
- var fn;
+ let fn;
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
diff --git a/benchmark/es/spread-assign.js b/benchmark/es/spread-assign.js
index bbe07e02e15110..97a5c5458e396b 100644
--- a/benchmark/es/spread-assign.js
+++ b/benchmark/es/spread-assign.js
@@ -16,26 +16,25 @@ function main({ n, context, count, rest, method }) {
src[`p${n}`] = n;
let obj; // eslint-disable-line no-unused-vars
- let i;
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case '_extend':
bench.start();
- for (i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
obj = util._extend({}, src);
bench.end(n);
break;
case 'assign':
bench.start();
- for (i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
obj = Object.assign({}, src);
bench.end(n);
break;
case 'spread':
bench.start();
- for (i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
obj = { ...src };
bench.end(n);
break;
diff --git a/benchmark/es/spread-bench.js b/benchmark/es/spread-bench.js
index 97c7596b6b732b..fc56c9433f2add 100644
--- a/benchmark/es/spread-bench.js
+++ b/benchmark/es/spread-bench.js
@@ -25,10 +25,10 @@ function makeTest(count, rest) {
function main({ n, context, count, rest, method }) {
const ctx = context === 'context' ? {} : null;
- var fn = makeTest(count, rest);
+ let fn = makeTest(count, rest);
const args = new Array(count);
- var i;
- for (i = 0; i < count; i++)
+
+ for (let i = 0; i < count; i++)
args[i] = i;
switch (method) {
@@ -36,7 +36,7 @@ function main({ n, context, count, rest, method }) {
// Empty string falls through to next line as default, mostly for tests.
case 'apply':
bench.start();
- for (i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
fn.apply(ctx, args);
bench.end(n);
break;
@@ -44,13 +44,13 @@ function main({ n, context, count, rest, method }) {
if (ctx !== null)
fn = fn.bind(ctx);
bench.start();
- for (i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
fn(...args);
bench.end(n);
break;
case 'call-spread':
bench.start();
- for (i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
fn.call(ctx, ...args);
bench.end(n);
break;
diff --git a/benchmark/events/ee-add-remove.js b/benchmark/events/ee-add-remove.js
index 2d20736b057568..715eab29a59c4c 100644
--- a/benchmark/events/ee-add-remove.js
+++ b/benchmark/events/ee-add-remove.js
@@ -8,17 +8,16 @@ function main({ n }) {
const ee = new events.EventEmitter();
const listeners = [];
- var k;
- for (k = 0; k < 10; k += 1)
+ for (let k = 0; k < 10; k += 1)
listeners.push(() => {});
bench.start();
- for (var i = 0; i < n; i += 1) {
+ for (let i = 0; i < n; i += 1) {
const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1';
- for (k = listeners.length; --k >= 0; /* empty */) {
+ for (let k = listeners.length; --k >= 0; /* empty */) {
ee.on(dummy, listeners[k]);
}
- for (k = listeners.length; --k >= 0; /* empty */) {
+ for (let k = listeners.length; --k >= 0; /* empty */) {
ee.removeListener(dummy, listeners[k]);
}
}
diff --git a/benchmark/events/ee-emit.js b/benchmark/events/ee-emit.js
index 8f1c2761ffd4ba..39bcbb937d6c56 100644
--- a/benchmark/events/ee-emit.js
+++ b/benchmark/events/ee-emit.js
@@ -11,35 +11,34 @@ const bench = common.createBenchmark(main, {
function main({ n, argc, listeners }) {
const ee = new EventEmitter();
- for (var k = 0; k < listeners; k += 1)
+ for (let k = 0; k < listeners; k += 1)
ee.on('dummy', () => {});
- var i;
switch (argc) {
case 2:
bench.start();
- for (i = 0; i < n; i += 1) {
+ for (let i = 0; i < n; i += 1) {
ee.emit('dummy', true, 5);
}
bench.end(n);
break;
case 4:
bench.start();
- for (i = 0; i < n; i += 1) {
+ for (let i = 0; i < n; i += 1) {
ee.emit('dummy', true, 5, 10, false);
}
bench.end(n);
break;
case 10:
bench.start();
- for (i = 0; i < n; i += 1) {
+ for (let i = 0; i < n; i += 1) {
ee.emit('dummy', true, 5, 10, false, 5, 'string', true, false, 11, 20);
}
bench.end(n);
break;
default:
bench.start();
- for (i = 0; i < n; i += 1) {
+ for (let i = 0; i < n; i += 1) {
ee.emit('dummy');
}
bench.end(n);
diff --git a/benchmark/events/ee-listener-count-on-prototype.js b/benchmark/events/ee-listener-count-on-prototype.js
index d48e96a46aafe2..04cadc8dcb64da 100644
--- a/benchmark/events/ee-listener-count-on-prototype.js
+++ b/benchmark/events/ee-listener-count-on-prototype.js
@@ -7,13 +7,13 @@ const bench = common.createBenchmark(main, { n: [5e7] });
function main({ n }) {
const ee = new EventEmitter();
- for (var k = 0; k < 5; k += 1) {
+ for (let k = 0; k < 5; k += 1) {
ee.on('dummy0', () => {});
ee.on('dummy1', () => {});
}
bench.start();
- for (var i = 0; i < n; i += 1) {
+ for (let i = 0; i < n; i += 1) {
const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1';
ee.listenerCount(dummy);
}
diff --git a/benchmark/events/ee-listeners-many.js b/benchmark/events/ee-listeners-many.js
index 7f9099c41790ea..bd3f3538d63c92 100644
--- a/benchmark/events/ee-listeners-many.js
+++ b/benchmark/events/ee-listeners-many.js
@@ -8,13 +8,13 @@ function main({ n }) {
const ee = new EventEmitter();
ee.setMaxListeners(101);
- for (var k = 0; k < 50; k += 1) {
+ for (let k = 0; k < 50; k += 1) {
ee.on('dummy0', () => {});
ee.on('dummy1', () => {});
}
bench.start();
- for (var i = 0; i < n; i += 1) {
+ for (let i = 0; i < n; i += 1) {
const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1';
ee.listeners(dummy);
}
diff --git a/benchmark/events/ee-listeners.js b/benchmark/events/ee-listeners.js
index 74b88b043401b5..867393efffcb04 100644
--- a/benchmark/events/ee-listeners.js
+++ b/benchmark/events/ee-listeners.js
@@ -7,13 +7,13 @@ const bench = common.createBenchmark(main, { n: [5e6] });
function main({ n }) {
const ee = new EventEmitter();
- for (var k = 0; k < 5; k += 1) {
+ for (let k = 0; k < 5; k += 1) {
ee.on('dummy0', () => {});
ee.on('dummy1', () => {});
}
bench.start();
- for (var i = 0; i < n; i += 1) {
+ for (let i = 0; i < n; i += 1) {
const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1';
ee.listeners(dummy);
}
diff --git a/benchmark/fixtures/simple-http-server.js b/benchmark/fixtures/simple-http-server.js
index 2b4f1ea956d7cc..fb5b0d87c16e0d 100644
--- a/benchmark/fixtures/simple-http-server.js
+++ b/benchmark/fixtures/simple-http-server.js
@@ -31,14 +31,14 @@ module.exports = http.createServer((req, res) => {
// URL format: /////chunkedEnc
const params = req.url.split('/');
const command = params[1];
- var body = '';
+ let body = '';
const arg = params[2];
const n_chunks = parseInt(params[3], 10);
const resHow = params.length >= 5 ? params[4] : 'normal';
const chunkedEnc = params.length >= 6 && params[5] === '0' ? false : true;
- var status = 200;
+ let status = 200;
- var n, i;
+ let n, i;
if (command === 'bytes') {
n = ~~arg;
if (n <= 0)
diff --git a/benchmark/fs/bench-readdirSync.js b/benchmark/fs/bench-readdirSync.js
index 5d0e97399a33ff..c0144d3460f8ff 100644
--- a/benchmark/fs/bench-readdirSync.js
+++ b/benchmark/fs/bench-readdirSync.js
@@ -15,7 +15,7 @@ function main({ n, dir, withFileTypes }) {
withFileTypes = withFileTypes === 'true';
const fullPath = path.resolve(__dirname, '../../', dir);
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
fs.readdirSync(fullPath, { withFileTypes });
}
bench.end(n);
diff --git a/benchmark/fs/bench-realpathSync.js b/benchmark/fs/bench-realpathSync.js
index 7a01bd18cb72bf..d0dbd7f891f126 100644
--- a/benchmark/fs/bench-realpathSync.js
+++ b/benchmark/fs/bench-realpathSync.js
@@ -17,7 +17,7 @@ const bench = common.createBenchmark(main, {
function main({ n, pathType }) {
const path = pathType === 'relative' ? relative_path : resolved_path;
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
fs.realpathSync(path);
}
bench.end(n);
diff --git a/benchmark/fs/bench-stat.js b/benchmark/fs/bench-stat.js
index 0b2e1972e2cb80..e1f51c762c8e5f 100644
--- a/benchmark/fs/bench-stat.js
+++ b/benchmark/fs/bench-stat.js
@@ -10,7 +10,7 @@ const bench = common.createBenchmark(main, {
function main({ n, statType }) {
- var arg;
+ let arg;
if (statType === 'fstat')
arg = fs.openSync(__filename, 'r');
else
diff --git a/benchmark/fs/bench-statSync.js b/benchmark/fs/bench-statSync.js
index bd8754a6c3d0e3..0c9366a402cb71 100644
--- a/benchmark/fs/bench-statSync.js
+++ b/benchmark/fs/bench-statSync.js
@@ -16,7 +16,7 @@ function main({ n, statSyncType }) {
const fn = fs[statSyncType];
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
fn(arg);
}
bench.end(n);
diff --git a/benchmark/fs/read-stream-throughput.js b/benchmark/fs/read-stream-throughput.js
index 4c8de582418960..34c25760ea9c38 100644
--- a/benchmark/fs/read-stream-throughput.js
+++ b/benchmark/fs/read-stream-throughput.js
@@ -52,7 +52,7 @@ function runTest() {
bench.start();
});
- var bytes = 0;
+ let bytes = 0;
rs.on('data', (chunk) => {
bytes += chunk.length;
});
@@ -68,7 +68,7 @@ function makeFile() {
const buf = Buffer.allocUnsafe(filesize / 1024);
if (encoding === 'utf8') {
// ü
- for (var i = 0; i < buf.length; i++) {
+ for (let i = 0; i < buf.length; i++) {
buf[i] = i % 2 === 0 ? 0xC3 : 0xBC;
}
} else if (encoding === 'ascii') {
@@ -78,7 +78,7 @@ function makeFile() {
}
try { fs.unlinkSync(filename); } catch {}
- var w = 1024;
+ let w = 1024;
const ws = fs.createWriteStream(filename);
ws.on('close', runTest);
ws.on('drain', write);
diff --git a/benchmark/fs/readFileSync.js b/benchmark/fs/readFileSync.js
index c28adeb229b358..47d210b7aa0463 100644
--- a/benchmark/fs/readFileSync.js
+++ b/benchmark/fs/readFileSync.js
@@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {
function main({ n }) {
bench.start();
- for (var i = 0; i < n; ++i)
+ for (let i = 0; i < n; ++i)
fs.readFileSync(__filename);
bench.end(n);
}
diff --git a/benchmark/fs/readfile-partitioned.js b/benchmark/fs/readfile-partitioned.js
index 90af3754ce3de2..51700cfd649dfd 100644
--- a/benchmark/fs/readfile-partitioned.js
+++ b/benchmark/fs/readfile-partitioned.js
@@ -22,25 +22,24 @@ const bench = common.createBenchmark(main, {
concurrent: [1, 10]
});
-function main(conf) {
- const len = +conf.len;
+function main({ len, dur, concurrent }) {
try { fs.unlinkSync(filename); } catch {}
- var data = Buffer.alloc(len, 'x');
+ let data = Buffer.alloc(len, 'x');
fs.writeFileSync(filename, data);
data = null;
const zipData = Buffer.alloc(1024, 'a');
- var reads = 0;
- var zips = 0;
- var benchEnded = false;
+ let reads = 0;
+ let zips = 0;
+ let benchEnded = false;
bench.start();
setTimeout(() => {
const totalOps = reads + zips;
benchEnded = true;
bench.end(totalOps);
try { fs.unlinkSync(filename); } catch {}
- }, +conf.dur * 1000);
+ }, dur * 1000);
function read() {
fs.readFile(filename, afterRead);
@@ -78,8 +77,7 @@ function main(conf) {
}
// Start reads
- var cur = +conf.concurrent;
- while (cur--) read();
+ while (concurrent-- > 0) read();
// Start a competing zip
zip();
diff --git a/benchmark/fs/readfile.js b/benchmark/fs/readfile.js
index 7460c8e233e59f..361ffbff597d6e 100644
--- a/benchmark/fs/readfile.js
+++ b/benchmark/fs/readfile.js
@@ -21,12 +21,12 @@ const bench = common.createBenchmark(main, {
function main({ len, dur, concurrent }) {
try { fs.unlinkSync(filename); } catch {}
- var data = Buffer.alloc(len, 'x');
+ let data = Buffer.alloc(len, 'x');
fs.writeFileSync(filename, data);
data = null;
- var reads = 0;
- var benchEnded = false;
+ let reads = 0;
+ let benchEnded = false;
bench.start();
setTimeout(() => {
benchEnded = true;
diff --git a/benchmark/fs/write-stream-throughput.js b/benchmark/fs/write-stream-throughput.js
index 44de0900d8ed15..44a3bb23b041d1 100644
--- a/benchmark/fs/write-stream-throughput.js
+++ b/benchmark/fs/write-stream-throughput.js
@@ -17,9 +17,9 @@ const bench = common.createBenchmark(main, {
});
function main({ dur, encodingType, size }) {
- var encoding;
+ let encoding;
- var chunk;
+ let chunk;
switch (encodingType) {
case 'buf':
chunk = Buffer.alloc(size, 'b');
@@ -38,8 +38,8 @@ function main({ dur, encodingType, size }) {
try { fs.unlinkSync(filename); } catch {}
- var started = false;
- var ended = false;
+ let started = false;
+ let ended = false;
const f = fs.createWriteStream(filename);
f.on('drain', write);
diff --git a/benchmark/http/_chunky_http_client.js b/benchmark/http/_chunky_http_client.js
index 1bf7fa284a835b..1ab95a2b9706c1 100644
--- a/benchmark/http/_chunky_http_client.js
+++ b/benchmark/http/_chunky_http_client.js
@@ -12,7 +12,7 @@ const bench = common.createBenchmark(main, {
function main({ len, n }) {
- var todo = [];
+ let todo = [];
const headers = [];
// Chose 7 because 9 showed "Connection error" / "Connection closed"
// An odd number could result in a better length dispersion.
@@ -48,19 +48,19 @@ function main({ len, n }) {
}
const min = 10;
- var size = 0;
+ let size = 0;
const mod = 317;
const mult = 17;
const add = 11;
- var count = 0;
+ let count = 0;
const PIPE = process.env.PIPE_NAME;
const socket = net.connect(PIPE, () => {
bench.start();
WriteHTTPHeaders(socket, 1, len);
socket.setEncoding('utf8');
socket.on('data', (d) => {
- var did = false;
- var pattern = 'HTTP/1.1 200 OK\r\n';
+ let did = false;
+ let pattern = 'HTTP/1.1 200 OK\r\n';
if ((d.length === pattern.length && d === pattern) ||
(d.length > pattern.length &&
d.slice(0, pattern.length) === pattern)) {
diff --git a/benchmark/http/client-request-body.js b/benchmark/http/client-request-body.js
index b5ac2828c6ff1f..6e2323b3f07e8a 100644
--- a/benchmark/http/client-request-body.js
+++ b/benchmark/http/client-request-body.js
@@ -12,8 +12,8 @@ const bench = common.createBenchmark(main, {
});
function main({ dur, len, type, method }) {
- var encoding;
- var chunk;
+ let encoding;
+ let chunk;
switch (type) {
case 'buf':
chunk = Buffer.alloc(len, 'x');
@@ -27,7 +27,7 @@ function main({ dur, len, type, method }) {
break;
}
- var nreqs = 0;
+ let nreqs = 0;
const options = {
headers: { 'Connection': 'keep-alive', 'Transfer-Encoding': 'chunked' },
agent: new http.Agent({ maxSockets: 1 }),
diff --git a/benchmark/http/cluster.js b/benchmark/http/cluster.js
index c2d6d8e1a70c90..3bcd061a0894c5 100644
--- a/benchmark/http/cluster.js
+++ b/benchmark/http/cluster.js
@@ -18,7 +18,7 @@ if (cluster.isMaster) {
function main({ type, len, c }) {
process.env.PORT = PORT;
- var workers = 0;
+ let workers = 0;
const w1 = cluster.fork();
const w2 = cluster.fork();
diff --git a/benchmark/http/end-vs-write-end.js b/benchmark/http/end-vs-write-end.js
index b4ca560b9a897c..38e9b89a97a6b4 100644
--- a/benchmark/http/end-vs-write-end.js
+++ b/benchmark/http/end-vs-write-end.js
@@ -19,7 +19,7 @@ const bench = common.createBenchmark(main, {
function main({ len, type, method, c }) {
const http = require('http');
- var chunk;
+ let chunk;
switch (type) {
case 'buf':
chunk = Buffer.alloc(len, 'x');
diff --git a/benchmark/http/set_header.js b/benchmark/http/set_header.js
index 470d4b008187bc..f2236696f1c7df 100644
--- a/benchmark/http/set_header.js
+++ b/benchmark/http/set_header.js
@@ -16,10 +16,7 @@ const bench = common.createBenchmark(main, {
n: [1e6],
});
-function main(conf) {
- const n = +conf.n;
- const value = conf.value;
-
+function main({ n, value }) {
const og = new OutgoingMessage();
bench.start();
diff --git a/benchmark/http2/headers.js b/benchmark/http2/headers.js
index f18a73b95e2421..56799da1987e53 100644
--- a/benchmark/http2/headers.js
+++ b/benchmark/http2/headers.js
@@ -24,7 +24,7 @@ function main({ n, nheaders }) {
'user-agent': 'SuperBenchmarker 3000'
};
- for (var i = 0; i < nheaders; i++) {
+ for (let i = 0; i < nheaders; i++) {
headersObject[`foo${i}`] = `some header value ${i}`;
}
diff --git a/benchmark/misc/arguments.js b/benchmark/misc/arguments.js
index 5b0cb0e2ca1488..8fefe617a51d56 100644
--- a/benchmark/misc/arguments.js
+++ b/benchmark/misc/arguments.js
@@ -32,7 +32,7 @@ function usingPredefined() {
}
function main({ n, method, args }) {
- var fn;
+ let fn;
switch (method) {
// '' is a default case for tests
case '':
@@ -53,7 +53,7 @@ function main({ n, method, args }) {
}
bench.start();
- for (var i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
fn('part 1', 'part', 2, 'part 3', 'part', 4);
bench.end(n);
}
diff --git a/benchmark/misc/freelist.js b/benchmark/misc/freelist.js
index e6868fae1ce8c5..d03c3674fdbfac 100644
--- a/benchmark/misc/freelist.js
+++ b/benchmark/misc/freelist.js
@@ -14,7 +14,7 @@ function main({ n }) {
FreeList = FreeList.FreeList;
const poolSize = 1000;
const list = new FreeList('test', poolSize, Object);
- var j;
+ let j;
const used = [];
// First, alloc `poolSize` items
@@ -24,7 +24,7 @@ function main({ n }) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
// Return all the items to the pool
for (j = 0; j < poolSize; j++) {
list.free(used[j]);
diff --git a/benchmark/misc/getstringwidth.js b/benchmark/misc/getstringwidth.js
index 97532bf2a7b50f..c10f7af8483cf9 100644
--- a/benchmark/misc/getstringwidth.js
+++ b/benchmark/misc/getstringwidth.js
@@ -12,7 +12,7 @@ const bench = common.createBenchmark(main, {
function main({ n, type }) {
// Default value for testing purposes.
type = type || 'ascii';
- const { getStringWidth } = require('internal/readline/utils');
+ const { getStringWidth } = require('internal/util/inspect');
const str = ({
ascii: 'foobar'.repeat(100),
diff --git a/benchmark/misc/object-property-bench.js b/benchmark/misc/object-property-bench.js
index fae11119b6fe23..0a4d004999ed23 100644
--- a/benchmark/misc/object-property-bench.js
+++ b/benchmark/misc/object-property-bench.js
@@ -11,9 +11,9 @@ const bench = common.createBenchmark(main, {
function runProperty(n) {
const object = {};
- var i = 0;
+
bench.start();
- for (; i < n; i++) {
+ for (let i = 0; i < n; i++) {
object.p1 = 21;
object.p2 = 21;
object.p1 += object.p2;
@@ -23,9 +23,9 @@ function runProperty(n) {
function runString(n) {
const object = {};
- var i = 0;
+
bench.start();
- for (; i < n; i++) {
+ for (let i = 0; i < n; i++) {
object['p1'] = 21;
object['p2'] = 21;
object['p1'] += object['p2'];
@@ -37,9 +37,9 @@ function runVariable(n) {
const object = {};
const var1 = 'p1';
const var2 = 'p2';
- var i = 0;
+
bench.start();
- for (; i < n; i++) {
+ for (let i = 0; i < n; i++) {
object[var1] = 21;
object[var2] = 21;
object[var1] += object[var2];
@@ -51,9 +51,9 @@ function runSymbol(n) {
const object = {};
const symbol1 = Symbol('p1');
const symbol2 = Symbol('p2');
- var i = 0;
+
bench.start();
- for (; i < n; i++) {
+ for (let i = 0; i < n; i++) {
object[symbol1] = 21;
object[symbol2] = 21;
object[symbol1] += object[symbol2];
diff --git a/benchmark/misc/punycode.js b/benchmark/misc/punycode.js
index 18023419709ee5..5f85df758ef7e3 100644
--- a/benchmark/misc/punycode.js
+++ b/benchmark/misc/punycode.js
@@ -45,18 +45,17 @@ function usingICU(val) {
}
function runPunycode(n, val) {
- var i = 0;
- for (; i < n; i++)
+ for (let i = 0; i < n; i++)
usingPunycode(val);
bench.start();
- for (i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
usingPunycode(val);
bench.end(n);
}
function runICU(n, val) {
bench.start();
- for (var i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
usingICU(val);
bench.end(n);
}
diff --git a/benchmark/misc/trace.js b/benchmark/misc/trace.js
index d76f53cf04e82d..bdbf547007e72e 100644
--- a/benchmark/misc/trace.js
+++ b/benchmark/misc/trace.js
@@ -15,7 +15,7 @@ const {
function doTrace(n, trace) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
trace(kBeforeEvent, 'foo', 'test', 0, 'test');
}
bench.end(n);
@@ -23,7 +23,7 @@ function doTrace(n, trace) {
function doIsTraceCategoryEnabled(n, isTraceCategoryEnabled) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
isTraceCategoryEnabled('foo');
isTraceCategoryEnabled('bar');
}
diff --git a/benchmark/misc/util-extend-vs-object-assign.js b/benchmark/misc/util-extend-vs-object-assign.js
index 3880711b660fe1..b3d95f0e2d97a4 100644
--- a/benchmark/misc/util-extend-vs-object-assign.js
+++ b/benchmark/misc/util-extend-vs-object-assign.js
@@ -22,13 +22,13 @@ function main({ n, type }) {
// Force-optimize the method to test so that the benchmark doesn't
// get disrupted by the optimizer kicking in halfway through.
- for (var i = 0; i < type.length * 10; i += 1)
+ for (let i = 0; i < type.length * 10; i += 1)
fn({}, process.env);
const obj = new Proxy({}, { set: function(a, b, c) { return true; } });
bench.start();
- for (var j = 0; j < n; j += 1)
+ for (let j = 0; j < n; j += 1)
fn(obj, process.env);
bench.end(n);
}
diff --git a/benchmark/module/module-loader-deep.js b/benchmark/module/module-loader-deep.js
index f686b8df47dfba..5b4f4b907a7ce6 100644
--- a/benchmark/module/module-loader-deep.js
+++ b/benchmark/module/module-loader-deep.js
@@ -19,7 +19,7 @@ function main({ ext, cache, files }) {
`${benchmarkDirectory}/a.js`,
'module.exports = {};'
);
- for (var i = 0; i <= files; i++) {
+ for (let i = 0; i <= files; i++) {
fs.mkdirSync(`${benchmarkDirectory}/${i}`);
fs.writeFileSync(
`${benchmarkDirectory}/${i}/package.json`,
@@ -37,14 +37,13 @@ function main({ ext, cache, files }) {
}
function measureDir(cache, files) {
- var i;
if (cache) {
- for (i = 0; i <= files; i++) {
+ for (let i = 0; i <= files; i++) {
require(`${benchmarkDirectory}/${i}`);
}
}
bench.start();
- for (i = 0; i <= files; i++) {
+ for (let i = 0; i <= files; i++) {
require(`${benchmarkDirectory}/${i}`);
}
bench.end(files);
diff --git a/benchmark/module/module-loader.js b/benchmark/module/module-loader.js
index 3b8e9be2d60636..f31ac8722cb208 100644
--- a/benchmark/module/module-loader.js
+++ b/benchmark/module/module-loader.js
@@ -21,7 +21,7 @@ const bench = common.createBenchmark(main, {
function main({ n, name, cache, files, dir }) {
tmpdir.refresh();
fs.mkdirSync(benchmarkDirectory);
- for (var i = 0; i <= files; i++) {
+ for (let i = 0; i <= files; i++) {
fs.mkdirSync(`${benchmarkDirectory}${i}`);
fs.writeFileSync(
`${benchmarkDirectory}${i}/package.json`,
@@ -42,15 +42,14 @@ function main({ n, name, cache, files, dir }) {
}
function measureDir(n, cache, files, name) {
- var i;
if (cache) {
- for (i = 0; i <= files; i++) {
+ for (let i = 0; i <= files; i++) {
require(`${benchmarkDirectory}${i}${name}`);
}
}
bench.start();
- for (i = 0; i <= files; i++) {
- for (var j = 0; j < n; j++)
+ for (let i = 0; i <= files; i++) {
+ for (let j = 0; j < n; j++)
require(`${benchmarkDirectory}${i}${name}`);
// Pretend mixed input (otherwise the results are less representative due to
// highly specialized code).
diff --git a/benchmark/napi/function_args/index.js b/benchmark/napi/function_args/index.js
index 8f13454944772e..8ce9fa9d528f5c 100644
--- a/benchmark/napi/function_args/index.js
+++ b/benchmark/napi/function_args/index.js
@@ -89,7 +89,7 @@ function main({ n, engine, type }) {
const args = generateArgs(type);
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
fn.apply(null, args);
}
bench.end(n);
diff --git a/benchmark/napi/function_call/index.js b/benchmark/napi/function_call/index.js
index 3eebf9c05acdb1..1e1d159c8ad83a 100644
--- a/benchmark/napi/function_call/index.js
+++ b/benchmark/napi/function_call/index.js
@@ -29,7 +29,7 @@ try {
}
const napi = napi_binding.hello;
-var c = 0;
+let c = 0;
function js() {
return c++;
}
@@ -44,7 +44,7 @@ const bench = common.createBenchmark(main, {
function main({ n, type }) {
const fn = type === 'cxx' ? cxx : type === 'napi' ? napi : js;
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
fn();
}
bench.end(n);
diff --git a/benchmark/net/net-c2s-cork.js b/benchmark/net/net-c2s-cork.js
index 12d15fe0795e57..1493cae68d0069 100644
--- a/benchmark/net/net-c2s-cork.js
+++ b/benchmark/net/net-c2s-cork.js
@@ -11,8 +11,8 @@ const bench = common.createBenchmark(main, {
dur: [5],
});
-var chunk;
-var encoding;
+let chunk;
+let encoding;
function main({ dur, len, type }) {
switch (type) {
diff --git a/benchmark/net/net-c2s.js b/benchmark/net/net-c2s.js
index 4b64cbeca18124..cacd6815630b2e 100644
--- a/benchmark/net/net-c2s.js
+++ b/benchmark/net/net-c2s.js
@@ -11,8 +11,8 @@ const bench = common.createBenchmark(main, {
dur: [5],
});
-var chunk;
-var encoding;
+let chunk;
+let encoding;
function main({ dur, len, type }) {
switch (type) {
diff --git a/benchmark/net/net-pipe.js b/benchmark/net/net-pipe.js
index 06426129f7f271..d86ff73041d845 100644
--- a/benchmark/net/net-pipe.js
+++ b/benchmark/net/net-pipe.js
@@ -11,8 +11,8 @@ const bench = common.createBenchmark(main, {
dur: [5],
});
-var chunk;
-var encoding;
+let chunk;
+let encoding;
function main({ dur, len, type }) {
switch (type) {
diff --git a/benchmark/net/net-s2c.js b/benchmark/net/net-s2c.js
index d8c26db9bdb035..789eadf0a18dba 100644
--- a/benchmark/net/net-s2c.js
+++ b/benchmark/net/net-s2c.js
@@ -12,10 +12,10 @@ const bench = common.createBenchmark(main, {
dur: [5]
});
-var chunk;
-var encoding;
-var recvbuf;
-var received = 0;
+let chunk;
+let encoding;
+let recvbuf;
+let received = 0;
function main({ dur, sendchunklen, type, recvbuflen, recvbufgenfn }) {
if (isFinite(recvbuflen) && recvbuflen > 0)
@@ -38,8 +38,8 @@ function main({ dur, sendchunklen, type, recvbuflen, recvbufgenfn }) {
}
const reader = new Reader();
- var writer;
- var socketOpts;
+ let writer;
+ let socketOpts;
if (recvbuf === undefined) {
writer = new Writer();
socketOpts = { port: PORT };
diff --git a/benchmark/net/net-wrap-js-stream-passthrough.js b/benchmark/net/net-wrap-js-stream-passthrough.js
index 1e8a1ee1c5a092..0d7be36c6aa545 100644
--- a/benchmark/net/net-wrap-js-stream-passthrough.js
+++ b/benchmark/net/net-wrap-js-stream-passthrough.js
@@ -12,8 +12,8 @@ const bench = common.createBenchmark(main, {
flags: ['--expose-internals']
});
-var chunk;
-var encoding;
+let chunk;
+let encoding;
function main({ dur, len, type }) {
// Can only require internals inside main().
diff --git a/benchmark/net/tcp-raw-c2s.js b/benchmark/net/tcp-raw-c2s.js
index fe320ddaa2716b..b8af124a7f40fc 100644
--- a/benchmark/net/tcp-raw-c2s.js
+++ b/benchmark/net/tcp-raw-c2s.js
@@ -24,7 +24,7 @@ function main({ dur, len, type }) {
const PORT = common.PORT;
const serverHandle = new TCP(TCPConstants.SERVER);
- var err = serverHandle.bind('127.0.0.1', PORT);
+ let err = serverHandle.bind('127.0.0.1', PORT);
if (err)
fail(err, 'bind');
@@ -38,7 +38,7 @@ function main({ dur, len, type }) {
// The meat of the benchmark is right here:
bench.start();
- var bytes = 0;
+ let bytes = 0;
setTimeout(() => {
// report in Gb/sec
@@ -67,7 +67,7 @@ function main({ dur, len, type }) {
}
function client(type, len) {
- var chunk;
+ let chunk;
switch (type) {
case 'buf':
chunk = Buffer.alloc(len, 'x');
@@ -102,7 +102,7 @@ function main({ dur, len, type }) {
function write() {
const writeReq = new WriteWrap();
writeReq.oncomplete = afterWrite;
- var err;
+ let err;
switch (type) {
case 'buf':
err = clientHandle.writeBuffer(writeReq, chunk);
diff --git a/benchmark/net/tcp-raw-pipe.js b/benchmark/net/tcp-raw-pipe.js
index 4420cc2e6dcc17..249b61046a84cf 100644
--- a/benchmark/net/tcp-raw-pipe.js
+++ b/benchmark/net/tcp-raw-pipe.js
@@ -31,7 +31,7 @@ function main({ dur, len, type }) {
// Server
const serverHandle = new TCP(TCPConstants.SERVER);
- var err = serverHandle.bind('127.0.0.1', PORT);
+ let err = serverHandle.bind('127.0.0.1', PORT);
if (err)
fail(err, 'bind');
@@ -66,7 +66,7 @@ function main({ dur, len, type }) {
};
// Client
- var chunk;
+ let chunk;
switch (type) {
case 'buf':
chunk = Buffer.alloc(len, 'x');
@@ -83,7 +83,7 @@ function main({ dur, len, type }) {
const clientHandle = new TCP(TCPConstants.SOCKET);
const connectReq = new TCPConnectWrap();
- var bytes = 0;
+ let bytes = 0;
err = clientHandle.connect(connectReq, '127.0.0.1', PORT);
if (err)
@@ -118,7 +118,7 @@ function main({ dur, len, type }) {
function write() {
const writeReq = new WriteWrap();
writeReq.oncomplete = afterWrite;
- var err;
+ let err;
switch (type) {
case 'buf':
err = clientHandle.writeBuffer(writeReq, chunk);
diff --git a/benchmark/net/tcp-raw-s2c.js b/benchmark/net/tcp-raw-s2c.js
index cc2f69019fff61..393cf060489cb8 100644
--- a/benchmark/net/tcp-raw-s2c.js
+++ b/benchmark/net/tcp-raw-s2c.js
@@ -26,7 +26,7 @@ function main({ dur, len, type }) {
const PORT = common.PORT;
const serverHandle = new TCP(TCPConstants.SERVER);
- var err = serverHandle.bind('127.0.0.1', PORT);
+ let err = serverHandle.bind('127.0.0.1', PORT);
if (err)
fail(err, 'bind');
@@ -38,7 +38,7 @@ function main({ dur, len, type }) {
if (err)
fail(err, 'connect');
- var chunk;
+ let chunk;
switch (type) {
case 'buf':
chunk = Buffer.alloc(len, 'x');
@@ -62,7 +62,7 @@ function main({ dur, len, type }) {
const writeReq = new WriteWrap();
writeReq.async = false;
writeReq.oncomplete = afterWrite;
- var err;
+ let err;
switch (type) {
case 'buf':
err = clientHandle.writeBuffer(writeReq, chunk);
@@ -108,7 +108,7 @@ function main({ dur, len, type }) {
fail(err, 'connect');
connectReq.oncomplete = function() {
- var bytes = 0;
+ let bytes = 0;
clientHandle.onread = function(buffer) {
// We're not expecting to ever get an EOF from the client.
// Just lots of data forever.
diff --git a/benchmark/os/cpus.js b/benchmark/os/cpus.js
index da158a1b061c7f..a8aa3ab6cbf46f 100644
--- a/benchmark/os/cpus.js
+++ b/benchmark/os/cpus.js
@@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {
function main({ n }) {
bench.start();
- for (var i = 0; i < n; ++i)
+ for (let i = 0; i < n; ++i)
cpus();
bench.end(n);
}
diff --git a/benchmark/os/loadavg.js b/benchmark/os/loadavg.js
index 2cd38316b24bdd..802e3c99ec0a59 100644
--- a/benchmark/os/loadavg.js
+++ b/benchmark/os/loadavg.js
@@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {
function main({ n }) {
bench.start();
- for (var i = 0; i < n; ++i)
+ for (let i = 0; i < n; ++i)
loadavg();
bench.end(n);
}
diff --git a/benchmark/os/networkInterfaces.js b/benchmark/os/networkInterfaces.js
index 3fa6073ae5c69e..12e956b7f05ddc 100644
--- a/benchmark/os/networkInterfaces.js
+++ b/benchmark/os/networkInterfaces.js
@@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {
function main({ n }) {
bench.start();
- for (var i = 0; i < n; ++i)
+ for (let i = 0; i < n; ++i)
networkInterfaces();
bench.end(n);
}
diff --git a/benchmark/path/basename-posix.js b/benchmark/path/basename-posix.js
index 45cad1e25660dc..6600068d4c53f6 100644
--- a/benchmark/path/basename-posix.js
+++ b/benchmark/path/basename-posix.js
@@ -19,7 +19,7 @@ const bench = common.createBenchmark(main, {
});
function main({ n, pathext }) {
- var ext;
+ let ext;
const extIdx = pathext.indexOf('|');
if (extIdx !== -1) {
ext = pathext.slice(extIdx + 1);
@@ -27,7 +27,7 @@ function main({ n, pathext }) {
}
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
posix.basename(i % 3 === 0 ? `${pathext}${i}` : pathext, ext);
}
bench.end(n);
diff --git a/benchmark/path/basename-win32.js b/benchmark/path/basename-win32.js
index 30d65f3ac6a4c9..dc26a134e29252 100644
--- a/benchmark/path/basename-win32.js
+++ b/benchmark/path/basename-win32.js
@@ -19,7 +19,7 @@ const bench = common.createBenchmark(main, {
});
function main({ n, pathext }) {
- var ext;
+ let ext;
const extIdx = pathext.indexOf('|');
if (extIdx !== -1) {
ext = pathext.slice(extIdx + 1);
@@ -27,7 +27,7 @@ function main({ n, pathext }) {
}
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
win32.basename(i % 3 === 0 ? `${pathext}${i}` : pathext, ext);
}
bench.end(n);
diff --git a/benchmark/path/dirname-posix.js b/benchmark/path/dirname-posix.js
index 93f2f32c012695..c98753562fbc93 100644
--- a/benchmark/path/dirname-posix.js
+++ b/benchmark/path/dirname-posix.js
@@ -17,7 +17,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
posix.dirname(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
diff --git a/benchmark/path/dirname-win32.js b/benchmark/path/dirname-win32.js
index 510595d721ace1..9eb5478b3b4d3b 100644
--- a/benchmark/path/dirname-win32.js
+++ b/benchmark/path/dirname-win32.js
@@ -17,7 +17,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
win32.dirname(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
diff --git a/benchmark/path/extname-posix.js b/benchmark/path/extname-posix.js
index ee1ea07eebc010..0e01d59a745883 100644
--- a/benchmark/path/extname-posix.js
+++ b/benchmark/path/extname-posix.js
@@ -20,7 +20,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
posix.extname(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
diff --git a/benchmark/path/extname-win32.js b/benchmark/path/extname-win32.js
index 1de4bca28a2988..6d8437e5c5d819 100644
--- a/benchmark/path/extname-win32.js
+++ b/benchmark/path/extname-win32.js
@@ -20,7 +20,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
win32.extname(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
diff --git a/benchmark/path/format-posix.js b/benchmark/path/format-posix.js
index 9c555f232c0099..7720bbc3b705ed 100644
--- a/benchmark/path/format-posix.js
+++ b/benchmark/path/format-posix.js
@@ -20,7 +20,7 @@ function main({ n, props }) {
};
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
obj.base = `a${i}${props[2] || ''}`;
obj.name = `a${i}${props[4] || ''}`;
posix.format(obj);
diff --git a/benchmark/path/format-win32.js b/benchmark/path/format-win32.js
index 65315c4dd638f1..fab7599ab58386 100644
--- a/benchmark/path/format-win32.js
+++ b/benchmark/path/format-win32.js
@@ -20,7 +20,7 @@ function main({ n, props }) {
};
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
obj.base = `a${i}${props[2] || ''}`;
obj.name = `a${i}${props[4] || ''}`;
win32.format(obj);
diff --git a/benchmark/path/isAbsolute-posix.js b/benchmark/path/isAbsolute-posix.js
index dd0dfd1964e0fb..90d06502d1fb02 100644
--- a/benchmark/path/isAbsolute-posix.js
+++ b/benchmark/path/isAbsolute-posix.js
@@ -15,7 +15,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
posix.isAbsolute(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
diff --git a/benchmark/path/isAbsolute-win32.js b/benchmark/path/isAbsolute-win32.js
index ff03f2628a328c..15da64f5e973a3 100644
--- a/benchmark/path/isAbsolute-win32.js
+++ b/benchmark/path/isAbsolute-win32.js
@@ -16,7 +16,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
win32.isAbsolute(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
diff --git a/benchmark/path/join-posix.js b/benchmark/path/join-posix.js
index e573166d7ae078..6619e4dea852db 100644
--- a/benchmark/path/join-posix.js
+++ b/benchmark/path/join-posix.js
@@ -15,7 +15,7 @@ function main({ n, paths }) {
const orig = copy[1];
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
if (i % 3 === 0) {
copy[1] = `${orig}${i}`;
posix.join(...copy);
diff --git a/benchmark/path/join-win32.js b/benchmark/path/join-win32.js
index cd69836c006e23..958dee706d499a 100644
--- a/benchmark/path/join-win32.js
+++ b/benchmark/path/join-win32.js
@@ -15,7 +15,7 @@ function main({ n, paths }) {
const orig = copy[1];
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
if (i % 3 === 0) {
copy[1] = `${orig}${i}`;
win32.join(...copy);
diff --git a/benchmark/path/makeLong-win32.js b/benchmark/path/makeLong-win32.js
index 45d0d8de60d7e0..864a9cfffe63b9 100644
--- a/benchmark/path/makeLong-win32.js
+++ b/benchmark/path/makeLong-win32.js
@@ -14,7 +14,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
win32._makeLong(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
diff --git a/benchmark/path/normalize-posix.js b/benchmark/path/normalize-posix.js
index 4383cff4a588f7..e0722097025020 100644
--- a/benchmark/path/normalize-posix.js
+++ b/benchmark/path/normalize-posix.js
@@ -16,7 +16,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
posix.normalize(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
diff --git a/benchmark/path/normalize-win32.js b/benchmark/path/normalize-win32.js
index 319c391d17a712..84e16ca3c2d0e9 100644
--- a/benchmark/path/normalize-win32.js
+++ b/benchmark/path/normalize-win32.js
@@ -16,7 +16,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
win32.normalize(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
diff --git a/benchmark/path/relative-posix.js b/benchmark/path/relative-posix.js
index 2c4dd31d2778c7..0285c2c968dcb2 100644
--- a/benchmark/path/relative-posix.js
+++ b/benchmark/path/relative-posix.js
@@ -16,7 +16,7 @@ const bench = common.createBenchmark(main, {
});
function main({ n, paths }) {
- var to = '';
+ let to = '';
const delimIdx = paths.indexOf('|');
if (delimIdx > -1) {
to = paths.slice(delimIdx + 1);
diff --git a/benchmark/path/relative-win32.js b/benchmark/path/relative-win32.js
index 5f34fdf8fd5842..401919aa20d802 100644
--- a/benchmark/path/relative-win32.js
+++ b/benchmark/path/relative-win32.js
@@ -14,7 +14,7 @@ const bench = common.createBenchmark(main, {
});
function main({ n, paths }) {
- var to = '';
+ let to = '';
const delimIdx = paths.indexOf('|');
if (delimIdx > -1) {
to = paths.slice(delimIdx + 1);
diff --git a/benchmark/path/resolve-posix.js b/benchmark/path/resolve-posix.js
index 3cdf1cd49a0754..dbae350c62a35f 100644
--- a/benchmark/path/resolve-posix.js
+++ b/benchmark/path/resolve-posix.js
@@ -18,7 +18,7 @@ function main({ n, paths }) {
const orig = copy[0];
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
if (i % 3 === 0) {
copy[0] = `${orig}${i}`;
posix.resolve(...copy);
diff --git a/benchmark/path/resolve-win32.js b/benchmark/path/resolve-win32.js
index cf8144ef2c57cd..7def7aa1025d50 100644
--- a/benchmark/path/resolve-win32.js
+++ b/benchmark/path/resolve-win32.js
@@ -18,7 +18,7 @@ function main({ n, paths }) {
const orig = copy[0];
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
if (i % 3 === 0) {
copy[0] = `${orig}${i}`;
win32.resolve(...copy);
diff --git a/benchmark/process/bench-hrtime.js b/benchmark/process/bench-hrtime.js
index d73ed7aae4336e..2da9035f806cf9 100644
--- a/benchmark/process/bench-hrtime.js
+++ b/benchmark/process/bench-hrtime.js
@@ -10,27 +10,26 @@ const bench = common.createBenchmark(main, {
function main({ n, type }) {
const hrtime = process.hrtime;
- var noDead = type === 'bigint' ? hrtime.bigint() : hrtime();
- var i;
+ let noDead = type === 'bigint' ? hrtime.bigint() : hrtime();
switch (type) {
case 'raw':
bench.start();
- for (i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
noDead = hrtime();
}
bench.end(n);
break;
case 'diff':
bench.start();
- for (i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
noDead = hrtime(noDead);
}
bench.end(n);
break;
case 'bigint':
bench.start();
- for (i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
noDead = hrtime.bigint();
}
bench.end(n);
diff --git a/benchmark/process/memoryUsage.js b/benchmark/process/memoryUsage.js
index f9b969ab885d8b..1c743d81f1f465 100644
--- a/benchmark/process/memoryUsage.js
+++ b/benchmark/process/memoryUsage.js
@@ -7,7 +7,7 @@ const bench = common.createBenchmark(main, {
function main({ n }) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
process.memoryUsage();
}
bench.end(n);
diff --git a/benchmark/process/next-tick-breadth-args.js b/benchmark/process/next-tick-breadth-args.js
index 03651dbdbb4eea..bd3b24ddc29fc5 100644
--- a/benchmark/process/next-tick-breadth-args.js
+++ b/benchmark/process/next-tick-breadth-args.js
@@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
});
function main({ n }) {
- var j = 0;
+ let j = 0;
function cb1(arg1) {
j++;
@@ -33,7 +33,7 @@ function main({ n }) {
}
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
if (i % 4 === 0)
process.nextTick(cb4, 3.14, 1024, true, false);
else if (i % 3 === 0)
diff --git a/benchmark/process/next-tick-breadth.js b/benchmark/process/next-tick-breadth.js
index 297bf43495d2e6..eb34ea830acfe7 100644
--- a/benchmark/process/next-tick-breadth.js
+++ b/benchmark/process/next-tick-breadth.js
@@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
});
function main({ n }) {
- var j = 0;
+ let j = 0;
function cb() {
j++;
@@ -15,7 +15,7 @@ function main({ n }) {
}
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
process.nextTick(cb);
}
}
diff --git a/benchmark/process/next-tick-exec-args.js b/benchmark/process/next-tick-exec-args.js
index ec172ea8931e3f..7893e2c70903e5 100644
--- a/benchmark/process/next-tick-exec-args.js
+++ b/benchmark/process/next-tick-exec-args.js
@@ -10,7 +10,7 @@ function main({ n }) {
bench.end(n);
}
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
if (i % 4 === 0)
process.nextTick(onNextTick, i, true, 10, 'test');
else if (i % 3 === 0)
diff --git a/benchmark/process/next-tick-exec.js b/benchmark/process/next-tick-exec.js
index 14fce9cccf8d6a..eefe2b7ceb765f 100644
--- a/benchmark/process/next-tick-exec.js
+++ b/benchmark/process/next-tick-exec.js
@@ -10,7 +10,7 @@ function main({ n }) {
bench.end(n);
}
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
process.nextTick(onNextTick, i);
}
diff --git a/benchmark/process/queue-microtask-breadth.js b/benchmark/process/queue-microtask-breadth.js
index 8bb33f6fdee6cc..610dfc584ef738 100644
--- a/benchmark/process/queue-microtask-breadth.js
+++ b/benchmark/process/queue-microtask-breadth.js
@@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
});
function main({ n }) {
- var j = 0;
+ let j = 0;
function cb() {
j++;
@@ -15,7 +15,7 @@ function main({ n }) {
}
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
queueMicrotask(cb);
}
}
diff --git a/benchmark/querystring/querystring-parse.js b/benchmark/querystring/querystring-parse.js
index ca4dca13bc14eb..2a5f3048de46b9 100644
--- a/benchmark/querystring/querystring-parse.js
+++ b/benchmark/querystring/querystring-parse.js
@@ -10,23 +10,23 @@ const bench = common.createBenchmark(main, {
function main({ type, n }) {
const input = inputs[type];
- var i;
+
// Execute the function a "sufficient" number of times before the timed
// loop to ensure the function is optimized just once.
if (type === 'multicharsep') {
- for (i = 0; i < n; i += 1)
+ for (let i = 0; i < n; i += 1)
querystring.parse(input, '&&&&&&&&&&');
bench.start();
- for (i = 0; i < n; i += 1)
+ for (let i = 0; i < n; i += 1)
querystring.parse(input, '&&&&&&&&&&');
bench.end(n);
} else {
- for (i = 0; i < n; i += 1)
+ for (let i = 0; i < n; i += 1)
querystring.parse(input);
bench.start();
- for (i = 0; i < n; i += 1)
+ for (let i = 0; i < n; i += 1)
querystring.parse(input);
bench.end(n);
}
diff --git a/benchmark/querystring/querystring-stringify.js b/benchmark/querystring/querystring-stringify.js
index 6c5da0f464034f..be81f67fa826d7 100644
--- a/benchmark/querystring/querystring-stringify.js
+++ b/benchmark/querystring/querystring-stringify.js
@@ -38,7 +38,7 @@ function main({ type, n }) {
querystring.stringify(inputs[name]);
bench.start();
- for (var i = 0; i < n; i += 1)
+ for (let i = 0; i < n; i += 1)
querystring.stringify(input);
bench.end(n);
}
diff --git a/benchmark/querystring/querystring-unescapebuffer.js b/benchmark/querystring/querystring-unescapebuffer.js
index 39dd085eda938c..e6b842b3f94127 100644
--- a/benchmark/querystring/querystring-unescapebuffer.js
+++ b/benchmark/querystring/querystring-unescapebuffer.js
@@ -14,7 +14,7 @@ const bench = common.createBenchmark(main, {
function main({ input, n }) {
bench.start();
- for (var i = 0; i < n; i += 1)
+ for (let i = 0; i < n; i += 1)
querystring.unescapeBuffer(input);
bench.end(n);
}
diff --git a/benchmark/streams/creation.js b/benchmark/streams/creation.js
index 46a0a547907c45..760ab5c89dca96 100644
--- a/benchmark/streams/creation.js
+++ b/benchmark/streams/creation.js
@@ -13,14 +13,13 @@ const bench = common.createBenchmark(main, {
});
function main({ n, kind }) {
- var i = 0;
switch (kind) {
case 'duplex':
new Duplex({});
new Duplex();
bench.start();
- for (; i < n; ++i)
+ for (let i = 0; i < n; ++i)
new Duplex();
bench.end(n);
break;
@@ -29,7 +28,7 @@ function main({ n, kind }) {
new Readable();
bench.start();
- for (; i < n; ++i)
+ for (let i = 0; i < n; ++i)
new Readable();
bench.end(n);
break;
@@ -38,7 +37,7 @@ function main({ n, kind }) {
new Writable();
bench.start();
- for (; i < n; ++i)
+ for (let i = 0; i < n; ++i)
new Writable();
bench.end(n);
break;
@@ -47,7 +46,7 @@ function main({ n, kind }) {
new Transform();
bench.start();
- for (; i < n; ++i)
+ for (let i = 0; i < n; ++i)
new Transform();
bench.end(n);
break;
diff --git a/benchmark/streams/pipe-object-mode.js b/benchmark/streams/pipe-object-mode.js
index d52b2238780ccb..33588819f00a6c 100644
--- a/benchmark/streams/pipe-object-mode.js
+++ b/benchmark/streams/pipe-object-mode.js
@@ -12,7 +12,7 @@ function main({ n }) {
const r = new Readable({ objectMode: true });
const w = new Writable({ objectMode: true });
- var i = 0;
+ let i = 0;
r._read = () => r.push(i++ === n ? null : b);
w._write = (data, enc, cb) => cb();
diff --git a/benchmark/streams/pipe.js b/benchmark/streams/pipe.js
index 4baeeb2d2e7706..0df1afdbe10134 100644
--- a/benchmark/streams/pipe.js
+++ b/benchmark/streams/pipe.js
@@ -12,7 +12,7 @@ function main({ n }) {
const r = new Readable();
const w = new Writable();
- var i = 0;
+ let i = 0;
r._read = () => r.push(i++ === n ? null : b);
w._write = (data, enc, cb) => cb();
diff --git a/benchmark/streams/readable-bigread.js b/benchmark/streams/readable-bigread.js
index c3cff3d933d915..1bd1dab4edb07f 100644
--- a/benchmark/streams/readable-bigread.js
+++ b/benchmark/streams/readable-bigread.js
@@ -14,8 +14,8 @@ function main({ n }) {
s._read = noop;
bench.start();
- for (var k = 0; k < n; ++k) {
- for (var i = 0; i < 1e4; ++i)
+ for (let k = 0; k < n; ++k) {
+ for (let i = 0; i < 1e4; ++i)
s.push(b);
while (s.read(128));
}
diff --git a/benchmark/streams/readable-bigunevenread.js b/benchmark/streams/readable-bigunevenread.js
index 95a4139c069e87..684986a778aba2 100644
--- a/benchmark/streams/readable-bigunevenread.js
+++ b/benchmark/streams/readable-bigunevenread.js
@@ -14,8 +14,8 @@ function main({ n }) {
s._read = noop;
bench.start();
- for (var k = 0; k < n; ++k) {
- for (var i = 0; i < 1e4; ++i)
+ for (let k = 0; k < n; ++k) {
+ for (let i = 0; i < 1e4; ++i)
s.push(b);
while (s.read(106));
}
diff --git a/benchmark/streams/readable-boundaryread.js b/benchmark/streams/readable-boundaryread.js
index 835c7d18b51285..edc90d04de161d 100644
--- a/benchmark/streams/readable-boundaryread.js
+++ b/benchmark/streams/readable-boundaryread.js
@@ -10,14 +10,14 @@ const bench = common.createBenchmark(main, {
function main({ n, type }) {
const s = new Readable();
- var data = 'a'.repeat(32);
+ let data = 'a'.repeat(32);
if (type === 'buffer')
data = Buffer.from(data);
s._read = function() {};
bench.start();
- for (var k = 0; k < n; ++k) {
- for (var i = 0; i < 1e4; ++i)
+ for (let k = 0; k < n; ++k) {
+ for (let i = 0; i < 1e4; ++i)
s.push(data);
while (s.read(32));
}
diff --git a/benchmark/streams/readable-readall.js b/benchmark/streams/readable-readall.js
index 3c177ec4c39988..d14fd7756586e9 100644
--- a/benchmark/streams/readable-readall.js
+++ b/benchmark/streams/readable-readall.js
@@ -14,8 +14,8 @@ function main({ n }) {
s._read = noop;
bench.start();
- for (var k = 0; k < n; ++k) {
- for (var i = 0; i < 1e4; ++i)
+ for (let k = 0; k < n; ++k) {
+ for (let i = 0; i < 1e4; ++i)
s.push(b);
while (s.read());
}
diff --git a/benchmark/streams/readable-unevenread.js b/benchmark/streams/readable-unevenread.js
index 690f1f420838c6..9da8410131bfff 100644
--- a/benchmark/streams/readable-unevenread.js
+++ b/benchmark/streams/readable-unevenread.js
@@ -14,8 +14,8 @@ function main({ n }) {
s._read = noop;
bench.start();
- for (var k = 0; k < n; ++k) {
- for (var i = 0; i < 1e4; ++i)
+ for (let k = 0; k < n; ++k) {
+ for (let i = 0; i < 1e4; ++i)
s.push(b);
while (s.read(12));
}
diff --git a/benchmark/streams/writable-manywrites.js b/benchmark/streams/writable-manywrites.js
index 049bf8eb281db2..e4ae9ab91e5f4a 100644
--- a/benchmark/streams/writable-manywrites.js
+++ b/benchmark/streams/writable-manywrites.js
@@ -35,8 +35,10 @@ function main({ n, sync, writev, callback }) {
let k = 0;
function run() {
while (k++ < n && s.write(b, cb));
- if (k >= n)
+ if (k >= n) {
bench.end(n);
+ s.removeListener('drain', run);
+ }
}
s.on('drain', run);
run();
diff --git a/benchmark/string_decoder/string-decoder-create.js b/benchmark/string_decoder/string-decoder-create.js
index fad727222e1870..f7fa5e0246b860 100644
--- a/benchmark/string_decoder/string-decoder-create.js
+++ b/benchmark/string_decoder/string-decoder-create.js
@@ -11,7 +11,7 @@ const bench = common.createBenchmark(main, {
function main({ encoding, n }) {
bench.start();
- for (var i = 0; i < n; ++i) {
+ for (let i = 0; i < n; ++i) {
const sd = new StringDecoder(encoding);
!!sd.encoding;
}
diff --git a/benchmark/string_decoder/string-decoder.js b/benchmark/string_decoder/string-decoder.js
index 0e34effbc7d964..afc0dde62e7937 100644
--- a/benchmark/string_decoder/string-decoder.js
+++ b/benchmark/string_decoder/string-decoder.js
@@ -14,12 +14,11 @@ const ASC_ALPHA = 'Blueberry jam';
const UTF16_BUF = Buffer.from('Blåbærsyltetøy', 'utf16le');
function main({ encoding, inLen, chunkLen, n }) {
- var alpha;
- var buf;
+ let alpha;
+ let buf;
const chunks = [];
- var str = '';
+ let str = '';
const isBase64 = (encoding === 'base64-ascii' || encoding === 'base64-utf8');
- var i;
if (encoding === 'ascii' || encoding === 'base64-ascii')
alpha = ASC_ALPHA;
@@ -33,7 +32,7 @@ function main({ encoding, inLen, chunkLen, n }) {
const sd = new StringDecoder(isBase64 ? 'base64' : encoding);
- for (i = 0; i < inLen; ++i) {
+ for (let i = 0; i < inLen; ++i) {
if (i > 0 && (i % chunkLen) === 0 && !isBase64) {
if (alpha) {
chunks.push(Buffer.from(str, encoding));
@@ -46,8 +45,8 @@ function main({ encoding, inLen, chunkLen, n }) {
if (alpha)
str += alpha[i % alpha.length];
else {
- var start = i;
- var end = i + 2;
+ let start = i;
+ let end = i + 2;
if (i % 2 !== 0) {
++start;
++end;
@@ -77,8 +76,8 @@ function main({ encoding, inLen, chunkLen, n }) {
const nChunks = chunks.length;
bench.start();
- for (i = 0; i < n; ++i) {
- for (var j = 0; j < nChunks; ++j)
+ for (let i = 0; i < n; ++i) {
+ for (let j = 0; j < nChunks; ++j)
sd.write(chunks[j]);
}
bench.end(n);
diff --git a/benchmark/timers/immediate.js b/benchmark/timers/immediate.js
index ba50f961daa6aa..d12106a0e030fc 100644
--- a/benchmark/timers/immediate.js
+++ b/benchmark/timers/immediate.js
@@ -66,7 +66,7 @@ function breadth(N) {
if (n === N)
bench.end(N);
}
- for (var i = 0; i < N; i++) {
+ for (let i = 0; i < N; i++) {
setImmediate(cb);
}
}
@@ -80,7 +80,7 @@ function breadth1(N) {
if (n === N)
bench.end(n);
}
- for (var i = 0; i < N; i++) {
+ for (let i = 0; i < N; i++) {
setImmediate(cb, 1);
}
}
@@ -95,7 +95,7 @@ function breadth4(N) {
if (n === N)
bench.end(n);
}
- for (var i = 0; i < N; i++) {
+ for (let i = 0; i < N; i++) {
setImmediate(cb, 1, 2, 3, 4);
}
}
@@ -107,7 +107,7 @@ function clear(N) {
if (a1 === 2)
bench.end(N);
}
- for (var i = 0; i < N; i++) {
+ for (let i = 0; i < N; i++) {
clearImmediate(setImmediate(cb, 1));
}
setImmediate(cb, 2);
diff --git a/benchmark/timers/timers-breadth-args.js b/benchmark/timers/timers-breadth-args.js
index bdb3adbbec6b7a..63a301dc9bc7dc 100644
--- a/benchmark/timers/timers-breadth-args.js
+++ b/benchmark/timers/timers-breadth-args.js
@@ -32,7 +32,7 @@ function main({ n }) {
}
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
if (i % 4 === 0)
setTimeout(cb4, 1, 3.14, 1024, true, false);
else if (i % 3 === 0)
diff --git a/benchmark/timers/timers-breadth.js b/benchmark/timers/timers-breadth.js
index 8cd77f4fab2852..78bd5a97ae84b8 100644
--- a/benchmark/timers/timers-breadth.js
+++ b/benchmark/timers/timers-breadth.js
@@ -13,7 +13,7 @@ function main({ n }) {
if (j === n)
bench.end(n);
}
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
setTimeout(cb, 1);
}
}
diff --git a/benchmark/timers/timers-cancel-pooled.js b/benchmark/timers/timers-cancel-pooled.js
index 6f16f3c91da8a8..5045983210263e 100644
--- a/benchmark/timers/timers-cancel-pooled.js
+++ b/benchmark/timers/timers-cancel-pooled.js
@@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {
function main({ n }) {
var timer = setTimeout(() => {}, 1);
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
setTimeout(cb, 1);
}
var next = timer._idlePrev;
@@ -17,7 +17,7 @@ function main({ n }) {
bench.start();
- for (var j = 0; j < n; j++) {
+ for (let j = 0; j < n; j++) {
timer = next;
next = timer._idlePrev;
clearTimeout(timer);
diff --git a/benchmark/timers/timers-cancel-unpooled.js b/benchmark/timers/timers-cancel-unpooled.js
index 1daf68bde0ed51..df203ee4810b1d 100644
--- a/benchmark/timers/timers-cancel-unpooled.js
+++ b/benchmark/timers/timers-cancel-unpooled.js
@@ -10,7 +10,7 @@ const bench = common.createBenchmark(main, {
function main({ n, direction }) {
const timersList = [];
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
timersList.push(setTimeout(cb, i + 1));
}
diff --git a/benchmark/timers/timers-insert-pooled.js b/benchmark/timers/timers-insert-pooled.js
index a7441a9eaf76f6..91b69d34514a86 100644
--- a/benchmark/timers/timers-insert-pooled.js
+++ b/benchmark/timers/timers-insert-pooled.js
@@ -9,7 +9,7 @@ function main({ n }) {
bench.start();
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
setTimeout(() => {}, 1);
}
diff --git a/benchmark/timers/timers-insert-unpooled.js b/benchmark/timers/timers-insert-unpooled.js
index 232cc7c31aff16..11d25d5fe79670 100644
--- a/benchmark/timers/timers-insert-unpooled.js
+++ b/benchmark/timers/timers-insert-unpooled.js
@@ -23,7 +23,7 @@ function main({ direction, n }) {
}
bench.end(n);
- for (var j = 0; j < n; j++) {
+ for (let j = 0; j < n; j++) {
clearTimeout(timersList[j]);
}
}
diff --git a/benchmark/timers/timers-timeout-nexttick.js b/benchmark/timers/timers-timeout-nexttick.js
index 638d8aec149cd5..784c8e0168dd28 100644
--- a/benchmark/timers/timers-timeout-nexttick.js
+++ b/benchmark/timers/timers-timeout-nexttick.js
@@ -30,7 +30,7 @@ function main({ n }) {
bench.end(n);
}
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
setTimeout(i % 2 ? cb : cb2, 1);
}
diff --git a/benchmark/timers/timers-timeout-pooled.js b/benchmark/timers/timers-timeout-pooled.js
index 1cdae07dc98bdc..eb54d3c7a0082a 100644
--- a/benchmark/timers/timers-timeout-pooled.js
+++ b/benchmark/timers/timers-timeout-pooled.js
@@ -27,7 +27,7 @@ function main({ n }) {
bench.end(n);
}
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
setTimeout(i % 2 ? cb : cb2, 1);
}
diff --git a/benchmark/timers/timers-timeout-unpooled.js b/benchmark/timers/timers-timeout-unpooled.js
index fecb73a36013b0..a7820805082047 100644
--- a/benchmark/timers/timers-timeout-unpooled.js
+++ b/benchmark/timers/timers-timeout-unpooled.js
@@ -27,7 +27,7 @@ function main({ n }) {
bench.end(n);
}
- for (var i = 0; i < n; i++) {
+ for (let i = 0; i < n; i++) {
// unref().ref() will cause each of these timers to
// allocate their own handle
setTimeout(i % 2 ? cb : cb2, 1).unref().ref();
diff --git a/benchmark/tls/convertprotocols.js b/benchmark/tls/convertprotocols.js
index 0ba6c6dd0873b5..74bb942bfcec4f 100644
--- a/benchmark/tls/convertprotocols.js
+++ b/benchmark/tls/convertprotocols.js
@@ -16,7 +16,7 @@ function main({ n }) {
m = {};
}
bench.start();
- for (var i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
tls.convertALPNProtocols(input, m);
bench.end(n);
}
diff --git a/benchmark/tls/tls-connect.js b/benchmark/tls/tls-connect.js
index 4300f6841f0cd6..1cb04d98a52721 100644
--- a/benchmark/tls/tls-connect.js
+++ b/benchmark/tls/tls-connect.js
@@ -31,7 +31,7 @@ function main(conf) {
function onListening() {
setTimeout(done, dur * 1000);
bench.start();
- for (var i = 0; i < concurrency; i++)
+ for (let i = 0; i < concurrency; i++)
makeConnection();
}
diff --git a/benchmark/url/legacy-vs-whatwg-url-get-prop.js b/benchmark/url/legacy-vs-whatwg-url-get-prop.js
index 16bcd226324ef8..fe0c464f52b3c9 100644
--- a/benchmark/url/legacy-vs-whatwg-url-get-prop.js
+++ b/benchmark/url/legacy-vs-whatwg-url-get-prop.js
@@ -71,9 +71,8 @@ function useWHATWG(data) {
}
function main({ type, method, e }) {
- e = +e;
- var data;
- var noDead; // Avoid dead code elimination.
+ let data;
+ let noDead; // Avoid dead code elimination.
switch (method) {
case 'legacy':
data = common.bakeUrlData(type, e, false, false);
diff --git a/benchmark/url/legacy-vs-whatwg-url-parse.js b/benchmark/url/legacy-vs-whatwg-url-parse.js
index 7c49654b47d8e2..6e5e25d231242f 100644
--- a/benchmark/url/legacy-vs-whatwg-url-parse.js
+++ b/benchmark/url/legacy-vs-whatwg-url-parse.js
@@ -46,7 +46,6 @@ function useWHATWGWithoutBase(data) {
}
function main({ e, method, type, withBase }) {
- e = +e;
withBase = withBase === 'true';
var noDead; // Avoid dead code elimination.
var data;
diff --git a/benchmark/url/legacy-vs-whatwg-url-serialize.js b/benchmark/url/legacy-vs-whatwg-url-serialize.js
index d6d8c8a4e71152..5523e549ceb233 100644
--- a/benchmark/url/legacy-vs-whatwg-url-serialize.js
+++ b/benchmark/url/legacy-vs-whatwg-url-serialize.js
@@ -35,7 +35,6 @@ function useWHATWG(data) {
}
function main({ type, e, method }) {
- e = +e;
const data = common.bakeUrlData(type, e, false, false);
var noDead; // Avoid dead code elimination.
diff --git a/benchmark/url/whatwg-url-properties.js b/benchmark/url/whatwg-url-properties.js
index 60f573e27a8fe2..ac71ff4f636d66 100644
--- a/benchmark/url/whatwg-url-properties.js
+++ b/benchmark/url/whatwg-url-properties.js
@@ -34,7 +34,6 @@ function get(data, prop) {
}
function main({ e, type, prop, withBase }) {
- e = +e;
withBase = withBase === 'true';
const data = common.bakeUrlData(type, e, withBase, true);
switch (prop) {
diff --git a/benchmark/v8/get-stats.js b/benchmark/v8/get-stats.js
index aa1f0516811983..d5ce102774df6e 100644
--- a/benchmark/v8/get-stats.js
+++ b/benchmark/v8/get-stats.js
@@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {
function main({ method, n }) {
bench.start();
- for (var i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
v8[method]();
bench.end(n);
}
diff --git a/benchmark/vm/run-in-context.js b/benchmark/vm/run-in-context.js
index 9b57067a19c9ac..980a08e7e56e8c 100644
--- a/benchmark/vm/run-in-context.js
+++ b/benchmark/vm/run-in-context.js
@@ -20,7 +20,7 @@ function main({ n, breakOnSigint, withSigintListener }) {
const contextifiedSandbox = vm.createContext();
bench.start();
- for (var i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
vm.runInContext('0', contextifiedSandbox, options);
bench.end(n);
}
diff --git a/benchmark/vm/run-in-this-context.js b/benchmark/vm/run-in-this-context.js
index 0754287376d58c..c612c1ea49ecf6 100644
--- a/benchmark/vm/run-in-this-context.js
+++ b/benchmark/vm/run-in-this-context.js
@@ -18,7 +18,7 @@ function main({ n, breakOnSigint, withSigintListener }) {
process.on('SIGINT', () => {});
bench.start();
- for (var i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
vm.runInThisContext('0', options);
bench.end(n);
}
diff --git a/benchmark/worker/echo.js b/benchmark/worker/echo.js
index 3e729d0e26fa04..8d45a1f76b5eac 100644
--- a/benchmark/worker/echo.js
+++ b/benchmark/worker/echo.js
@@ -1,6 +1,7 @@
'use strict';
const common = require('../common.js');
+const { Worker } = require('worker_threads');
const path = require('path');
const bench = common.createBenchmark(main, {
workers: [1],
@@ -11,19 +12,14 @@ const bench = common.createBenchmark(main, {
const workerPath = path.resolve(__dirname, '..', 'fixtures', 'echo.worker.js');
-function main(conf) {
- const { Worker } = require('worker_threads');
-
- const n = +conf.n;
- const workers = +conf.workers;
- const sends = +conf.sendsPerBroadcast;
+function main({ n, workers, sendsPerBroadcast: sends, payload: payloadType }) {
const expectedPerBroadcast = sends * workers;
- var payload;
- var readies = 0;
- var broadcasts = 0;
- var msgCount = 0;
+ let payload;
+ let readies = 0;
+ let broadcasts = 0;
+ let msgCount = 0;
- switch (conf.payload) {
+ switch (payloadType) {
case 'string':
payload = 'hello world!';
break;
@@ -36,7 +32,7 @@ function main(conf) {
const workerObjs = [];
- for (var i = 0; i < workers; ++i) {
+ for (let i = 0; i < workers; ++i) {
const worker = new Worker(workerPath);
workerObjs.push(worker);
worker.on('online', onOnline);
diff --git a/benchmark/worker/messageport.js b/benchmark/worker/messageport.js
new file mode 100644
index 00000000000000..8e2ddae73ff3ab
--- /dev/null
+++ b/benchmark/worker/messageport.js
@@ -0,0 +1,42 @@
+'use strict';
+
+const common = require('../common.js');
+const { MessageChannel } = require('worker_threads');
+const bench = common.createBenchmark(main, {
+ payload: ['string', 'object'],
+ n: [1e6]
+});
+
+function main(conf) {
+ const n = conf.n;
+ let payload;
+
+ switch (conf.payload) {
+ case 'string':
+ payload = 'hello world!';
+ break;
+ case 'object':
+ payload = { action: 'pewpewpew', powerLevel: 9001 };
+ break;
+ default:
+ throw new Error('Unsupported payload type');
+ }
+
+ const { port1, port2 } = new MessageChannel();
+
+ let messages = 0;
+ port2.onmessage = () => {
+ if (messages++ === n) {
+ bench.end(n);
+ port1.close();
+ } else {
+ write();
+ }
+ };
+ bench.start();
+ write();
+
+ function write() {
+ port1.postMessage(payload);
+ }
+}
diff --git a/benchmark/zlib/createInflate.js b/benchmark/zlib/createInflate.js
new file mode 100644
index 00000000000000..30ccaef7a14fb2
--- /dev/null
+++ b/benchmark/zlib/createInflate.js
@@ -0,0 +1,32 @@
+'use strict';
+const common = require('../common.js');
+const zlib = require('zlib');
+
+const bench = common.createBenchmark(main, {
+ inputLen: [16 * 1024 * 1024],
+ chunkLen: [1024],
+ n: [1e2]
+});
+
+function main({ n, inputLen, chunkLen }) {
+ const input = zlib.deflateSync(Buffer.alloc(inputLen, 'a'));
+
+ let i = 0;
+ bench.start();
+ (function next() {
+ let p = 0;
+ const inflater = zlib.createInflate();
+ inflater.resume();
+ inflater.on('finish', () => {
+ if (i++ === n)
+ return bench.end(n);
+ next();
+ });
+
+ (function nextChunk() {
+ if (p >= input.length)
+ return inflater.end();
+ inflater.write(input.slice(p, p += chunkLen), nextChunk);
+ })();
+ })();
+}
diff --git a/benchmark/zlib/deflate.js b/benchmark/zlib/deflate.js
index 5e86d659803747..6d3bda90c6fdfa 100644
--- a/benchmark/zlib/deflate.js
+++ b/benchmark/zlib/deflate.js
@@ -9,6 +9,8 @@ const bench = common.createBenchmark(main, {
});
function main({ n, method, inputLen }) {
+ // Default method value for testing.
+ method = method || 'deflate';
const chunk = Buffer.alloc(inputLen, 'a');
var i = 0;
diff --git a/benchmark/zlib/inflate.js b/benchmark/zlib/inflate.js
new file mode 100644
index 00000000000000..09379c00c1250b
--- /dev/null
+++ b/benchmark/zlib/inflate.js
@@ -0,0 +1,39 @@
+'use strict';
+const common = require('../common.js');
+const zlib = require('zlib');
+
+const bench = common.createBenchmark(main, {
+ method: ['inflate', 'inflateSync'],
+ inputLen: [1024],
+ n: [4e5]
+});
+
+function main({ n, method, inputLen }) {
+ // Default method value for tests.
+ method = method || 'inflate';
+ const chunk = zlib.deflateSync(Buffer.alloc(inputLen, 'a'));
+
+ let i = 0;
+ switch (method) {
+ // Performs `n` single inflate operations
+ case 'inflate':
+ const inflate = zlib.inflate;
+ bench.start();
+ (function next(err, result) {
+ if (i++ === n)
+ return bench.end(n);
+ inflate(chunk, next);
+ })();
+ break;
+ // Performs `n` single inflateSync operations
+ case 'inflateSync':
+ const inflateSync = zlib.inflateSync;
+ bench.start();
+ for (; i < n; ++i)
+ inflateSync(chunk);
+ bench.end(n);
+ break;
+ default:
+ throw new Error('Unsupported inflate method');
+ }
+}
diff --git a/common.gypi b/common.gypi
index ab28ca65e7676d..b8a37491893c91 100644
--- a/common.gypi
+++ b/common.gypi
@@ -202,7 +202,10 @@
'RuntimeLibrary': '<(MSVC_runtimeType)',
'RuntimeTypeInfo': 'false',
}
- }
+ },
+ 'xcode_settings': {
+ 'GCC_OPTIMIZATION_LEVEL': '3', # stop gyp from defaulting to -Os
+ },
}
},
diff --git a/configure.py b/configure.py
index 682feb44e459a3..beb08df0884f76 100755
--- a/configure.py
+++ b/configure.py
@@ -89,6 +89,11 @@
dest='debug',
help='also build debug build')
+parser.add_option('--debug-node',
+ action='store_true',
+ dest='debug_node',
+ help='build the Node.js part of the binary with debugging symbols')
+
parser.add_option('--dest-cpu',
action='store',
dest='dest_cpu',
@@ -609,6 +614,12 @@
default=False,
help='compile V8 with minimal optimizations and with runtime checks')
+parser.add_option('--node-builtin-modules-path',
+ action='store',
+ dest='node_builtin_modules_path',
+ default=False,
+ help='node will load builtin modules from disk instead of from binary')
+
# Create compile_commands.json in out/Debug and out/Release.
parser.add_option('-C',
action='store_true',
@@ -969,6 +980,7 @@ def configure_node(o):
o['variables']['node_prefix'] = options.prefix
o['variables']['node_install_npm'] = b(not options.without_npm)
o['variables']['node_report'] = b(not options.without_report)
+ o['variables']['debug_node'] = b(options.debug_node)
o['default_configuration'] = 'Debug' if options.debug else 'Release'
host_arch = host_arch_win() if os.name == 'nt' else host_arch_cc()
@@ -992,18 +1004,18 @@ def configure_node(o):
o['variables']['want_separate_host_toolset'] = int(cross_compiling)
- if not options.without_node_snapshot:
+ if options.without_node_snapshot or options.node_builtin_modules_path:
+ o['variables']['node_use_node_snapshot'] = 'false'
+ else:
o['variables']['node_use_node_snapshot'] = b(
not cross_compiling and not options.shared)
- else:
- o['variables']['node_use_node_snapshot'] = 'false'
- if not options.without_node_code_cache:
+ if options.without_node_code_cache or options.node_builtin_modules_path:
+ o['variables']['node_use_node_code_cache'] = 'false'
+ else:
# TODO(refack): fix this when implementing embedded code-cache when cross-compiling.
o['variables']['node_use_node_code_cache'] = b(
not cross_compiling and not options.shared)
- else:
- o['variables']['node_use_node_code_cache'] = 'false'
if target_arch == 'arm':
configure_arm(o)
@@ -1145,6 +1157,10 @@ def configure_node(o):
else:
o['variables']['node_target_type'] = 'executable'
+ if options.node_builtin_modules_path:
+ print('Warning! Loading builtin modules from disk is for development')
+ o['variables']['node_builtin_modules_path'] = options.node_builtin_modules_path
+
def configure_napi(output):
version = getnapibuildversion.get_napi_version()
output['variables']['napi_build_version'] = version
diff --git a/test/fixtures/bluebird/node_modules/bluebird/js/release/bluebird.js b/deps/npm/.npmrc
similarity index 100%
rename from test/fixtures/bluebird/node_modules/bluebird/js/release/bluebird.js
rename to deps/npm/.npmrc
diff --git a/deps/npm/AUTHORS b/deps/npm/AUTHORS
index 5b2f0f9c2e176a..3e75785db4763a 100644
--- a/deps/npm/AUTHORS
+++ b/deps/npm/AUTHORS
@@ -681,3 +681,4 @@ Felix Yan
Zhenya Vinogradov
Rafael Hengles
Jan-Philip Gehrcke
+Caleb Sacks <16855387+clabe45@users.noreply.github.com>
diff --git a/deps/npm/CHANGELOG.md b/deps/npm/CHANGELOG.md
index 8c7105645973eb..3abd37703a4d02 100644
--- a/deps/npm/CHANGELOG.md
+++ b/deps/npm/CHANGELOG.md
@@ -1,3 +1,23 @@
+## 6.13.7 (2020-01-28)
+
+### BUG FIXES
+* [`7dbb91438`](https://github.com/npm/cli/commit/7dbb914382ecd2074fffb7eba81d93262e2d23c6)
+ [#655](https://github.com/npm/cli/pull/655)
+ Update CI detection cases
+ ([@isaacs](https://github.com/isaacs))
+
+### DEPENDENCIES
+* [`0fb1296c7`](https://github.com/npm/cli/commit/0fb1296c7d6d4bb9e78c96978c433cd65e55c0ea)
+ `libnpx@10.2.2`
+ ([@mikemimik](https://github.com/mikemimik))
+* [`c9b69d569`](https://github.com/npm/cli/commit/c9b69d569fec7944375a746e9c08a6fa9bec96ff)
+ `node-gyp@5.0.7`
+ ([@mikemimik](https://github.com/mikemimik))
+* [`e8dbaf452`](https://github.com/npm/cli/commit/e8dbaf452a1f6c5350bb0c37059b89a7448e7986)
+ `bin-links@1.1.7`
+ ([@mikemimik](https://github.com/mikemimik))
+ * [#613](https://github.com/npm/cli/issues/613) Fixes bin entry for package
+
## 6.13.6 (2020-01-09)
### DEPENDENCIES
diff --git a/deps/npm/CONTRIBUTING.md b/deps/npm/CONTRIBUTING.md
index 3fc4ff5dc7a828..981f0457d5c6bf 100644
--- a/deps/npm/CONTRIBUTING.md
+++ b/deps/npm/CONTRIBUTING.md
@@ -3,80 +3,190 @@
## Table of Contents
* [Introduction](#introduction)
-* [Roles](#roles)
- * [Community Members](#community-members)
- * [Collaborators](#collaborators)
- * [npm, Inc Employees](#npm-inc-employees)
-
+* [Code Structure](#code-structure)
+* [Running Tests](#running-tests)
+* [Debugging](#debugging)
+* [Coverage](#coverage)
+* [Benchmarking](#benchmarking)
+* [Types of Contributions](#types-of-contributions)
+ * [Contributing an Issue?](#contributing-an-issue)
+ * [Contributing a Question?](#contributing-a-question)
+ * [Contributing a Bug Fix?](#contributing-a-bug-fix)
+ * [Contributing a Feature?](#contributing-a-bug-feature)
+* [Development Dependencies](#development-dependencies)
+* [Dependencies](#dependencies)
## Introduction
-Welcome to the npm CLI Contributor Guide! This document outlines the npm CLI repository's process for community interaction and contribution. This includes the issue tracker, pull requests, wiki pages, and, to a certain extent, outside communication in the context of the npm CLI. It defines roles, responsibilities, and procedures, and is an entry point for anyone wishing to contribute their time and effort to making npm a better tool for the JavaScript community!
+Welcome to the npm CLI Contributor Guide! This document outlines the npm CLI repository's process for community interaction and contribution. This includes the issue tracker, pull requests, wiki pages, and, to a certain extent, outside communication in the context of the npm CLI. This is an entry point for anyone wishing to contribute their time and effort to making npm a better tool for the JavaScript community!
All interactions in the npm repository are covered by the [npm Code of Conduct](https://www.npmjs.com/policies/conduct)
-## Roles
-There are three main roles for people participating in the npm issue tracker. Each has a specific set of abilities and responsibilities: [Community members](#community-members), [Collaborators](#collaborators), and [npm, Inc employees](#npm-inc-employees).
+## Code Structure
+```
+/
+├── bin/
+│ │ # Directory for executable files. It's very rare that you
+│ │ # will need to update a file in this directory.
+│ │
+│ ├── npm # npm-cli entrypoint for bourne shell
+│ ├── npm-cli.js # npm-cli entrypoint for node
+│ ├── npm.cmd # npm-cli entrypoint for windows
+│ ├── npx # npx entrypoint for bourne shell
+│ ├── npx-cli.js # npx entrypoint for node
+│ └── npx.cmd # npx entrypoint for windows
+│
+├── docs/ 📖
+│ │ # Directory that contains the documentation website for
+│ │ # the npm-cli. You can run this website locally, and have
+│ │ # offline docs! 🔥📖🤓
+│ │
+│ ├── content/ # Markdown files for site content
+│ ├── src/ # Source files for the website; gatsby related
+│ └── package.json # Site manifest; scripts and dependencies
+│
+├── lib/ 📦
+│ # All the Good Bits(tm) of the CLI project live here
+│
+├── node_modules/ 🔋
+│ # Vendored dependencies for the CLI project (See the
+│ # dependencies section below for more details).
+│
+├── scripts/ 📜
+│ # We've created some helper scripts for working with the
+│ # CLI project, specifically around managing our vendored
+│ # dependencies, merging in pull-requests, and publishing
+│ # releases.
+│
+├── test/ 🧪
+│ # All the tests for the CLI live in this folder. We've
+│ # got a lot of tests 🤓🧪🩺
+│
+├── CONTRIBUTING.md # This file! 🎉
+└── package.json # The projects main manifest file 📃
+```
+
+## Running Tests
+
+```
+# Make sure you install the dependencies first before running tests.
+$ npm install
+
+# Run tests for the CLI (it could take awhile).
+$ npm run test
+```
+
+## Debugging
+
+It can be tricky to track down issues in the CLI. It's a large code base that has been evolving for over a decade. There is a handy `make` command that will connect the **cloned repository** you have on your machine with the global command, so you can add `console.log` statements or debug any other way you feel most comfortable with.
+
+```
+# Clone the repository to start with
+$ git clone git@github.com:npm/cli.git
+
+# Change working directories into the repository
+$ cd cli
+
+# Make sure you have the latest code (if that's what you're trying to debug)
+$ git fetch origin latest
+
+# Connect repository to the global namespace
+$ make link
+
+#################
+# ALTERNATIVELY
+#################
+# If ou're working on a feature or bug, you can run the same command on your
+# working branch and link that code.
+
+# Create new branch to work from (there are many ways)
+$ git checkout -b feature/awesome-feature
+
+# Connect repository to global namespace
+$ make link
+```
+
+## Coverage
+
+We try and make sure that each new feature or bug fix has tests to go along with them in order to keep code coverages consistent and increasing. We are actively striving for 100% code coverage!
+
+```
+# You can run the following command to find out coverage
+$ npm run test-coverage
+```
+
+## Benchmarking
+
+We often want to know if the bug we've fixed for the feature we've added has any sort of performance impact. We've created a [benchmark suite](https://github.com/npm/benchmarks) to run against the CLI project from pull-requests. If you would like to know if there are any performance impacts to the work you're contributing, simply do the following:
+
+1. Make a pull-request against this repository
+2. Add the following comment to the pull-request: "`test this please ✅`"
+
+This will trigger the [benmark suite](https://github.com/npm/benchmarks) to run against your pull-request, and when it's finished running it will post a comment on your pull-request just like bellow. You'll be able to see the results from the suite inline in your pull-request.
+
+> You'll notice that the bot-user will also add a 🚀 reaction to your comment to
+let you know that it's sent the request to start the benchmark suite.
+
+![image](https://user-images.githubusercontent.com/2818462/72312698-e2e57f80-3656-11ea-9fcf-4a8f6b97b0d1.png)
+
+If you've updated your pull-reuqest and you'd like to run the the benchmark suite again, simple update your original comment, by adding `test this please ✅` again, or simply just adding another emoji to the **end**. _(The trigger is the phrase "test this please ✅" at the beginning of a comment. Updates will trigger as well, so long as the phrase stays at the beginning.)_.
+
+![image](https://user-images.githubusercontent.com/2818462/72313006-ec231c00-3657-11ea-9bd9-227634d67362.png)
+
+## Types of Contributions
+
+### Contributing an Issue?
-Failure to comply with the expected responsibilities of each role, or violating the Code of Conduct will result in punitive action relative to the transgression, ranging from a warning to full removal from the project, at the discretion of npm employees.
+Great!! Is your [new issue](https://github.com/npm/cli/issues/new/choose) a [bug](https://github.com/npm/cli/issues/new?template=bug.md&title=%5BBUG%5D+%3Ctitle%3E), a [feature](https://github.com/npm/cli/issues/new?template=feature.md&title=%5BFEATURE%5D+%3Ctitle%3E), or a [question](https://github.com/npm/cli/issues/new?template=question.md&title=%5BQUESTION%5D+%3Ctitle%3E)?
-### Community Members
+### Contributing a Question?
-This includes anyone who may show up to the npm/npm repo with issues, PRs, comments etc. They may not have any other involvement with npm.
+Huh? 🤔 Got a situation you're not sure about?! Perfect! We've got some resources you can use.
-#### Abilities
+* Our [documentation site](https://docs.npmjs.com/)
+* The local docs that come with the CLI project
-* Open issues and PRs
-* Comment on issues and PRs
+ > **Example**: `npm help install --viewer browser`
-#### Responsibilities
+* The man pages that are built and shipped with the CLI
-* Comment on issues when they have a reference to the answer.
-* If community members aren't sure they are correct and don't have a reference to the answer, please leave the issue and try another one.
-* Defer to collaborators and npm employees for answers.
-* Make sure to search for [the troubleshooting posts on npm.community](https://npm.community/c/support/troubleshooting) and search on the issue tracker for similar issues before opening a new one.
-* Any users with urgent support needs are welcome to email support@npmjs.com, and our dedicated support team will be happy to help.
+ > **Example**: `man npm-install` (only on linux/macOS)
-PLEASE don't @ collaborators or npm employees on issues. The CLI team is small, and has many outstanding commitments to fulfill.
+* Search of the [current issues](https://github.com/npm/cli/issues)
-### Collaborators
+### Contributing a Bug Fix?
-These are folks who have the ability to label and close issues. The role of collaborators may expand over time, but for now it is a limited (& important) role. This is an excellent way to contribute to npm without writing code.
+We'd be happy to triage and help! Head over to the issues and [create a new one](https://github.com/npm/cli/issues/new?template=bug.md&title=%5BBUG%5D+%3Ctitle%3E)!
-Community members may become collaborators by showing consistent, proven track record of quality contributions to the project, a reasonable level of proficiency with the CLI, and regular participation through the tracker and other related mediums, including regular contact with the CLI team itself. This role entails a higher level of responsibility than community member, so we ask for a higher level of understanding and commitment.
+> We'll need a little bit of information about what happened, rather than "it broke". Such as:
+* When did/does this bug happen?
+* Can you reproduce it? _(Can you make it happen more than once.)_
+* What version of `node`/`npm` are you running on your computer?
+* What did you expect it to do?
+* What did it _actually do?
+* etc...
-Collaborators who become inactive for 3 months or longer may have their collaborator privileges removed until they are ready to return.
+### Contributing a Feature?
-#### Abilities
+Snazzy, we're always up for fancy new things! If the feature is fairly minor, the team can triage it and prioritize it into our backlog. However, if the feature is a little more complex, then it's best to create an [RFC](https://en.wikipedia.org/wiki/Request_for_Comments) in our [RFC repository](https://github.com/npm/rfcs). Exactly how to do that is outlined in that repository. If you're not sure _exactly_ how to implement your idea, or don't want to make a document about your idea, then please create an issue on that repository. We consider these RRFC's, or a "Requesting Request For Comment".
-* Label/triage new issues
-* Respond to ongoing issues
-* Close resolved issues.
+## Development Dependencies
-#### Responsibilities
+You'll need a few things installed in order to update and test the CLI project during development:
-* Only answer questions when they know the answer, and provide a reference to the answer.
-* If collaborators aren't totally confident about their answer, please leave the issue and try another one.
-* If they've responded to an issue, it becomes their responsibility to see it to resolution.
-* Defer to fellow Collaborators & npm employees for answers (Again, please don't @ collaborators or npm employees, thank you!)
-* Make sure to search [the troubleshooting posts on npm.community](https://npm.community/c/support/troubleshooting) and search the rest of the forum for similar topics.
+* [node](https://nodejs.org/) v8 or greater
-### npm, Inc Employees
+> We recommend that you have a [node version manager](https://github.com/nvm-sh/nvm) installed if you plan on fixing bugs that might be present in a specific version of node. With a version manager you can easily switch versions of node and test if your changes to the CLI project are working.
-Folks who work at npm, Inc, who have a responsibility to ensure the stability and functionality of the tools npm offers.
+* [git](https://git-scm.com/) v2.11+
-#### Abilities
-* Label/triage new issues
-* Respond to ongoing issues
-* Close resolved issues
-* Land PRs
+## Dependencies
-Please note that this is a living document, and the CLI team will put up PRs to it as needed.
+> Package vendoring is commonly referred to as the case where dependent packages are stored in the same place as your project. That usually means you dependencies are checked into your source management system, such as Git.
-#### Responsibilities
+The CLI project vendors it's dependencies in the `node_modules/` folder. Meaning all the dependencies that the CLI project uses are contained withing the project itself. This is represented by the `bundledDependencies` section in the root level `package.json` file. The main reason for this is because the `npm` CLI project is distributed with the NodeJS runtime and needs to work out of the box, which means all dependencies need to be available after the runtime is installed.
-* Preserve and promote the health of the CLI, the registry, the website, etc.
+There are a couple scripts created to help manage this process in the `scripts/` folder.
-In special cases, [Collaborators](#collaborators) may request time to speak with an npm employee directly, by contacting them and coordinating a time/place.
diff --git a/deps/npm/README.md b/deps/npm/README.md
index 16c7e4b18cdf00..05da169f259619 100644
--- a/deps/npm/README.md
+++ b/deps/npm/README.md
@@ -155,10 +155,6 @@ When you find issues, please report them:
Be sure to include *all* of the output from the npm command that didn't work
as expected. The `npm-debug.log` file is also helpful to provide.
-You can also find npm people in `#npm` on https://package.community/ or
-[on Twitter](https://twitter.com/npm_support). Whoever responds will no
-doubt tell you to put the output in a gist or email.
-
## SEE ALSO
* npm(1)
diff --git a/deps/npm/docs/content/configuring-npm/package-json.md b/deps/npm/docs/content/configuring-npm/package-json.md
index b7759f482f914a..ccdbe041fb063f 100644
--- a/deps/npm/docs/content/configuring-npm/package-json.md
+++ b/deps/npm/docs/content/configuring-npm/package-json.md
@@ -740,7 +740,8 @@ If a dependency can be used, but you would like npm to proceed if it cannot be
found or fails to install, then you may put it in the `optionalDependencies`
object. This is a map of package name to version or url, just like the
`dependencies` object. The difference is that build failures do not cause
-installation to fail.
+installation to fail. Running `npm install --no-optional` will prevent these
+dependencies from being installed.
It is still your program's responsibility to handle the lack of the
dependency. For example, something like this:
diff --git a/deps/npm/docs/public/cli-commands/npm-access/index.html b/deps/npm/docs/public/cli-commands/npm-access/index.html
index 6dee07ecbfda50..33febc80177727 100644
--- a/deps/npm/docs/public/cli-commands/npm-access/index.html
+++ b/deps/npm/docs/public/cli-commands/npm-access/index.html
@@ -74,7 +74,7 @@
}
}
})
-