Skip to content

Commit 9db9be7

Browse files
aduh95danielleadams
authored andcommitted
buffer: refactor to use primordials instead of Array#reduce
PR-URL: #36392 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
1 parent fbcb72a commit 9db9be7

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,
@@ -825,11 +826,12 @@ Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
825826
if (ctx) {
826827
let extras = false;
827828
const filter = ctx.showHidden ? ALL_PROPERTIES : ONLY_ENUMERABLE;
828-
const obj = getOwnNonIndexProperties(this, filter).reduce((obj, key) => {
829-
extras = true;
830-
obj[key] = this[key];
831-
return obj;
832-
}, ObjectCreate(null));
829+
const obj = ObjectCreate(null);
830+
ArrayPrototypeForEach(getOwnNonIndexProperties(this, filter),
831+
(key) => {
832+
extras = true;
833+
obj[key] = this[key];
834+
});
833835
if (extras) {
834836
if (this.length !== 0)
835837
str += ', ';

0 commit comments

Comments
 (0)