|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | import { FunctionCov, RangeCov, ScriptCov } from "./types";
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * Compares two script coverages.
|
|---|
| 5 | *
|
|---|
| 6 | * The result corresponds to the comparison of their `url` value (alphabetical sort).
|
|---|
| 7 | */
|
|---|
| 8 | export function compareScriptCovs(a: Readonly<ScriptCov>, b: Readonly<ScriptCov>): number {
|
|---|
| 9 | if (a.url === b.url) {
|
|---|
| 10 | return 0;
|
|---|
| 11 | } else if (a.url < b.url) {
|
|---|
| 12 | return -1;
|
|---|
| 13 | } else {
|
|---|
| 14 | return 1;
|
|---|
| 15 | }
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | /**
|
|---|
| 19 | * Compares two function coverages.
|
|---|
| 20 | *
|
|---|
| 21 | * The result corresponds to the comparison of the root ranges.
|
|---|
| 22 | */
|
|---|
| 23 | export function compareFunctionCovs(a: Readonly<FunctionCov>, b: Readonly<FunctionCov>): number {
|
|---|
| 24 | return compareRangeCovs(a.ranges[0], b.ranges[0]);
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | /**
|
|---|
| 28 | * Compares two range coverages.
|
|---|
| 29 | *
|
|---|
| 30 | * The ranges are first ordered by ascending `startOffset` and then by
|
|---|
| 31 | * descending `endOffset`.
|
|---|
| 32 | * This corresponds to a pre-order tree traversal.
|
|---|
| 33 | */
|
|---|
| 34 | export function compareRangeCovs(a: Readonly<RangeCov>, b: Readonly<RangeCov>): number {
|
|---|
| 35 | if (a.startOffset !== b.startOffset) {
|
|---|
| 36 | return a.startOffset - b.startOffset;
|
|---|
| 37 | } else {
|
|---|
| 38 | return b.endOffset - a.endOffset;
|
|---|
| 39 | }
|
|---|
| 40 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.