MCPcopy Index your code
hub / github.com/nodejs/node / lineLengths

Function lineLengths

lib/internal/source_map/source_map_cache.js:260–278  ·  view source on GitHub ↗
(content)

Source from the content-addressed store, hash-verified

258// from. This allows translation from byte offset V8 coverage reports,
259// to line/column offset Source Map V3.
260function lineLengths(content) {
261 const contentLength = content.length;
262 const output = [];
263 let lineLength = 0;
264 for (let i = 0; i < contentLength; i++, lineLength++) {
265 const codePoint = StringPrototypeCodePointAt(content, i);
266
267 // We purposefully keep \r as part of the line-length calculation, in
268 // cases where there is a \r\n separator, so that this can be taken into
269 // account in coverage calculations.
270 // codepoints for \n (new line), \u2028 (line separator) and \u2029 (paragraph separator)
271 if (codePoint === 10 || codePoint === 0x2028 || codePoint === 0x2029) {
272 ArrayPrototypePush(output, lineLength);
273 lineLength = -1; // To not count the matched codePoint such as \n character
274 }
275 }
276 ArrayPrototypePush(output, lineLength);
277 return output;
278}
279
280/**
281 * Read source map from file.

Callers 1

maybeCacheSourceMapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…