Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0d70c79

Browse files
rayark1marco-ippolito
authored andcommitted
lib: optimize copyError with ObjectAssign in primordials
optimized the copyError function by using ObjectAssign from primordials.this change replaces the for-loop with ObjectAssign, which improvesmemory usage and performance.this change updates the copyError function in internal/assert.js touse ObjectAssign for copying properties.PR-URL:#53999Reviewed-By: James M Snell <jasnell@gmail.com>Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
1 parentbfabfb4 commit0d70c79

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

‎lib/internal/assert/assertion_error.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ const {
66
Error,
77
ErrorCaptureStackTrace,
88
MathMax,
9+
ObjectAssign,
910
ObjectDefineProperty,
1011
ObjectGetPrototypeOf,
11-
ObjectKeys,
1212
String,
1313
StringPrototypeEndsWith,
1414
StringPrototypeRepeat,
@@ -46,11 +46,7 @@ const kReadableOperator = {
4646
constkMaxShortLength=12;
4747

4848
functioncopyError(source){
49-
constkeys=ObjectKeys(source);
50-
consttarget={__proto__:ObjectGetPrototypeOf(source)};
51-
for(constkeyofkeys){
52-
target[key]=source[key];
53-
}
49+
consttarget=ObjectAssign({__proto__:ObjectGetPrototypeOf(source)},source);
5450
ObjectDefineProperty(target,'message',{__proto__:null,value:source.message});
5551
returntarget;
5652
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp