mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
lib: replace Symbol global by the primordials Symbol
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
1 parent
d1f4936fab
commit
eac3f0adc4
60 files changed
+93
-3
No files matched your search
@@ -23,6 +23,8 @@ rules:
|
||||
message: "Use `const { Object } = primordials;` instead of the global."
|
||||
- name: Reflect
|
||||
message: "Use `const { Reflect } = primordials;` instead of the global."
|
||||
- name: Symbol
|
||||
message: "Use `const { Symbol } = primordials;` instead of the global."
|
||||
no-restricted-syntax:
|
||||
# Config copied from .eslintrc.js
|
||||
- error
|
||||
|
||||
@@ -25,6 +25,7 @@ const {
|
||||
ObjectKeys,
|
||||
ObjectSetPrototypeOf,
|
||||
ObjectValues,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const net = require('net');
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
const {
|
||||
MathMin,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
const { setImmediate } = require('timers');
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ const {
|
||||
ObjectKeys,
|
||||
ObjectPrototypeHasOwnProperty,
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { getDefaultHighWaterMark } = require('internal/streams/state');
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
const {
|
||||
ObjectKeys,
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const net = require('net');
|
||||
|
||||
@@ -27,6 +27,7 @@ const {
|
||||
NumberIsNaN,
|
||||
ObjectDefineProperty,
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
module.exports = Readable;
|
||||
|
||||
@@ -29,6 +29,7 @@ const {
|
||||
Array,
|
||||
ObjectDefineProperty,
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
module.exports = Writable;
|
||||
|
||||
@@ -25,6 +25,7 @@ const {
|
||||
ObjectAssign,
|
||||
ObjectDefineProperty,
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
const {
|
||||
NumberIsSafeInteger,
|
||||
ReflectApply,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -34,6 +34,7 @@ const {
|
||||
ObjectDefineProperties,
|
||||
ObjectDefineProperty,
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -30,6 +30,7 @@ const {
|
||||
Array,
|
||||
ObjectDefineProperty,
|
||||
ReflectApply,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const EventEmitter = require('events');
|
||||
|
||||
@@ -32,6 +32,7 @@ const {
|
||||
ObjectKeys,
|
||||
ReflectApply,
|
||||
ReflectOwnKeys,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
const kRejection = Symbol.for('nodejs.rejection');
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
const {
|
||||
JSONParse,
|
||||
JSONStringify,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -4,6 +4,7 @@ const {
|
||||
FunctionPrototypeBind,
|
||||
NumberIsSafeInteger,
|
||||
ObjectDefineProperty,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -4,6 +4,7 @@ const {
|
||||
ArrayIsArray,
|
||||
ObjectDefineProperty,
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
const {
|
||||
JSONParse,
|
||||
JSONStringify,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
const { Buffer } = require('buffer');
|
||||
const { StringDecoder } = require('string_decoder');
|
||||
|
||||
@@ -15,6 +15,7 @@ const {
|
||||
ObjectPrototypeHasOwnProperty,
|
||||
ObjectValues,
|
||||
ReflectOwnKeys,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { trace } = internalBinding('trace_events');
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const {
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const {
|
||||
ObjectDefineProperty,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
getCiphers: _getCiphers,
|
||||
getCurves: _getCurves,
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { codes } = require('internal/errors');
|
||||
const { UDP } = internalBinding('udp_wrap');
|
||||
const { guessHandleType } = internalBinding('util');
|
||||
|
||||
@@ -7,6 +7,7 @@ const {
|
||||
ObjectCreate,
|
||||
ObjectDefineProperties,
|
||||
ObjectGetOwnPropertyDescriptors,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -16,6 +16,7 @@ const {
|
||||
NumberIsInteger,
|
||||
ObjectDefineProperty,
|
||||
ObjectKeys,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const messages = new Map();
|
||||
|
||||
@@ -31,7 +31,7 @@ module.exports = function() {
|
||||
getOwnPropertyDescriptors,
|
||||
getOwnPropertyNames,
|
||||
getOwnPropertySymbols,
|
||||
getPrototypeOf
|
||||
getPrototypeOf,
|
||||
} = Object;
|
||||
const objectHasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
const { ownKeys } = Reflect;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const {
|
||||
ObjectDefineProperty,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const pathModule = require('path');
|
||||
|
||||
@@ -4,6 +4,7 @@ const {
|
||||
MathMax,
|
||||
MathMin,
|
||||
NumberIsSafeInteger,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -7,6 +7,7 @@ const {
|
||||
NumberIsFinite,
|
||||
ObjectSetPrototypeOf,
|
||||
ReflectOwnKeys,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { Buffer } = require('buffer');
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
const {
|
||||
ObjectDefineProperty,
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const errors = require('internal/errors');
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { setUnrefTimeout } = require('internal/timers');
|
||||
const { PerformanceEntry, notify } = internalBinding('performance');
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ const {
|
||||
ObjectKeys,
|
||||
ObjectPrototypeHasOwnProperty,
|
||||
ReflectGetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const assert = require('internal/assert');
|
||||
|
||||
@@ -11,6 +11,7 @@ const {
|
||||
ObjectDefineProperty,
|
||||
ObjectPrototypeHasOwnProperty,
|
||||
ReflectGetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -6,6 +6,7 @@ const {
|
||||
Number,
|
||||
ObjectCreate,
|
||||
ObjectKeys,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const binding = internalBinding('http2');
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { setImmediate } = require('timers');
|
||||
const assert = require('internal/assert');
|
||||
const { Socket } = require('net');
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const Buffer = require('buffer').Buffer;
|
||||
const { writeBuffer } = internalBinding('fs');
|
||||
const errors = require('internal/errors');
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const {
|
||||
Array,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const kCompare = Symbol('compare');
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const acorn = require('internal/deps/acorn/acorn/dist/acorn');
|
||||
const privateMethods =
|
||||
require('internal/deps/acorn-plugins/acorn-private-methods/index');
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const {
|
||||
Array,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { Buffer } = require('buffer');
|
||||
|
||||
@@ -4,6 +4,7 @@ const {
|
||||
ObjectCreate,
|
||||
ObjectGetPrototypeOf,
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const finished = require('internal/streams/end-of-stream');
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { Buffer } = require('buffer');
|
||||
const { inspect } = require('internal/util/inspect');
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { Duplex } = require('stream');
|
||||
|
||||
const kCallback = Symbol('Callback');
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
ERR_INVALID_ARG_TYPE
|
||||
} = require('internal/errors').codes;
|
||||
|
||||
@@ -77,6 +77,7 @@ const {
|
||||
MathTrunc,
|
||||
NumberMIN_SAFE_INTEGER,
|
||||
ObjectCreate,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -4,6 +4,7 @@ const {
|
||||
ObjectKeys,
|
||||
SafeMap,
|
||||
SafeSet,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { trace } = internalBinding('trace_events');
|
||||
|
||||
@@ -11,6 +11,7 @@ const {
|
||||
ObjectKeys,
|
||||
ReflectGetOwnPropertyDescriptor,
|
||||
ReflectOwnKeys,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { inspect } = require('internal/util/inspect');
|
||||
|
||||
@@ -11,7 +11,9 @@ const {
|
||||
ObjectGetPrototypeOf,
|
||||
ObjectSetPrototypeOf,
|
||||
ReflectConstruct,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
codes: {
|
||||
ERR_INVALID_ARG_TYPE,
|
||||
|
||||
@@ -15,6 +15,7 @@ const {
|
||||
ObjectPrototypePropertyIsEnumerable,
|
||||
ObjectPrototypeToString,
|
||||
StringPrototypeValueOf,
|
||||
Symbol,
|
||||
SymbolPrototypeValueOf,
|
||||
} = primordials;
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ const {
|
||||
ArrayIsArray,
|
||||
ObjectCreate,
|
||||
ObjectDefineProperty,
|
||||
Symbol,
|
||||
SafePromise,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { isContext } = internalBinding('contextify');
|
||||
|
||||
@@ -7,6 +7,7 @@ const {
|
||||
MathMax,
|
||||
ObjectCreate,
|
||||
ObjectEntries,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const EventEmitter = require('events');
|
||||
|
||||
@@ -7,6 +7,7 @@ const {
|
||||
ObjectGetOwnPropertyDescriptors,
|
||||
ObjectGetPrototypeOf,
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -28,6 +28,7 @@ const {
|
||||
NumberIsNaN,
|
||||
ObjectDefineProperty,
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const EventEmitter = require('events');
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
const {
|
||||
ObjectDefineProperties,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { safeGetenv } = internalBinding('credentials');
|
||||
|
||||
@@ -7,6 +7,7 @@ const {
|
||||
ObjectDefineProperties,
|
||||
ObjectDefineProperty,
|
||||
ObjectKeys,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -36,6 +36,7 @@ const {
|
||||
NumberIsNaN,
|
||||
ObjectDefineProperty,
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -55,6 +55,7 @@ const {
|
||||
ObjectKeys,
|
||||
ObjectPrototypeHasOwnProperty,
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
const {
|
||||
ArrayBufferIsView,
|
||||
ObjectDefineProperties,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { Buffer } = require('buffer');
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const {
|
||||
ArrayIsArray,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { hasTracing } = internalBinding('config');
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
const {
|
||||
Array,
|
||||
ObjectPrototypeToString,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const { Buffer } = require('buffer');
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
const {
|
||||
ArrayIsArray,
|
||||
ArrayPrototypeForEach,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
+3
-1
@@ -5,8 +5,10 @@ const {
|
||||
ArrayPrototypeForEach,
|
||||
ArrayPrototypeMap,
|
||||
FunctionPrototypeBind,
|
||||
ObjectKeys
|
||||
ObjectKeys,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
ERR_INVALID_ARG_TYPE,
|
||||
ERR_WASI_ALREADY_STARTED
|
||||
|
||||
@@ -31,6 +31,7 @@ const {
|
||||
ObjectGetPrototypeOf,
|
||||
ObjectKeys,
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
Reference in new issue
Block a user