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

Function mapRangeToLines

lib/internal/test_runner/coverage.js:628–667  ·  view source on GitHub ↗
(range, lines)

Source from the content-addressed store, hash-verified

626}
627
628function mapRangeToLines(range, lines) {
629 const { startOffset, endOffset, count } = range;
630 const mappedLines = [];
631 let ignoredLines = 0;
632 let start = 0;
633 let end = lines.length;
634 let mid;
635
636 while (start <= end) {
637 mid = MathFloor((start + end) / 2);
638 let line = lines[mid];
639
640 if (startOffset >= line?.startOffset && startOffset <= line?.endOffset) {
641 while (endOffset > line?.startOffset) {
642 // If the range is not covered, and the range covers the entire line,
643 // then mark that line as not covered.
644 if (startOffset <= line.startOffset && endOffset >= line.endOffset) {
645 line.count = count;
646 }
647
648 ArrayPrototypePush(mappedLines, line);
649
650 if (line.ignore) {
651 ignoredLines++;
652 }
653
654 mid++;
655 line = lines[mid];
656 }
657
658 break;
659 } else if (startOffset >= line?.endOffset) {
660 start = mid + 1;
661 } else {
662 end = mid - 1;
663 }
664 }
665
666 return { __proto__: null, lines: mappedLines, ignoredLines };
667}
668
669function mergeCoverageScripts(oldScript, newScript) {
670 // Merge the functions from the new coverage into the functions from the

Callers 2

summaryMethod · 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…