diff options
Diffstat (limited to 'lib/internal/source_map/source_map_cache.js')
-rw-r--r-- | lib/internal/source_map/source_map_cache.js | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/lib/internal/source_map/source_map_cache.js b/lib/internal/source_map/source_map_cache.js index 340615eb6c..8211e51e3e 100644 --- a/lib/internal/source_map/source_map_cache.js +++ b/lib/internal/source_map/source_map_cache.js @@ -1,26 +1,21 @@ 'use strict'; const { - JSON, - Object: { - create: ObjectCreate, - keys: ObjectKeys, - getOwnPropertyDescriptor: ObjectGetOwnPropertyDescriptor, - }, - ObjectPrototype: { - hasOwnProperty: ObjectHasOwnProperty - }, - MapPrototype: { - entries: MapEntries - }, uncurryThis + JSONParse, + ObjectCreate, + ObjectKeys, + ObjectGetOwnPropertyDescriptor, + ObjectPrototypeHasOwnProperty, + MapPrototypeEntries, + WeakMapPrototypeGet, + uncurryThis, } = primordials; -const MapIteratorNext = uncurryThis(MapEntries(new Map()).next); -const WeakMapGet = uncurryThis(WeakMap.prototype.get); +const MapIteratorNext = uncurryThis(MapPrototypeEntries(new Map()).next); function ObjectGetValueSafe(obj, key) { const desc = ObjectGetOwnPropertyDescriptor(obj, key); - return ObjectHasOwnProperty(desc, 'value') ? desc.value : undefined; + return ObjectPrototypeHasOwnProperty(desc, 'value') ? desc.value : undefined; } // See https://sourcemaps.info/spec.html for SourceMap V3 specification. @@ -115,7 +110,7 @@ function lineLengths(content) { function sourceMapFromFile(sourceMapFile) { try { const content = fs.readFileSync(sourceMapFile, 'utf8'); - const data = JSON.parse(content); + const data = JSONParse(content); return sourcesToAbsolute(dirname(sourceMapFile), data); } catch (err) { debug(err.stack); @@ -134,7 +129,7 @@ function sourceMapFromDataUrl(basePath, url) { const decodedData = base64 ? Buffer.from(data, 'base64').toString('utf8') : data; try { - const parsedData = JSON.parse(decodedData); + const parsedData = JSONParse(decodedData); return sourcesToAbsolute(basePath, parsedData); } catch (err) { debug(err.stack); @@ -182,7 +177,7 @@ function rekeySourceMap(cjsModuleInstance, newInstance) { function sourceMapCacheToObject() { const obj = ObjectCreate(null); - const it = MapEntries(esmSourceMapCache); + const it = MapPrototypeEntries(esmSourceMapCache); let entry; while (!(entry = MapIteratorNext(it)).done) { const k = entry.value[0]; @@ -211,7 +206,7 @@ function appendCJSCache(obj) { for (let i = 0; i < cjsModules.length; i++) { const key = cjsModules[i]; const module = ObjectGetValueSafe(cjsModuleCache, key); - const value = WeakMapGet(cjsSourceMapCache, module); + const value = WeakMapPrototypeGet(cjsSourceMapCache, module); if (value) { // This is okay because `obj` has a null prototype. obj[`file://${key}`] = { |