| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1e923f1 commit 4b3cc3c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,12 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | - ArrayPrototypeMap, | ||
| 4 | + ArrayPrototypePush, | ||
| 5 | 5 | JSONParse, | |
| 6 | 6 | ObjectKeys, | |
| 7 | 7 | RegExpPrototypeExec, | |
| 8 | - RegExpPrototypeSymbolSplit, | ||
| 9 | 8 | SafeMap, | |
| 9 | + StringPrototypeCodePointAt, | ||
| 10 | 10 | StringPrototypeSplit, | |
| 11 | 11 | } = primordials; | |
| 12 | 12 | ||
@@ -205,14 +205,26 @@ function dataFromUrl(sourceURL, sourceMappingURL) { | |||
| 205 | 205 | // from. This allows translation from byte offset V8 coverage reports, | |
| 206 | 206 | // to line/column offset Source Map V3. | |
| 207 | 207 | function lineLengths(content) { | |
| 208 | - // We purposefully keep \r as part of the line-length calculation, in | ||
| 209 | - // cases where there is a \r\n separator, so that this can be taken into | ||
| 210 | - // account in coverage calculations. | ||
| 211 | - return ArrayPrototypeMap(RegExpPrototypeSymbolSplit(/\n|\u2028|\u2029/, content), (line) => { | ||
| 212 | - return line.length; | ||
| 213 | - }); | ||
| 208 | + const contentLength = content.length; | ||
| 209 | + const output = []; | ||
| 210 | + let lineLength = 0; | ||
| 211 | + for (let i = 0; i < contentLength; i++, lineLength++) { | ||
| 212 | + const codePoint = StringPrototypeCodePointAt(content, i); | ||
| 213 | + | ||
| 214 | + // We purposefully keep \r as part of the line-length calculation, in | ||
| 215 | + // cases where there is a \r\n separator, so that this can be taken into | ||
| 216 | + // account in coverage calculations. | ||
| 217 | + // codepoints for \n (new line), \u2028 (line separator) and \u2029 (paragraph separator) | ||
| 218 | + if (codePoint === 10 || codePoint === 0x2028 || codePoint === 0x2029) { | ||
| 219 | + ArrayPrototypePush(output, lineLength); | ||
| 220 | + lineLength = -1; // To not count the matched codePoint such as \n character | ||
| 221 | + } | ||
| 222 | + } | ||
| 223 | + ArrayPrototypePush(output, lineLength); | ||
| 224 | + return output; | ||
| 214 | 225 | } | |
| 215 | 226 | ||
| 227 | + | ||
| 216 | 228 | function sourceMapFromFile(mapURL) { | |
| 217 | 229 | try { | |
| 218 | 230 | const fs = require('fs'); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments