Skip to content
Permalink
Browse files

util: avoid using forEach

PR-URL: #11582
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information...
jasnell committed Feb 27, 2017
1 parent 2d230fa commit f6dbead126e852b6666b53c37d49b0127780a931
Showing with 12 additions and 11 deletions.
  1. +12 −11 lib/util.js
@@ -677,12 +677,13 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
if (remaining > 0) {
output.push(`... ${remaining} more item${remaining > 1 ? 's' : ''}`);
}
keys.forEach(function(key) {
for (var n = 0; n < keys.length; n++) {
var key = keys[n];
if (typeof key === 'symbol' || !key.match(/^\d+$/)) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
key, true));
}
});
}
return output;
}

@@ -713,10 +714,10 @@ function formatSet(ctx, value, recurseTimes, visibleKeys, keys) {
var str = formatValue(ctx, v, nextRecurseTimes);
output.push(str);
});
keys.forEach(function(key) {
for (var n = 0; n < keys.length; n++) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
key, false));
});
keys[n], false));
}
return output;
}

@@ -730,10 +731,10 @@ function formatMap(ctx, value, recurseTimes, visibleKeys, keys) {
str += formatValue(ctx, v, nextRecurseTimes);
output.push(str);
});
keys.forEach(function(key) {
for (var n = 0; n < keys.length; n++) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
key, false));
});
keys[n], false));
}
return output;
}

@@ -763,10 +764,10 @@ function formatPromise(ctx, value, recurseTimes, visibleKeys, keys) {
output.push(str);
}
}
keys.forEach(function(key) {
for (var n = 0; n < keys.length; n++) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
key, false));
});
keys[n], false));
}
return output;
}

0 comments on commit f6dbead

Please sign in to comment.
You can’t perform that action at this time.