From e5b7d64f2d41edb9fe6013e325f768984bc9d2d0 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 PR-URL: https://github.com/nodejs/node/pull/31154 Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: David Carlier Reviewed-By: Rich Trott Reviewed-By: Trivikram Kamat --- lib/.eslintrc.yaml | 2 ++ 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/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 + 13 files changed, 17 insertions(+) diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 982d899744d9d7..059371f8663c0a 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -27,6 +27,8 @@ rules: message: "Use `const { Promise } = primordials;` instead of the global." - name: Reflect message: "Use `const { Reflect } = primordials;` instead of the global." + - name: Set + message: "Use `const { Set } = primordials;` instead of the global." - name: Symbol message: "Use `const { Symbol } = primordials;` instead of the global." - name: WeakMap diff --git a/lib/internal/fs/rimraf.js b/lib/internal/fs/rimraf.js index 7998430230c039..be7e1ba154ba97 100644 --- a/lib/internal/fs/rimraf.js +++ b/lib/internal/fs/rimraf.js @@ -8,6 +8,7 @@ const { Promise, + Set, } = primordials; const { diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index b4aacec21836a1..c0cd8228dff103 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 650033f352e438..a1dd4442089502 100644 --- a/lib/internal/process/per_thread.js +++ b/lib/internal/process/per_thread.js @@ -12,6 +12,7 @@ const { ObjectFreeze, ObjectGetOwnPropertyDescriptors, RegExpPrototypeTest, + Set, SetPrototype, SetPrototypeHas, StringPrototypeReplace, 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 b2784217171410..ec59d4a50dddbb 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -14,6 +14,7 @@ const { ObjectPrototypeHasOwnProperty, ObjectPrototypePropertyIsEnumerable, ObjectPrototypeToString, + Set, StringPrototypeValueOf, SymbolPrototypeValueOf, } = primordials; diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 8a67b018930c1f..ad0a2b08a18d04 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -34,6 +34,7 @@ const { ObjectPrototypePropertyIsEnumerable, ObjectSeal, RegExpPrototypeToString, + Set, SetPrototypeValues, StringPrototypeValueOf, SymbolPrototypeToString, 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 62d39a17d045ca..e2fb41f98cf084 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -57,6 +57,7 @@ const { ObjectSetPrototypeOf, Promise, PromiseRace, + Set, Symbol, WeakMap, WeakSet, 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;