From f509aaa7fa0a32253772d5a317e5f48b61e8828a 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 8299e79a00..f3a0d9f1d3 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 aff24f9345..5e29c72918 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 a0b7ee38cf..fcce048c28 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 e2a589a802..01450d75df 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 8211e51e3e..2d30d53db8 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 2a89165409..d12362184a 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');