summaryrefslogtreecommitdiff
path: root/lib/internal/source_map
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2019-11-22 18:04:46 +0100
committerMichaël Zasso <targos@protonmail.com>2019-11-25 10:28:15 +0100
commit0646eda4fc0affb98e13c30acb522e63b7fd6dde (patch)
tree078209f50b044e24ea2c72cbbe7dca6e34bb7e25 /lib/internal/source_map
parent35c6e0cc2b56a5380e6808ef5603ecc2b167e032 (diff)
downloadandroid-node-v8-0646eda4fc0affb98e13c30acb522e63b7fd6dde.tar.gz
android-node-v8-0646eda4fc0affb98e13c30acb522e63b7fd6dde.tar.bz2
android-node-v8-0646eda4fc0affb98e13c30acb522e63b7fd6dde.zip
lib: flatten access to primordials
Store all primordials as properties of the primordials object. Static functions are prefixed by the constructor's name and prototype methods are prefixed by the constructor's name followed by "Prototype". For example: primordials.Object.keys becomes primordials.ObjectKeys. PR-URL: https://github.com/nodejs/node/pull/30610 Refs: https://github.com/nodejs/node/issues/29766 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'lib/internal/source_map')
-rw-r--r--lib/internal/source_map/source_map_cache.js33
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}`] = {