Range.d.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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(
  55. values: Array<[number, boolean]>,
  56. logic: boolean
  57. ): [number, boolean];
  58. /** @type {Array<RangeValue>} */
  59. _left: Array<[number, boolean]>;
  60. /** @type {Array<RangeValue>} */
  61. _right: Array<[number, boolean]>;
  62. /**
  63. * @param {number} value
  64. * @param {boolean=} exclusive
  65. */
  66. left(value: number, exclusive?: boolean | undefined): void;
  67. /**
  68. * @param {number} value
  69. * @param {boolean=} exclusive
  70. */
  71. right(value: number, exclusive?: boolean | undefined): void;
  72. /**
  73. * @param {boolean} logic is not logic applied
  74. * @return {string} "smart" range string representation
  75. */
  76. format(logic?: boolean): string;
  77. }
  78. declare namespace Range {
  79. export { RangeValue, RangeValueCallback };
  80. }
  81. type RangeValue = [number, boolean];
  82. type RangeValueCallback = (rangeValue: [number, boolean]) => boolean;