From 0b8eaf2e5cbf6dfab286dbf911b2fdcb7cce1b8a Mon Sep 17 00:00:00 2001 From: Sebastien Ahkrin Date: Thu, 2 Jan 2020 15:05:55 +0100 Subject: [PATCH] lib: replace WeakMap global by the primordials PR-URL: https://github.com/nodejs/node/pull/31158 Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Anto Aravinth Reviewed-By: David Carlier Reviewed-By: Rich Trott Reviewed-By: Trivikram Kamat --- lib/.eslintrc.yaml | 2 ++ lib/internal/console/constructor.js | 1 + lib/internal/errors.js | 1 + lib/internal/process/promises.js | 1 + lib/internal/source_map/source_map_cache.js | 1 + lib/internal/vm/module.js | 1 + 6 files changed, 7 insertions(+) diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 8299e79a00eba0..f3a0d9f1d3e5c9 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: WeakMap + message: "Use `const { WeakMap } = primordials;` instead of the global." no-restricted-syntax: # Config copied from .eslintrc.js - error diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index aff24f93455c8b..5e29c72918a163 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -17,6 +17,7 @@ const { ReflectOwnKeys, Symbol, SymbolHasInstance, + WeakMap, } = primordials; const { trace } = internalBinding('trace_events'); diff --git a/lib/internal/errors.js b/lib/internal/errors.js index a0b7ee38cf1963..fcce048c2822c8 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -18,6 +18,7 @@ const { ObjectKeys, Symbol, SymbolFor, + WeakMap, } = primordials; const messages = new Map(); diff --git a/lib/internal/process/promises.js b/lib/internal/process/promises.js index e2a589a802682d..01450d75dfeae9 100644 --- a/lib/internal/process/promises.js +++ b/lib/internal/process/promises.js @@ -2,6 +2,7 @@ const { ObjectDefineProperty, + WeakMap, } = primordials; const { diff --git a/lib/internal/source_map/source_map_cache.js b/lib/internal/source_map/source_map_cache.js index 8211e51e3ec413..2d30d53db84c9e 100644 --- a/lib/internal/source_map/source_map_cache.js +++ b/lib/internal/source_map/source_map_cache.js @@ -7,6 +7,7 @@ const { ObjectGetOwnPropertyDescriptor, ObjectPrototypeHasOwnProperty, MapPrototypeEntries, + WeakMap, WeakMapPrototypeGet, uncurryThis, } = primordials; diff --git a/lib/internal/vm/module.js b/lib/internal/vm/module.js index 2a89165409dec6..d12362184a5051 100644 --- a/lib/internal/vm/module.js +++ b/lib/internal/vm/module.js @@ -7,6 +7,7 @@ const { ObjectDefineProperty, SafePromise, Symbol, + WeakMap, } = primordials; const { isContext } = internalBinding('contextify');