From 015e801ea6e962fc2478517692b3b086b55d7310 Mon Sep 17 00:00:00 2001 From: Sebastien Ahkrin Date: Thu, 2 Jan 2020 14:27:54 +0100 Subject: [PATCH] lib: replace Set global by the primordials --- lib/.eslintrc.yaml | 2 ++ lib/_stream_readable.js | 1 + lib/internal/fs/rimraf.js | 1 + lib/internal/http2/core.js | 1 + lib/internal/http2/util.js | 1 + lib/internal/inspector_async_hook.js | 4 ++++ lib/internal/modules/esm/create_dynamic_module.js | 1 + lib/internal/process/per_thread.js | 1 + lib/internal/repl/utils.js | 1 + lib/internal/util.js | 1 + lib/internal/util/comparisons.js | 1 + lib/internal/util/inspect.js | 1 + lib/perf_hooks.js | 1 + lib/repl.js | 1 + lib/trace_events.js | 1 + 15 files changed, 19 insertions(+) diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 8299e79a00eba0..74630553570801 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -29,6 +29,8 @@ rules: message: "Use `const { Reflect } = primordials;` instead of the global." - name: Symbol message: "Use `const { Symbol } = primordials;` instead of the global." + - name: Set + message: "Use `const { Set } = primordials;` instead of the global." no-restricted-syntax: # Config copied from .eslintrc.js - error diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index bda03cc1529892..07db237514f405 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -27,6 +27,7 @@ const { NumberIsNaN, ObjectDefineProperty, ObjectSetPrototypeOf, + Set, SymbolAsyncIterator, Symbol } = primordials; diff --git a/lib/internal/fs/rimraf.js b/lib/internal/fs/rimraf.js index 02cdfdf4b5da3f..e88dd9697b1938 100644 --- a/lib/internal/fs/rimraf.js +++ b/lib/internal/fs/rimraf.js @@ -8,6 +8,7 @@ const { Promise, + Set, } = primordials; const { Buffer } = require('buffer'); diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 7e3f217617cef0..d4787332b24577 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -12,6 +12,7 @@ const { ObjectPrototypeHasOwnProperty, Promise, ReflectGetPrototypeOf, + Set, Symbol, } = primordials; diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js index 3bf3a8fdd56df9..62ea60d06f4bca 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -6,6 +6,7 @@ const { Number, ObjectCreate, ObjectKeys, + Set, Symbol, } = primordials; diff --git a/lib/internal/inspector_async_hook.js b/lib/internal/inspector_async_hook.js index b16e8d025ec957..a6112697cfdaa2 100644 --- a/lib/internal/inspector_async_hook.js +++ b/lib/internal/inspector_async_hook.js @@ -3,6 +3,10 @@ let hook; let config; +const { + Set, +} = primordials; + function lazyHookCreation() { const inspector = internalBinding('inspector'); const { createHook } = require('async_hooks'); diff --git a/lib/internal/modules/esm/create_dynamic_module.js b/lib/internal/modules/esm/create_dynamic_module.js index f8e00fd2ad1889..38344f69640e6c 100644 --- a/lib/internal/modules/esm/create_dynamic_module.js +++ b/lib/internal/modules/esm/create_dynamic_module.js @@ -5,6 +5,7 @@ const { ArrayPrototypeMap, JSONStringify, ObjectCreate, + Set, } = primordials; const debug = require('internal/util/debuglog').debuglog('esm'); diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js index 2ead72781d53f0..107caba3d07154 100644 --- a/lib/internal/process/per_thread.js +++ b/lib/internal/process/per_thread.js @@ -12,6 +12,7 @@ const { ObjectFreeze, ObjectGetOwnPropertyDescriptors, RegExpPrototypeTest, + Set, SetPrototypeHas, StringPrototypeReplace, } = primordials; diff --git a/lib/internal/repl/utils.js b/lib/internal/repl/utils.js index 75781be32b8971..4da23e096c95ed 100644 --- a/lib/internal/repl/utils.js +++ b/lib/internal/repl/utils.js @@ -2,6 +2,7 @@ const { MathMin, + Set, Symbol, } = primordials; diff --git a/lib/internal/util.js b/lib/internal/util.js index 8d4f66a0be26ff..41af51a4c100a8 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -12,6 +12,7 @@ const { ObjectSetPrototypeOf, Promise, ReflectConstruct, + Set, Symbol, SymbolFor, } = primordials; diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index 0d59f37ad846e5..3f9d2fc91fad89 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -14,6 +14,7 @@ const { ObjectPrototypeHasOwnProperty, ObjectPrototypePropertyIsEnumerable, ObjectPrototypeToString, + Set, StringPrototypeValueOf, SymbolPrototypeValueOf, SymbolToStringTag, diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 7054e35477e172..168fd8a116e1c9 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -33,6 +33,7 @@ const { ObjectPrototypePropertyIsEnumerable, ObjectSeal, RegExpPrototypeToString, + Set, SetPrototype, SetPrototypeValues, StringPrototypeValueOf, diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index 3fb06f4e93dfa1..92ee414bf8d3f9 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -7,6 +7,7 @@ const { ObjectDefineProperties, ObjectDefineProperty, ObjectKeys, + Set, Symbol, } = primordials; diff --git a/lib/repl.js b/lib/repl.js index d9efb8c5ece523..7fce42a741c255 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -55,6 +55,7 @@ const { ObjectSetPrototypeOf, Promise, PromiseRace, + Set, Symbol, } = primordials; diff --git a/lib/trace_events.js b/lib/trace_events.js index 1ff2b5a4fb1515..35f776ad53c310 100644 --- a/lib/trace_events.js +++ b/lib/trace_events.js @@ -2,6 +2,7 @@ const { ArrayIsArray, + Set, Symbol, } = primordials;