diff --git a/lib/internal/crypto/util.js b/lib/internal/crypto/util.js index eafcc3d9669288..7c901e307fcd39 100644 --- a/lib/internal/crypto/util.js +++ b/lib/internal/crypto/util.js @@ -8,6 +8,7 @@ const { Number, ObjectKeys, Promise, + SafeMap, StringPrototypeToLowerCase, Symbol, } = primordials; @@ -62,12 +63,14 @@ const { const kHandle = Symbol('kHandle'); const kKeyObject = Symbol('kKeyObject'); -const lazyRequireCache = {}; +const lazyRequireCache = new SafeMap(); function lazyRequire(name) { - let ret = lazyRequireCache[name]; - if (ret === undefined) - ret = lazyRequireCache[name] = require(name); + let ret = lazyRequireCache.get(name); + if (ret === undefined) { + ret = require(name); + lazyRequireCache.set(name, ret); + } return ret; }