Skip to content

Commit 9a59913

Browse files
jasnellitaloacasas
authored andcommitted
util: avoid using forEach
PR-URL: #11582 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 5b1d61c commit 9a59913

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/util.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -682,12 +682,13 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
682682
if (remaining > 0) {
683683
output.push(`... ${remaining} more item${remaining > 1 ? 's' : ''}`);
684684
}
685-
keys.forEach(function(key) {
685+
for (var n = 0; n < keys.length; n++) {
686+
var key = keys[n];
686687
if (typeof key === 'symbol' || !key.match(/^\d+$/)) {
687688
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
688689
key, true));
689690
}
690-
});
691+
}
691692
return output;
692693
}
693694

@@ -718,10 +719,10 @@ function formatSet(ctx, value, recurseTimes, visibleKeys, keys) {
718719
var str = formatValue(ctx, v, nextRecurseTimes);
719720
output.push(str);
720721
});
721-
keys.forEach(function(key) {
722+
for (var n = 0; n < keys.length; n++) {
722723
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
723-
key, false));
724-
});
724+
keys[n], false));
725+
}
725726
return output;
726727
}
727728

@@ -735,10 +736,10 @@ function formatMap(ctx, value, recurseTimes, visibleKeys, keys) {
735736
str += formatValue(ctx, v, nextRecurseTimes);
736737
output.push(str);
737738
});
738-
keys.forEach(function(key) {
739+
for (var n = 0; n < keys.length; n++) {
739740
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
740-
key, false));
741-
});
741+
keys[n], false));
742+
}
742743
return output;
743744
}
744745

@@ -768,10 +769,10 @@ function formatPromise(ctx, value, recurseTimes, visibleKeys, keys) {
768769
output.push(str);
769770
}
770771
}
771-
keys.forEach(function(key) {
772+
for (var n = 0; n < keys.length; n++) {
772773
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
773-
key, false));
774-
});
774+
keys[n], false));
775+
}
775776
return output;
776777
}
777778

0 commit comments

Comments
 (0)