Skip to content

Commit

Permalink
buffer: refactor to use primordials instead of Array#reduce
Browse files Browse the repository at this point in the history
PR-URL: #36392
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
  • Loading branch information
aduh95 authored and danielleadams committed Dec 7, 2020
1 parent fbcb72a commit 9db9be7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
const {
Array,
ArrayIsArray,
ArrayPrototypeForEach,
Error,
MathFloor,
MathMin,
Expand Down Expand Up @@ -825,11 +826,12 @@ Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
if (ctx) {
let extras = false;
const filter = ctx.showHidden ? ALL_PROPERTIES : ONLY_ENUMERABLE;
const obj = getOwnNonIndexProperties(this, filter).reduce((obj, key) => {
extras = true;
obj[key] = this[key];
return obj;
}, ObjectCreate(null));
const obj = ObjectCreate(null);
ArrayPrototypeForEach(getOwnNonIndexProperties(this, filter),
(key) => {
extras = true;
obj[key] = this[key];
});
if (extras) {
if (this.length !== 0)
str += ', ';
Expand Down

0 comments on commit 9db9be7

Please sign in to comment.