Skip to content

Commit

Permalink
util: avoid using forEach
Browse files Browse the repository at this point in the history
PR-URL: #11582
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
jasnell committed Mar 17, 2017
1 parent 2d230fa commit f6dbead
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit f6dbead

Please sign in to comment.