From 0dd8605425cdac6a658f37a6f16bfa6779e30259 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/main_thread_only.js | 1 + 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, 28 insertions(+), 1 deletion(-) diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 1e1dab537d0ca8..70a2e76c20ce47 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 8bdf45dadec752..4a5dca9b49466a 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -25,6 +25,7 @@ const { ObjectAssign, ObjectIs, ObjectKeys, + Map, } = primordials; const { Buffer } = require('buffer'); diff --git a/lib/domain.js b/lib/domain.js index 8edd4ee2676df0..29232a90de08ab 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 2ce8b085919f69..167ee9d7b3fe7f 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 65231addacd7b6..1a0db5f882fc6f 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 1db758f424e2e7..6cc82a56c6d4af 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 730a3eddd54b65..819d5e0fe749ae 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 6462fc0829ed63..c8ae659358d9a5 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -8,6 +8,7 @@ const { ArrayIsArray, Boolean, Error, + Map, ObjectDefineProperties, ObjectDefineProperty, ObjectKeys, 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 461c420d79a6f6..49148602a49606 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 c0cd8228dff103..4e40460f744d30 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 840100ff1e3da7..7b410f631e5750 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/main_thread_only.js b/lib/internal/process/main_thread_only.js index 7fa849f46cffa4..17df409472f58e 100644 --- a/lib/internal/process/main_thread_only.js +++ b/lib/internal/process/main_thread_only.js @@ -5,6 +5,7 @@ const { ArrayIsArray, + Map, } = primordials; const { 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 587652a3dff76a..cd45e162117550 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 ad0a2b08a18d04..d4ac786401e57e 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -10,6 +10,7 @@ const { DatePrototypeToString, ErrorPrototypeToString, JSONStringify, + Map, MapPrototypeEntries, MathFloor, MathMax, diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index 92ee414bf8d3f9..8b2d32b352f922 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,