@rzl-zone/utils-js 3.1.0-beta.2 → 3.1.0

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 (195) hide show
  1. package/README.md +56 -27
  2. package/dist/NumberRangeUnion-DC-C3_Kq.d.ts +23 -23
  3. package/dist/any-BmdI8UbK.d.ts +56 -56
  4. package/dist/arrays-normalize-recursive-CnjYJ9xg.d.ts +66 -66
  5. package/dist/assertions/index.cjs +1 -1
  6. package/dist/assertions/index.d.ts +396 -396
  7. package/dist/assertions/index.js +1 -1
  8. package/dist/chunk-26XIKDJI.cjs +1 -0
  9. package/dist/chunk-2NWHDDM5.js +1 -0
  10. package/dist/chunk-2UIRWYE3.js +1 -0
  11. package/dist/chunk-3KBHD3BS.cjs +1 -0
  12. package/dist/chunk-4HD2O5A4.js +1 -0
  13. package/dist/chunk-5C2SMIGX.cjs +1 -0
  14. package/dist/chunk-5I2B5DOG.js +1 -0
  15. package/dist/chunk-6HQDHIOD.js +1 -0
  16. package/dist/chunk-735HJXBT.cjs +1 -0
  17. package/dist/chunk-7BXIZM57.cjs +1 -0
  18. package/dist/chunk-7KJBDGEP.js +1 -0
  19. package/dist/chunk-7U44T63D.cjs +1 -0
  20. package/dist/chunk-AJ65QFV2.js +1 -0
  21. package/dist/chunk-APHDUCVQ.js +1 -0
  22. package/dist/chunk-BSVZRN7C.js +1 -0
  23. package/dist/chunk-C6JFHUR2.cjs +1 -0
  24. package/dist/chunk-CPLBRGST.js +1 -0
  25. package/dist/chunk-CTBRLEOG.js +1 -0
  26. package/dist/chunk-DUK2K4FB.js +1 -0
  27. package/dist/chunk-DVMHRLKP.cjs +1 -0
  28. package/dist/chunk-E63WVPZE.cjs +1 -0
  29. package/dist/chunk-EBMHQW7X.cjs +1 -0
  30. package/dist/chunk-EGNZCW4K.js +1 -0
  31. package/dist/chunk-FEKDB32T.js +1 -0
  32. package/dist/chunk-FIAAX3UE.js +1 -0
  33. package/dist/chunk-FUS3DVLB.cjs +1 -0
  34. package/dist/chunk-GGRMHIFJ.cjs +1 -0
  35. package/dist/chunk-HQ5GQTEE.js +1 -0
  36. package/dist/chunk-I5X5IN4H.js +1 -0
  37. package/dist/chunk-I7YGXQPI.cjs +1 -0
  38. package/dist/chunk-INUFZJLX.cjs +1 -0
  39. package/dist/chunk-IREHUBF7.js +1 -0
  40. package/dist/chunk-J2RGTPGK.cjs +1 -0
  41. package/dist/chunk-KHO2SBNA.cjs +1 -0
  42. package/dist/chunk-KXIXXSWX.cjs +1 -0
  43. package/dist/chunk-LBMEEJWA.js +1 -0
  44. package/dist/chunk-MC3LXMCQ.js +1 -0
  45. package/dist/chunk-MMSYCIJ2.cjs +1 -1
  46. package/dist/chunk-NU3N4WHD.cjs +1 -0
  47. package/dist/chunk-ODZQXH7E.cjs +1 -0
  48. package/dist/chunk-ONZFBJVW.js +1 -0
  49. package/dist/chunk-PXDRHFIE.js +1 -0
  50. package/dist/chunk-Q6NHYWVX.js +1 -0
  51. package/dist/chunk-QNKGP5DY.js +1 -0
  52. package/dist/chunk-S6Z6I2EG.cjs +1 -0
  53. package/dist/chunk-SMADKXZE.js +1 -0
  54. package/dist/chunk-TSLYDPBJ.js +1 -0
  55. package/dist/chunk-TVXADXCC.cjs +1 -0
  56. package/dist/chunk-UDA26MCU.cjs +1 -0
  57. package/dist/chunk-UET567YM.cjs +1 -0
  58. package/dist/chunk-VEYMQ3UA.js +1 -0
  59. package/dist/chunk-W2W3L2M5.js +1 -0
  60. package/dist/chunk-WBWTXKMC.cjs +1 -0
  61. package/dist/chunk-WVSPXFTY.js +1 -0
  62. package/dist/chunk-XC2PYCT4.cjs +1 -0
  63. package/dist/chunk-XIXA5KDF.cjs +1 -0
  64. package/dist/chunk-Y4O5KZF6.cjs +1 -0
  65. package/dist/chunk-YRM7IJLX.js +1 -0
  66. package/dist/chunk-YT3MSZKK.cjs +1 -0
  67. package/dist/chunk-YXHCULSO.cjs +1 -0
  68. package/dist/chunk-YZR5OGJA.cjs +1 -0
  69. package/dist/chunk-Z4DXK7A6.cjs +1 -0
  70. package/dist/chunk-ZXIWDFEQ.js +1 -0
  71. package/dist/conversions/index.cjs +1 -1
  72. package/dist/conversions/index.d.ts +1347 -1297
  73. package/dist/conversions/index.js +1 -1
  74. package/dist/env/index.cjs +1 -1
  75. package/dist/env/index.d.ts +14 -14
  76. package/dist/env/index.js +1 -1
  77. package/dist/events/index.cjs +1 -1
  78. package/dist/events/index.d.ts +109 -109
  79. package/dist/events/index.js +1 -1
  80. package/dist/extends-Bk_SBGdT.d.ts +330 -330
  81. package/dist/formatting/index.cjs +1 -1
  82. package/dist/formatting/index.d.ts +855 -855
  83. package/dist/formatting/index.js +1 -1
  84. package/dist/generator/index.cjs +1 -1
  85. package/dist/generator/index.d.ts +155 -155
  86. package/dist/generator/index.js +1 -1
  87. package/dist/if-CvT4R7Kh.d.ts +16 -16
  88. package/dist/is-array-Cymwrsmm.d.ts +1119 -0
  89. package/dist/isPlainObject-BVhBAPHX.d.ts +154 -154
  90. package/dist/never-BfayMBF9.d.ts +64 -64
  91. package/dist/next/index.cjs +1 -8
  92. package/dist/next/index.d.ts +183 -183
  93. package/dist/next/index.js +1 -8
  94. package/dist/next/server/index.cjs +1 -2
  95. package/dist/next/server/index.d.ts +25 -25
  96. package/dist/next/server/index.js +1 -2
  97. package/dist/nils-DMz3kU7M.d.ts +155 -155
  98. package/dist/omit-VvmIsZmX.d.ts +25 -25
  99. package/dist/operations/index.cjs +1 -1
  100. package/dist/operations/index.d.ts +120 -120
  101. package/dist/operations/index.js +1 -1
  102. package/dist/or-DyZCRvaU.d.ts +89 -0
  103. package/dist/parsers/index.cjs +1 -1
  104. package/dist/parsers/index.d.ts +34 -34
  105. package/dist/parsers/index.js +1 -1
  106. package/dist/predicates/index.cjs +1 -1
  107. package/dist/predicates/index.d.ts +1774 -1680
  108. package/dist/predicates/index.js +1 -1
  109. package/dist/prettify-C4xLcYOP.d.ts +328 -328
  110. package/dist/promise/index.cjs +1 -1
  111. package/dist/promise/index.d.ts +29 -29
  112. package/dist/promise/index.js +1 -1
  113. package/dist/rzl-utils.global.js +1 -4
  114. package/dist/string-XA-til3C.d.ts +318 -318
  115. package/dist/strings/index.cjs +1 -1
  116. package/dist/strings/index.d.ts +690 -690
  117. package/dist/strings/index.js +1 -1
  118. package/dist/tailwind/index.cjs +1 -0
  119. package/dist/tailwind/index.d.ts +565 -0
  120. package/dist/tailwind/index.js +1 -0
  121. package/dist/type-data-DDs-u2kq.d.ts +241 -241
  122. package/dist/types/index.d.ts +3266 -3266
  123. package/dist/urls/index.cjs +1 -1
  124. package/dist/urls/index.d.ts +373 -373
  125. package/dist/urls/index.js +1 -1
  126. package/package.json +24 -23
  127. package/dist/chunk-25G6B35W.js +0 -1
  128. package/dist/chunk-2AUUPGMN.js +0 -1
  129. package/dist/chunk-2JQQQ625.js +0 -1
  130. package/dist/chunk-445TAVT4.cjs +0 -1
  131. package/dist/chunk-467VEMJH.js +0 -1
  132. package/dist/chunk-56QBKKRE.js +0 -1
  133. package/dist/chunk-5SZUSNGZ.js +0 -1
  134. package/dist/chunk-6Q4I2RPC.cjs +0 -1
  135. package/dist/chunk-6SMJMZ7G.cjs +0 -1
  136. package/dist/chunk-7YWAQOA4.cjs +0 -1
  137. package/dist/chunk-BLCANGFS.js +0 -1
  138. package/dist/chunk-CK3BZGEU.js +0 -1
  139. package/dist/chunk-D43GV6EF.cjs +0 -1
  140. package/dist/chunk-DFSTVQFI.cjs +0 -1
  141. package/dist/chunk-DYRDBYPF.cjs +0 -1
  142. package/dist/chunk-ELDDNERR.js +0 -1
  143. package/dist/chunk-EXXLUO7L.cjs +0 -1
  144. package/dist/chunk-FIEZKTAZ.cjs +0 -1
  145. package/dist/chunk-G72VSVGO.js +0 -1
  146. package/dist/chunk-GAJTFCUA.js +0 -1
  147. package/dist/chunk-GOJNH55O.cjs +0 -1
  148. package/dist/chunk-HXST7RJB.js +0 -1
  149. package/dist/chunk-HXTACM3O.cjs +0 -1
  150. package/dist/chunk-IJTZWWRJ.cjs +0 -1
  151. package/dist/chunk-ISJ33O2J.cjs +0 -1
  152. package/dist/chunk-JISH2VGG.js +0 -1
  153. package/dist/chunk-JQZUWBIX.js +0 -1
  154. package/dist/chunk-K4PLGD7C.js +0 -1
  155. package/dist/chunk-KZQB7H4E.cjs +0 -1
  156. package/dist/chunk-LUVV5KSD.cjs +0 -2
  157. package/dist/chunk-LVUSFXQS.cjs +0 -1
  158. package/dist/chunk-ME5OV5HN.js +0 -1
  159. package/dist/chunk-MF5Y5K4N.cjs +0 -1
  160. package/dist/chunk-MJAW5RAK.js +0 -1
  161. package/dist/chunk-MWLEM7ED.js +0 -1
  162. package/dist/chunk-NNM7QCNB.js +0 -1
  163. package/dist/chunk-NSVLG7NY.js +0 -4
  164. package/dist/chunk-NUHOOAUN.cjs +0 -1
  165. package/dist/chunk-NUVGETPD.js +0 -2
  166. package/dist/chunk-O5VXBNUQ.cjs +0 -4
  167. package/dist/chunk-O7SJR4CY.cjs +0 -1
  168. package/dist/chunk-OX6RLS2F.cjs +0 -1
  169. package/dist/chunk-PFLNHD4B.cjs +0 -1
  170. package/dist/chunk-PSWITZK5.js +0 -1
  171. package/dist/chunk-PUQXRLZH.cjs +0 -1
  172. package/dist/chunk-PYUVKHUF.cjs +0 -1
  173. package/dist/chunk-REFMEB4A.js +0 -1
  174. package/dist/chunk-RHE3M2NJ.cjs +0 -1
  175. package/dist/chunk-RHIBYOFQ.js +0 -1
  176. package/dist/chunk-RV2VULM7.cjs +0 -1
  177. package/dist/chunk-S7GMG4TB.js +0 -1
  178. package/dist/chunk-SW6HYEW7.cjs +0 -1
  179. package/dist/chunk-SYJC7UAW.js +0 -1
  180. package/dist/chunk-TQMZ2LPI.js +0 -1
  181. package/dist/chunk-U4TZO7WV.js +0 -1
  182. package/dist/chunk-UUMKL74S.js +0 -1
  183. package/dist/chunk-VQLAPEL3.js +0 -1
  184. package/dist/chunk-VTR75UID.cjs +0 -1
  185. package/dist/chunk-XFCJDSB2.cjs +0 -1
  186. package/dist/chunk-XOYX4PLZ.cjs +0 -1
  187. package/dist/chunk-Z6FLCEN6.js +0 -1
  188. package/dist/chunk-ZO5364A6.cjs +0 -1
  189. package/dist/index.cjs +0 -1
  190. package/dist/index.d.ts +0 -1
  191. package/dist/index.js +0 -1
  192. package/dist/is-array--YjXV-Wx.d.ts +0 -1207
  193. package/dist/stylings/index.cjs +0 -1
  194. package/dist/stylings/index.d.ts +0 -41
  195. package/dist/stylings/index.js +0 -1
@@ -0,0 +1,1119 @@
1
+ import{O as OrArr,A as And,a as AndArr}from'./or-DyZCRvaU.js';import{E as Extends,N as Not,I as IfExtends,a as NotExtends}from'./extends-Bk_SBGdT.js';import{I as If}from'./if-CvT4R7Kh.js';import{T as Trim,I as IfNot}from'./string-XA-til3C.js';import{I as IsNever}from'./never-BfayMBF9.js';import{I as IsAny}from'./any-BmdI8UbK.js';import{P as Prettify}from'./prettify-C4xLcYOP.js';
2
+ /** -------------------------------------------------------
3
+ * * ***IsStringLiteral.***
4
+ * -------------------------------------------------------
5
+ * Returns a boolean whether the passed argument is literal string
6
+ *
7
+ * @template T - The type value to check.
8
+ * @example
9
+ * type Case1 = IsStringLiteral<'a'>; // ➔ true
10
+ * type Case2 = IsStringLiteral<1>; // ➔ false
11
+ * type Case3 = IsStringLiteral<string>; // ➔ false
12
+ */
13
+ type IsStringLiteral<T>=If<Extends<T,string>,Extends<string,T>extends true?false:true,false>;
14
+ /** -------------------------------------------------------
15
+ * * ***Push.***
16
+ * -------------------------------------------------------
17
+ *
18
+ * Appends a type `U` to the end of a tuple or readonly array type `T`.
19
+ *
20
+ * @template T - The tuple or readonly array type to append to.
21
+ * @template U - The type of the element to push.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * type Case1 = Push<[1, 2, 3, 4], 5>;
26
+ * // ➔ [1, 2, 3, 4, 5]
27
+ *
28
+ * type Case2 = Push<["a", "b"], "c">;
29
+ * // ➔ ["a", "b", "c"]
30
+ * ```
31
+ */
32
+ type Push<T extends readonly unknown[],U>=[...T,U];type _Repeat<T extends string,Count extends number,Result extends string="",Iteration extends unknown[]=[]>=Iteration["length"] extends Count?Result:_Repeat<T,Count,`${T}${Result}`,Push<Iteration,unknown>>;
33
+ /** -------------------------------------------------------
34
+ * * ***Repeat.***
35
+ * -------------------------------------------------------
36
+ *
37
+ * Repeats a string literal type `T` a specified number of times `Count`.
38
+ * - Supports a range of `[0, 999]` due to TypeScript recursion limits.
39
+ * - If `Count > 999`, it is automatically error `Type instantiation is excessively deep and possibly infinite.ts(2589)`.
40
+ *
41
+ * @template T - The string literal to repeat.
42
+ * @template Count - Number of times to repeat.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * type Case0 = Repeat<'x', 0>; // ➔ ''
47
+ * type Case1 = Repeat<'x', 1>; // ➔ 'x'
48
+ * type Case2 = Repeat<'x', 5>; // ➔ 'xxxxx'
49
+ * type Case3 = Repeat<'ab', 3>; // ➔ 'ababab'
50
+ *
51
+ * // ❌ Invalid:
52
+ * type Case1000 = Repeat<'x', 1000>;
53
+ * // ➔ same as any (because: TypeScript recursion limits)
54
+ * ```
55
+ */
56
+ type Repeat<T extends string,Count extends number>=_Repeat<T,Count>;
57
+ /** -------------------------------------------------------
58
+ * * ***OddDigit.***
59
+ * -------------------------------------------------------
60
+ *
61
+ * A union of string literal digits considered ***odd***.
62
+ *
63
+ * - Includes: `"1" | "3" | "5" | "7" | "9"`.
64
+ *
65
+ * @example
66
+ *
67
+ * ```ts
68
+ * type A = OddDigit; // ➔ "1" | "3" | "5" | "7" | "9"
69
+ * ```
70
+ */
71
+ type OddDigit="1"|"3"|"5"|"7"|"9";
72
+ /** -------------------------------------------------------
73
+ * * ***EvenDigit.***
74
+ * -------------------------------------------------------
75
+ *
76
+ * A union of string literal digits considered ***even***.
77
+ *
78
+ * - Includes: `"0" | "2" | "4" | "6" | "8"`.
79
+ *
80
+ * @example
81
+ *
82
+ * ```ts
83
+ * type A = EvenDigit; // ➔ "0" | "2" | "4" | "6" | "8"
84
+ * ```
85
+ */
86
+ type EvenDigit="0"|"2"|"4"|"6"|"8";
87
+ /** -------------------------------------------------------
88
+ * * ***Integer.***
89
+ * -------------------------------------------------------
90
+ *
91
+ * A type-level utility that validates if `T` is an ***integer***.
92
+ *
93
+ * - Returns `T` if it is an integer.
94
+ * - Returns `never` if `T` is a ***float*** (decimal).
95
+ *
96
+ * @template T - A number type to validate.
97
+ *
98
+ * @example
99
+ *
100
+ * ```ts
101
+ * type A = Integer<42>; // ➔ 42
102
+ * type B = Integer<-10>; // ➔ -10
103
+ * type C = Integer<3.14>; // ➔ never
104
+ * ```
105
+ */
106
+ type Integer<T extends number>=`${T}`extends`${string}.${string}`?never:T;
107
+ /** -------------------------------------------------------
108
+ * * ***Float.***
109
+ * -------------------------------------------------------
110
+ *
111
+ * A type-level utility that validates if `T` is a ***float***.
112
+ *
113
+ * - Returns `T` if it is a float.
114
+ * - Returns `never` if `T` is an ***integer***.
115
+ *
116
+ * @template T - A number type to validate.
117
+ *
118
+ * @example
119
+ *
120
+ * ```ts
121
+ * type A = Float<3.14>; // ➔ 3.14
122
+ * type B = Float<42>; // ➔ never
123
+ * ```
124
+ */
125
+ type Float<T extends number>=If<IsNever<Integer<T>>,T,never>;
126
+ /** -------------------------------------------------------
127
+ * * ***Negative.***
128
+ * -------------------------------------------------------
129
+ *
130
+ * Extracts `T` if it is ***negative***, otherwise `never`.
131
+ *
132
+ * @template T - A number type to check.
133
+ *
134
+ * @example
135
+ *
136
+ * ```ts
137
+ * type A = Negative<-10>; // ➔ -10
138
+ * type B = Negative<5>; // ➔ never
139
+ * type C = Negative<0>; // ➔ never
140
+ * ```
141
+ */
142
+ type Negative<T extends number>=`${T}`extends`-${string}`?T:never;
143
+ /** -------------------------------------------------------
144
+ * * ***Positive.***
145
+ * -------------------------------------------------------
146
+ *
147
+ * Extracts `T` if it is ***positive*** (or zero), otherwise `never`.
148
+ *
149
+ * @template T - A number type to check.
150
+ *
151
+ * @example
152
+ *
153
+ * ```ts
154
+ * type A = Positive<10>; // ➔ 10
155
+ * type B = Positive<0>; // ➔ 0
156
+ * type C = Positive<-5>; // ➔ never
157
+ * ```
158
+ */
159
+ type Positive<T extends number>=If<IsNever<Negative<T>>,T,never>;
160
+ /** -------------------------------------------------------
161
+ * * ***PositiveInteger.***
162
+ * -------------------------------------------------------
163
+ *
164
+ * Restricts `T` to ***positive integers*** only.
165
+ *
166
+ * @template T - A number type.
167
+ *
168
+ * @example
169
+ *
170
+ * ```ts
171
+ * type A = PositiveInteger<42>; // ➔ 42
172
+ * type B = PositiveInteger<0>; // ➔ 0
173
+ * type C = PositiveInteger<-5>; // ➔ never
174
+ * type D = PositiveInteger<3.14>; // ➔ never
175
+ * ```
176
+ */
177
+ type PositiveInteger<T extends number>=Positive<Integer<T>>;
178
+ /** -------------------------------------------------------
179
+ * * ***NegativeInteger.***
180
+ * -------------------------------------------------------
181
+ *
182
+ * Restricts `T` to ***negative integers*** only.
183
+ *
184
+ * @template T - A number type.
185
+ *
186
+ * @example
187
+ *
188
+ * ```ts
189
+ * type A = NegativeInteger<-42>; // ➔ -42
190
+ * type B = NegativeInteger<5>; // ➔ never
191
+ * type C = NegativeInteger<-3.14>; // ➔ never
192
+ * ```
193
+ */
194
+ type NegativeInteger<T extends number>=Negative<Integer<T>>;
195
+ /** -------------------------------------------------------
196
+ * * ***PositiveFloat.***
197
+ * -------------------------------------------------------
198
+ *
199
+ * Restricts `T` to ***positive floats*** only.
200
+ *
201
+ * @template T - A number type.
202
+ *
203
+ * @example
204
+ *
205
+ * ```ts
206
+ * type A = PositiveFloat<3.14>; // ➔ 3.14
207
+ * type B = PositiveFloat<-2.5>; // ➔ never
208
+ * type C = PositiveFloat<5>; // ➔ never
209
+ * ```
210
+ */
211
+ type PositiveFloat<T extends number>=Positive<Float<T>>;
212
+ /** -------------------------------------------------------
213
+ * * ***NegativeFloat.***
214
+ * -------------------------------------------------------
215
+ *
216
+ * Restricts `T` to ***negative floats*** only.
217
+ *
218
+ * @template T - A number type.
219
+ *
220
+ * @example
221
+ *
222
+ * ```ts
223
+ * type A = NegativeFloat<-3.14>; // ➔ -3.14
224
+ * type B = NegativeFloat<2.5>; // ➔ never
225
+ * type C = NegativeFloat<-5>; // ➔ never
226
+ * ```
227
+ */
228
+ type NegativeFloat<T extends number>=Negative<Float<T>>;
229
+ /** -------------------------------------------------------
230
+ * * ***Even.***
231
+ * -------------------------------------------------------
232
+ *
233
+ * A type-level utility that extracts `T` if it is an ***even integer***.
234
+ *
235
+ * @template T - A number type to check.
236
+ *
237
+ * @example
238
+ *
239
+ * ```ts
240
+ * type A = Even<0>; // ➔ 0
241
+ * type B = Even<4>; // ➔ 4
242
+ * type C = Even<5>; // ➔ never
243
+ * type D = Even<24>; // ➔ 24
244
+ * type E = Even<27>; // ➔ never
245
+ * type F = Even<3.14>; // ➔ never
246
+ * ```
247
+ */
248
+ type Even<T extends number>=IfNot<IsNever<Integer<T>>,`${T}`extends`${string}${EvenDigit}`?T:never,never>;
249
+ /** -------------------------------------------------------
250
+ * * ***Odd.***
251
+ * -------------------------------------------------------
252
+ *
253
+ * A type-level utility that extracts `T` if it is an ***odd integer***.
254
+ *
255
+ * @template T - A number type to check.
256
+ *
257
+ * @example
258
+ *
259
+ * ```ts
260
+ * type A = Odd<0>; // ➔ never
261
+ * type B = Odd<5>; // ➔ 5
262
+ * type C = Odd<4>; // ➔ never
263
+ * type D = Odd<23>; // ➔ 23
264
+ * type E = Odd<26>; // ➔ never
265
+ * type F = Odd<4.2>; // ➔ never
266
+ * ```
267
+ */
268
+ type Odd<T extends number>=IfNot<IsNever<Integer<T>>,If<IsNever<Even<T>>,T,never>,never>;
269
+ /** -------------------------------------------------------
270
+ * * ***IsInteger.***
271
+ * -------------------------------------------------------
272
+ *
273
+ * Whether `T` is an ***integer***.
274
+ *
275
+ * @example
276
+ *
277
+ * ```ts
278
+ * type A = IsInteger<-2>; // ➔ true
279
+ * type B = IsInteger<0>; // ➔ true
280
+ * type C = IsInteger<42>; // ➔ true
281
+ * type D = IsInteger<3.14>; // ➔ false
282
+ * ```
283
+ */
284
+ type IsInteger<T extends number>=Not<IsNever<Integer<T>>>;
285
+ /** -------------------------------------------------------
286
+ * * ***IsFloat.***
287
+ * -------------------------------------------------------
288
+ *
289
+ * Whether `T` is a ***float***.
290
+ *
291
+ * @example
292
+ *
293
+ * ```ts
294
+ * type A = IsFloat<3.14>; // ➔ true
295
+ * type B = IsFloat<-3.14>; // ➔ true
296
+ * type C = IsFloat<0>; // ➔ false
297
+ * type D = IsFloat<42>; // ➔ false
298
+ * type E = IsFloat<-42>; // ➔ false
299
+ * ```
300
+ */
301
+ type IsFloat<T extends number>=Not<IsNever<Float<T>>>;
302
+ /** -------------------------------------------------------
303
+ * * ***IsEven.***
304
+ * -------------------------------------------------------
305
+ *
306
+ * Whether `T` is ***even***.
307
+ *
308
+ * @example
309
+ *
310
+ * ```ts
311
+ * type A = IsEven<0>; // ➔ true
312
+ * type B = IsEven<4>; // ➔ true
313
+ * type C = IsEven<5>; // ➔ false
314
+ * type D = IsEven<24>; // ➔ true
315
+ * type E = IsEven<27>; // ➔ false
316
+ * type F = IsEven<3.14>; // ➔ false
317
+ * ```
318
+ */
319
+ type IsEven<T extends number>=If<IsInteger<T>,`${T}`extends`${string}${EvenDigit}`?true:false>;
320
+ /** -------------------------------------------------------
321
+ * * ***IsOdd.***
322
+ * -------------------------------------------------------
323
+ *
324
+ * Whether `T` is ***odd***.
325
+ *
326
+ * @example
327
+ *
328
+ * ```ts
329
+ * type A = IsEven<0>; // ➔ false
330
+ * type B = IsEven<4>; // ➔ false
331
+ * type C = IsEven<5>; // ➔ true
332
+ * type D = IsEven<24>; // ➔ false
333
+ * type E = IsEven<27>; // ➔ true
334
+ * type F = IsEven<3.14>; // ➔ true
335
+ * ```
336
+ */
337
+ type IsOdd<T extends number>=If<IsInteger<T>,Not<IsEven<T>>>;
338
+ /** -------------------------------------------------------
339
+ * * ***IsPositive.***
340
+ * -------------------------------------------------------
341
+ *
342
+ * Whether `T` is ***positive***.
343
+ *
344
+ * @example
345
+ *
346
+ * ```ts
347
+ * type A = IsPositive<10>; // ➔ true
348
+ * type B = IsPositive<0>; // ➔ true
349
+ * type C = IsPositive<-5>; // ➔ false
350
+ * type D = IsPositive<3.5>; // ➔ true
351
+ * type E = IsPositive<-3.5>; // ➔ false
352
+ * ```
353
+ */
354
+ type IsPositive<T extends number>=Not<IsNever<Positive<T>>>;
355
+ /** -------------------------------------------------------
356
+ * * ***IsNegative.***
357
+ * -------------------------------------------------------
358
+ *
359
+ * Whether `T` is ***negative***.
360
+ *
361
+ * @example
362
+ *
363
+ * ```ts
364
+ * type A = IsNegative<-10>; // ➔ true
365
+ * type B = IsNegative<5>; // ➔ false
366
+ * type C = IsNegative<0>; // ➔ false
367
+ * type D = IsPositive<3.5>; // ➔ false
368
+ * type E = IsPositive<-3.5>; // ➔ true
369
+ * ```
370
+ */
371
+ type IsNegative<T extends number>=Not<IsNever<Negative<T>>>;
372
+ /** -------------------------------------------------------
373
+ * * ***IsPositiveInteger.***
374
+ * -------------------------------------------------------
375
+ *
376
+ * Whether `T` is a ***positive integer***.
377
+ *
378
+ * @example
379
+ *
380
+ * ```ts
381
+ * type A = IsPositiveInteger<42>; // ➔ true
382
+ * type B = IsPositiveInteger<0>; // ➔ true
383
+ * type C = IsPositiveInteger<-5>; // ➔ false
384
+ * type D = IsPositiveInteger<3.14>; // ➔ false
385
+ * ```
386
+ */
387
+ type IsPositiveInteger<T extends number>=Not<IsNever<PositiveInteger<T>>>;
388
+ /** -------------------------------------------------------
389
+ * * ***IsNegativeInteger.***
390
+ * -------------------------------------------------------
391
+ *
392
+ * Whether `T` is a ***negative integer***.
393
+ *
394
+ * @example
395
+ *
396
+ * ```ts
397
+ * type A = IsNegativeInteger<-42>; // ➔ true
398
+ * type B = IsNegativeInteger<5>; // ➔ false
399
+ * type C = IsNegativeInteger<-3.14>; // ➔ false
400
+ * ```
401
+ */
402
+ type IsNegativeInteger<T extends number>=Not<IsNever<NegativeInteger<T>>>;
403
+ /** -------------------------------------------------------
404
+ * * ***IsPositiveFloat.***
405
+ * -------------------------------------------------------
406
+ *
407
+ * Whether `T` is a ***positive float***.
408
+ *
409
+ * @example
410
+ *
411
+ * ```ts
412
+ * type A = IsPositiveFloat<3.14>; // ➔ true
413
+ * type B = IsPositiveFloat<-2.5>; // ➔ false
414
+ * type C = IsPositiveFloat<5>; // ➔ false
415
+ * ```
416
+ */
417
+ type IsPositiveFloat<T extends number>=Not<IsNever<PositiveFloat<T>>>;
418
+ /** -------------------------------------------------------
419
+ * * ***IsNegativeFloat.***
420
+ * -------------------------------------------------------
421
+ *
422
+ * Whether `T` is a ***negative float***.
423
+ *
424
+ * @example
425
+ *
426
+ * ```ts
427
+ * type A = IsNegativeFloat<-3.14>; // ➔ true
428
+ * type B = IsNegativeFloat<2.5>; // ➔ false
429
+ * type C = IsNegativeFloat<-5>; // ➔ false
430
+ * ```
431
+ */
432
+ type IsNegativeFloat<T extends number>=Not<IsNever<NegativeFloat<T>>>;
433
+ /** -------------------------------------------------------
434
+ * * ***IfInteger.***
435
+ * -------------------------------------------------------
436
+ *
437
+ * Conditional: `If` branch if `T` is an ***integer***.
438
+ *
439
+ * @example
440
+ *
441
+ * ```ts
442
+ * type A = IfInteger<42>; // ➔ true
443
+ * type B = IfInteger<3.14>; // ➔ false
444
+ * type C = IfInteger<42, "yes", "no">; // ➔ "yes"
445
+ * type D = IfInteger<3.14, "yes", "no">; // ➔ "no"
446
+ * ```
447
+ */
448
+ type IfInteger<T extends number,IfTrue=true,IfFalse=false>=If<IsInteger<T>,IfTrue,IfFalse>;
449
+ /** -------------------------------------------------------
450
+ * * ***IfFloat.***
451
+ * -------------------------------------------------------
452
+ *
453
+ * Conditional: selects one of two branches depending on whether `T` is a ***float***.
454
+ *
455
+ * - Defaults: `IfTrue = true`, `IfFalse = false`.
456
+ *
457
+ * @template T - A number type.
458
+ * @template IfTrue - The branch type if condition is met. (default: `true`)
459
+ * @template IfFalse - The branch type if condition is not met. (default: `false`)
460
+ *
461
+ * @example
462
+ *
463
+ * ```ts
464
+ * type A = IfFloat<3.14>; // ➔ true
465
+ * type B = IfFloat<42>; // ➔ false
466
+ * type C = IfFloat<3.14, "yes", "no">; // ➔ "yes"
467
+ * type D = IfFloat<42, "yes", "no">; // ➔ "no"
468
+ * ```
469
+ */
470
+ type IfFloat<T extends number,IfTrue=true,IfFalse=false>=If<IsFloat<T>,IfTrue,IfFalse>;
471
+ /** -------------------------------------------------------
472
+ * * ***IfEven.***
473
+ * -------------------------------------------------------
474
+ *
475
+ * Conditional: selects one of two branches depending on whether `T` is ***even***.
476
+ *
477
+ * - Defaults: `IfTrue = true`, `IfFalse = false`.
478
+ *
479
+ * @template T - A number type.
480
+ * @template IfTrue - The branch type if condition is met. (default: `true`)
481
+ * @template IfFalse - The branch type if condition is not met. (default: `false`)
482
+ *
483
+ * @example
484
+ *
485
+ * ```ts
486
+ * type A = IfEven<4>; // ➔ true
487
+ * type B = IfEven<5>; // ➔ false
488
+ * type C = IfEven<4, "even", "odd">; // ➔ "even"
489
+ * type D = IfEven<5, "even", "odd">; // ➔ "odd"
490
+ * ```
491
+ */
492
+ type IfEven<T extends number,IfTrue=true,IfFalse=false>=If<IsEven<T>,IfTrue,IfFalse>;
493
+ /** -------------------------------------------------------
494
+ * * ***IfOdd.***
495
+ * -------------------------------------------------------
496
+ *
497
+ * Conditional: selects one of two branches depending on whether `T` is ***odd***.
498
+ *
499
+ * - Defaults: `IfTrue = true`, `IfFalse = false`.
500
+ *
501
+ * @template T - A number type.
502
+ * @template IfTrue - The branch type if condition is met. (default: `true`)
503
+ * @template IfFalse - The branch type if condition is not met. (default: `false`)
504
+ *
505
+ * @example
506
+ *
507
+ * ```ts
508
+ * type A = IfOdd<5>; // ➔ true
509
+ * type B = IfOdd<4>; // ➔ false
510
+ * type C = IfOdd<5, "odd", "even">; // ➔ "odd"
511
+ * type D = IfOdd<4, "odd", "even">; // ➔ "even"
512
+ * ```
513
+ */
514
+ type IfOdd<T extends number,IfTrue=true,IfFalse=false>=If<IsOdd<T>,IfTrue,IfFalse>;
515
+ /** -------------------------------------------------------
516
+ * * ***IfPositive.***
517
+ * -------------------------------------------------------
518
+ *
519
+ * Conditional: selects one of two branches depending on whether `T` is ***positive***.
520
+ *
521
+ * - Defaults: `IfTrue = true`, `IfFalse = false`.
522
+ *
523
+ * @template T - A number type.
524
+ * @template IfTrue - The branch type if condition is met. (default: `true`)
525
+ * @template IfFalse - The branch type if condition is not met. (default: `false`)
526
+ *
527
+ * @example
528
+ *
529
+ * ```ts
530
+ * type A = IfPositive<10>; // ➔ true
531
+ * type B = IfPositive<-5>; // ➔ false
532
+ * type C = IfPositive<10, "yes", "no">; // ➔ "yes"
533
+ * type D = IfPositive<-5, "yes", "no">; // ➔ "no"
534
+ * ```
535
+ */
536
+ type IfPositive<T extends number,IfTrue=true,IfFalse=false>=If<IsPositive<T>,IfTrue,IfFalse>;
537
+ /** -------------------------------------------------------
538
+ * * ***IfNegative.***
539
+ * -------------------------------------------------------
540
+ *
541
+ * Conditional: selects one of two branches depending on whether `T` is ***negative***.
542
+ *
543
+ * - Defaults: `IfTrue = true`, `IfFalse = false`.
544
+ *
545
+ * @template T - A number type.
546
+ * @template IfTrue - The branch type if condition is met. (default: `true`)
547
+ * @template IfFalse - The branch type if condition is not met. (default: `false`)
548
+ *
549
+ * @example
550
+ *
551
+ * ```ts
552
+ * type A = IfNegative<-10>; // ➔ true
553
+ * type B = IfNegative<5>; // ➔ false
554
+ * type C = IfNegative<-10, "yes", "no">; // ➔ "yes"
555
+ * type D = IfNegative<5, "yes", "no">; // ➔ "no"
556
+ * ```
557
+ */
558
+ type IfNegative<T extends number,IfTrue=true,IfFalse=false>=If<IsNegative<T>,IfTrue,IfFalse>;
559
+ /** -------------------------------------------------------
560
+ * * ***IfPositiveInteger.***
561
+ * -------------------------------------------------------
562
+ *
563
+ * Conditional: selects one of two branches depending on whether `T` is a ***positive integer***.
564
+ *
565
+ * - Defaults: `IfTrue = true`, `IfFalse = false`.
566
+ *
567
+ * @template T - A number type.
568
+ * @template IfTrue - The branch type if condition is met. (default: `true`)
569
+ * @template IfFalse - The branch type if condition is not met. (default: `false`)
570
+ *
571
+ * @example
572
+ *
573
+ * ```ts
574
+ * type A = IfPositiveInteger<42>; // ➔ true
575
+ * type B = IfPositiveInteger<-5>; // ➔ false
576
+ * type C = IfPositiveInteger<42, "yes", "no">; // ➔ "yes"
577
+ * type D = IfPositiveInteger<-5, "yes", "no">; // ➔ "no"
578
+ * ```
579
+ */
580
+ type IfPositiveInteger<T extends number,IfTrue=true,IfFalse=false>=If<IsPositiveInteger<T>,IfTrue,IfFalse>;
581
+ /** -------------------------------------------------------
582
+ * * ***IfNegativeInteger.***
583
+ * -------------------------------------------------------
584
+ *
585
+ * Conditional: selects one of two branches depending on whether `T` is a ***negative integer***.
586
+ *
587
+ * - Defaults: `IfTrue = true`, `IfFalse = false`.
588
+ *
589
+ * @template T - A number type.
590
+ * @template IfTrue - The branch type if condition is met. (default: `true`)
591
+ * @template IfFalse - The branch type if condition is not met. (default: `false`)
592
+ *
593
+ * @example
594
+ *
595
+ * ```ts
596
+ * type A = IfNegativeInteger<-42>; // ➔ true
597
+ * type B = IfNegativeInteger<5>; // ➔ false
598
+ * type C = IfNegativeInteger<-42, "yes", "no">; // ➔ "yes"
599
+ * type D = IfNegativeInteger<5, "yes", "no">; // ➔ "no"
600
+ * ```
601
+ */
602
+ type IfNegativeInteger<T extends number,IfTrue=true,IfFalse=false>=If<IsNegativeInteger<T>,IfTrue,IfFalse>;
603
+ /** -------------------------------------------------------
604
+ * * ***IfPositiveFloat.***
605
+ * -------------------------------------------------------
606
+ *
607
+ * Conditional: selects one of two branches depending on whether `T` is a ***positive float***.
608
+ *
609
+ * - Defaults: `IfTrue = true`, `IfFalse = false`.
610
+ *
611
+ * @template T - A number type.
612
+ * @template IfTrue - The branch type if condition is met. (default: `true`)
613
+ * @template IfFalse - The branch type if condition is not met. (default: `false`)
614
+ *
615
+ * @example
616
+ *
617
+ * ```ts
618
+ * type A = IfPositiveFloat<3.14>; // ➔ true
619
+ * type B = IfPositiveFloat<-2.5>; // ➔ false
620
+ * type C = IfPositiveFloat<3.14, "yes", "no">; // ➔ "yes"
621
+ * type D = IfPositiveFloat<-2.5, "yes", "no">; // ➔ "no"
622
+ * ```
623
+ */
624
+ type IfPositiveFloat<T extends number,IfTrue=true,IfFalse=false>=If<IsPositiveFloat<T>,IfTrue,IfFalse>;
625
+ /** -------------------------------------------------------
626
+ * * ***IfNegativeFloat.***
627
+ * -------------------------------------------------------
628
+ * Conditional: selects one of two branches depending on whether `T` is a ***negative float***.
629
+ * - Defaults: `IfTrue = true`, `IfFalse = false`.
630
+ *
631
+ * @template T - A number type.
632
+ * @template IfTrue - The branch type if condition is met. (default: `true`)
633
+ * @template IfFalse - The branch type if condition is not met. (default: `false`)
634
+ * @example
635
+ * ```ts
636
+ * type A = IfNegativeFloat<-3.14>; // ➔ true
637
+ * type B = IfNegativeFloat<2.5>; // ➔ false
638
+ * type C = IfNegativeFloat<-3.14, "yes", "no">; // ➔ "yes"
639
+ * type D = IfNegativeFloat<2.5, "yes", "no">; // ➔ "no"
640
+ * ```
641
+ */
642
+ type IfNegativeFloat<T extends number,IfTrue=true,IfFalse=false>=If<IsNegativeFloat<T>,IfTrue,IfFalse>;
643
+ /** -------------------------------------------------------
644
+ * * ***ParseNumber.***
645
+ * --------------------------------------------------------
646
+ * Converts a string or property key literal into a ***number literal***.
647
+ * - Supports decimal numbers only.
648
+ * - Automatically trims whitespace.
649
+ * - Returns the number literal if valid.
650
+ * - Supports scientific notation strings (e.g., `"2e-3"`, `"-5e2"`, `"2E-3"`, `"-5E2"`).
651
+ * - **Note:** TypeScript cannot represent very small (<1e-6) or very large (>1e15)
652
+ * numbers as literal types. In such cases, scientific notation strings return `0`.
653
+ * - Returns `0` for strings representing hexadecimal (`0x...`), octal (`0o...`), or binary (`0b...`) if they are string literals.
654
+ * - Returns `never` for non-numeric strings or unsupported formats.
655
+ *
656
+ * @template T - A string, number, or symbol (property key).
657
+ * @example
658
+ * ```ts
659
+ * // Number:
660
+ * type A = ParseNumber<0>; // ➔ 0
661
+ * type B = ParseNumber<-0>; // ➔ 0
662
+ * type C = ParseNumber<-0.>; // ➔ 0
663
+ * type D = ParseNumber<42>; // ➔ 42
664
+ * type E = ParseNumber<0.42>; // ➔ 0.42
665
+ * type F = ParseNumber<-5>; // ➔ -5
666
+ * type G = ParseNumber<-2.5>; // ➔ -2.5
667
+ * type H = ParseNumber<2.5e3>; // ➔ 2500
668
+ * type I = ParseNumber<-2.5e3>;// ➔ -2500
669
+ * type J = ParseNumber<5e3>; // ➔ 5000
670
+ * type K = ParseNumber<-5e3>; // ➔ -5000
671
+ * type L = ParseNumber<5e21>; // ➔ 5e+21
672
+ * type M = ParseNumber<5e-3>; // ➔ 0.005
673
+ * type N = ParseNumber<5e-21>; // ➔ 5e-21
674
+ * type O = ParseNumber<-5e-3>; // ➔ -0.005
675
+ *
676
+ * // Numeric String:
677
+ * type A = ParseNumber<"0">; // ➔ 0
678
+ * type B = ParseNumber<"-0">; // ➔ 0
679
+ * type C = ParseNumber<"42">; // ➔ 42
680
+ * type D = ParseNumber<"0.42">; // ➔ 0.42
681
+ * type E = ParseNumber<"-42">; // ➔ -42
682
+ * type F = ParseNumber<"-0.42">; // ➔ -0.42
683
+ * type G = ParseNumber<" 42 ">; // ➔ 42
684
+ * type H = ParseNumber<" -42 ">; // ➔ -1
685
+ *
686
+ * // Scientific notation string:
687
+ * type S1 = ParseNumber<"2e3">; // ➔ 2000
688
+ * type S2 = ParseNumber<"-2e3">; // ➔ -2000
689
+ * type S3 = ParseNumber<"2e-3">; // ➔ 0.002
690
+ * type S4 = ParseNumber<"-2e-3">; // ➔ -0.002
691
+ * type S5 = ParseNumber<"2.5e3">; // ➔ 0
692
+ * type S6 = ParseNumber<"2.5e-3">; // ➔ 0
693
+ * type S7 = ParseNumber<"2e-7">; // ➔ 0 (too small include "-2e-7" for TypeScript literal)
694
+ * type S8 = ParseNumber<"5e21">; // ➔ 0 (too large include "-5e21" for TypeScript literal)
695
+ *
696
+ * // Number representing hexadecimal, octal or binary:
697
+ * type A = ParseNumber<"011">; // ➔ 9 (same as octal but deprecated)
698
+ * type B = ParseNumber<"0o11">; // ➔ 9 (octal)
699
+ * type C = ParseNumber<"-0o11">; // ➔ -9 (octal)
700
+ * type D = ParseNumber<"0x12">; // ➔ 18 (hexadecimal)
701
+ * type E = ParseNumber<"-0x12">; // ➔ -18 (hexadecimal)
702
+ * type F = ParseNumber<"0b111">; // ➔ 7 (binary)
703
+ * type G = ParseNumber<"-0b111">; // ➔ -7 (binary)
704
+ *
705
+ * // String representing hexadecimal, octal or binary:
706
+ * type A = ParseNumber<"0x2A">; // ➔ 0 (hex on string not supported)
707
+ * type B = ParseNumber<"0o52">; // ➔ 0 (octal on string not supported)
708
+ * type C = ParseNumber<"0b101010">; // ➔ 0 (binary on string not supported)
709
+ *
710
+ * // Never Result
711
+ * type A = ParseNumber<string>; // ➔ never
712
+ * type B = ParseNumber<number>; // ➔ never
713
+ * type C = ParseNumber<"abc">; // ➔ never
714
+ * type D = ParseNumber<"a1">; // ➔ never
715
+ * type E = ParseNumber<"3b">; // ➔ never
716
+ * ```
717
+ */
718
+ type ParseNumber<T extends PropertyKey|bigint>=T extends bigint?T:If<number extends T?false:true,IfExtends<OrArr<[ Extends<`-0`,Trim<Extract<T,PropertyKey>>>,Extends<-0,T>,Extends<T,`${"-" | ""}${"0"}.`>]>,true,0,T extends`${"-" | ""}0${"x" | "b" | "o"}${number}`?0:Trim<Extract<T,PropertyKey>>extends`${infer NumT extends number | string}`?T extends`${infer N extends number}.`?N:NumT extends string?ParseScientificNumber<NumT>:NumT:Trim<Extract<T,PropertyKey>>extends number?T:never>,never>;
719
+ /** -------------------------------------------------------
720
+ * * ***IsScientificNumber.***
721
+ * -------------------------------------------------------
722
+ *
723
+ * Checks if a string literal `T` represents a **scientific number**.
724
+ *
725
+ * A scientific number is defined as a number in the form of:
726
+ * - Optional negative sign (`-`)
727
+ * - Mantissa (digits, can be integer or decimal)
728
+ * - Exponent indicated by `e` or `E`
729
+ * - Exponent value (digits, optional negative sign)
730
+ *
731
+ * **Important:** TypeScript cannot detect numeric literals in scientific notation
732
+ * at type-level because number literals are normalized to decimals.
733
+ * Only string literals like `"2.5E3"` or `"-1e-5"` can be detected.
734
+ *
735
+ * @template T - A string literal to check.
736
+ *
737
+ * @example
738
+ * ```ts
739
+ * type A = IsScientificNumber<"1e5">; // true
740
+ * type B = IsScientificNumber<"-1e-5">; // true
741
+ * type C = IsScientificNumber<"2.5E3">; // true
742
+ * type D = IsScientificNumber<"42">; // false
743
+ * type E = IsScientificNumber<"-0.42">; // false
744
+ * type F = IsScientificNumber<string>; // false
745
+ * ```
746
+ *
747
+ * @remarks
748
+ * - Uses template literal types and conditional type {@link Extends}.
749
+ * - Returns `true` if `T` is scientific number string literal, otherwise `false`.
750
+ * - Returns `boolean` if `T` is generic `string`.
751
+ */
752
+ type IsScientificNumber<T extends string>=Extends<T,`${"-" | ""}${number}${"e" | "E"}${number}`>;
753
+ /**
754
+ * Helper for {@link ParseScientificNumber}
755
+ */
756
+ type BuildTuple<L extends number,T extends unknown[]=[]>=T["length"] extends L?T:BuildTuple<L,[...T,unknown]>;
757
+ /**
758
+ * Helper for {@link ParseScientificNumber}
759
+ */
760
+ type _DecrementParseScientific<N extends number>=BuildTuple<N>extends [ infer _,...infer Rest]?Rest["length"]:never;
761
+ /** -------------------------------------------------------
762
+ * * ***ParseScientificNumber***
763
+ * -------------------------------------------------------
764
+ *
765
+ * Converts a numeric string in scientific notation (e.g., `"2e-3"`, `"-5e2"`)
766
+ * into a literal number type.
767
+ *
768
+ * **Important:** TypeScript cannot represent very small or very large numbers
769
+ * as literal types. In such cases, this utility will return `0`.
770
+ *
771
+ * @template T - A numeric string to parse. Can be in:
772
+ * - Positive or negative scientific notation (e.g., `"1e3"`, `"-2e-2"`)
773
+ * - Regular number literal (e.g., `"42"`, `"-5"`)
774
+ *
775
+ * @example
776
+ * ```ts
777
+ * type A1 = ParseScientificNumber<"2e-3">; // 0.002
778
+ * type A2 = ParseScientificNumber<"-2e-3">; // -0.002
779
+ * type A3 = ParseScientificNumber<"5e2">; // 500
780
+ * type A4 = ParseScientificNumber<"-5e2">; // -500
781
+ * type A5 = ParseScientificNumber<"2e-7">; // 0 (TypeScript cannot represent literal)
782
+ * type A6 = ParseScientificNumber<"5e21">; // 0 (TypeScript cannot represent literal)
783
+ * type A7 = ParseScientificNumber<"42">; // 42
784
+ * type A8 = ParseScientificNumber<"-42">; // -42
785
+ * ```
786
+ *
787
+ * @remarks
788
+ * - Uses type-level string manipulation to handle scientific notation.
789
+ * - Negative exponents are adjusted with {@link _DecrementParseScientific} and {@link Repeat}.
790
+ * - Returns `0` if TypeScript cannot infer the exact numeric literal.
791
+ */
792
+ type ParseScientificNumber<T extends string>=T extends`-${infer Mantissa}${"e" | "E"}-${infer Exp extends number}`?`-${"0."}${Repeat<"0", _DecrementParseScientific<Exp>>}${Mantissa}`extends`${infer N extends number}`?number extends N?0:N:never:T extends`${infer Mantissa}${"e" | "E"}-${infer Exp extends number}`?`0.${Repeat<"0", _DecrementParseScientific<Exp>>}${Mantissa}`extends`${infer N extends number}`?number extends N?0:N:never:T extends`-${infer Mantissa}${"e" | "E"}${infer Exp extends number}`?`-${Mantissa}${Repeat<"0", Exp>}`extends`${infer N extends number}`?number extends N?0:N:never:T extends`${infer Mantissa}${"e" | "E"}${infer Exp extends number}`?`${Mantissa}${Repeat<"0", Exp>}`extends`${infer N extends number}`?number extends N?0:N:never:T extends`${infer N extends number}`?number extends N?0:N:never;
793
+ /** -------------------------------------------------------
794
+ * * ***Abs.***
795
+ * -------------------------------------------------------
796
+ *
797
+ * Computes the ***absolute value*** of `T`.
798
+ *
799
+ * - Accepts `number` literals or numeric `string` literals.
800
+ * - Returns the ***absolute value*** as a `number`.
801
+ * - If `T` is not a valid number (e.g., hex, binary, octal, or non-numeric string), the result is `never`.
802
+ *
803
+ * @template T - A number type or string literal representing a number.
804
+ *
805
+ * @example
806
+ *
807
+ * ```ts
808
+ * type A = Abs<-42>; // ➔ 42
809
+ * type B = Abs<10>; // ➔ 10
810
+ * type C = Abs<"11">; // ➔ 11
811
+ * type D = Abs<"-11">; // ➔ 11
812
+ *
813
+ * // Not a number
814
+ * type Invalid1 = Abs<"1a">; // ➔ never
815
+ * type Invalid2 = Abs<"a1">; // ➔ never
816
+ * type Invalid3 = Abs<"a1a">; // ➔ never
817
+ * type Invalid4 = Abs<"abc">; // ➔ never
818
+ * type Invalid5 = Abs<string>; // ➔ never
819
+ * type Invalid6 = Abs<number>; // ➔ never
820
+ * ```
821
+ */
822
+ type Abs<T extends PropertyKey|bigint>=`${Exclude<T, symbol>}`extends`-${infer PositiveT extends number}`?ParseNumber<PositiveT>:ParseNumber<T>;
823
+ /** -------------------------------------------------------
824
+ * * ***Negate.***
825
+ * -------------------------------------------------------
826
+ *
827
+ * Produces the ***negated value*** of `T` (multiplies by `-1`).
828
+ *
829
+ * - Only supports valid **number literals** or **numeric-strings**.
830
+ * - Invalid numeric-strings (e.g. `"1a"`, `"abc"`, hex, binary, octal)
831
+ * or non-numeric types (e.g. `string`, `number`, `symbol`) will return `0`.
832
+ *
833
+ * @template T - A number type or numeric-string.
834
+ *
835
+ * @example
836
+ *
837
+ * ```ts
838
+ * type A = Negate<5>; // ➔ -5
839
+ * type B = Negate<-10>; // ➔ -10
840
+ * type C = Negate<0>; // ➔ 0
841
+ * type D = Negate<-0>; // ➔ 0
842
+ * type E = Negate<"123">; // ➔ -123
843
+ *
844
+ * // Not a number or numeric-string:
845
+ * type Invalid1 = Negate<string>; // ➔ 0
846
+ * type Invalid2 = Negate<number>; // ➔ 0
847
+ * type Invalid3 = Negate<"abc">; // ➔ 0
848
+ * type Invalid4 = Negate<"1a">; // ➔ 0
849
+ * type Invalid5 = Negate<"2b">; // ➔ 0
850
+ * type Invalid6 = Negate<"0x1f">; // ➔ 0
851
+ * type Invalid7 = Negate<"0b101">; // ➔ 0
852
+ * type Invalid8 = Negate<"0o77">; // ➔ 0
853
+ * ```
854
+ */
855
+ type Negate<T extends PropertyKey>=ParseNumber<`-${Abs<ParseNumber<T>>}`>;
856
+ /** -------------------------------------------------------
857
+ * * ***Split***
858
+ * -------------------------------------------------------
859
+ *
860
+ * A type-level utility that mimics `String.prototype.split()`.
861
+ * Splits a string literal `Str` into a tuple of substrings,
862
+ * using `Del` as the delimiter.
863
+ *
864
+ * - If `Del` is the empty string `""`, the result is a tuple of characters.
865
+ * - If `Del` is not found in `Str`, the result is a tuple with the original string.
866
+ * - Works only with string literals. If `Str` is just `string`, the result is `string[]`.
867
+ *
868
+ * @template Str - The input string literal to be split.
869
+ * @template Del - The delimiter used to split the string.
870
+ * Defaults to `""` (character-level split).
871
+ *
872
+ * #### Constraints
873
+ * - `Str` must be a string literal to get precise results.
874
+ * - `Del` can be a string or number (numbers are converted to strings).
875
+ *
876
+ * #### Examples
877
+ * ```ts
878
+ * // ✅ Split into characters
879
+ * type A = Split<"abc">; // ["a", "b", "c"]
880
+ *
881
+ * // ✅ Split by a comma
882
+ * type B = Split<"a,b,c", ",">; // ["a", "b", "c"]
883
+ *
884
+ * // ✅ Split by multi-char delimiter
885
+ * type C = Split<"2025-08-22", "-">; // ["2025", "08", "22"]
886
+ *
887
+ * // ✅ Delimiter not found → returns whole string
888
+ * type D = Split<"hello", "|">; // ["hello"]
889
+ *
890
+ * // ⚠️ Non-literal string
891
+ * type E = Split<string, ",">; // string[]
892
+ * ```
893
+ */
894
+ type Split<Str extends string,Del extends string|number="">=string extends Str?string[]:""extends Str?[]:Str extends`${infer T}${Del}${infer U}`?[T,...Split<U,Del>]:[Str];type _CharAt<I extends string,N extends number|`${number}`,_S extends string[]=Split<I,"">>=IfExtends<And<Extends<IsPositive<ParseNumber<N>>,true>,Extends<And<Extends<N,keyof _S>,Extends<IsStringLiteral<I>,true>>,true>>,true,_S[Extract<N,keyof _S>],undefined>;
895
+ /** -------------------------------------------------------
896
+ * * ***CharAt.***
897
+ * -------------------------------------------------------
898
+ * A type-level utility that extracts the character at a given index `N`
899
+ * from a string literal type `I`.
900
+ * - If the index is out of range, the result is `undefined`.
901
+ * - If `I` is not a literal string (just `string`), the result is `undefined`.
902
+ * - Only **positive indices** are supported (`0` and above`).
903
+ *
904
+ * @template I - The input string literal to extract the character from.
905
+ * @template N - The zero-based index of the character to retrieve.
906
+ * Can be a `number` or a stringified number (e.g. `2` or "2").
907
+ * @example
908
+ * ```ts
909
+ * // ✅ Basic usage
910
+ * type A = CharAt<"hello", 0>; // ➔ "h"
911
+ * type B = CharAt<"hello", 1>; // ➔ "e"
912
+ * type C = CharAt<"hello", 4>; // ➔ "o"
913
+ *
914
+ * // ✅ Index out of range → undefined
915
+ * type D = CharAt<"hello", 5>; // ➔ undefined
916
+ * type E = CharAt<"abc", 99>; // ➔ undefined
917
+ *
918
+ * // ✅ Stringified index also works
919
+ * type F = CharAt<"testing", "0">; // ➔ "t"
920
+ * type G = CharAt<"testing", "2">; // ➔ "s"
921
+ * type H = CharAt<"testing", "6">; // ➔ "g"
922
+ * type I = CharAt<"testing", "7">; // ➔ undefined
923
+ *
924
+ * // ⚠️ Non-literal strings → undefined
925
+ * type J = CharAt<string, 2>; // ➔ undefined
926
+ *
927
+ * // ⚠️ Negative indices are not supported
928
+ * type K = CharAt<"abc", -1>; // ➔ undefined
929
+ * ```
930
+ */
931
+ type CharAt<I extends string,N extends number|`${number}`>=_CharAt<I,N>;
932
+ /** -------------------------------------------------------
933
+ * * ***IsUnknown.***
934
+ * -------------------------------------------------------
935
+ * Returns a boolean indicating whether the given type `T` is `unknown`.
936
+ *
937
+ * @template T - The type to check.
938
+ *
939
+ * @example
940
+ * ```ts
941
+ * type TrueResult = IsUnknown<unknown>; // ➔ true
942
+ * type FalseResult1 = IsUnknown<any>; // ➔ false
943
+ * type FalseResult2 = IsUnknown<string>; // ➔ false
944
+ * ```
945
+ */
946
+ type IsUnknown<T>=IsAny<T>extends true?false:[unknown] extends [T]?true:false;
947
+ /** -------------------------------------------------------
948
+ * * ***IfUnknown.***
949
+ * -------------------------------------------------------
950
+ * Conditional type: returns `IfTrue` if `T` is `unknown`, otherwise returns `IfFalse`.
951
+ *
952
+ * @template T - The type to check.
953
+ * @template IfTrue - The type returned if `T` is `unknown` (default: `true`).
954
+ * @template IfFalse - The type returned if `T` is not `unknown` (default: `false`).
955
+ *
956
+ * @example
957
+ * ```ts
958
+ * type Result1 = IfUnknown<unknown, "foo", "bar">; // ➔ "foo"
959
+ * type Result2 = IfUnknown<string, "foo", "bar">; // ➔ "bar"
960
+ * ```
961
+ */
962
+ type IfUnknown<T,IfTrue=true,IfFalse=false>=If<IsUnknown<T>,IfTrue,IfFalse>;
963
+ /** -------------------------------------------------------
964
+ * * ***UnknownifyPropertiesOptions.***
965
+ * -------------------------------------------------------
966
+ * Options for `UnknownifyProperties`.
967
+ *
968
+ * @property makeOptional - If `true`, all properties become optional.
969
+ */
970
+ type UnknownifyPropertiesOptions={
971
+ /**
972
+ * If `true`, all properties of the object become optional.
973
+ *
974
+ * DefaultValue: `false`.
975
+ *
976
+ * @default false
977
+ * @example
978
+ * ```ts
979
+ * type A = { a: string; b: number };
980
+ *
981
+ * type B = UnknownifyProperties<A, { makeOptional: true }>;
982
+ * // ➔ { a?: unknown; b?: unknown }
983
+ * ```
984
+ */
985
+ makeOptional:boolean;};
986
+ /** -------------------------------------------------------
987
+ * * ***UnknownifyProperties.***
988
+ * -------------------------------------------------------
989
+ * Transforms all properties of an object type `T` to `unknown`.
990
+ * Optionally, makes all properties optional based on `Options`.
991
+ *
992
+ * @template T - The object type to transform.
993
+ * @template Options - Configuration options (default: `{ makeOptional: false }`).
994
+ *
995
+ * @example
996
+ * ```ts
997
+ * type A = { a: string; b: number };
998
+ *
999
+ * type Result1 = UnknownifyProperties<A>;
1000
+ * // ➔ { a: unknown; b: unknown }
1001
+ *
1002
+ * type Result2 = UnknownifyProperties<A, { makeOptional: true }>;
1003
+ * // ➔ { a?: unknown; b?: unknown }
1004
+ * ```
1005
+ */
1006
+ type UnknownifyProperties<T extends object,Options extends UnknownifyPropertiesOptions={makeOptional:false;}>={[K in keyof T]:unknown;}extends infer Result?If<Options["makeOptional"],Partial<Result>,Result>:never;
1007
+ /** -------------------------------------------------------
1008
+ * * ***MutableOptions***
1009
+ * -------------------------------------------------------
1010
+ *
1011
+ * Configuration options for the ***{@link Mutable}*** type utilities.
1012
+ *
1013
+ * @property recursive - Whether to make nested objects mutable recursively.
1014
+ * - If `true`, all nested objects will also have their `readonly` removed.
1015
+ * - Default: `false`.
1016
+ *
1017
+ * @example
1018
+ * ```ts
1019
+ * type Opt1 = MutableOptions;
1020
+ * // ➔ { recursive: boolean }
1021
+ * ```
1022
+ */
1023
+ type MutableOptions={
1024
+ /** Whether to make nested objects mutable recursively.
1025
+ *
1026
+ * - If `true`, all nested objects will also have their `readonly` removed.
1027
+ * - Default value: `false`.
1028
+ *
1029
+ * @default false
1030
+ */
1031
+ recursive:boolean;};
1032
+ /** -------------------------------------------------------
1033
+ * * ***Mutable.***
1034
+ * -------------------------------------------------------
1035
+ * Removes `readonly` from all properties of the passed type `T`.
1036
+ * - If `Options["recursive"]` is `true`, nested objects are also made mutable.
1037
+ *
1038
+ * @template T - The type to make mutable.
1039
+ * @template Options - Configuration options. Default: `{ recursive: false }`.
1040
+ * @example
1041
+ * ```ts
1042
+ * type Case1 = Mutable<{ readonly a: { readonly b: string } }>;
1043
+ * // ➔ { a: { b: string } } (non-recursive by default)
1044
+ *
1045
+ * type Case2 = Mutable<{ readonly a: { readonly b: string } }, { recursive: true }>;
1046
+ * // ➔ { a: { b: string } } (nested properties also mutable)
1047
+ * ```
1048
+ */
1049
+ type Mutable<T,Options extends MutableOptions={recursive:false;}>=Prettify<{-readonly [K in keyof T]:And<Options["recursive"],Extends<T[K],object>>extends true?Mutable<T[K],Options>:T[K];}>;
1050
+ /** -------------------------------------------------------
1051
+ * * ***MutableOnly.***
1052
+ * -------------------------------------------------------
1053
+ * Removes `readonly` only from the specified keys `K` of type `T`.
1054
+ *
1055
+ * @template T - The type to modify.
1056
+ * @template K - Keys to make mutable.
1057
+ * @example
1058
+ * ```ts
1059
+ * type Case1 = MutableOnly<{ readonly a: string; readonly b: string }, "a">;
1060
+ * // ➔ { a: string; readonly b: string }
1061
+ *
1062
+ * type Case2 = MutableOnly<{ readonly a: string; readonly b: string }, "a" | "b">;
1063
+ * // ➔ { a: string; b: string }
1064
+ * ```
1065
+ */
1066
+ type MutableOnly<T,K extends keyof T>=Prettify<Pick<T,Exclude<keyof T,K>>&{-readonly [P in K]:T[P];}>;
1067
+ /** -------------------------------------------------------
1068
+ * * ***MutableExcept.***
1069
+ * -------------------------------------------------------
1070
+ * Removes `readonly` from all properties of `T` **except** the specified keys `K`.
1071
+ *
1072
+ * @template T - The type to modify.
1073
+ * @template K - Keys to keep as readonly.
1074
+ * @example
1075
+ * ```ts
1076
+ * type Case1 = MutableExcept<{ readonly a: string; readonly b: string }, "b">;
1077
+ * // ➔ { a: string; readonly b: string }
1078
+ *
1079
+ * type Case2 = MutableExcept<{ a: string; readonly b: string }, "a">;
1080
+ * // ➔ { a: string; b: string } (all except "a" made mutable)
1081
+ * ```
1082
+ */
1083
+ type MutableExcept<T,K extends keyof T>=Prettify<Pick<T,K>&{-readonly [P in Exclude<keyof T,K>]:T[P];}>;
1084
+ /** -------------------------------------------------------
1085
+ * * ***IsArray.***
1086
+ * -------------------------------------------------------
1087
+ * Returns a boolean whether the passed argument is an array.
1088
+ *
1089
+ * @example
1090
+ * type Case1 = IsArray<[]>;
1091
+ * // ➔ true
1092
+ * type Case2 = IsArray<string>;
1093
+ * // ➔ false
1094
+ */
1095
+ type IsArray<T>=AndArr<[ Not<IsAny<T>>,Not<IsNever<T>>,Extends<T,readonly unknown[]>]>;
1096
+ /** -------------------------------------------------------
1097
+ * * ***IsMutableArray.***
1098
+ * -------------------------------------------------------
1099
+ * Returns a boolean whether the passed argument is a mutable array.
1100
+ *
1101
+ * @example
1102
+ * type Case1 = IsMutableArray<[]>;
1103
+ * // ➔ true
1104
+ * type Case2 = IsMutableArray<readonly []>;
1105
+ * // ➔ false
1106
+ */
1107
+ type IsMutableArray<T>=And<IsArray<T>,NotExtends<Readonly<T>,T>>;
1108
+ /** -------------------------------------------------------
1109
+ * * ***IsReadonlyArray.***
1110
+ * -------------------------------------------------------
1111
+ * Returns a boolean whether the passed argument is a read-only array.
1112
+ *
1113
+ * @example
1114
+ * type Case1 = IsReadonlyArray<readonly []>;
1115
+ * // ➔ true
1116
+ * type Case2 = IsReadonlyArray<[]>;
1117
+ * // ➔ false
1118
+ */
1119
+ type IsReadonlyArray<T>=And<IsArray<T>,NotExtends<T,Mutable<T>>>;export type{Abs as A,IsNegativeFloat as B,CharAt as C,IsOdd as D,Even as E,Float as F,IsPositiveFloat as G,IsPositiveInteger as H,IsStringLiteral as I,IsScientificNumber as J,Negative as K,NegativeFloat as L,Mutable as M,Negate as N,NegativeInteger as O,ParseNumber as P,Odd as Q,Repeat as R,Split as S,OddDigit as T,ParseScientificNumber as U,Positive as V,PositiveFloat as W,PositiveInteger as X,IfUnknown as Y,UnknownifyProperties as Z,UnknownifyPropertiesOptions as _,IsNegative as a,IsFloat as b,IsUnknown as c,IsNegativeInteger as d,IsInteger as e,Push as f,IfNegative as g,IsPositive as h,IsEven as i,IsReadonlyArray as j,IfPositive as k,IsArray as l,IsMutableArray as m,MutableExcept as n,MutableOnly as o,MutableOptions as p,EvenDigit as q,IfEven as r,IfFloat as s,IfInteger as t,IfNegativeFloat as u,IfNegativeInteger as v,IfOdd as w,IfPositiveFloat as x,IfPositiveInteger as y,Integer as z};