From 089d84f8fa2f31252b7312bfaf87070733e3f315 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 66a3fa448f30eb..a2162cae7c9c97 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('..'); } @@ -503,7 +503,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 50cc5bc5b4b25d..2908d4ece9192f 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(' '); }