Skip to content

Commit

Permalink
lib: refactor source_map to avoid unsafe array iteration
Browse files Browse the repository at this point in the history
PR-URL: #36734
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Pooja D P <Pooja.D.P@ibm.com>
  • Loading branch information
aduh95 authored and targos committed Jun 5, 2021
1 parent 79bf95a commit 3efd960
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/internal/source_map/source_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ function cloneSourceMapV3(payload) {
* @return {number}
*/
function compareSourceMapEntry(entry1, entry2) {
const [lineNumber1, columnNumber1] = entry1;
const [lineNumber2, columnNumber2] = entry2;
const { 0: lineNumber1, 1: columnNumber1 } = entry1;
const { 0: lineNumber2, 1: columnNumber2 } = entry2;
if (lineNumber1 !== lineNumber2) {
return lineNumber1 - lineNumber2;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/source_map/source_map_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function sourceMapFromFile(mapURL) {
// data:[<mediatype>][;base64],<data> see:
// https://tools.ietf.org/html/rfc2397#section-2
function sourceMapFromDataUrl(sourceURL, url) {
const [format, data] = StringPrototypeSplit(url, ',');
const { 0: format, 1: data } = StringPrototypeSplit(url, ',');
const splitFormat = StringPrototypeSplit(format, ';');
const contentType = splitFormat[0];
const base64 = splitFormat[splitFormat.length - 1] === 'base64';
Expand Down

0 comments on commit 3efd960

Please sign in to comment.