mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
47 lines
3.7 KiB
JavaScript
47 lines
3.7 KiB
JavaScript
|
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
/**
|
||
|
* Compares two script coverages.
|
||
|
*
|
||
|
* The result corresponds to the comparison of their `url` value (alphabetical sort).
|
||
|
*/
|
||
|
function compareScriptCovs(a, b) {
|
||
|
if (a.url === b.url) {
|
||
|
return 0;
|
||
|
}
|
||
|
else if (a.url < b.url) {
|
||
|
return -1;
|
||
|
}
|
||
|
else {
|
||
|
return 1;
|
||
|
}
|
||
|
}
|
||
|
exports.compareScriptCovs = compareScriptCovs;
|
||
|
/**
|
||
|
* Compares two function coverages.
|
||
|
*
|
||
|
* The result corresponds to the comparison of the root ranges.
|
||
|
*/
|
||
|
function compareFunctionCovs(a, b) {
|
||
|
return compareRangeCovs(a.ranges[0], b.ranges[0]);
|
||
|
}
|
||
|
exports.compareFunctionCovs = compareFunctionCovs;
|
||
|
/**
|
||
|
* 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.
|
||
|
*/
|
||
|
function compareRangeCovs(a, b) {
|
||
|
if (a.startOffset !== b.startOffset) {
|
||
|
return a.startOffset - b.startOffset;
|
||
|
}
|
||
|
else {
|
||
|
return b.endOffset - a.endOffset;
|
||
|
}
|
||
|
}
|
||
|
exports.compareRangeCovs = compareRangeCovs;
|
||
|
|
||
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIl9zcmMvY29tcGFyZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBOzs7O0dBSUc7QUFDSCxTQUFnQixpQkFBaUIsQ0FBQyxDQUFzQixFQUFFLENBQXNCO0lBQzlFLElBQUksQ0FBQyxDQUFDLEdBQUcsS0FB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