compare.js 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. /**
  4. * Compares two script coverages.
  5. *
  6. * The result corresponds to the comparison of their `url` value (alphabetical sort).
  7. */
  8. function compareScriptCovs(a, b) {
  9. if (a.url === b.url) {
  10. return 0;
  11. }
  12. else if (a.url < b.url) {
  13. return -1;
  14. }
  15. else {
  16. return 1;
  17. }
  18. }
  19. exports.compareScriptCovs = compareScriptCovs;
  20. /**
  21. * Compares two function coverages.
  22. *
  23. * The result corresponds to the comparison of the root ranges.
  24. */
  25. function compareFunctionCovs(a, b) {
  26. return compareRangeCovs(a.ranges[0], b.ranges[0]);
  27. }
  28. exports.compareFunctionCovs = compareFunctionCovs;
  29. /**
  30. * Compares two range coverages.
  31. *
  32. * The ranges are first ordered by ascending `startOffset` and then by
  33. * descending `endOffset`.
  34. * This corresponds to a pre-order tree traversal.
  35. */
  36. function compareRangeCovs(a, b) {
  37. if (a.startOffset !== b.startOffset) {
  38. return a.startOffset - b.startOffset;
  39. }
  40. else {
  41. return b.endOffset - a.endOffset;
  42. }
  43. }
  44. exports.compareRangeCovs = compareRangeCovs;
  45. //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIl9zcmMvY29tcGFyZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBOzs7O0dBSUc7QUFDSCxTQUFnQixpQkFBaUIsQ0FBQyxDQUFzQixFQUFFLENBQXNCO0lBQzlFLElBQUksQ0FBQyxDQUFDLEdBQUcsS0FBSyxDQUFDLENBQUMsR0FBRyxFQUFFO1FBQ25CLE9BQU8sQ0FBQyxDQUFDO0tBQ1Y7U0FBTSxJQUFJLENBQUMsQ0FBQyxHQUFHLEdBQUcsQ0FBQyxDQUFDLEdBQUcsRUFBRTtRQUN4QixPQUFPLENBQUMsQ0FBQyxDQUFDO0tBQ1g7U0FBTTtR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