Range.d.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. export = Range;
  2. /**
  3. * @typedef {[number, boolean]} RangeValue
  4. */
  5. /**
  6. * @callback RangeValueCallback
  7. * @param {RangeValue} rangeValue
  8. * @returns {boolean}
  9. */
  10. declare class Range {
  11. /**
  12. * @param {"left" | "right"} side
  13. * @param {boolean} exclusive
  14. * @returns {">" | ">=" | "<" | "<="}
  15. */
  16. static getOperator(
  17. side: "left" | "right",
  18. exclusive: boolean
  19. ): ">" | ">=" | "<" | "<=";
  20. /**
  21. * @param {number} value
  22. * @param {boolean} logic is not logic applied
  23. * @param {boolean} exclusive is range exclusive
  24. * @returns {string}
  25. */
  26. static formatRight(value: number, logic: boolean, exclusive: boolean): string;
  27. /**
  28. * @param {number} value
  29. * @param {boolean} logic is not logic applied
  30. * @param {boolean} exclusive is range exclusive
  31. * @returns {string}
  32. */
  33. static formatLeft(value: number, logic: boolean, exclusive: boolean): string;
  34. /**
  35. * @param {number} start left side value
  36. * @param {number} end right side value
  37. * @param {boolean} startExclusive is range exclusive from left side
  38. * @param {boolean} endExclusive is range exclusive from right side
  39. * @param {boolean} logic is not logic applied
  40. * @returns {string}
  41. */
  42. static formatRange(
  43. start: number,
  44. end: number,
  45. startExclusive: boolean,
  46. endExclusive: boolean,
  47. logic: boolean
  48. ): string;
  49. /**
  50. * @param {Array<RangeValue>} values
  51. * @param {boolean} logic is not logic applied
  52. * @return {RangeValue} computed value and it's exclusive flag
  53. */
  54. static getRangeValue(values: Array<RangeValue>, logic: boolean): RangeValue;
  55. /** @type {Array<RangeValue>} */
  56. _left: Array<RangeValue>;
  57. /** @type {Array<RangeValue>} */
  58. _right: Array<RangeValue>;
  59. /**
  60. * @param {number} value
  61. * @param {boolean=} exclusive
  62. */
  63. left(value: number, exclusive?: boolean | undefined): void;
  64. /**
  65. * @param {number} value
  66. * @param {boolean=} exclusive
  67. */
  68. right(value: number, exclusive?: boolean | undefined): void;
  69. /**
  70. * @param {boolean} logic is not logic applied
  71. * @return {string} "smart" range string representation
  72. */
  73. format(logic?: boolean): string;
  74. }
  75. declare namespace Range {
  76. export { RangeValue, RangeValueCallback };
  77. }
  78. type RangeValue = [number, boolean];
  79. type RangeValueCallback = (rangeValue: RangeValue) => boolean;