From 9085c03806dbc9eb48e14c2afa49080deee0ee3c 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/31155 Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: David Carlier Reviewed-By: Rich Trott Reviewed-By: Trivikram Kamat --- 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 3f21aed7161cb4..04084df3fd9d57 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -19,6 +19,8 @@ rules: message: "Use `const { Error } = primordials;` instead of the global." - name: JSON message: "Use `const { JSON } = primordials;` instead of the global." + - name: Map + message: "Use `const { Map } = primordials;` instead of the global." - name: Math message: "Use `const { Math } = primordials;` instead of the global." - name: Number diff --git a/lib/assert.js b/lib/assert.js index 2447566719ff90..d01e9ccc2b29b4 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -26,6 +26,7 @@ const { ObjectIs, ObjectKeys, ObjectPrototypeIsPrototypeOf, + Map, NumberIsNaN, RegExpPrototypeTest, } = primordials; diff --git a/lib/domain.js b/lib/domain.js index 9a07f22e66712b..f18823960cde02 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -29,6 +29,7 @@ const { Array, Error, + Map, ObjectDefineProperty, ReflectApply, Symbol, diff --git a/lib/fs.js b/lib/fs.js index d972c1465b910f..3810ad2e6ca916 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 203cd739a7ac06..269f95dbd27a12 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 3308957e4a152e..c4ef1d12a2974c 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -45,11 +45,12 @@ const { Error, - 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 7af4be660fcc8b..1f4d5c04b9b9d5 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 ed5d7ce76dbc90..250a82ecabaa34 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 bee224a67d9406..9bdb0181d3db93 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 61023b83705bcb..e89a309c79844c 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 b6d572fd0ea44c..9e7a1186ffc2bf 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 d9f3dc02133941..f1ba8fbbd7c7e6 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -8,6 +8,7 @@ const { ArrayIsArray, Boolean, Error, + Map, MathFloor, Number, ObjectDefineProperties, diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index 927fd5afc5a507..6cb840e9d1e84f 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 a4450dc0b05b4b..76f211c95bb373 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -13,6 +13,7 @@ const { ArrayIsArray, Error, + Map, MathAbs, NumberIsInteger, ObjectDefineProperty, diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index d209a3405ded89..b24083f86d0d9f 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 b127ee4ae7615a..cc888f14bb44ce 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -25,6 +25,7 @@ const { ArrayIsArray, Error, JSONParse, + Map, ObjectCreate, ObjectDefineProperty, ObjectFreeze, diff --git a/lib/internal/process/signal.js b/lib/internal/process/signal.js index 6929c73c51f41c..abc2b93dbfb7f3 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 2d30d53db84c9e..593c2c8277f224 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, WeakMap, WeakMapPrototypeGet, diff --git a/lib/internal/util.js b/lib/internal/util.js index a2c647f1a9981c..5eb5ba9e966ff9 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -4,6 +4,7 @@ const { ArrayFrom, ArrayIsArray, Error, + Map, ObjectCreate, ObjectDefineProperties, ObjectDefineProperty, diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index db30ffcf487545..917de00918e028 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -6,6 +6,7 @@ const { BooleanPrototypeValueOf, DatePrototypeGetTime, Error, + Map, NumberIsNaN, NumberPrototypeValueOf, ObjectGetOwnPropertySymbols, diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 43b61ac1ff32b3..89b9c7b8b9df03 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 82fb66258b940b..267b4577ffee3d 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 ea99e14792114b..a648d995404836 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -23,6 +23,7 @@ const { Int16Array, Int32Array, Int8Array, + Map, ObjectPrototypeToString, Symbol, Uint16Array,