From 01c67c78cabbec2800a881f5c022eb932caf4b01 Mon Sep 17 00:00:00 2001 From: Sebastien Ahkrin Date: Thu, 2 Jan 2020 14:43:02 +0100 Subject: [PATCH] lib: replace Map global by the primordials --- lib/.eslintrc.yaml | 2 ++ lib/assert.js | 1 + lib/domain.js | 1 + lib/fs.js | 1 + lib/inspector.js | 1 + lib/internal/bootstrap/loaders.js | 3 ++- lib/internal/bootstrap/pre_execution.js | 1 + lib/internal/cluster/child.js | 1 + lib/internal/cluster/master.js | 1 + lib/internal/cluster/round_robin_handle.js | 1 + lib/internal/cluster/utils.js | 4 ++++ lib/internal/console/constructor.js | 1 + lib/internal/encoding.js | 1 + lib/internal/errors.js | 1 + lib/internal/http2/core.js | 1 + lib/internal/modules/cjs/loader.js | 1 + lib/internal/process/signal.js | 4 ++++ lib/internal/source_map/source_map_cache.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/v8.js | 1 + 23 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 8299e79a00eb..6dc07df6df45 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: Map + message: "Use `const { Map } = primordials;` instead of the global." no-restricted-syntax: # Config copied from .eslintrc.js - error diff --git a/lib/assert.js b/lib/assert.js index e937fb159ea4..c703221c31e9 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -25,6 +25,7 @@ const { ObjectIs, ObjectKeys, ObjectPrototypeIsPrototypeOf, + Map, NumberIsNaN, RegExpPrototypeTest, } = primordials; diff --git a/lib/domain.js b/lib/domain.js index 4f340f20ec34..0c4a76d0f17a 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -28,6 +28,7 @@ const { Array, + Map, ObjectDefineProperty, ReflectApply, Symbol, diff --git a/lib/fs.js b/lib/fs.js index d972c1465b91..3810ad2e6ca9 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -25,6 +25,7 @@ 'use strict'; const { + Map, MathMax, NumberIsSafeInteger, ObjectCreate, diff --git a/lib/inspector.js b/lib/inspector.js index 203cd739a7ac..269f95dbd27a 100644 --- a/lib/inspector.js +++ b/lib/inspector.js @@ -3,6 +3,7 @@ const { JSONParse, JSONStringify, + Map, Symbol, } = primordials; diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index 1029d52de9f9..45f5c7376889 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -44,11 +44,12 @@ /* global process, getLinkedBinding, getInternalBinding, primordials */ const { - ReflectGet, + Map, ObjectCreate, ObjectDefineProperty, ObjectKeys, ObjectPrototypeHasOwnProperty, + ReflectGet, SafeSet, } = primordials; diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js index 7af4be660fcc..1f4d5c04b9b9 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -1,6 +1,7 @@ 'use strict'; const { + Map, ObjectDefineProperty, SafeWeakMap, } = primordials; diff --git a/lib/internal/cluster/child.js b/lib/internal/cluster/child.js index ed5d7ce76dbc..250a82ecabaa 100644 --- a/lib/internal/cluster/child.js +++ b/lib/internal/cluster/child.js @@ -1,6 +1,7 @@ 'use strict'; const { + Map, ObjectAssign, } = primordials; diff --git a/lib/internal/cluster/master.js b/lib/internal/cluster/master.js index bee224a67d94..9bdb0181d3db 100644 --- a/lib/internal/cluster/master.js +++ b/lib/internal/cluster/master.js @@ -1,6 +1,7 @@ 'use strict'; const { + Map, ObjectKeys, ObjectValues, } = primordials; diff --git a/lib/internal/cluster/round_robin_handle.js b/lib/internal/cluster/round_robin_handle.js index 61023b83705b..e89a309c7984 100644 --- a/lib/internal/cluster/round_robin_handle.js +++ b/lib/internal/cluster/round_robin_handle.js @@ -2,6 +2,7 @@ const { Boolean, + Map, } = primordials; const assert = require('internal/assert'); diff --git a/lib/internal/cluster/utils.js b/lib/internal/cluster/utils.js index b6d572fd0ea4..9e7a1186ffc2 100644 --- a/lib/internal/cluster/utils.js +++ b/lib/internal/cluster/utils.js @@ -1,5 +1,9 @@ 'use strict'; +const { + Map, +} = primordials; + module.exports = { sendHelper, internal diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index aff24f93455c..65d0248a20d2 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -7,6 +7,7 @@ const { ArrayFrom, ArrayIsArray, Boolean, + Map, MathFloor, Number, ObjectDefineProperties, diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index 927fd5afc5a5..6cb840e9d1e8 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -4,6 +4,7 @@ // https://encoding.spec.whatwg.org const { + Map, ObjectCreate, ObjectDefineProperties, ObjectGetOwnPropertyDescriptors, diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 8b0a7a0d7aab..d88bdb830f85 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -12,6 +12,7 @@ const { ArrayIsArray, + Map, MathAbs, NumberIsInteger, ObjectDefineProperty, diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 7e3f217617ce..0cafd2ccda7d 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -5,6 +5,7 @@ const { ArrayFrom, ArrayIsArray, + Map, MathMin, ObjectAssign, ObjectCreate, diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 19cbc7ab54d6..70d999e050e8 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -24,6 +24,7 @@ const { ArrayIsArray, JSONParse, + Map, ObjectCreate, ObjectDefineProperty, ObjectFreeze, diff --git a/lib/internal/process/signal.js b/lib/internal/process/signal.js index 6929c73c51f4..abc2b93dbfb7 100644 --- a/lib/internal/process/signal.js +++ b/lib/internal/process/signal.js @@ -1,5 +1,9 @@ 'use strict'; +const { + Map, +} = primordials; + const { errnoException, } = require('internal/errors'); diff --git a/lib/internal/source_map/source_map_cache.js b/lib/internal/source_map/source_map_cache.js index 8211e51e3ec4..48307dc7ec62 100644 --- a/lib/internal/source_map/source_map_cache.js +++ b/lib/internal/source_map/source_map_cache.js @@ -6,6 +6,7 @@ const { ObjectKeys, ObjectGetOwnPropertyDescriptor, ObjectPrototypeHasOwnProperty, + Map, MapPrototypeEntries, WeakMapPrototypeGet, uncurryThis, diff --git a/lib/internal/util.js b/lib/internal/util.js index 8d4f66a0be26..16bce5db32bb 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -3,6 +3,7 @@ const { ArrayFrom, ArrayIsArray, + Map, ObjectCreate, ObjectDefineProperties, ObjectDefineProperty, diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index 0d59f37ad846..82ab16447e64 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -5,6 +5,7 @@ const { BigIntPrototypeValueOf, BooleanPrototypeValueOf, DatePrototypeGetTime, + Map, NumberIsNaN, NumberPrototypeValueOf, ObjectGetOwnPropertySymbols, diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 7054e35477e1..30b79c436b94 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -10,6 +10,7 @@ const { DatePrototypeToString, ErrorPrototypeToString, JSONStringify, + Map, MapPrototype, MapPrototypeEntries, MathFloor, diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index 3fb06f4e93df..ba9753e74b5a 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -3,6 +3,7 @@ const { ArrayIsArray, Boolean, + Map, NumberIsSafeInteger, ObjectDefineProperties, ObjectDefineProperty, diff --git a/lib/v8.js b/lib/v8.js index c328a3c57327..8f8f061255f1 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -22,6 +22,7 @@ const { Int16Array, Int32Array, Int8Array, + Map, ObjectPrototypeToString, Symbol, Uint16Array,