mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
buffer: refactor to use primordials instead of Array#reduce
PR-URL: https://github.com/nodejs/node/pull/36392 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
This commit is contained in:
1 parent
b5b8a996f3
commit
ff546ff744
1 file changed
+7
-5
+7
-5
@@ -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 += ', ';
|
||||
|
||||
Reference in new issue
Block a user