Skip to content

Commit 39898a9

Browse files
Sebastien-AhkrinMylesBorins
authored andcommitted
lib: replace every Symbol.for by SymbolFor primordials
PR-URL: #30857 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 1cce000 commit 39898a9

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

lib/_http_server.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const {
2525
ObjectKeys,
2626
ObjectSetPrototypeOf,
2727
Symbol,
28+
SymbolFor,
2829
} = primordials;
2930

3031
const net = require('net');
@@ -378,7 +379,7 @@ Server.prototype[EE.captureRejectionSymbol] = function(
378379
}
379380
break;
380381
default:
381-
net.Server.prototype[Symbol.for('nodejs.rejection')]
382+
net.Server.prototype[SymbolFor('nodejs.rejection')]
382383
.call(this, err, event, ...args);
383384
}
384385
};

lib/_tls_wrap.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const {
2626
ObjectDefineProperty,
2727
ObjectSetPrototypeOf,
2828
Symbol,
29+
SymbolFor,
2930
} = primordials;
3031

3132
const {
@@ -1294,7 +1295,7 @@ Server.prototype[EE.captureRejectionSymbol] = function(
12941295
sock.destroy(err);
12951296
break;
12961297
default:
1297-
net.Server.prototype[Symbol.for('nodejs.rejection')]
1298+
net.Server.prototype[SymbolFor('nodejs.rejection')]
12981299
.call(this, err, event, sock);
12991300
}
13001301
};

lib/events.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ const {
3333
ReflectApply,
3434
ReflectOwnKeys,
3535
Symbol,
36+
SymbolFor,
3637
} = primordials;
37-
const kRejection = Symbol.for('nodejs.rejection');
38+
const kRejection = SymbolFor('nodejs.rejection');
3839

3940
let spliceOne;
4041

lib/internal/errors.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const {
1717
ObjectDefineProperty,
1818
ObjectKeys,
1919
Symbol,
20+
SymbolFor,
2021
} = primordials;
2122

2223
const messages = new Map();
@@ -199,7 +200,7 @@ class SystemError extends Error {
199200
return `${this.name} [${this.code}]: ${this.message}`;
200201
}
201202

202-
[Symbol.for('nodejs.util.inspect.custom')](recurseTimes, ctx) {
203+
[SymbolFor('nodejs.util.inspect.custom')](recurseTimes, ctx) {
203204
return lazyInternalUtilInspect().inspect(this, {
204205
...ctx,
205206
getters: true,

lib/internal/util.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const {
1212
ObjectSetPrototypeOf,
1313
ReflectConstruct,
1414
Symbol,
15+
SymbolFor,
1516
} = primordials;
1617

1718
const {
@@ -425,7 +426,7 @@ module.exports = {
425426

426427
// Symbol used to provide a custom inspect function for an object as an
427428
// alternative to using 'inspect'
428-
customInspectSymbol: Symbol.for('nodejs.util.inspect.custom'),
429+
customInspectSymbol: SymbolFor('nodejs.util.inspect.custom'),
429430

430431
// Used by the buffer module to capture an internal reference to the
431432
// default isEncoding implementation, just in case userland overrides it.

lib/internal/worker.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const {
88
ObjectCreate,
99
ObjectEntries,
1010
Symbol,
11+
SymbolFor,
1112
} = primordials;
1213

1314
const EventEmitter = require('events');
@@ -62,7 +63,7 @@ const kOnCouldNotSerializeErr = Symbol('kOnCouldNotSerializeErr');
6263
const kOnErrorMessage = Symbol('kOnErrorMessage');
6364
const kParentSideStdio = Symbol('kParentSideStdio');
6465

65-
const SHARE_ENV = Symbol.for('nodejs.worker_threads.SHARE_ENV');
66+
const SHARE_ENV = SymbolFor('nodejs.worker_threads.SHARE_ENV');
6667
const debug = require('internal/util/debuglog').debuglog('worker');
6768

6869
let cwdCounter;

0 commit comments

Comments
 (0)