You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
3.4 KiB
JavaScript

/**
* Compares two script coverages.
*
* The result corresponds to the comparison of their `url` value (alphabetical sort).
*/
export function compareScriptCovs(a, b) {
if (a.url === b.url) {
return 0;
}
else if (a.url < b.url) {
return -1;
}
else {
return 1;
}
}
/**
* Compares two function coverages.
*
* The result corresponds to the comparison of the root ranges.
*/
export function compareFunctionCovs(a, b) {
return compareRangeCovs(a.ranges[0], b.ranges[0]);
}
/**
* Compares two range coverages.
*
* The ranges are first ordered by ascending `startOffset` and then by
* descending `endOffset`.
* This corresponds to a pre-order tree traversal.
*/
export function compareRangeCovs(a, b) {
if (a.startOffset !== b.startOffset) {
return a.startOffset - b.startOffset;
}
else {
return b.endOffset - a.endOffset;
}
}
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIl9zcmMvY29tcGFyZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQTs7OztHQUlHO0FBQ0gsTUFBTSxVQUFVLGlCQUFpQixDQUFDLENBQXNCLEVBQUUsQ0FBc0I7SUFDOUUsSUFBSSxDQUFDLENBQUMsR0FBRyxLQUFLLENBQUMsQ0FBQyxHQUFHLEVBQUU7UUFDbkIsT0FBTyxDQUFDLENBQUM7S0FDVjtTQUFNLElBQUksQ0FBQyxDQUFDLEdBQUcsR0FBRyxDQUFDLENBQUMsR0FBRyxFQUFFO1FBQ3hCLE9BQU8sQ0FBQyxDQUFDLENBQUM7S0FDWDtTQUFNO1FBQ0wsT0FBTyxDQUFDLENBQUM7S0FDVjtBQUNILENBQUM7QUFFRDs7OztHQUlHO0FBQ0gsTUFBTSxVQUFVLG1CQUFtQixDQUFDLENBQXdCLEVBQUUsQ0FBd0I7SUFDcEYsT0FBTyxnQkFBZ0IsQ0FBQyxDQUFDLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsQ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