diff --git a/lib/internal/source_map/source_map_cache.js b/lib/internal/source_map/source_map_cache.js index ea8834d6a930b8..a520af68eb7efa 100644 --- a/lib/internal/source_map/source_map_cache.js +++ b/lib/internal/source_map/source_map_cache.js @@ -4,22 +4,12 @@ const { ArrayPrototypeMap, JSONParse, ObjectKeys, - ObjectGetOwnPropertyDescriptor, - ObjectPrototypeHasOwnProperty, RegExpPrototypeExec, RegExpPrototypeSymbolSplit, SafeMap, StringPrototypeSplit, } = primordials; -function ObjectGetValueSafe(obj, key) { - const desc = ObjectGetOwnPropertyDescriptor(obj, key); - if (desc === undefined) { - return undefined; - } - return ObjectPrototypeHasOwnProperty(desc, 'value') ? desc.value : undefined; -} - // See https://sourcemaps.info/spec.html for SourceMap V3 specification. const { Buffer } = require('buffer'); let debug = require('internal/util/debuglog').debuglog('source_map', (fn) => { @@ -301,11 +291,11 @@ function sourceMapCacheToObject() { function appendCJSCache(obj) { for (const value of getCjsSourceMapCache()) { - obj[ObjectGetValueSafe(value, 'filename')] = { + obj[value.filename] = { __proto__: null, - lineLengths: ObjectGetValueSafe(value, 'lineLengths'), - data: ObjectGetValueSafe(value, 'data'), - url: ObjectGetValueSafe(value, 'url') + lineLengths: value.lineLengths, + data: value.data, + url: value.url, }; } } @@ -320,8 +310,8 @@ function findSourceMap(sourceURL) { let entry = esmSourceMapCache.get(sourceURL) ?? generatedSourceMapCache.get(sourceURL); if (entry === undefined) { for (const value of getCjsSourceMapCache()) { - const filename = ObjectGetValueSafe(value, 'filename'); - const cachedSourceURL = ObjectGetValueSafe(value, 'sourceURL'); + const filename = value.filename; + const cachedSourceURL = value.sourceURL; if (sourceURL === filename || sourceURL === cachedSourceURL) { entry = value; } @@ -330,9 +320,9 @@ function findSourceMap(sourceURL) { if (entry === undefined) { return undefined; } - let sourceMap = ObjectGetValueSafe(entry, 'sourceMap'); + let sourceMap = entry.sourceMap; if (sourceMap === undefined) { - sourceMap = new SourceMap(ObjectGetValueSafe(entry, 'data')); + sourceMap = new SourceMap(entry.data); entry.sourceMap = sourceMap; } return sourceMap;