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..5f452319b4d28f 100644 --- a/benchmark/fs/readfile-partitioned.js +++ b/benchmark/fs/readfile-partitioned.js @@ -25,15 +25,15 @@ const bench = common.createBenchmark(main, { function main(conf) { const len = +conf.len; 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; @@ -78,7 +78,7 @@ function main(conf) { } // Start reads - var cur = +conf.concurrent; + let cur = +conf.concurrent; while (cur--) read(); // Start a competing 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/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/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); }