Skip to content
Permalink
Browse files
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>
  • Loading branch information
aduh95 authored and targos committed Jun 11, 2021
1 parent b5b8a99 commit ff546ff7444e160f85ea880373d824054ba893ef
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/buffer.js
@@ -24,6 +24,7 @@
const {
Array,
ArrayIsArray,
ArrayPrototypeForEach,
Error,
MathFloor,
MathMin,
@@ -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 += ', ';

0 comments on commit ff546ff

Please sign in to comment.