Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions lib/internal/source_map/source_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@
'use strict';

const {
ArrayIsArray
ArrayIsArray,
ArrayPrototypePush,
ArrayPrototypeSlice,
ArrayPrototypeSort,
ObjectPrototypeHasOwnProperty,
StringPrototypeCharAt,
} = primordials;

const {
Expand All @@ -94,14 +99,14 @@ class StringCharIterator {
* @return {string}
*/
next() {
return this._string.charAt(this._position++);
return StringPrototypeCharAt(this._string, this._position++);
}

/**
* @return {string}
*/
peek() {
return this._string.charAt(this._position);
return StringPrototypeCharAt(this._string, this._position);
}

/**
Expand Down Expand Up @@ -158,7 +163,7 @@ class SourceMap {
} else {
this.#parseMap(this.#payload, 0, 0);
}
this.#mappings.sort(compareSourceMapEntry);
ArrayPrototypeSort(this.#mappings, compareSourceMapEntry);
}

/**
Expand Down Expand Up @@ -211,7 +216,7 @@ class SourceMap {
/**
* @override
*/
#parseMap = (map, lineNumber, columnNumber) => {
#parseMap(map, lineNumber, columnNumber) {
let sourceIndex = 0;
let sourceLineNumber = 0;
let sourceColumnNumber = 0;
Expand All @@ -222,7 +227,7 @@ class SourceMap {
for (let i = 0; i < map.sources.length; ++i) {
const url = map.sources[i];
originalToCanonicalURLMap[url] = url;
sources.push(url);
ArrayPrototypePush(sources, url);
this.#sources[url] = true;

if (map.sourcesContent && map.sourcesContent[i])
Expand All @@ -246,7 +251,7 @@ class SourceMap {

columnNumber += decodeVLQ(stringCharIterator);
if (isSeparator(stringCharIterator.peek())) {
this.#mappings.push([lineNumber, columnNumber]);
ArrayPrototypePush(this.#mappings, [lineNumber, columnNumber]);
continue;
}

Expand All @@ -264,8 +269,11 @@ class SourceMap {
name = map.names?.[nameIndex];
}

this.#mappings.push([lineNumber, columnNumber, sourceURL,
sourceLineNumber, sourceColumnNumber, name]);
ArrayPrototypePush(
this.#mappings,
[lineNumber, columnNumber, sourceURL, sourceLineNumber,
sourceColumnNumber, name]
);
}
};
}
Expand Down Expand Up @@ -320,8 +328,9 @@ function cloneSourceMapV3(payload) {
}
payload = { ...payload };
for (const key in payload) {
if (payload.hasOwnProperty(key) && ArrayIsArray(payload[key])) {
payload[key] = payload[key].slice(0);
if (ObjectPrototypeHasOwnProperty(payload, key) &&
ArrayIsArray(payload[key])) {
payload[key] = ArrayPrototypeSlice(payload[key]);
}
}
return payload;
Expand Down