Skip to content

Commit fec90a3

Browse files
committed
lib: use assignFunctionName util where it makes sense
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #64515 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Jordan Harband <ljharb@gmail.com>
1 parent 86f27e2 commit fec90a3

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

lib/internal/dns/callback_resolver.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const {
44
ArrayPrototypeMap,
55
FunctionPrototypeCall,
6-
ObjectDefineProperty,
76
Symbol,
87
} = primordials;
98

@@ -33,6 +32,7 @@ const {
3332
startPerf,
3433
stopPerf,
3534
} = require('internal/perf/observe');
35+
const { assignFunctionName } = require('internal/util');
3636

3737
const kPerfHooksDnsLookupResolveContext = Symbol('kPerfHooksDnsLookupResolveContext');
3838

@@ -82,8 +82,7 @@ function resolver(bindingName) {
8282
}
8383
return req;
8484
}
85-
ObjectDefineProperty(query, 'name', { __proto__: null, value: bindingName });
86-
return query;
85+
return assignFunctionName(bindingName, query);
8786
}
8887

8988
// This is the callback-based resolver. There is another similar

lib/internal/util/inspector.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const {
44
ArrayPrototypePushApply,
55
ArrayPrototypeSome,
66
FunctionPrototypeBind,
7-
ObjectDefineProperty,
87
ObjectKeys,
98
ObjectPrototypeHasOwnProperty,
109
RegExpPrototypeExec,
@@ -13,6 +12,7 @@ const {
1312

1413
const { validatePort } = require('internal/validators');
1514
const permission = require('internal/process/permission');
15+
const { assignFunctionName } = require('internal/util');
1616

1717
const kMinPort = 1024;
1818
const kMaxPort = 65535;
@@ -88,16 +88,12 @@ function wrapConsole(consoleFromNode) {
8888
// then wrap these two methods into one. Native wrapper will preserve
8989
// the original stack.
9090
if (ObjectPrototypeHasOwnProperty(consoleFromNode, key)) {
91-
consoleFromNode[key] = FunctionPrototypeBind(
91+
consoleFromNode[key] = assignFunctionName(key, FunctionPrototypeBind(
9292
consoleCall,
9393
consoleFromNode,
9494
consoleFromVM[key],
9595
consoleFromNode[key],
96-
);
97-
ObjectDefineProperty(consoleFromNode[key], 'name', {
98-
__proto__: null,
99-
value: key,
100-
});
96+
));
10197
} else {
10298
// Add additional console APIs from the inspector
10399
consoleFromNode[key] = consoleFromVM[key];

0 commit comments

Comments
 (0)