diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
commit | 0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch) | |
tree | f9864d4a4148621378958794cbbfdc2393733283 /node_modules/source-map/lib/source-node.js | |
parent | 6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff) |
upgrade dependencies
Diffstat (limited to 'node_modules/source-map/lib/source-node.js')
-rw-r--r-- | node_modules/source-map/lib/source-node.js | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/node_modules/source-map/lib/source-node.js b/node_modules/source-map/lib/source-node.js index e927f6663..d196a53f8 100644 --- a/node_modules/source-map/lib/source-node.js +++ b/node_modules/source-map/lib/source-node.js @@ -60,13 +60,19 @@ SourceNode.fromStringWithSourceMap = // All even indices of this array are one line of the generated code, // while all odd indices are the newlines between two adjacent lines // (since `REGEX_NEWLINE` captures its match). - // Processed fragments are removed from this array, by calling `shiftNextLine`. + // Processed fragments are accessed by calling `shiftNextLine`. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE); + var remainingLinesIndex = 0; var shiftNextLine = function() { - var lineContents = remainingLines.shift(); + var lineContents = getNextLine(); // The last line of a file might not have a newline. - var newLine = remainingLines.shift() || ""; + var newLine = getNextLine() || ""; return lineContents + newLine; + + function getNextLine() { + return remainingLinesIndex < remainingLines.length ? + remainingLines[remainingLinesIndex++] : undefined; + } }; // We need to remember the position of "remainingLines" @@ -91,10 +97,10 @@ SourceNode.fromStringWithSourceMap = // There is no new line in between. // Associate the code between "lastGeneratedColumn" and // "mapping.generatedColumn" with "lastMapping" - var nextLine = remainingLines[0]; + var nextLine = remainingLines[remainingLinesIndex]; var code = nextLine.substr(0, mapping.generatedColumn - lastGeneratedColumn); - remainingLines[0] = nextLine.substr(mapping.generatedColumn - + remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn - lastGeneratedColumn); lastGeneratedColumn = mapping.generatedColumn; addMappingWithCode(lastMapping, code); @@ -111,21 +117,21 @@ SourceNode.fromStringWithSourceMap = lastGeneratedLine++; } if (lastGeneratedColumn < mapping.generatedColumn) { - var nextLine = remainingLines[0]; + var nextLine = remainingLines[remainingLinesIndex]; node.add(nextLine.substr(0, mapping.generatedColumn)); - remainingLines[0] = nextLine.substr(mapping.generatedColumn); + remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn); lastGeneratedColumn = mapping.generatedColumn; } lastMapping = mapping; }, this); // We have processed all mappings. - if (remainingLines.length > 0) { + if (remainingLinesIndex < remainingLines.length) { if (lastMapping) { // Associate the remaining code in the current line with "lastMapping" addMappingWithCode(lastMapping, shiftNextLine()); } // and add the remaining lines without any mapping - node.add(remainingLines.join("")); + node.add(remainingLines.splice(remainingLinesIndex).join("")); } // Copy sourcesContent into SourceNode |