From a2dd36069f066f975f121d52706aab44f02d145e Mon Sep 17 00:00:00 2001 From: Luciano Date: Tue, 12 Nov 2019 14:52:09 +0000 Subject: [PATCH 1/2] util: use let instead of var for util/inspect.js --- lib/internal/util/inspect.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 2f922f6659931c..e51e3e04f37798 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -1136,7 +1136,7 @@ function formatPrimitive(fn, value, ctx) { function formatNamespaceObject(ctx, value, recurseTimes, keys) { const output = new Array(keys.length); - for (var i = 0; i < keys.length; i++) { + for (let i = 0; i < keys.length; i++) { try { output[i] = formatProperty(ctx, value, recurseTimes, keys[i], kObjectType); @@ -1224,7 +1224,7 @@ function formatArray(ctx, value, recurseTimes) { const remaining = valLen - len; const output = []; - for (var i = 0; i < len; i++) { + for (let i = 0; i < len; i++) { // Special handle sparse arrays. if (!hasOwnProperty(value, i)) { return formatSpecialArray(ctx, value, recurseTimes, len, output, i); @@ -1300,7 +1300,7 @@ function formatSetIterInner(ctx, recurseTimes, entries, state) { const maxLength = Math.min(maxArrayLength, entries.length); let output = new Array(maxLength); ctx.indentationLvl += 2; - for (var i = 0; i < maxLength; i++) { + for (let i = 0; i < maxLength; i++) { output[i] = formatValue(ctx, entries[i], recurseTimes); } ctx.indentationLvl -= 2; @@ -1468,7 +1468,7 @@ function isBelowBreakLength(ctx, output, start, base) { let totalLength = output.length + start; if (totalLength + output.length > ctx.breakLength) return false; - for (var i = 0; i < output.length; i++) { + for (let i = 0; i < output.length; i++) { if (ctx.colors) { totalLength += removeColors(output[i]).length; } else { @@ -1589,7 +1589,7 @@ function formatWithOptionsInternal(inspectOptions, ...args) { let tempStr; let lastPos = 0; - for (var i = 0; i < first.length - 1; i++) { + for (let i = 0; i < first.length - 1; i++) { if (first.charCodeAt(i) === 37) { // '%' const nextChar = first.charCodeAt(++i); if (a + 1 !== args.length) { From c5b9ffd90473c4468d989a0e956d0fddb07f5215 Mon Sep 17 00:00:00 2001 From: Luciano Date: Tue, 12 Nov 2019 14:52:09 +0000 Subject: [PATCH 2/2] util: use let instead of var for util/inspect.js --- lib/internal/util/inspect.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 2f922f6659931c..e51e3e04f37798 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -1136,7 +1136,7 @@ function formatPrimitive(fn, value, ctx) { function formatNamespaceObject(ctx, value, recurseTimes, keys) { const output = new Array(keys.length); - for (var i = 0; i < keys.length; i++) { + for (let i = 0; i < keys.length; i++) { try { output[i] = formatProperty(ctx, value, recurseTimes, keys[i], kObjectType); @@ -1224,7 +1224,7 @@ function formatArray(ctx, value, recurseTimes) { const remaining = valLen - len; const output = []; - for (var i = 0; i < len; i++) { + for (let i = 0; i < len; i++) { // Special handle sparse arrays. if (!hasOwnProperty(value, i)) { return formatSpecialArray(ctx, value, recurseTimes, len, output, i); @@ -1300,7 +1300,7 @@ function formatSetIterInner(ctx, recurseTimes, entries, state) { const maxLength = Math.min(maxArrayLength, entries.length); let output = new Array(maxLength); ctx.indentationLvl += 2; - for (var i = 0; i < maxLength; i++) { + for (let i = 0; i < maxLength; i++) { output[i] = formatValue(ctx, entries[i], recurseTimes); } ctx.indentationLvl -= 2; @@ -1468,7 +1468,7 @@ function isBelowBreakLength(ctx, output, start, base) { let totalLength = output.length + start; if (totalLength + output.length > ctx.breakLength) return false; - for (var i = 0; i < output.length; i++) { + for (let i = 0; i < output.length; i++) { if (ctx.colors) { totalLength += removeColors(output[i]).length; } else { @@ -1589,7 +1589,7 @@ function formatWithOptionsInternal(inspectOptions, ...args) { let tempStr; let lastPos = 0; - for (var i = 0; i < first.length - 1; i++) { + for (let i = 0; i < first.length - 1; i++) { if (first.charCodeAt(i) === 37) { // '%' const nextChar = first.charCodeAt(++i); if (a + 1 !== args.length) {