Skip to content

Commit ff546ff

Browse files
aduh95targos
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 b5b8a99 commit ff546ff

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎lib/buffer.js‎

Lines changed: 7 additions & 5 deletions
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,
@@ -841,11 +842,12 @@ Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
841842
if(ctx){
842843
letextras=false;
843844
constfilter=ctx.showHidden ? ALL_PROPERTIES : ONLY_ENUMERABLE;
844-
constobj=getOwnNonIndexProperties(this,filter).reduce((obj,key)=>{
845-
extras=true;
846-
obj[key]=this[key];
847-
returnobj;
848-
},ObjectCreate(null));
845+
constobj=ObjectCreate(null);
846+
ArrayPrototypeForEach(getOwnNonIndexProperties(this,filter),
847+
(key)=>{
848+
extras=true;
849+
obj[key]=this[key];
850+
});
849851
if(extras){
850852
if(this.length!==0)
851853
str+=', ';

0 commit comments

Comments
 (0)