Skip to content

Commit 9db9be7

Browse files
aduh95danielleadams
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 fbcb72a commit 9db9be7

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,
@@ -825,11 +826,12 @@ Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
825826
if(ctx){
826827
letextras=false;
827828
constfilter=ctx.showHidden ? ALL_PROPERTIES : ONLY_ENUMERABLE;
828-
constobj=getOwnNonIndexProperties(this,filter).reduce((obj,key)=>{
829-
extras=true;
830-
obj[key]=this[key];
831-
returnobj;
832-
},ObjectCreate(null));
829+
constobj=ObjectCreate(null);
830+
ArrayPrototypeForEach(getOwnNonIndexProperties(this,filter),
831+
(key)=>{
832+
extras=true;
833+
obj[key]=this[key];
834+
});
833835
if(extras){
834836
if(this.length!==0)
835837
str+=', ';

0 commit comments

Comments
 (0)