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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. class Range {
  7. static copy(orig) {
  8. return new Range(orig.start, orig.end);
  9. }
  10. constructor(start, end) {
  11. this.start = start;
  12. this.end = end || start;
  13. }
  14. isEmpty() {
  15. return typeof this.start !== 'number' || !this.end || this.end <= this.start;
  16. }
  17. /**
  18. * Set `origStart` and `origEnd` to point to the original source range for
  19. * this node, which may differ due to dropped CR characters.
  20. *
  21. * @param {number[]} cr - Positions of dropped CR characters
  22. * @param {number} offset - Starting index of `cr` from the last call
  23. * @returns {number} - The next offset, matching the one found for `origStart`
  24. */
  25. setOrigRange(cr, offset) {
  26. const {
  27. start,
  28. end
  29. } = this;
  30. if (cr.length === 0 || end <= cr[0]) {
  31. this.origStart = start;
  32. this.origEnd = end;
  33. return offset;
  34. }
  35. let i = offset;
  36. while (i < cr.length) {
  37. if (cr[i] > start) break;else ++i;
  38. }
  39. this.origStart = start + i;
  40. const nextOffset = i;
  41. while (i < cr.length) {
  42. // if end was at \n, it should now be at \r
  43. if (cr[i] >= end) break;else ++i;
  44. }
  45. this.origEnd = end + i;
  46. return nextOffset;
  47. }
  48. }
  49. exports.default = Range;