Browse Source

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 <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
process-exit-stdio-flushing
Rich Trott 9 years ago
committed by James M Snell
parent
commit
089d84f8fa
  1. 4
      lib/path.js
  2. 4
      lib/util.js

4
lib/path.js

@ -282,7 +282,7 @@ win32.relative = function(from, to) {
} }
var outputParts = []; var outputParts = [];
for (var i = samePartsLength; i < lowerFromParts.length; i++) { for (var j = samePartsLength; j < lowerFromParts.length; j++) {
outputParts.push('..'); outputParts.push('..');
} }
@ -503,7 +503,7 @@ posix.relative = function(from, to) {
} }
var outputParts = []; var outputParts = [];
for (var i = samePartsLength; i < fromParts.length; i++) { for (var j = samePartsLength; j < fromParts.length; j++) {
outputParts.push('..'); outputParts.push('..');
} }

4
lib/util.js

@ -13,8 +13,8 @@ const formatRegExp = /%[sdj%]/g;
exports.format = function(f) { exports.format = function(f) {
if (typeof f !== 'string') { if (typeof f !== 'string') {
var objects = []; var objects = [];
for (var i = 0; i < arguments.length; i++) { for (var index = 0; index < arguments.length; index++) {
objects.push(inspect(arguments[i])); objects.push(inspect(arguments[index]));
} }
return objects.join(' '); return objects.join(' ');
} }

Loading…
Cancel
Save