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 <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
  • Loading branch information
aduh95 authored and targos committed Jun 11, 2021
1 parent b5b8a99 commit ff546ff
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 @@ -841,11 +842,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 ff546ff

Please sign in to comment.