@absoluteui/helpers 0.0.0-stage → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +5 -0
  3. package/README.md +47 -2
  4. package/SECURITY.md +102 -0
  5. package/dist/array/compare.d.ts +8 -0
  6. package/dist/array/compare.js +2 -0
  7. package/dist/array/index.d.ts +328 -0
  8. package/dist/array/index.js +2 -0
  9. package/dist/array/tree.d.ts +48 -0
  10. package/dist/array/tree.js +2 -0
  11. package/dist/async/batch.d.ts +103 -0
  12. package/dist/async/batch.js +2 -0
  13. package/dist/async/concurrency.d.ts +92 -0
  14. package/dist/async/concurrency.js +2 -0
  15. package/dist/async/control.d.ts +77 -0
  16. package/dist/async/control.js +2 -0
  17. package/dist/async/index.d.ts +8 -0
  18. package/dist/async/index.js +2 -0
  19. package/dist/async/signal.d.ts +95 -0
  20. package/dist/async/signal.js +2 -0
  21. package/dist/boolean/index.d.ts +83 -0
  22. package/dist/boolean/index.js +2 -0
  23. package/dist/business-calendar/days.d.ts +397 -0
  24. package/dist/business-calendar/days.js +2 -0
  25. package/dist/business-calendar/describe.d.ts +45 -0
  26. package/dist/business-calendar/describe.js +2 -0
  27. package/dist/business-calendar/engine.d.ts +305 -0
  28. package/dist/business-calendar/engine.js +2 -0
  29. package/dist/business-calendar/hours.d.ts +96 -0
  30. package/dist/business-calendar/hours.js +2 -0
  31. package/dist/business-calendar/index.d.ts +29 -0
  32. package/dist/business-calendar/index.js +2 -0
  33. package/dist/business-calendar/internal.d.ts +44 -0
  34. package/dist/business-calendar/internal.js +2 -0
  35. package/dist/business-calendar/rules.d.ts +260 -0
  36. package/dist/business-calendar/rules.js +2 -0
  37. package/dist/color/index.d.ts +200 -0
  38. package/dist/color/index.js +2 -0
  39. package/dist/color/named.d.ts +4 -0
  40. package/dist/color/named.js +2 -0
  41. package/dist/compare/index.d.ts +186 -0
  42. package/dist/compare/index.js +2 -0
  43. package/dist/convert/index.d.ts +152 -0
  44. package/dist/convert/index.js +2 -0
  45. package/dist/csv/index.d.ts +6 -0
  46. package/dist/csv/index.js +2 -0
  47. package/dist/csv/parse.d.ts +85 -0
  48. package/dist/csv/parse.js +12 -0
  49. package/dist/csv/stringify.d.ts +48 -0
  50. package/dist/csv/stringify.js +5 -0
  51. package/dist/date/calendar.d.ts +339 -0
  52. package/dist/date/calendar.js +2 -0
  53. package/dist/date/format.d.ts +66 -0
  54. package/dist/date/format.js +2 -0
  55. package/dist/date/index.d.ts +26 -0
  56. package/dist/date/index.js +2 -0
  57. package/dist/date/intervals.d.ts +110 -0
  58. package/dist/date/intervals.js +2 -0
  59. package/dist/date/intl-cache.d.ts +10 -0
  60. package/dist/date/intl-cache.js +2 -0
  61. package/dist/date/locale.d.ts +58 -0
  62. package/dist/date/locale.js +2 -0
  63. package/dist/date/plain-date.d.ts +105 -0
  64. package/dist/date/plain-date.js +2 -0
  65. package/dist/date/plain-time.d.ts +121 -0
  66. package/dist/date/plain-time.js +2 -0
  67. package/dist/date/zone.d.ts +121 -0
  68. package/dist/date/zone.js +2 -0
  69. package/dist/decimal/index.d.ts +149 -0
  70. package/dist/decimal/index.js +2 -0
  71. package/dist/ds/avl.d.ts +50 -0
  72. package/dist/ds/avl.js +2 -0
  73. package/dist/ds/bitset.d.ts +46 -0
  74. package/dist/ds/bitset.js +2 -0
  75. package/dist/ds/bloom.d.ts +41 -0
  76. package/dist/ds/bloom.js +2 -0
  77. package/dist/ds/caches.d.ts +141 -0
  78. package/dist/ds/caches.js +2 -0
  79. package/dist/ds/disjoint-set.d.ts +38 -0
  80. package/dist/ds/disjoint-set.js +2 -0
  81. package/dist/ds/emitter.d.ts +53 -0
  82. package/dist/ds/emitter.js +2 -0
  83. package/dist/ds/graph.d.ts +84 -0
  84. package/dist/ds/graph.js +2 -0
  85. package/dist/ds/heap.d.ts +49 -0
  86. package/dist/ds/heap.js +2 -0
  87. package/dist/ds/index.d.ts +20 -0
  88. package/dist/ds/index.js +2 -0
  89. package/dist/ds/internal.d.ts +19 -0
  90. package/dist/ds/internal.js +2 -0
  91. package/dist/ds/interval-tree.d.ts +49 -0
  92. package/dist/ds/interval-tree.js +2 -0
  93. package/dist/ds/linked-list.d.ts +54 -0
  94. package/dist/ds/linked-list.js +2 -0
  95. package/dist/ds/maps.d.ts +89 -0
  96. package/dist/ds/maps.js +2 -0
  97. package/dist/ds/ring.d.ts +99 -0
  98. package/dist/ds/ring.js +2 -0
  99. package/dist/ds/sorted.d.ts +104 -0
  100. package/dist/ds/sorted.js +2 -0
  101. package/dist/ds/stack.d.ts +28 -0
  102. package/dist/ds/stack.js +2 -0
  103. package/dist/ds/trie.d.ts +84 -0
  104. package/dist/ds/trie.js +2 -0
  105. package/dist/duration/index.d.ts +146 -0
  106. package/dist/duration/index.js +2 -0
  107. package/dist/encoding/index.d.ts +144 -0
  108. package/dist/encoding/index.js +2 -0
  109. package/dist/error/index.d.ts +316 -0
  110. package/dist/error/index.js +2 -0
  111. package/dist/fn/index.d.ts +129 -0
  112. package/dist/fn/index.js +2 -0
  113. package/dist/fn/memo.d.ts +46 -0
  114. package/dist/fn/memo.js +2 -0
  115. package/dist/fn/timing.d.ts +64 -0
  116. package/dist/fn/timing.js +2 -0
  117. package/dist/http/headers.d.ts +160 -0
  118. package/dist/http/headers.js +2 -0
  119. package/dist/http/index.d.ts +10 -0
  120. package/dist/http/index.js +2 -0
  121. package/dist/http/problem.d.ts +37 -0
  122. package/dist/http/problem.js +2 -0
  123. package/dist/http/response.d.ts +43 -0
  124. package/dist/http/response.js +2 -0
  125. package/dist/http/status.d.ts +169 -0
  126. package/dist/http/status.js +2 -0
  127. package/dist/index.d.ts +34 -0
  128. package/dist/index.js +2 -0
  129. package/dist/internal/keys.d.ts +6 -0
  130. package/dist/internal/keys.js +2 -0
  131. package/dist/is/index.d.ts +219 -0
  132. package/dist/is/index.js +2 -0
  133. package/dist/json/index.d.ts +9 -0
  134. package/dist/json/index.js +2 -0
  135. package/dist/json/internal.d.ts +12 -0
  136. package/dist/json/internal.js +2 -0
  137. package/dist/json/ndjson.d.ts +28 -0
  138. package/dist/json/ndjson.js +4 -0
  139. package/dist/json/parse.d.ts +45 -0
  140. package/dist/json/parse.js +2 -0
  141. package/dist/json/patch.d.ts +62 -0
  142. package/dist/json/patch.js +2 -0
  143. package/dist/json/pointer.d.ts +43 -0
  144. package/dist/json/pointer.js +2 -0
  145. package/dist/json/stringify.d.ts +42 -0
  146. package/dist/json/stringify.js +2 -0
  147. package/dist/linq/enumerable.d.ts +208 -0
  148. package/dist/linq/enumerable.js +2 -0
  149. package/dist/linq/index.d.ts +6 -0
  150. package/dist/linq/index.js +2 -0
  151. package/dist/linq/operators.d.ts +503 -0
  152. package/dist/linq/operators.js +2 -0
  153. package/dist/number/core.d.ts +164 -0
  154. package/dist/number/core.js +2 -0
  155. package/dist/number/format.d.ts +80 -0
  156. package/dist/number/format.js +2 -0
  157. package/dist/number/index.d.ts +12 -0
  158. package/dist/number/index.js +2 -0
  159. package/dist/number/internal.d.ts +18 -0
  160. package/dist/number/internal.js +2 -0
  161. package/dist/number/parse.d.ts +45 -0
  162. package/dist/number/parse.js +2 -0
  163. package/dist/number/words.d.ts +19 -0
  164. package/dist/number/words.js +2 -0
  165. package/dist/object/basic.d.ts +130 -0
  166. package/dist/object/basic.js +2 -0
  167. package/dist/object/deep.d.ts +90 -0
  168. package/dist/object/deep.js +2 -0
  169. package/dist/object/diff.d.ts +57 -0
  170. package/dist/object/diff.js +2 -0
  171. package/dist/object/index.d.ts +8 -0
  172. package/dist/object/index.js +2 -0
  173. package/dist/object/internal.d.ts +21 -0
  174. package/dist/object/internal.js +2 -0
  175. package/dist/object/path.d.ts +17 -0
  176. package/dist/object/path.js +2 -0
  177. package/dist/random/core.d.ts +14 -0
  178. package/dist/random/core.js +2 -0
  179. package/dist/random/index.d.ts +167 -0
  180. package/dist/random/index.js +2 -0
  181. package/dist/random/seeded.d.ts +27 -0
  182. package/dist/random/seeded.js +2 -0
  183. package/dist/sanitize/index.d.ts +8 -0
  184. package/dist/sanitize/index.js +2 -0
  185. package/dist/sanitize/pii.d.ts +48 -0
  186. package/dist/sanitize/pii.js +2 -0
  187. package/dist/sanitize/records.d.ts +100 -0
  188. package/dist/sanitize/records.js +2 -0
  189. package/dist/sanitize/text.d.ts +101 -0
  190. package/dist/sanitize/text.js +2 -0
  191. package/dist/set/index.d.ts +162 -0
  192. package/dist/set/index.js +2 -0
  193. package/dist/stats/index.d.ts +190 -0
  194. package/dist/stats/index.js +2 -0
  195. package/dist/string/index.d.ts +494 -0
  196. package/dist/string/index.js +8 -0
  197. package/dist/string/internal.d.ts +33 -0
  198. package/dist/string/internal.js +2 -0
  199. package/dist/string/words.d.ts +14 -0
  200. package/dist/string/words.js +2 -0
  201. package/dist/timezone/index.d.ts +76 -0
  202. package/dist/timezone/index.js +2 -0
  203. package/dist/url/index.d.ts +178 -0
  204. package/dist/url/index.js +2 -0
  205. package/dist/validate/builders.d.ts +6 -0
  206. package/dist/validate/builders.js +2 -0
  207. package/dist/validate/formats.d.ts +237 -0
  208. package/dist/validate/formats.js +2 -0
  209. package/dist/validate/index.d.ts +13 -0
  210. package/dist/validate/index.js +2 -0
  211. package/dist/validate/schema.d.ts +220 -0
  212. package/dist/validate/schema.js +2 -0
  213. package/dist/zip/index.d.ts +8 -0
  214. package/dist/zip/index.js +2 -0
  215. package/dist/zip/internal.d.ts +69 -0
  216. package/dist/zip/internal.js +2 -0
  217. package/dist/zip/reader.d.ts +56 -0
  218. package/dist/zip/reader.js +2 -0
  219. package/dist/zip/writer.d.ts +65 -0
  220. package/dist/zip/writer.js +2 -0
  221. package/package.json +150 -4
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Restricts `value` to `[min, max]`. Throws `HLP_NUMBER_RANGE` when `min > max`.
3
+ * @example clamp(15, 0, 10) // => 10
4
+ */
5
+ export declare function clamp(value: number, min: number, max: number): number;
6
+ export interface InRangeOptions {
7
+ /** Which bounds are included. `true` (default) = both, `false` = neither. */
8
+ readonly inclusive?: boolean | 'min' | 'max';
9
+ }
10
+ /**
11
+ * True when `value` lies between `min` and `max` (bounds may be given in either order).
12
+ * @example inRange(10, 0, 10, { inclusive: 'min' }) // => false
13
+ */
14
+ export declare function inRange(value: number, min: number, max: number, options?: InRangeOptions): boolean;
15
+ /**
16
+ * Rounds half away from zero to `places` decimals, exact for decimal inputs (Excel `ROUND`).
17
+ * Negative `places` round to tens, hundreds, ...
18
+ * @example
19
+ * round(1.005, 2); // => 1.01 // naive Math.round(1.005 * 100) / 100 gives 1
20
+ */
21
+ export declare function round(value: number, places?: number): number;
22
+ /**
23
+ * Rounds half to even ("banker's rounding") to `places` decimals, exact for decimal inputs.
24
+ * @example
25
+ * roundHalfEven(2.5); // => 2
26
+ * roundHalfEven(0.125, 2); // => 0.12
27
+ */
28
+ export declare function roundHalfEven(value: number, places?: number): number;
29
+ /**
30
+ * Rounds toward -infinity to `places` decimals, exact for decimal inputs.
31
+ * @example floor(1.99, 1) // => 1.9
32
+ */
33
+ export declare function floor(value: number, places?: number): number;
34
+ /**
35
+ * Rounds toward +infinity to `places` decimals, exact for decimal inputs.
36
+ * @example ceil(1.01, 1) // => 1.1
37
+ */
38
+ export declare function ceil(value: number, places?: number): number;
39
+ /**
40
+ * Drops digits beyond `places` decimals (rounds toward zero). Named `trunc` to avoid
41
+ * clashing with the string module's `truncate`.
42
+ * @example trunc(-1.29, 1) // => -1.2
43
+ */
44
+ export declare function trunc(value: number, places?: number): number;
45
+ /**
46
+ * Rounds to the nearest multiple of `step` (half away from zero), without float drift.
47
+ * @example
48
+ * roundTo(1.13, 0.25); // => 1.25
49
+ * roundTo(0.125, 0.05); // => 0.15
50
+ */
51
+ export declare function roundTo(value: number, step: number): number;
52
+ /** True for even integers. @example isEven(-4) // => true */
53
+ export declare function isEven(value: number): boolean;
54
+ /** True for odd integers. @example isOdd(-3) // => true */
55
+ export declare function isOdd(value: number): boolean;
56
+ /**
57
+ * Sign as `-1 | 0 | 1` (`-0` gives `0`), or `NaN` for `NaN`.
58
+ * @example sign(-0) // => 0
59
+ */
60
+ export declare function sign(value: number): number;
61
+ /** True only for `-0`. @example isNegativeZero(-0) // => true */
62
+ export declare function isNegativeZero(value: number): boolean;
63
+ /** Converts `-0` to `0`; other values pass through. @example normalizeZero(-0) // => 0 */
64
+ export declare function normalizeZero(value: number): number;
65
+ export interface PercentOptions {
66
+ /** Round the result to this many decimals. */
67
+ readonly places?: number;
68
+ }
69
+ /**
70
+ * `part` as a percentage of `total`; `undefined` when `total` is 0 or inputs are not finite.
71
+ * @example percent(1, 3, { places: 2 }) // => 33.33
72
+ */
73
+ export declare function percent(part: number, total: number, options?: PercentOptions): number | undefined;
74
+ /**
75
+ * Percentage change from `from` to `to` relative to `|from|`; `undefined` when `from` is 0.
76
+ * @example percentChange(80, 100) // => 25
77
+ */
78
+ export declare function percentChange(from: number, to: number, options?: PercentOptions): number | undefined;
79
+ /**
80
+ * `a / b`, or `undefined` when `b` is 0 or the result is not finite.
81
+ * @example ratio(3, 4) // => 0.75
82
+ */
83
+ export declare function ratio(a: number, b: number, options?: PercentOptions): number | undefined;
84
+ /**
85
+ * Linear interpolation; exact at `t = 0` and `t = 1`.
86
+ * @example lerp(10, 20, 0.25) // => 12.5
87
+ */
88
+ export declare function lerp(a: number, b: number, t: number): number;
89
+ /**
90
+ * Inverse of `lerp`: where `value` sits between `a` and `b` (0 when `a === b`).
91
+ * @example inverseLerp(10, 20, 15) // => 0.5
92
+ */
93
+ export declare function inverseLerp(a: number, b: number, value: number): number;
94
+ export interface RemapOptions {
95
+ /** Clamp the result to the output range. Default false. */
96
+ readonly clamp?: boolean;
97
+ }
98
+ /**
99
+ * Maps `value` from `[inMin, inMax]` to `[outMin, outMax]`.
100
+ * @example remap(5, 0, 10, 0, 100) // => 50
101
+ */
102
+ export declare function remap(value: number, inMin: number, inMax: number, outMin: number, outMax: number, options?: RemapOptions): number;
103
+ export interface ApproxOptions {
104
+ /** Relative tolerance, scaled by the larger magnitude. Default 1e-9. */
105
+ readonly relative?: number;
106
+ /** Absolute tolerance, for values near zero. Default 1e-12. */
107
+ readonly absolute?: number;
108
+ }
109
+ /**
110
+ * Tolerant equality: `|a - b| <= max(relative x max(|a|, |b|), absolute)`. `NaN` is never equal.
111
+ * @example approximatelyEqual(0.1 + 0.2, 0.3) // => true
112
+ */
113
+ export declare function approximatelyEqual(a: number, b: number, options?: ApproxOptions): boolean;
114
+ /**
115
+ * Compensated (Kahan-Babuška-Neumaier) sum; far less rounding error than a plain loop.
116
+ * @example kahanSum([0.1, 0.2, 0.3]) // => 0.6 // plain reduce gives 0.6000000000000001
117
+ */
118
+ export declare function kahanSum(values: Iterable<number>): number;
119
+ /**
120
+ * Compensated sum (alias of `kahanSum`). Empty input gives 0.
121
+ * @example sum([1, 2, 3]) // => 6
122
+ */
123
+ export declare function sum(values: Iterable<number>): number;
124
+ /**
125
+ * Product of all values. Empty input gives 1.
126
+ * @example product([2, 3, 4]) // => 24
127
+ */
128
+ export declare function product(values: Iterable<number>): number;
129
+ /**
130
+ * Greatest common divisor of two integers (always >= 0).
131
+ * @example gcd(12, -18) // => 6
132
+ */
133
+ export declare function gcd(a: number, b: number): number;
134
+ /**
135
+ * Least common multiple of two integers; throws `HLP_NUMBER_UNSAFE` when the result is not a safe integer.
136
+ * @example lcm(4, 6) // => 12
137
+ */
138
+ export declare function lcm(a: number, b: number): number;
139
+ /** `gcd` for `bigint`. @example gcdBigInt(12n, 18n) // => 6n */
140
+ export declare function gcdBigInt(a: bigint, b: bigint): bigint;
141
+ /** `lcm` for `bigint`. @example lcmBigInt(4n, 6n) // => 12n */
142
+ export declare function lcmBigInt(a: bigint, b: bigint): bigint;
143
+ /**
144
+ * Deterministic primality test for safe integers and for `bigint` below 3.3 × 10²⁴
145
+ * (trial division for small values, Miller–Rabin with fixed bases otherwise).
146
+ * @example isPrime(2_147_483_647) // => true
147
+ */
148
+ export declare function isPrime(n: number | bigint): boolean;
149
+ /** Largest accepted `factorial` argument. */
150
+ export declare const MAX_FACTORIAL = 10000;
151
+ /**
152
+ * Exact factorial as `bigint`; `n` must be an integer in `0..MAX_FACTORIAL`.
153
+ * @example factorial(20) // => 2432902008176640000n
154
+ */
155
+ export declare function factorial(n: number): bigint;
156
+ /**
157
+ * Plain decimal string with no exponent notation. With `places`, rounds half away from
158
+ * zero on the exact decimal value (unlike `Number#toFixed`) and pads to `places` digits.
159
+ * `-0` and negative values that round to zero print without a minus sign.
160
+ * @example
161
+ * toFixedSafe(1e21); // => '1000000000000000000000'
162
+ * toFixedSafe(1.005, 2); // => '1.01'
163
+ */
164
+ export declare function toFixedSafe(value: number, places?: number): string;
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.2 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{LimitError as p,ValidationError as b}from"../error/index.js";import{assertInteger as c,fractionDigits as d,numberParts as _,shift as m}from"./internal.js";const f=n=>n===0?0:n;function x(n){if(!Number.isInteger(n)||n<-308||n>308)throw new b("HLP_NUMBER_PLACES","Decimal places must be an integer between -308 and 308.")}function T(n,e,r){if(e>r)throw new b("HLP_NUMBER_RANGE","The minimum must not exceed the maximum.");return n<e?e:n>r?r:n}function U(n,e,r,t={}){const{inclusive:i=!0}=t,u=Math.min(e,r),o=Math.max(e,r),s=i===!0||i==="min"?n>=u:n>u,a=i===!0||i==="max"?n<=o:n<o;return s&&a}function M(n,e=0){if(x(e),!Number.isFinite(n))return n;const r=m(Math.abs(n),e);return Number.isFinite(r)?f(Math.sign(n)*m(Math.round(r),-e)):n}function y(n,e=0){if(x(e),!Number.isFinite(n))return n;const r=m(Math.abs(n),e);if(!Number.isFinite(r))return n;const t=Math.floor(r),i=r-t,u=i>.5?t+1:i<.5||t%2===0?t:t+1;return f(Math.sign(n)*m(u,-e))}function h(n,e,r){if(x(r),!Number.isFinite(e))return e;const t=m(e,r);return Number.isFinite(t)?f(m(n(t),-r)):e}function H(n,e=0){return h(Math.floor,n,e)}function k(n,e=0){return h(Math.ceil,n,e)}function C(n,e=0){return h(Math.trunc,n,e)}function G(n,e){if(!(e>0)||!Number.isFinite(e))throw new b("HLP_NUMBER_STEP","The step must be a positive finite number.");if(!Number.isFinite(n))return n;const r=Math.max(d(n),d(e)),t=m(n,r)/m(e,r),i=Math.sign(t)*Math.round(Math.abs(t));return M(i*e,d(e))}function q(n){return Number.isInteger(n)&&n%2===0}function D(n){return Number.isInteger(n)&&n%2!==0}function Z(n){return n>0?1:n<0?-1:n===0?0:Number.NaN}function $(n){return n===0&&1/n<0}function V(n){return f(n)}const g=(n,e)=>Number.isFinite(n)?e===void 0?f(n):M(n,e):void 0;function z(n,e,r={}){if(e!==0)return g(n/e*100,r.places)}function X(n,e,r={}){if(n!==0)return g((e-n)/Math.abs(n)*100,r.places)}function j(n,e,r={}){if(e!==0)return g(n/e,r.places)}function E(n,e,r){return(1-r)*n+r*e}function w(n,e,r){return n===e?0:(r-n)/(e-n)}function J(n,e,r,t,i,u={}){const o=w(e,r,n);return E(t,i,u.clamp?Math.min(1,Math.max(0,o)):o)}function K(n,e,r={}){const{relative:t=1e-9,absolute:i=1e-12}=r;return n===e?!0:!Number.isFinite(n)||!Number.isFinite(e)?!1:Math.abs(n-e)<=Math.max(t*Math.max(Math.abs(n),Math.abs(e)),i)}function I(n){let e=0,r=0,t=0;for(const i of n){t+=i;const u=e+i;r+=Math.abs(e)>=Math.abs(i)?e-u+i:i-u+e,e=u}return Number.isFinite(t)?f(e+r):t}function Q(n){return I(n)}function W(n){let e=1;for(const r of n)e*=r;return e}function P(n,e){c(n),c(e);let r=Math.abs(n),t=Math.abs(e);for(;t;)[r,t]=[t,r%t];return r}function Y(n,e){if(n===0||e===0)return c(n),c(e),0;const r=Math.abs(n/P(n,e)*e);if(!Number.isSafeInteger(r))throw new p("HLP_NUMBER_UNSAFE","The result is not a safe integer.");return r}const l=n=>n<0n?-n:n;function R(n,e){let r=l(n),t=l(e);for(;t;)[r,t]=[t,r%t];return r}function v(n,e){return n===0n||e===0n?0n:l(n/R(n,e)*e)}function O(n,e,r){let t=1n,i=n%r,u=e;for(;u>0n;)u&1n&&(t=t*i%r),i=i*i%r,u>>=1n;return t}const N=[2n,3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n],B=3317044064679887385961981n;function F(n){if(typeof n=="number"){if(!Number.isInteger(n)||n<2)return!1;if(!Number.isSafeInteger(n))throw new b("HLP_NUMBER_UNSAFE","Expected a safe integer; pass a bigint for larger values.");if(n<4)return!0;if(n%2===0||n%3===0)return!1;if(n<1e10){for(let t=5;t*t<=n;t+=6)if(n%t===0||n%(t+2)===0)return!1;return!0}return F(BigInt(n))}if(n<2n)return!1;if(n>=B)throw new p("HLP_NUMBER_TOO_LARGE","The value exceeds the deterministic primality limit.");for(const t of N){if(n===t)return!0;if(n%t===0n)return!1}let e=n-1n,r=0;for(;(e&1n)===0n;)e>>=1n,r++;n:for(const t of N){let i=O(t,e,n);if(!(i===1n||i===n-1n)){for(let u=1;u<r;u++)if(i=i*i%n,i===n-1n)continue n;return!1}}return!0}const L=1e4;function nn(n){if(c(n),n<0)throw new b("HLP_NUMBER_NEGATIVE","Expected a non-negative integer.");if(n>L)throw new p("HLP_NUMBER_TOO_LARGE","The value exceeds the factorial limit.");let e=1n;for(let r=2n,t=BigInt(n);r<=t;r++)e*=r;return e}function en(n,e){if(!Number.isFinite(n))return String(n);if(e!==void 0&&(!Number.isInteger(e)||e<0||e>100))throw new b("HLP_NUMBER_PLACES","Decimal places must be an integer between 0 and 100.");const r=_(n),t=e===void 0?Math.min(r.exponent,0):-e;let i=BigInt(r.digits);if(r.exponent>=t)i*=10n**BigInt(r.exponent-t);else{const s=10n**BigInt(t-r.exponent),a=i/s;i=i%s*2n>=s?a+1n:a}const u=-t;let o=i.toString();return u>0&&(o=o.padStart(u+1,"0"),o=`${o.slice(0,-u)}.${o.slice(-u)}`),r.negative&&i!==0n?`-${o}`:o}export{L as MAX_FACTORIAL,K as approximatelyEqual,k as ceil,T as clamp,nn as factorial,H as floor,P as gcd,R as gcdBigInt,U as inRange,w as inverseLerp,q as isEven,$ as isNegativeZero,D as isOdd,F as isPrime,I as kahanSum,Y as lcm,v as lcmBigInt,E as lerp,V as normalizeZero,z as percent,X as percentChange,W as product,j as ratio,J as remap,M as round,y as roundHalfEven,G as roundTo,Z as sign,Q as sum,en as toFixedSafe,C as trunc};
@@ -0,0 +1,80 @@
1
+ /** A BCP 47 locale tag or a list of them; `undefined` uses the runtime default. */
2
+ export type LocaleInput = string | readonly string[] | undefined;
3
+ /** Values `Intl.NumberFormat` formats exactly, including decimal strings such as `'0.1'`. */
4
+ export type NumericValue = number | bigint | Intl.StringNumericLiteral;
5
+ /** Cached `Intl.NumberFormat` (internal). */
6
+ export declare function numberFormat(locale: LocaleInput, options?: Intl.NumberFormatOptions): Intl.NumberFormat;
7
+ export interface FormatNumberOptions extends Intl.NumberFormatOptions {
8
+ readonly locale?: LocaleInput;
9
+ }
10
+ /**
11
+ * `Intl.NumberFormat` with a cached formatter per locale and options. Decimal strings format without float loss.
12
+ * @example formatNumber(1234.5, { locale: 'de-DE' }) // => '1.234,5'
13
+ */
14
+ export declare function formatNumber(value: NumericValue, options?: FormatNumberOptions): string;
15
+ export interface FormatCurrencyOptions extends Omit<FormatNumberOptions, 'style' | 'currency' | 'currencyDisplay'> {
16
+ /** `symbol` (default, "US$" in some locales), `narrowSymbol` ("$"), `code` ("USD"), `name` ("US dollars", best for speech). */
17
+ readonly display?: 'symbol' | 'narrowSymbol' | 'code' | 'name';
18
+ }
19
+ /**
20
+ * Formats money in an ISO 4217 currency.
21
+ * @example formatCurrency(1234.5, 'EUR', { locale: 'fr-FR' }) // => '1\u202f234,50\u00a0€'
22
+ */
23
+ export declare function formatCurrency(value: NumericValue, currency: string, options?: FormatCurrencyOptions): string;
24
+ /**
25
+ * Formats a ratio as a percentage (`0.256` -> "26%").
26
+ * @example formatPercent(0.256, { maximumFractionDigits: 1 }) // => '25.6%'
27
+ */
28
+ export declare function formatPercent(value: number, options?: Omit<FormatNumberOptions, 'style'>): string;
29
+ export interface FormatCompactOptions extends Omit<FormatNumberOptions, 'notation' | 'compactDisplay'> {
30
+ /** `short` ("1.2K", default) or `long` ("1.2 thousand", unambiguous for screen readers). */
31
+ readonly display?: 'short' | 'long';
32
+ }
33
+ /**
34
+ * Compact notation.
35
+ * @example
36
+ * formatCompact(1234, { locale: 'en-US' }); // => '1.2K'
37
+ * formatCompact(1234, { locale: 'en-US', display: 'long' }); // => '1.2 thousand'
38
+ */
39
+ export declare function formatCompact(value: NumericValue, options?: FormatCompactOptions): string;
40
+ export interface FormatUnitOptions extends Omit<FormatNumberOptions, 'style' | 'unit' | 'unitDisplay'> {
41
+ /** `short` (default, "5 km"), `narrow` ("5km"), `long` ("5 kilometers"). */
42
+ readonly unitDisplay?: 'short' | 'narrow' | 'long';
43
+ }
44
+ /**
45
+ * Formats with an ECMA-402 sanctioned unit (or a `-per-` compound such as `kilometer-per-hour`).
46
+ * @example formatUnit(5, 'kilometer', { unitDisplay: 'long' }) // => '5 kilometers'
47
+ */
48
+ export declare function formatUnit(value: NumericValue, unit: string, options?: FormatUnitOptions): string;
49
+ type PluralCategory = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other';
50
+ export interface FormatOrdinalOptions {
51
+ readonly locale?: LocaleInput;
52
+ /** Suffix per `Intl.PluralRules` ordinal category; overrides the built-in table. */
53
+ readonly suffixes?: Partial<Record<PluralCategory, string>>;
54
+ }
55
+ /**
56
+ * Ordinal number ("1st", "2nd"). The category comes from `Intl.PluralRules({ type: 'ordinal' })`;
57
+ * suffixes are built in for en, fr, de, nl, es, it, pt, sv, da, nb, fi, pl, cs. Other languages
58
+ * (whose ordinals depend on grammatical gender or case) return the plain number unless `suffixes` is given.
59
+ * @example
60
+ * formatOrdinal(22, 'en'); // => '22nd'
61
+ * formatOrdinal(1, 'fr'); // => '1er'
62
+ */
63
+ export declare function formatOrdinal(n: number, localeOrOptions?: string | FormatOrdinalOptions): string;
64
+ export interface FormatBytesOptions {
65
+ readonly locale?: LocaleInput;
66
+ /** 1000 (SI, default) or 1024. Intl has no IEC units, so 1024 still prints "KB"/"MB" (JEDEC convention). */
67
+ readonly base?: 1000 | 1024;
68
+ /** `short` ("2.4 MB", default), `narrow`, or `long` ("2.4 megabytes", for screen readers). */
69
+ readonly style?: 'short' | 'narrow' | 'long';
70
+ /** Default 1. */
71
+ readonly maximumFractionDigits?: number;
72
+ }
73
+ /**
74
+ * Human-readable byte size through `Intl` units.
75
+ * @example
76
+ * formatBytes(2_400_000, { locale: 'en-US' }); // => '2.4 MB'
77
+ * formatBytes(2_400_000, { locale: 'en-US', style: 'long' }); // => '2.4 megabytes'
78
+ */
79
+ export declare function formatBytes(bytes: number, options?: FormatBytesOptions): string;
80
+ export {};
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.2 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{ValidationError as c}from"../error/index.js";import{assertFinite as y}from"./internal.js";const b=64,h=new Map,O=new Map;function f(t,e){const o=t===void 0?"":typeof t=="string"?t:t.join(","),r=Object.entries(e).filter(([,n])=>n!==void 0);return r.sort(([n],[a])=>n<a?-1:n>a?1:0),`${o}|${JSON.stringify(r)}`}function d(t,e,o){let r=t.get(e);if(r===void 0){try{r=o()}catch(n){throw new c("HLP_NUMBER_FORMAT_OPTIONS","Invalid locale or format options.",{cause:n})}if(t.size>=b){const n=t.keys().next();n.done||t.delete(n.value)}t.set(e,r)}return r}function l(t,e={}){return d(h,f(t,e),()=>new Intl.NumberFormat(t,e))}function F(t,e){return d(O,f(t,e),()=>new Intl.PluralRules(t,e))}function C(t,e={}){const{locale:o,...r}=e;return l(o,r).format(t)}function R(t,e,o={}){if(!/^[a-z]{3}$/i.test(e))throw new c("HLP_NUMBER_CURRENCY","Expected a three-letter ISO 4217 currency code.");const{locale:r,display:n,...a}=o;return l(r,{...a,style:"currency",currency:e.toUpperCase(),...n?{currencyDisplay:n}:{}}).format(t)}function M(t,e={}){const{locale:o,...r}=e;return l(o,{...r,style:"percent"}).format(t)}function P(t,e={}){const{locale:o,display:r="short",...n}=e;return l(o,{...n,notation:"compact",compactDisplay:r}).format(t)}function x(t,e,o={}){const{locale:r,unitDisplay:n="short",...a}=o;return l(r,{...a,style:"unit",unit:e,unitDisplay:n}).format(t)}const N={en:{one:"st",two:"nd",few:"rd",other:"th"},fr:{one:"er",other:"e"},de:{other:"."},nl:{other:"e"},es:{other:"\xBA"},it:{other:"\xBA"},pt:{other:"\xBA"},sv:{one:":a",other:":e"},da:{other:"."},nb:{other:"."},fi:{other:"."},pl:{other:"."},cs:{other:"."}};function L(t,e){y(t);const o=typeof e=="string"?{locale:e}:e??{},r=F(o.locale,{type:"ordinal"}),n=r.resolvedOptions().locale.split("-")[0]??"en",a=o.suffixes??N[n]??{},s=r.select(t),i=a[s]??a.other??"";return`${l(o.locale).format(t)}${i}`}const m=["byte","kilobyte","megabyte","gigabyte","terabyte","petabyte"];function D(t,e={}){y(t);const{locale:o,base:r=1e3,style:n="short",maximumFractionDigits:a=1}=e;if(![1e3,1024].includes(r))throw new c("HLP_NUMBER_BYTES_BASE","The base must be 1000 or 1024.");const s=Math.abs(t);let i=s<1?0:Math.min(m.length-1,Math.floor(Math.log(s)/Math.log(r)));i>0&&s<r**i&&i--;let u=s/r**i;const p=10**a;Math.round(u*p)/p>=r&&i<m.length-1&&(i++,u=s/r**i);const g=m[i]??"byte";return x(Math.sign(t)*u,g,{locale:o,unitDisplay:n,maximumFractionDigits:a})}export{D as formatBytes,P as formatCompact,R as formatCurrency,C as formatNumber,L as formatOrdinal,M as formatPercent,x as formatUnit,l as numberFormat};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Number helpers: exact decimal rounding, compensated sums, integer math, locale-aware
3
+ * parsing and formatting (docs/PLAN-HELPERS.md section 2). Randomness lives in `random`.
4
+ */
5
+ export { clamp, inRange, round, roundHalfEven, floor, ceil, trunc, roundTo, isEven, isOdd, sign, isNegativeZero, normalizeZero, percent, percentChange, ratio, lerp, inverseLerp, remap, approximatelyEqual, kahanSum, sum, product, gcd, lcm, gcdBigInt, lcmBigInt, isPrime, factorial, MAX_FACTORIAL, toFixedSafe } from './core.js';
6
+ export type { InRangeOptions, PercentOptions, RemapOptions, ApproxOptions } from './core.js';
7
+ export { formatNumber, formatCurrency, formatPercent, formatCompact, formatUnit, formatOrdinal, formatBytes } from './format.js';
8
+ export type { LocaleInput, NumericValue, FormatNumberOptions, FormatCurrencyOptions, FormatCompactOptions, FormatUnitOptions, FormatOrdinalOptions, FormatBytesOptions } from './format.js';
9
+ export { parseNumber, parseNumberString, parseBytes, isSafeNumberString, MAX_NUMBER_TEXT } from './parse.js';
10
+ export type { ParseNumberOptions, ParseBytesOptions } from './parse.js';
11
+ export { numberToWords, toRoman, fromRoman } from './words.js';
12
+ export type { NumberToWordsOptions } from './words.js';
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.2 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{clamp as e,inRange as t,round as a,roundHalfEven as m,floor as n,ceil as p,trunc as i,roundTo as s,isEven as f,isOdd as u,sign as c,isNegativeZero as O,normalizeZero as l,percent as d,percentChange as g,ratio as x,lerp as y,inverseLerp as N,remap as b,approximatelyEqual as F,kahanSum as B,sum as R,product as C,gcd as T,lcm as A,gcdBigInt as E,lcmBigInt as I,isPrime as P,factorial as S,MAX_FACTORIAL as j,toFixedSafe as v}from"./core.js";import{formatNumber as M,formatCurrency as U,formatPercent as X,formatCompact as _,formatUnit as h,formatOrdinal as W,formatBytes as Z}from"./format.js";import{parseNumber as q,parseNumberString as w,parseBytes as z,isSafeNumberString as H,MAX_NUMBER_TEXT as V}from"./parse.js";import{numberToWords as G,toRoman as J,fromRoman as K}from"./words.js";export{j as MAX_FACTORIAL,V as MAX_NUMBER_TEXT,F as approximatelyEqual,p as ceil,e as clamp,S as factorial,n as floor,Z as formatBytes,_ as formatCompact,U as formatCurrency,M as formatNumber,W as formatOrdinal,X as formatPercent,h as formatUnit,K as fromRoman,T as gcd,E as gcdBigInt,t as inRange,N as inverseLerp,f as isEven,O as isNegativeZero,u as isOdd,P as isPrime,H as isSafeNumberString,B as kahanSum,A as lcm,I as lcmBigInt,y as lerp,l as normalizeZero,G as numberToWords,z as parseBytes,q as parseNumber,w as parseNumberString,d as percent,g as percentChange,C as product,x as ratio,b as remap,a as round,m as roundHalfEven,s as roundTo,c as sign,R as sum,v as toFixedSafe,J as toRoman,i as trunc};
@@ -0,0 +1,18 @@
1
+ /** Sign, digits (no leading zeros except a lone "0"), and power-of-ten exponent: value = +/-digits x 10^exponent. */
2
+ export interface DecimalParts {
3
+ readonly negative: boolean;
4
+ readonly digits: string;
5
+ readonly exponent: number;
6
+ }
7
+ /** Decomposes the shortest round-trip representation of a finite number. */
8
+ export declare function numberParts(value: number): DecimalParts;
9
+ /** Plain (never exponential) decimal string for parts. */
10
+ export declare function partsToPlain(parts: DecimalParts): string;
11
+ /** Plain decimal string of a finite number (no exponent notation, `-0` becomes `"0"`). */
12
+ export declare function plainString(value: number): string;
13
+ /** Number of fractional decimal digits in the shortest representation of `value`. */
14
+ export declare function fractionDigits(value: number): number;
15
+ /** Multiplies by 10^places exactly in decimal space (the exponent-shift technique). */
16
+ export declare function shift(value: number, places: number): number;
17
+ export declare function assertFinite(value: number, code?: string): void;
18
+ export declare function assertInteger(value: number, code?: string): void;
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.2 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{ValidationError as c}from"../error/index.js";function a(t){const e=String(Math.abs(t)),n=e.indexOf("e"),r=n===-1?e:e.slice(0,n);let o=n===-1?0:Number(e.slice(n+1));const i=r.indexOf(".");let s=r;return i!==-1&&(s=r.slice(0,i)+r.slice(i+1),o-=r.length-i-1),s=s.replace(/^0+(?=\d)/,""),{negative:t<0,digits:s,exponent:o}}function u(t){const{digits:e,exponent:n}=t;let r;if(n>=0)r=e==="0"?"0":e+"0".repeat(n);else{const o=e.padStart(-n+1,"0"),i=o.length+n;r=`${o.slice(0,i)}.${o.slice(i)}`}return t.negative&&/[1-9]/.test(e)?`-${r}`:r}function l(t){return u(a(t))}function b(t){const{exponent:e}=a(t);return e<0?-e:0}function f(t,e){const n=String(t),r=n.indexOf("e");return r===-1?+`${n}e${e}`:+`${n.slice(0,r)}e${Number(n.slice(r+1))+e}`}function g(t,e="HLP_NUMBER_NOT_FINITE"){if(!Number.isFinite(t))throw new c(e,"Expected a finite number.")}function p(t,e="HLP_NUMBER_NOT_INTEGER"){if(!Number.isInteger(t))throw new c(e,"Expected an integer.")}export{g as assertFinite,p as assertInteger,b as fractionDigits,a as numberParts,u as partsToPlain,l as plainString,f as shift};
@@ -0,0 +1,45 @@
1
+ import { type LocaleInput } from './format.js';
2
+ /** Longest accepted input for `parseNumber` / `parseNumberString`. */
3
+ export declare const MAX_NUMBER_TEXT = 1000;
4
+ export interface ParseNumberOptions {
5
+ /** Locale whose group, decimal, sign and percent symbols are expected. Default: runtime locale. */
6
+ readonly locale?: LocaleInput;
7
+ /** Reject misplaced group separators (e.g. "1,2,3") and dangling decimal points. Default false. */
8
+ readonly strict?: boolean;
9
+ }
10
+ /**
11
+ * Parses localized numeric text into a canonical ASCII decimal string (lossless, no exponent),
12
+ * or `undefined` when the text is not a number. A percent sign divides by 100.
13
+ * Non-Latin digits (Arabic-Indic, Devanagari, ...), NBSP / narrow NBSP group separators and
14
+ * U+2212 minus are accepted. Throws `HLP_NUMBER_TOO_LONG` above `MAX_NUMBER_TEXT` characters.
15
+ * @example parseNumberString('1.234.567,891', { locale: 'de' }) // => '1234567.891'
16
+ */
17
+ export declare function parseNumberString(text: string, options?: ParseNumberOptions): string | undefined;
18
+ /**
19
+ * Locale-aware number parse; `undefined` for garbage, empty text, or values outside the double range.
20
+ * @example
21
+ * parseNumber('١٢٣٫٥', { locale: 'ar-EG' }); // => 123.5
22
+ * parseNumber('12 %', { locale: 'fr' }); // => 0.12
23
+ */
24
+ export declare function parseNumber(text: string, options?: ParseNumberOptions): number | undefined;
25
+ export interface ParseBytesOptions {
26
+ /** Multiplier for "KB", "MB", ... (default 1000). "KiB", "MiB", ... are always 1024. */
27
+ readonly base?: 1000 | 1024;
28
+ /** Locale of the numeric part. Default `'en'`. */
29
+ readonly locale?: LocaleInput;
30
+ }
31
+ /**
32
+ * Parses a byte size ("1.5 GB", "512 KiB", "3 megabytes", "42") into whole bytes; `undefined` when invalid or negative.
33
+ * @example
34
+ * parseBytes('1.5 GB'); // => 1500000000
35
+ * parseBytes('1 KiB'); // => 1024
36
+ */
37
+ export declare function parseBytes(text: string, options?: ParseBytesOptions): number | undefined;
38
+ /**
39
+ * True when `text` is a plain decimal string (`-12.5`, `.5`, no exponent) whose value a `number`
40
+ * holds exactly: integers must be safe, fractions at most 15 significant digits.
41
+ * @example
42
+ * isSafeNumberString('9007199254740993'); // => false
43
+ * isSafeNumberString('0.1'); // => true
44
+ */
45
+ export declare function isSafeNumberString(text: string): boolean;
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.2 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{LimitError as w}from"../error/index.js";import{numberFormat as N}from"./format.js";import{partsToPlain as T}from"./internal.js";const A=1e3,S=[" ","\xA0","\u202F","\u2009"],R=[1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,6112,6160,6470,6608,6992,43216,43264,65296],v=e=>e===1564||e===8206||e===8207||e>=8234&&e<=8238||e>=8294&&e<=8297,k=e=>Array.from(e).filter(s=>!v(s.codePointAt(0)??0)).join(""),P=new Map;function M(e){const s=e===void 0?"":typeof e=="string"?e:e.join(","),n=P.get(s);if(n)return n;const f=N(e,{useGrouping:!0}).formatToParts(-12345678905e-1),r=k;let t=",",g=".",a="-";const u=[];for(const i of f)i.type==="group"?t=i.value:i.type==="decimal"?g=i.value:i.type==="minusSign"?a=r(i.value)||"-":i.type==="integer"&&u.push(i.value.length);const b=N(e,{signDisplay:"always"}).formatToParts(1).find(i=>i.type==="plusSign"),p=N(e,{style:"percent"}).formatToParts(.5).find(i=>i.type==="percentSign"),d=new Set([t]);if(S.includes(t))for(const i of S)d.add(i);(t==="\u2019"||t==="'")&&(d.add("'"),d.add("\u2019"));const l=u.at(-1)??3,m={group:d,decimal:g,minus:new Set(["-","\u2212",a]),plus:new Set(["+",b&&r(b.value)||"+"]),percent:new Set(["%","\u066A",p&&r(p.value)||"%"]),primary:l,secondary:u.length>2?u.at(-2)??l:l};return P.size>=32&&P.clear(),P.set(s,m),m}function _(e){const s=e.codePointAt(0)??0;for(const n of R)if(s>=n&&s<=n+9)return String(s-n);return e}function E(e,s={}){if(typeof e!="string")return;if(e.length>A)throw new w("HLP_NUMBER_TOO_LONG","The numeric text exceeds the length limit.");const n=M(s.locale),f=s.strict===!0,r=Array.from(k(e).trim(),_);let t=0,g=!1,a=!1,u=!1;const b=()=>{for(;t<r.length&&S.includes(r[t]??"");)t++};for(let o=0;o<2;o++){const c=r[t]??"";!a&&(n.minus.has(c)||n.plus.has(c))?(g=n.minus.has(c),a=!0,t++):!u&&n.percent.has(c)&&(u=!0,t++,b())}let p=-1;for(let o=r.length-1;o>=0;o--){const c=r[o]??"";if(c>="0"&&c<="9"){p=o;break}}const d=[];let l="",m="",i="",y=!1,L=!1,h=!1;for(;t<r.length;t++){const o=r[t]??"";if(o>="0"&&o<="9")L=!0,h=!1,y?i+=o:l+=o;else if(o===n.decimal&&!y){if(h)return;y=!0,d.push(l.length),m+=l,l=""}else if(n.group.has(o)&&!y){if(S.includes(o)&&t>p)break;if(l===""||h)return;d.push(l.length),m+=l,l="",h=!0}else break}if(y||(d.push(l.length),m+=l),h||(b(),!u&&n.percent.has(r[t]??"")&&(u=!0,t++),t!==r.length||!L))return;if(f){if(y&&(i===""||m===""))return;if(d.length>1){const o=d.length-1;for(let c=0;c<=o;c++){const x=d[c]??0;if(c===o?x!==n.primary:c===0?x<1||x>n.secondary:x!==n.secondary)return}}}const I=(m+i).replace(/^0+(?=\d)/,"");return T({negative:g,digits:I,exponent:-i.length-(u?2:0)})}function D(e,s={}){const n=E(e,s);if(n===void 0)return;const f=Number(n);return Number.isFinite(f)?f===0?0:f:void 0}const O=new Map([["k",1],["kb",1],["kilobyte",1],["kilobytes",1],["m",2],["mb",2],["megabyte",2],["megabytes",2],["g",3],["gb",3],["gigabyte",3],["gigabytes",3],["t",4],["tb",4],["terabyte",4],["terabytes",4],["p",5],["pb",5],["petabyte",5],["petabytes",5]]),B=new Map([["kib",1],["kibibyte",1],["kibibytes",1],["mib",2],["mebibyte",2],["mebibytes",2],["gib",3],["gibibyte",3],["gibibytes",3],["tib",4],["tebibyte",4],["tebibytes",4],["pib",5],["pebibyte",5],["pebibytes",5]]);function F(e,s={}){if(typeof e!="string")return;if(e.length>256)throw new w("HLP_NUMBER_TOO_LONG","The byte size text exceeds the length limit.");const{base:n=1e3,locale:f="en"}=s,r=e.trim(),t=r.search(/\p{L}/u),g=(t===-1?r:r.slice(0,t)).trim(),a=(t===-1?"":r.slice(t)).trim().toLowerCase();if(g.includes("%"))return;const u=D(g,{locale:f});if(u===void 0||u<0)return;let b;if(a===""||a==="b"||a==="byte"||a==="bytes")b=1;else if(O.has(a))b=n**(O.get(a)??0);else if(B.has(a))b=1024**(B.get(a)??0);else return;const p=Math.round(u*b);return Number.isSafeInteger(p)?p:void 0}function U(e){if(typeof e!="string"||e.length>400||!/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/.test(e))return!1;const s=e.replace(/^[+-]/,""),[n="",f=""]=s.split(".");let r=f.length;for(;r>0&&f.charCodeAt(r-1)===48;)r--;const t=f.slice(0,r);if(t===""){const a=Number(n||"0");return Number.isSafeInteger(a)&&BigInt(n||"0")===BigInt(a)}return(n+t).replace(/^0+/,"").length<=15&&Number(s)!==0}export{A as MAX_NUMBER_TEXT,U as isSafeNumberString,F as parseBytes,D as parseNumber,E as parseNumberString};
@@ -0,0 +1,19 @@
1
+ export interface NumberToWordsOptions {
2
+ /** British style "one hundred and five". Default false (US: "one hundred five"). */
3
+ readonly and?: boolean;
4
+ }
5
+ /**
6
+ * English words for a number up to +/-10¹⁵ (English only, by design). Fractions are read digit by digit.
7
+ * @example numberToWords(-1234.05) // => 'minus one thousand two hundred thirty-four point zero five'
8
+ */
9
+ export declare function numberToWords(value: number, options?: NumberToWordsOptions): string;
10
+ /**
11
+ * Roman numeral for an integer in `1..3999`.
12
+ * @example toRoman(2026) // => 'MMXXVI'
13
+ */
14
+ export declare function toRoman(value: number): string;
15
+ /**
16
+ * Parses a canonical Roman numeral (case-insensitive, `1..3999`); `undefined` for non-canonical forms like "IIII".
17
+ * @example fromRoman('mcmxcix') // => 1999
18
+ */
19
+ export declare function fromRoman(text: string): number | undefined;
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.2 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{LimitError as c,ValidationError as p}from"../error/index.js";import{assertFinite as g,plainString as b}from"./internal.js";const a=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],N=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],h=["","thousand","million","billion","trillion","quadrillion"];function d(e,o){const t=Math.floor(e/100),n=e%100,r=[];return t&&r.push(`${a[t]??""} hundred`),n&&(t&&o&&r.push("and"),r.push(n<20?a[n]??"":`${N[Math.floor(n/10)]??""}${n%10?`-${a[n%10]??""}`:""}`)),r.join(" ")}function E(e,o={}){if(g(e),Math.abs(e)>1e15)throw new c("HLP_NUMBER_TOO_LARGE","The value exceeds the supported range for words.");const t=o.and===!0,[n="0",r=""]=b(Math.abs(e)).split(".");let i=Number(n);const f=[];i===0&&f.push("zero");for(let s=0;i>0;s++){const l=i%1e3;i=Math.floor(i/1e3),l&&f.unshift(h[s]?`${d(l,t)} ${h[s]??""}`:d(l,t))}let u=f.join(" ");if(t&&Number(n)>=1e3&&Number(n)%1e3<100&&Number(n)%1e3>0){const s=f.pop()??"";u=`${f.join(" ")} and ${s}`}return r&&(u+=` point ${Array.from(r,s=>a[Number(s)]??"").join(" ")}`),e<0&&u!=="zero"?`minus ${u}`:u}const M=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];function y(e){if(!Number.isInteger(e)||e<1||e>3999)throw new p("HLP_NUMBER_ROMAN_RANGE","Roman numerals support integers from 1 to 3999.");let o=e,t="";for(const[n,r]of M)for(;o>=n;)t+=r,o-=n;return t}const m=new Map([["I",1],["V",5],["X",10],["L",50],["C",100],["D",500],["M",1e3]]);function R(e){if(typeof e!="string"||e.length===0||e.length>15)return;const o=e.toUpperCase();let t=0;for(let n=0;n<o.length;n++){const r=m.get(o.charAt(n));if(r===void 0)return;const i=m.get(o.charAt(n+1))??0;t+=r<i?-r:r}return t>=1&&t<=3999&&y(t)===o?t:void 0}export{R as fromRoman,E as numberToWords,y as toRoman};
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Keeps the listed own keys.
3
+ * @example pick({ a: 1, b: 2 }, ['a']) // => { a: 1 }
4
+ */
5
+ export declare function pick<T extends object, K extends keyof T>(obj: T, keys: readonly K[]): Pick<T, K>;
6
+ /**
7
+ * Drops the listed keys.
8
+ * @example omit({ a: 1, b: 2 }, ['a']) // => { b: 2 }
9
+ */
10
+ export declare function omit<T extends object, K extends keyof T>(obj: T, keys: readonly K[]): Omit<T, K>;
11
+ /**
12
+ * Keeps entries whose value and key pass `predicate`.
13
+ * @example pickBy({ a: 1, b: null }, (v) => v !== null) // => { a: 1 }
14
+ */
15
+ export declare function pickBy<T extends object>(obj: T, predicate: (value: T[keyof T], key: keyof T & string) => boolean): Partial<T>;
16
+ /**
17
+ * Drops entries whose value and key pass `predicate`.
18
+ * @example omitBy({ a: 1, b: null }, (v) => v === null) // => { a: 1 }
19
+ */
20
+ export declare function omitBy<T extends object>(obj: T, predicate: (value: T[keyof T], key: keyof T & string) => boolean): Partial<T>;
21
+ /**
22
+ * Renames keys with `fn`. Later entries win on collisions.
23
+ * @example mapKeys({ a: 1 }, (_, k) => k.toUpperCase()) // => { A: 1 }
24
+ */
25
+ export declare function mapKeys<T extends object, K extends PropertyKey>(obj: T, fn: (value: T[keyof T], key: keyof T & string) => K): Record<K, T[keyof T]>;
26
+ /**
27
+ * Transforms values, keeping keys.
28
+ * @example mapValues({ a: 1 }, (v) => v * 2) // => { a: 2 }
29
+ */
30
+ export declare function mapValues<T extends object, R>(obj: T, fn: (value: T[keyof T], key: keyof T & string) => R): Record<keyof T & string, R>;
31
+ /**
32
+ * Transforms entries; return `[newKey, newValue]`.
33
+ * @example mapEntries({ a: 1 }, ([k, v]) => [`${k}!`, v + 1]) // => { 'a!': 2 }
34
+ */
35
+ export declare function mapEntries<T extends object, K extends PropertyKey, V>(obj: T, fn: (entry: [keyof T & string, T[keyof T]]) => readonly [K, V]): Record<K, V>;
36
+ /**
37
+ * Keeps entries whose key passes `predicate`.
38
+ * @example filterKeys({ a: 1, _b: 2 }, (k) => !k.startsWith('_')) // => { a: 1 }
39
+ */
40
+ export declare function filterKeys<T extends object>(obj: T, predicate: (key: keyof T & string) => boolean): Partial<T>;
41
+ /**
42
+ * Keeps entries whose value passes `predicate`.
43
+ * @example filterValues({ a: 1, b: 0 }, Boolean) // => { a: 1 }
44
+ */
45
+ export declare function filterValues<T extends object>(obj: T, predicate: (value: T[keyof T]) => boolean): Partial<T>;
46
+ /**
47
+ * Swaps keys and values (values must be strings, numbers, booleans or bigints). Later keys win.
48
+ * @example invert({ a: 'x', b: 'y' }) // => { x: 'a', y: 'b' }
49
+ */
50
+ export declare function invert(obj: Readonly<Record<string, string | number | boolean | bigint>>): Record<string, string>;
51
+ /**
52
+ * Groups keys by a value-derived key.
53
+ * @example invertBy({ a: 1, b: 2, c: 1 }) // => { '1': ['a', 'c'], '2': ['b'] }
54
+ */
55
+ export declare function invertBy<T extends object>(obj: T, fn?: (value: T[keyof T]) => unknown): Record<string, (keyof T & string)[]>;
56
+ /**
57
+ * Renames keys by a mapping; unmapped keys are kept. Later entries win on collisions.
58
+ * @example renameKeys({ first: 'A' }, { first: 'givenName' }) // => { givenName: 'A' }
59
+ */
60
+ export declare function renameKeys(obj: object, mapping: Readonly<Record<string, string>>): Record<string, unknown>;
61
+ export interface CompactObjectOptions {
62
+ /** `'nullish'` (default) removes `null`/`undefined`; `'undefined'` only `undefined`; `'empty'` also `''`, `[]`, `{}`. */
63
+ readonly remove?: 'nullish' | 'undefined' | 'empty';
64
+ /** Recurse into plain objects and arrays (array elements are compacted, never removed). */
65
+ readonly deep?: boolean;
66
+ }
67
+ /**
68
+ * Removes nullish (or empty) values.
69
+ * @example compactObject({ a: 1, b: null, c: undefined }) // => { a: 1 }
70
+ */
71
+ export declare function compactObject<T extends object>(obj: T, options?: CompactObjectOptions): Partial<T>;
72
+ /**
73
+ * Fills keys that are missing or `undefined` from the sources, in order.
74
+ * @example defaults({ a: 1, b: undefined }, { b: 2, c: 3 }) // => { a: 1, b: 2, c: 3 }
75
+ */
76
+ export declare function defaults<T extends object, S extends object>(obj: T, ...sources: readonly S[]): T & Partial<S>;
77
+ /** `Object.keys` typed as the object's string keys. @example typedKeys({ a: 1 }) // => ['a'] */
78
+ export declare function typedKeys<T extends object>(obj: T): (keyof T & string)[];
79
+ /** `Object.values` typed. @example typedValues({ a: 1 }) // => [1] */
80
+ export declare function typedValues<T extends object>(obj: T): T[keyof T][];
81
+ /** `Object.entries` typed. @example typedEntries({ a: 1 }) // => [['a', 1]] */
82
+ export declare function typedEntries<T extends object>(obj: T): [keyof T & string, T[keyof T]][];
83
+ /**
84
+ * `Object.fromEntries` typed (defines own data properties; never calls the `__proto__` setter).
85
+ * @example typedFromEntries([['a', 1]] as const) // => { a: 1 }
86
+ */
87
+ export declare function typedFromEntries<K extends PropertyKey, V>(entries: Iterable<readonly [K, V]>): Record<K, V>;
88
+ /**
89
+ * One-level equality with `Object.is` for arrays and objects (own enumerable string keys).
90
+ * @example isShallowEqual({ a: 1 }, { a: 1 }) // => true
91
+ */
92
+ export declare function isShallowEqual(a: unknown, b: unknown): boolean;
93
+ /**
94
+ * Own property value, or `undefined` (never reads inherited properties).
95
+ * @example getOwn({}, 'toString') // => undefined
96
+ */
97
+ export declare function getOwn(obj: unknown, key: PropertyKey): unknown;
98
+ /**
99
+ * Element count: length of arrays/strings, size of maps/sets, own enumerable keys of objects, 0 for nullish.
100
+ * @example size({ a: 1, b: 2 }) // => 2
101
+ */
102
+ export declare function size(value: unknown): number;
103
+ /**
104
+ * Counts values by a derived key (defaults to the value itself).
105
+ * @example countValuesBy({ a: 'x', b: 'y', c: 'x' }) // => { x: 2, y: 1 }
106
+ */
107
+ export declare function countValuesBy<T extends object>(obj: T, fn?: (value: T[keyof T]) => unknown): Record<string, number>;
108
+ export interface SortKeysOptions {
109
+ /** Sort nested plain objects (including those inside arrays). Default false. */
110
+ readonly recursive?: boolean;
111
+ /** Key comparator. Default: UTF-16 code unit order. */
112
+ readonly compare?: (a: string, b: string) => number;
113
+ }
114
+ /**
115
+ * Returns a copy with keys inserted in sorted order (for canonical output). Note that JavaScript
116
+ * always enumerates integer-like keys first, in ascending numeric order.
117
+ * @example Object.keys(sortKeys({ b: 1, a: 2 })) // => ['a', 'b']
118
+ */
119
+ export declare function sortKeys<T extends object>(obj: T, options?: SortKeysOptions): T;
120
+ /**
121
+ * Own enumerable string-keyed entries as a `Map`.
122
+ * @example objectToMap({ a: 1 }).get('a') // => 1
123
+ */
124
+ export declare function objectToMap<V>(obj: Readonly<Record<string, V>>): Map<string, V>;
125
+ /**
126
+ * Converts a `Map` with string/number keys to a plain object. Throws `HLP_OBJECT_INVALID_KEY`
127
+ * for other key types and `HLP_UNSAFE_KEY` for `__proto__`/`constructor`/`prototype`.
128
+ * @example mapToObject(new Map([['a', 1]])) // => { a: 1 }
129
+ */
130
+ export declare function mapToObject<V>(map: ReadonlyMap<unknown, V>): Record<string, V>;
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.2 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{ValidationError as j}from"../error/index.js";import{isPlainObject as d}from"../is/index.js";import{assertSafeKey as y,hasOwn as k}from"../internal/keys.js";import{circular as p,put as f}from"./internal.js";function V(e,n){const t={};for(const o of n)k(e,o)&&f(t,o,e[o]);return t}function h(e,n){const t=new Set(n),o={};for(const[r,c]of Object.entries(e))t.has(r)||f(o,r,c);return o}function l(e,n){const t={};for(const[o,r]of Object.entries(e))n(r,o)&&f(t,o,r);return t}function P(e,n){return l(e,(t,o)=>!n(t,o))}function A(e,n){const t={};for(const[o,r]of Object.entries(e)){const c=n(r,o);y(c),t[c]=r}return t}function S(e,n){const t={};for(const[o,r]of Object.entries(e))f(t,o,n(r,o));return t}function E(e,n){const t={};for(const o of Object.entries(e)){const[r,c]=n(o);y(r),t[r]=c}return t}function _(e,n){return l(e,(t,o)=>n(o))}function B(e,n){return l(e,t=>n(t))}function b(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);throw new j("HLP_OBJECT_INVALID_KEY","The value cannot be used as an object key.")}function I(e){const n={};for(const[t,o]of Object.entries(e)){const r=b(o);y(r),n[r]=t}return n}function M(e,n=t=>t){const t={};for(const[o,r]of Object.entries(e)){const c=b(n(r));y(c),(t[c]??=[]).push(o)}return t}function C(e,n){const t={};for(const[o,r]of Object.entries(e)){const c=k(n,o)?n[o]??o:o;c!==o&&y(c),f(t,c,r)}return t}function L(e,n={}){const{remove:t="nullish",deep:o=!1}=n,r=new Set,c=s=>s===void 0?!0:t==="undefined"?!1:s===null?!0:t!=="empty"?!1:s===""?!0:Array.isArray(s)?s.length===0:d(s)&&Object.keys(s).length===0,T=s=>{if(!o||!Array.isArray(s)&&!d(s))return s;r.has(s)&&p(),r.add(s);let a;if(Array.isArray(s))a=s.map(T);else{const u={};for(const[x,O]of Object.entries(s)){const g=T(O);c(g)||f(u,x,g)}a=u}return r.delete(s),a},i={};for(const[s,a]of Object.entries(e)){const u=T(a);c(u)||f(i,s,u)}return i}function z(e,...n){const t={};for(const[o,r]of Object.entries(e))f(t,o,r);for(const o of n)for(const[r,c]of Object.entries(o))(!k(t,r)||t[r]===void 0)&&f(t,r,c);return t}function D(e){return Object.keys(e)}function H(e){return Object.values(e)}function J(e){return Object.entries(e)}function N(e){return Object.fromEntries(e)}function Y(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||typeof n!="object"||e===null||n===null||Array.isArray(e)!==Array.isArray(n))return!1;const t=Object.keys(e);if(t.length!==Object.keys(n).length)return!1;for(const o of t)if(!k(n,o)||!Object.is(e[o],n[o]))return!1;return!0}function q(e,n){if(!(typeof e!="object"&&typeof e!="function"||e===null))return k(e,n)?e[n]:void 0}function F(e){return e==null?0:typeof e=="string"||Array.isArray(e)?e.length:e instanceof Map||e instanceof Set?e.size:typeof e=="object"?Object.keys(e).length:0}function G(e,n=t=>t){const t={};for(const o of Object.values(e)){const r=b(n(o));y(r),t[r]=(t[r]??0)+1}return t}function Q(e,n={}){const{recursive:t=!1,compare:o}=n,r=new Set,c=i=>{r.has(i)&&p(),r.add(i);const s=Object.keys(i);o?s.sort(o):s.sort();const a={};for(const u of s)f(a,u,t?T(i[u]):i[u]);return r.delete(i),a},T=i=>{if(Array.isArray(i)){r.has(i)&&p(),r.add(i);const s=i.map(T);return r.delete(i),s}return d(i)?c(i):i};return c(e)}function U(e){return new Map(Object.entries(e))}function W(e){const n={};for(const[t,o]of e){if(typeof t!="string"&&typeof t!="number")throw new j("HLP_OBJECT_INVALID_KEY","The value cannot be used as an object key.");const r=String(t);y(r),n[r]=o}return n}export{L as compactObject,G as countValuesBy,z as defaults,_ as filterKeys,B as filterValues,q as getOwn,I as invert,M as invertBy,Y as isShallowEqual,E as mapEntries,A as mapKeys,W as mapToObject,S as mapValues,U as objectToMap,h as omit,P as omitBy,V as pick,l as pickBy,C as renameKeys,F as size,Q as sortKeys,J as typedEntries,N as typedFromEntries,D as typedKeys,H as typedValues};