Skip to content

Commit

Permalink
lib: replace Symbol global by the primordials Symbol
Browse files Browse the repository at this point in the history
PR-URL: #30737
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
Sebastien-Ahkrin authored and targos committed Jan 14, 2020
1 parent d4d6172 commit c6535c0
Show file tree
Hide file tree
Showing 57 changed files with 88 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/_http_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const {
ObjectKeys,
ObjectSetPrototypeOf,
ObjectValues,
Symbol,
} = primordials;

const net = require('net');
Expand Down
1 change: 1 addition & 0 deletions lib/_http_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

const {
MathMin,
Symbol,
} = primordials;
const { setImmediate } = require('timers');

Expand Down
1 change: 1 addition & 0 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const {
ObjectKeys,
ObjectPrototypeHasOwnProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const { getDefaultHighWaterMark } = require('internal/streams/state');
Expand Down
1 change: 1 addition & 0 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
const {
ObjectKeys,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const net = require('net');
Expand Down
1 change: 1 addition & 0 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const {
NumberIsNaN,
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

module.exports = Readable;
Expand Down
1 change: 1 addition & 0 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const {
Array,
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

module.exports = Writable;
Expand Down
1 change: 1 addition & 0 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const {
ObjectAssign,
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const {
Expand Down
1 change: 1 addition & 0 deletions lib/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const {
NumberIsSafeInteger,
ReflectApply,
Symbol,
} = primordials;

const {
Expand Down
1 change: 1 addition & 0 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const {
ObjectDefineProperties,
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const {
Expand Down
1 change: 1 addition & 0 deletions lib/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const {
Array,
ObjectDefineProperty,
ReflectApply,
Symbol,
} = primordials;

const EventEmitter = require('events');
Expand Down
1 change: 1 addition & 0 deletions lib/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const {
JSONParse,
JSONStringify,
Symbol,
} = primordials;

const {
Expand Down
1 change: 1 addition & 0 deletions lib/internal/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
FunctionPrototypeBind,
NumberIsSafeInteger,
ObjectDefineProperty,
Symbol,
} = primordials;

const {
Expand Down
1 change: 1 addition & 0 deletions lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
ArrayIsArray,
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const {
Expand Down
1 change: 1 addition & 0 deletions lib/internal/child_process/serialization.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const {
JSONParse,
JSONStringify,
Symbol,
} = primordials;
const { Buffer } = require('buffer');
const { StringDecoder } = require('string_decoder');
Expand Down
1 change: 1 addition & 0 deletions lib/internal/console/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const {
ObjectPrototypeHasOwnProperty,
ObjectValues,
ReflectOwnKeys,
Symbol,
} = primordials;

const { trace } = internalBinding('trace_events');
Expand Down
1 change: 1 addition & 0 deletions lib/internal/crypto/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const {
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const {
Expand Down
1 change: 1 addition & 0 deletions lib/internal/crypto/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const {
ObjectDefineProperty,
Symbol,
} = primordials;

const {
Expand Down
4 changes: 4 additions & 0 deletions lib/internal/crypto/util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const {
getCiphers: _getCiphers,
getCurves: _getCurves,
Expand Down
5 changes: 5 additions & 0 deletions lib/internal/dgram.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const { codes } = require('internal/errors');
const { UDP } = internalBinding('udp_wrap');
const { guessHandleType } = internalBinding('util');
Expand Down
1 change: 1 addition & 0 deletions lib/internal/encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
ObjectCreate,
ObjectDefineProperties,
ObjectGetOwnPropertyDescriptors,
Symbol,
} = primordials;

const {
Expand Down
1 change: 1 addition & 0 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const {
NumberIsInteger,
ObjectDefineProperty,
ObjectKeys,
Symbol,
} = primordials;

const messages = new Map();
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/freeze_intrinsics.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = function() {
getOwnPropertyDescriptors,
getOwnPropertyNames,
getOwnPropertySymbols,
getPrototypeOf
getPrototypeOf,
} = Object;
const objectHasOwnProperty = Object.prototype.hasOwnProperty;
const { ownKeys } = Reflect;
Expand Down
1 change: 1 addition & 0 deletions lib/internal/fs/dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const {
ObjectDefineProperty,
Symbol,
} = primordials;

const pathModule = require('path');
Expand Down
1 change: 1 addition & 0 deletions lib/internal/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
MathMax,
MathMin,
NumberIsSafeInteger,
Symbol,
} = primordials;

const {
Expand Down
1 change: 1 addition & 0 deletions lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
NumberIsFinite,
ObjectSetPrototypeOf,
ReflectOwnKeys,
Symbol,
} = primordials;

const { Buffer, kMaxLength } = require('buffer');
Expand Down
1 change: 1 addition & 0 deletions lib/internal/fs/watchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const {
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const errors = require('internal/errors');
Expand Down
4 changes: 4 additions & 0 deletions lib/internal/http.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const { setUnrefTimeout } = require('internal/timers');
const { PerformanceEntry, notify } = internalBinding('performance');

Expand Down
1 change: 1 addition & 0 deletions lib/internal/http2/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
ObjectKeys,
ObjectPrototypeHasOwnProperty,
ReflectGetPrototypeOf,
Symbol,
} = primordials;

const assert = require('internal/assert');
Expand Down
1 change: 1 addition & 0 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
ObjectDefineProperty,
ObjectPrototypeHasOwnProperty,
ReflectGetPrototypeOf,
Symbol,
} = primordials;

const {
Expand Down
1 change: 1 addition & 0 deletions lib/internal/http2/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
Number,
ObjectCreate,
ObjectKeys,
Symbol,
} = primordials;

const binding = internalBinding('http2');
Expand Down
4 changes: 4 additions & 0 deletions lib/internal/js_stream_socket.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const { setImmediate } = require('timers');
const assert = require('internal/assert');
const { Socket } = require('net');
Expand Down
4 changes: 4 additions & 0 deletions lib/internal/net.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const Buffer = require('buffer').Buffer;
const { writeBuffer } = internalBinding('fs');
const errors = require('internal/errors');
Expand Down
1 change: 1 addition & 0 deletions lib/internal/priority_queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const {
Array,
Symbol,
} = primordials;

const kCompare = Symbol('compare');
Expand Down
4 changes: 4 additions & 0 deletions lib/internal/repl/utils.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
1 change: 1 addition & 0 deletions lib/internal/stream_base_commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const {
Array,
Symbol,
} = primordials;

const { Buffer } = require('buffer');
Expand Down
1 change: 1 addition & 0 deletions lib/internal/streams/async_iterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
ObjectCreate,
ObjectGetPrototypeOf,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const finished = require('internal/streams/end-of-stream');
Expand Down
4 changes: 4 additions & 0 deletions lib/internal/streams/buffer_list.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

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

Expand Down
5 changes: 5 additions & 0 deletions lib/internal/streams/duplexpair.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const { Duplex } = require('stream');

const kCallback = Symbol('Callback');
Expand Down
4 changes: 4 additions & 0 deletions lib/internal/streams/from.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const {
ERR_INVALID_ARG_TYPE
} = require('internal/errors').codes;
Expand Down
1 change: 1 addition & 0 deletions lib/internal/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const {
MathTrunc,
NumberMIN_SAFE_INTEGER,
ObjectCreate,
Symbol,
} = primordials;

const {
Expand Down
1 change: 1 addition & 0 deletions lib/internal/trace_events_async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
ObjectKeys,
SafeMap,
SafeSet,
Symbol,
} = primordials;

const { trace } = internalBinding('trace_events');
Expand Down
1 change: 1 addition & 0 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
ObjectKeys,
ReflectGetOwnPropertyDescriptor,
ReflectOwnKeys,
Symbol,
} = primordials;

const { inspect } = require('internal/util/inspect');
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const {
ObjectGetPrototypeOf,
ObjectSetPrototypeOf,
ReflectConstruct,
Symbol,
} = primordials;

const {
codes: {
ERR_INVALID_ARG_TYPE,
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/vm/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const {
ArrayIsArray,
ObjectCreate,
ObjectDefineProperty,
Symbol,
SafePromise,
Symbol,
} = primordials;

const { isContext } = internalBinding('contextify');
Expand Down
1 change: 1 addition & 0 deletions lib/internal/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
MathMax,
ObjectCreate,
ObjectEntries,
Symbol,
} = primordials;

const EventEmitter = require('events');
Expand Down
1 change: 1 addition & 0 deletions lib/internal/worker/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
ObjectGetOwnPropertyDescriptors,
ObjectGetPrototypeOf,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const {
Expand Down
Loading

0 comments on commit c6535c0

Please sign in to comment.