Skip to content

Commit ff546ff

Browse files
aduh95targos
authored andcommitted
buffer: refactor to use primordials instead of Array#reduce
PR-URL: #36392 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Minwoo Jung <[email protected]>
1 parent b5b8a99 commit ff546ff

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/buffer.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
const {
2525
Array,
2626
ArrayIsArray,
27+
ArrayPrototypeForEach,
2728
Error,
2829
MathFloor,
2930
MathMin,
@@ -841,11 +842,12 @@ Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
841842
if (ctx) {
842843
let extras = false;
843844
const filter = ctx.showHidden ? ALL_PROPERTIES : ONLY_ENUMERABLE;
844-
const obj = getOwnNonIndexProperties(this, filter).reduce((obj, key) => {
845-
extras = true;
846-
obj[key] = this[key];
847-
return obj;
848-
}, ObjectCreate(null));
845+
const obj = ObjectCreate(null);
846+
ArrayPrototypeForEach(getOwnNonIndexProperties(this, filter),
847+
(key) => {
848+
extras = true;
849+
obj[key] = this[key];
850+
});
849851
if (extras) {
850852
if (this.length !== 0)
851853
str += ', ';

0 commit comments

Comments
 (0)