From a99111a7008288aedaf14bd56c486c57f01ab2d4 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 29 Jan 2016 20:34:13 -0800 Subject: [PATCH] lib: scope loop variables Refactor instances in `lib` where a loop variable is redeclared in the same scope with `var`. In these cases, `let` can be used to scope the variable declarations more precisely. PR-URL: https://github.com/nodejs/node/pull/4965 Reviewed-By: Brian White Reviewed-By: James M Snell --- lib/path.js | 4 ++-- lib/util.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/path.js b/lib/path.js index c867dac83b9aad..44f398d0a792ca 100644 --- a/lib/path.js +++ b/lib/path.js @@ -282,7 +282,7 @@ win32.relative = function(from, to) { } var outputParts = []; - for (var i = samePartsLength; i < lowerFromParts.length; i++) { + for (var j = samePartsLength; j < lowerFromParts.length; j++) { outputParts.push('..'); } @@ -511,7 +511,7 @@ posix.relative = function(from, to) { } var outputParts = []; - for (var i = samePartsLength; i < fromParts.length; i++) { + for (var j = samePartsLength; j < fromParts.length; j++) { outputParts.push('..'); } diff --git a/lib/util.js b/lib/util.js index 6f8d841dd438f7..c302bd9c0bf0ba 100644 --- a/lib/util.js +++ b/lib/util.js @@ -13,8 +13,8 @@ const formatRegExp = /%[sdj%]/g; exports.format = function(f) { if (typeof f !== 'string') { var objects = []; - for (var i = 0; i < arguments.length; i++) { - objects.push(inspect(arguments[i])); + for (var index = 0; index < arguments.length; index++) { + objects.push(inspect(arguments[index])); } return objects.join(' '); }