Skip to content

Commit b95c50b

Browse files
Sebastien-AhkrinBethGriggs
authored andcommitted
lib: replace Symbol global by the primordials Symbol
PR-URL: #30737 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 8f911fe commit b95c50b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+88
-2
lines changed

lib/.eslintrc.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ rules:
2323
message: "Use `const { Object } = primordials;` instead of the global."
2424
- name: Reflect
2525
message: "Use `const { Reflect } = primordials;` instead of the global."
26+
- name: Symbol
27+
message: "Use `const { Symbol } = primordials;` instead of the global."
2628
no-restricted-syntax:
2729
# Config copied from .eslintrc.js
2830
- error

lib/_http_agent.js

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

3031
const net = require('net');

lib/_http_common.js

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
const {
2525
MathMin,
26+
Symbol,
2627
} = primordials;
2728
const { setImmediate } = require('timers');
2829

lib/_http_outgoing.js

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const {
2828
ObjectKeys,
2929
ObjectPrototypeHasOwnProperty,
3030
ObjectSetPrototypeOf,
31+
Symbol,
3132
} = primordials;
3233

3334
const { getDefaultHighWaterMark } = require('internal/streams/state');

lib/_http_server.js

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
const {
2525
ObjectKeys,
2626
ObjectSetPrototypeOf,
27+
Symbol,
2728
} = primordials;
2829

2930
const net = require('net');

lib/_stream_readable.js

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const {
2727
NumberIsNaN,
2828
ObjectDefineProperty,
2929
ObjectSetPrototypeOf,
30+
Symbol,
3031
} = primordials;
3132

3233
module.exports = Readable;

lib/_stream_writable.js

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const {
2929
Array,
3030
ObjectDefineProperty,
3131
ObjectSetPrototypeOf,
32+
Symbol,
3233
} = primordials;
3334

3435
module.exports = Writable;

lib/_tls_wrap.js

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

3031
const {

lib/async_hooks.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const {
44
NumberIsSafeInteger,
55
ReflectApply,
6+
Symbol,
67
} = primordials;
78

89
const {

lib/buffer.js

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const {
3434
ObjectDefineProperties,
3535
ObjectDefineProperty,
3636
ObjectSetPrototypeOf,
37+
Symbol,
3738
} = primordials;
3839

3940
const {

lib/domain.js

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const {
3030
Array,
3131
ObjectDefineProperty,
3232
ReflectApply,
33+
Symbol,
3334
} = primordials;
3435

3536
const EventEmitter = require('events');

lib/inspector.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const {
44
JSONParse,
55
JSONStringify,
6+
Symbol,
67
} = primordials;
78

89
const {

lib/internal/async_hooks.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const {
44
FunctionPrototypeBind,
55
NumberIsSafeInteger,
66
ObjectDefineProperty,
7+
Symbol,
78
} = primordials;
89

910
const {

lib/internal/child_process.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const {
44
ArrayIsArray,
55
ObjectDefineProperty,
66
ObjectSetPrototypeOf,
7+
Symbol,
78
} = primordials;
89

910
const {

lib/internal/child_process/serialization.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const {
44
JSONParse,
55
JSONStringify,
6+
Symbol,
67
} = primordials;
78
const { Buffer } = require('buffer');
89
const { StringDecoder } = require('string_decoder');

lib/internal/console/constructor.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const {
1313
ObjectPrototypeHasOwnProperty,
1414
ObjectValues,
1515
ReflectOwnKeys,
16+
Symbol,
1617
} = primordials;
1718

1819
const { trace } = internalBinding('trace_events');

lib/internal/crypto/hash.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const {
44
ObjectSetPrototypeOf,
5+
Symbol,
56
} = primordials;
67

78
const {

lib/internal/crypto/keys.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const {
44
ObjectDefineProperty,
5+
Symbol,
56
} = primordials;
67

78
const {

lib/internal/crypto/util.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
const {
4+
Symbol,
5+
} = primordials;
6+
37
const {
48
getCiphers: _getCiphers,
59
getCurves: _getCurves,

lib/internal/dgram.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
'use strict';
2+
3+
const {
4+
Symbol,
5+
} = primordials;
6+
27
const { codes } = require('internal/errors');
38
const { UDP } = internalBinding('udp_wrap');
49
const { guessHandleType } = internalBinding('util');

lib/internal/encoding.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const {
77
ObjectCreate,
88
ObjectDefineProperties,
99
ObjectGetOwnPropertyDescriptors,
10+
Symbol,
1011
} = primordials;
1112

1213
const {

lib/internal/errors.js

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const {
1616
NumberIsInteger,
1717
ObjectDefineProperty,
1818
ObjectKeys,
19+
Symbol,
1920
} = primordials;
2021

2122
const messages = new Map();

lib/internal/freeze_intrinsics.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = function() {
3131
getOwnPropertyDescriptors,
3232
getOwnPropertyNames,
3333
getOwnPropertySymbols,
34-
getPrototypeOf
34+
getPrototypeOf,
3535
} = Object;
3636
const objectHasOwnProperty = Object.prototype.hasOwnProperty;
3737
const { ownKeys } = Reflect;

lib/internal/fs/dir.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const {
44
ObjectDefineProperty,
5+
Symbol,
56
} = primordials;
67

78
const pathModule = require('path');

lib/internal/fs/promises.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const {
44
MathMax,
55
MathMin,
66
NumberIsSafeInteger,
7+
Symbol,
78
} = primordials;
89

910
const {

lib/internal/fs/utils.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const {
77
NumberIsFinite,
88
ObjectSetPrototypeOf,
99
ReflectOwnKeys,
10+
Symbol,
1011
} = primordials;
1112

1213
const { Buffer, kMaxLength } = require('buffer');

lib/internal/fs/watchers.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const {
44
ObjectDefineProperty,
55
ObjectSetPrototypeOf,
6+
Symbol,
67
} = primordials;
78

89
const errors = require('internal/errors');

lib/internal/http.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
const {
4+
Symbol,
5+
} = primordials;
6+
37
const { setUnrefTimeout } = require('internal/timers');
48
const { PerformanceEntry, notify } = internalBinding('performance');
59

lib/internal/http2/compat.js

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const {
88
ObjectKeys,
99
ObjectPrototypeHasOwnProperty,
1010
ReflectGetPrototypeOf,
11+
Symbol,
1112
} = primordials;
1213

1314
const assert = require('internal/assert');

lib/internal/http2/core.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const {
1111
ObjectDefineProperty,
1212
ObjectPrototypeHasOwnProperty,
1313
ReflectGetPrototypeOf,
14+
Symbol,
1415
} = primordials;
1516

1617
const {

lib/internal/http2/util.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {
66
Number,
77
ObjectCreate,
88
ObjectKeys,
9+
Symbol,
910
} = primordials;
1011

1112
const binding = internalBinding('http2');

lib/internal/js_stream_socket.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
const {
4+
Symbol,
5+
} = primordials;
6+
37
const { setImmediate } = require('timers');
48
const assert = require('internal/assert');
59
const { Socket } = require('net');

lib/internal/net.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
const {
4+
Symbol,
5+
} = primordials;
6+
37
const Buffer = require('buffer').Buffer;
48
const { writeBuffer } = internalBinding('fs');
59
const errors = require('internal/errors');

lib/internal/priority_queue.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const {
44
Array,
5+
Symbol,
56
} = primordials;
67

78
const kCompare = Symbol('compare');

lib/internal/repl/utils.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
const {
4+
Symbol,
5+
} = primordials;
6+
37
const acorn = require('internal/deps/acorn/acorn/dist/acorn');
48
const privateMethods =
59
require('internal/deps/acorn-plugins/acorn-private-methods/index');

lib/internal/stream_base_commons.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const {
44
Array,
5+
Symbol,
56
} = primordials;
67

78
const { Buffer } = require('buffer');

lib/internal/streams/async_iterator.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const {
44
ObjectCreate,
55
ObjectGetPrototypeOf,
66
ObjectSetPrototypeOf,
7+
Symbol,
78
} = primordials;
89

910
const finished = require('internal/streams/end-of-stream');

lib/internal/streams/buffer_list.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
const {
4+
Symbol,
5+
} = primordials;
6+
37
const { Buffer } = require('buffer');
48
const { inspect } = require('internal/util/inspect');
59

lib/internal/streams/duplexpair.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
'use strict';
2+
3+
const {
4+
Symbol,
5+
} = primordials;
6+
27
const { Duplex } = require('stream');
38

49
const kCallback = Symbol('Callback');

lib/internal/streams/from.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
const {
4+
Symbol,
5+
} = primordials;
6+
37
const {
48
ERR_INVALID_ARG_TYPE
59
} = require('internal/errors').codes;

lib/internal/timers.js

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const {
7777
MathTrunc,
7878
NumberMIN_SAFE_INTEGER,
7979
ObjectCreate,
80+
Symbol,
8081
} = primordials;
8182

8283
const {

lib/internal/trace_events_async_hooks.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const {
44
ObjectKeys,
55
SafeMap,
66
SafeSet,
7+
Symbol,
78
} = primordials;
89

910
const { trace } = internalBinding('trace_events');

lib/internal/url.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const {
1111
ObjectKeys,
1212
ReflectGetOwnPropertyDescriptor,
1313
ReflectOwnKeys,
14+
Symbol,
1415
} = primordials;
1516

1617
const { inspect } = require('internal/util/inspect');

lib/internal/util.js

+2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ const {
1111
ObjectGetPrototypeOf,
1212
ObjectSetPrototypeOf,
1313
ReflectConstruct,
14+
Symbol,
1415
} = primordials;
16+
1517
const {
1618
codes: {
1719
ERR_INVALID_ARG_TYPE,

lib/internal/vm/module.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const {
44
ArrayIsArray,
55
ObjectCreate,
66
ObjectDefineProperty,
7-
Symbol,
87
SafePromise,
8+
Symbol,
99
} = primordials;
1010

1111
const { isContext } = internalBinding('contextify');

lib/internal/worker.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const {
77
MathMax,
88
ObjectCreate,
99
ObjectEntries,
10+
Symbol,
1011
} = primordials;
1112

1213
const EventEmitter = require('events');

lib/internal/worker/io.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const {
77
ObjectGetOwnPropertyDescriptors,
88
ObjectGetPrototypeOf,
99
ObjectSetPrototypeOf,
10+
Symbol,
1011
} = primordials;
1112

1213
const {

0 commit comments

Comments
 (0)