@rzl-zone/utils-js 3.12.0 → 3.12.1-beta.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 (286) hide show
  1. package/{LICENSE.md → LICENSE} +3 -3
  2. package/README.md +62 -89
  3. package/dist/.references/index.d.cts +25 -0
  4. package/dist/.references/index.d.ts +25 -0
  5. package/dist/assertIsArray-BChqwPiP.cjs +26 -0
  6. package/dist/assertIsArray-BChqwPiP.cjs.map +1 -0
  7. package/dist/assertIsArray-BfAbIUfa.js +20 -0
  8. package/dist/assertIsArray-BfAbIUfa.js.map +1 -0
  9. package/dist/assertIsBoolean-BlBct0Fc.js +1073 -0
  10. package/dist/assertIsBoolean-BlBct0Fc.js.map +1 -0
  11. package/dist/assertIsBoolean-DozdtbNi.cjs +1283 -0
  12. package/dist/assertIsBoolean-DozdtbNi.cjs.map +1 -0
  13. package/dist/assertIsString-Bvk7bUL7.cjs +26 -0
  14. package/dist/assertIsString-Bvk7bUL7.cjs.map +1 -0
  15. package/dist/assertIsString-DqV9NwbI.js +20 -0
  16. package/dist/assertIsString-DqV9NwbI.js.map +1 -0
  17. package/dist/assertions/index.cjs +37 -40
  18. package/dist/assertions/index.cjs.map +1 -0
  19. package/dist/assertions/index.d.cts +12 -0
  20. package/dist/assertions/index.d.ts +10 -824
  21. package/dist/assertions/index.js +30 -13
  22. package/dist/assertions/index.js.map +1 -0
  23. package/dist/conversions/index.cjs +34 -103
  24. package/dist/conversions/index.d.cts +12 -0
  25. package/dist/conversions/index.d.ts +10 -1791
  26. package/dist/conversions/index.js +14 -24
  27. package/dist/conversions-CBs8-REq.cjs +448 -0
  28. package/dist/conversions-CBs8-REq.cjs.map +1 -0
  29. package/dist/conversions-EMJa3g-D.js +382 -0
  30. package/dist/conversions-EMJa3g-D.js.map +1 -0
  31. package/dist/events/index.cjs +55 -31
  32. package/dist/events/index.cjs.map +1 -0
  33. package/dist/events/index.d.cts +174 -0
  34. package/dist/events/index.d.ts +31 -35
  35. package/dist/events/index.js +50 -12
  36. package/dist/events/index.js.map +1 -0
  37. package/dist/formatEnvPort-DpIXzPAZ.js +159 -0
  38. package/dist/formatEnvPort-DpIXzPAZ.js.map +1 -0
  39. package/dist/formatEnvPort-hHNvOim-.cjs +171 -0
  40. package/dist/formatEnvPort-hHNvOim-.cjs.map +1 -0
  41. package/dist/formatters/index.cjs +21 -61
  42. package/dist/formatters/index.d.cts +12 -0
  43. package/dist/formatters/index.d.ts +10 -2152
  44. package/dist/formatters/index.js +10 -18
  45. package/dist/formatters-QcZO_Cpx.js +367 -0
  46. package/dist/formatters-QcZO_Cpx.js.map +1 -0
  47. package/dist/formatters-lAYgA11L.cjs +427 -0
  48. package/dist/formatters-lAYgA11L.cjs.map +1 -0
  49. package/dist/generators/index.cjs +161 -41
  50. package/dist/generators/index.cjs.map +1 -0
  51. package/dist/generators/index.d.cts +12 -0
  52. package/dist/generators/index.d.ts +10 -338
  53. package/dist/generators/index.js +154 -14
  54. package/dist/generators/index.js.map +1 -0
  55. package/dist/index-26W7ItWx.d.ts +760 -0
  56. package/dist/index-BPPQjAfs.d.cts +2359 -0
  57. package/dist/index-BXjlgBLz.d.cts +2139 -0
  58. package/dist/index-B_Wwo91H.d.ts +2359 -0
  59. package/dist/index-CpufydcI.d.cts +704 -0
  60. package/dist/index-Czc4O526.d.ts +333 -0
  61. package/dist/index-DPs1_p5G.d.cts +760 -0
  62. package/dist/index-DRpOyBSC.d.ts +1703 -0
  63. package/dist/index-DWWvtHUn.d.cts +822 -0
  64. package/dist/index-DnM0LD0n.d.cts +333 -0
  65. package/dist/index-GUZ9fK6T.d.ts +2139 -0
  66. package/dist/index-I4fAzwXV.d.ts +704 -0
  67. package/dist/index-JDrOl_19.d.ts +822 -0
  68. package/dist/index-b66P49Qe.d.cts +1703 -0
  69. package/dist/isBigInt-B1cijjqm.cjs +20 -0
  70. package/dist/isBigInt-B1cijjqm.cjs.map +1 -0
  71. package/dist/isBigInt-C0bN0Rhu.js +14 -0
  72. package/dist/isBigInt-C0bN0Rhu.js.map +1 -0
  73. package/dist/isEmptyObject-DI42NEo0.cjs +37 -0
  74. package/dist/isEmptyObject-DI42NEo0.cjs.map +1 -0
  75. package/dist/isEmptyObject-DeLVIJpl.js +25 -0
  76. package/dist/isEmptyObject-DeLVIJpl.js.map +1 -0
  77. package/dist/isEmptyString-BTUWYTbw.js +15 -0
  78. package/dist/isEmptyString-BTUWYTbw.js.map +1 -0
  79. package/dist/isEmptyString-CCK3bP74.cjs +21 -0
  80. package/dist/isEmptyString-CCK3bP74.cjs.map +1 -0
  81. package/dist/isEmptyValue-DMSMFTU8.cjs +30 -0
  82. package/dist/isEmptyValue-DMSMFTU8.cjs.map +1 -0
  83. package/dist/isEmptyValue-fjnfQnt5.js +24 -0
  84. package/dist/isEmptyValue-fjnfQnt5.js.map +1 -0
  85. package/dist/isEqual-B1fRgEuU.cjs +111 -0
  86. package/dist/isEqual-B1fRgEuU.cjs.map +1 -0
  87. package/dist/isEqual-DhyP8fB_.js +87 -0
  88. package/dist/isEqual-DhyP8fB_.js.map +1 -0
  89. package/dist/isFinite-BYMOo0os.js +15 -0
  90. package/dist/isFinite-BYMOo0os.js.map +1 -0
  91. package/dist/isFinite-sFkps2TY.cjs +21 -0
  92. package/dist/isFinite-sFkps2TY.cjs.map +1 -0
  93. package/dist/isInteger-DS9V7l_f.js +14 -0
  94. package/dist/isInteger-DS9V7l_f.js.map +1 -0
  95. package/dist/isInteger-FTCthMre.cjs +20 -0
  96. package/dist/isInteger-FTCthMre.cjs.map +1 -0
  97. package/dist/isPlainObject-DcFGh3_5.d.ts +530 -0
  98. package/dist/isPlainObject-doTI11Ib.d.cts +530 -0
  99. package/dist/isServer-D1TXfOs3.js +14 -0
  100. package/dist/isServer-D1TXfOs3.js.map +1 -0
  101. package/dist/isServer-q-QLFCqE.cjs +20 -0
  102. package/dist/isServer-q-QLFCqE.cjs.map +1 -0
  103. package/dist/isTypedArray-47R0wdrc.js +31 -0
  104. package/dist/isTypedArray-47R0wdrc.js.map +1 -0
  105. package/dist/isTypedArray-DiCoqffZ.cjs +43 -0
  106. package/dist/isTypedArray-DiCoqffZ.cjs.map +1 -0
  107. package/dist/isURL-CQiowFq2.js +14 -0
  108. package/dist/isURL-CQiowFq2.js.map +1 -0
  109. package/dist/isURL-WZypXsax.cjs +20 -0
  110. package/dist/isURL-WZypXsax.cjs.map +1 -0
  111. package/dist/isValidDomain-BSXshgkC.cjs +1788 -0
  112. package/dist/isValidDomain-BSXshgkC.cjs.map +1 -0
  113. package/dist/isValidDomain-DwA2EN79.js +1782 -0
  114. package/dist/isValidDomain-DwA2EN79.js.map +1 -0
  115. package/dist/next/index.cjs +119 -214
  116. package/dist/next/index.cjs.map +1 -0
  117. package/dist/next/index.d.cts +226 -0
  118. package/dist/next/index.d.ts +26 -31
  119. package/dist/next/index.js +117 -212
  120. package/dist/next/index.js.map +1 -0
  121. package/dist/next/server/index.cjs +25 -40
  122. package/dist/next/server/index.cjs.map +1 -0
  123. package/dist/next/server/index.d.cts +39 -0
  124. package/dist/next/server/index.d.ts +9 -10
  125. package/dist/next/server/index.js +23 -38
  126. package/dist/next/server/index.js.map +1 -0
  127. package/dist/noop-B2mTBhW-.cjs +18 -0
  128. package/dist/noop-B2mTBhW-.cjs.map +1 -0
  129. package/dist/noop-BzktGBVz.js +12 -0
  130. package/dist/noop-BzktGBVz.js.map +1 -0
  131. package/dist/normalizeSpaces-DQHR3Tlr.cjs +29 -0
  132. package/dist/normalizeSpaces-DQHR3Tlr.cjs.map +1 -0
  133. package/dist/normalizeSpaces-WS_iERJk.js +23 -0
  134. package/dist/normalizeSpaces-WS_iERJk.js.map +1 -0
  135. package/dist/normalizeString-2WLth_Gj.js +15 -0
  136. package/dist/normalizeString-2WLth_Gj.js.map +1 -0
  137. package/dist/normalizeString-D8euBcRD.cjs +21 -0
  138. package/dist/normalizeString-D8euBcRD.cjs.map +1 -0
  139. package/dist/operations/index.cjs +65 -32
  140. package/dist/operations/index.cjs.map +1 -0
  141. package/dist/operations/index.d.cts +139 -0
  142. package/dist/operations/index.d.ts +10 -15
  143. package/dist/operations/index.js +61 -17
  144. package/dist/operations/index.js.map +1 -0
  145. package/dist/parsers/index.cjs +12 -19
  146. package/dist/parsers/index.d.cts +239 -0
  147. package/dist/parsers/index.d.ts +71 -72
  148. package/dist/parsers/index.js +10 -12
  149. package/dist/parsers-DXtpsDyj.cjs +649 -0
  150. package/dist/parsers-DXtpsDyj.cjs.map +1 -0
  151. package/dist/parsers-Dpuq-V4u.js +643 -0
  152. package/dist/parsers-Dpuq-V4u.js.map +1 -0
  153. package/dist/parsing-B43x1sxn.js +50 -0
  154. package/dist/parsing-B43x1sxn.js.map +1 -0
  155. package/dist/parsing-lRoxn1Nz.cjs +56 -0
  156. package/dist/parsing-lRoxn1Nz.cjs.map +1 -0
  157. package/dist/predicates/index.cjs +91 -296
  158. package/dist/predicates/index.d.cts +13 -0
  159. package/dist/predicates/index.d.ts +12 -2482
  160. package/dist/predicates/index.js +23 -25
  161. package/dist/predicates-DiaYA7Ps.cjs +413 -0
  162. package/dist/predicates-DiaYA7Ps.cjs.map +1 -0
  163. package/dist/predicates-gNepszvo.js +257 -0
  164. package/dist/predicates-gNepszvo.js.map +1 -0
  165. package/dist/promises/index.cjs +76 -24
  166. package/dist/promises/index.cjs.map +1 -0
  167. package/dist/promises/index.d.cts +123 -0
  168. package/dist/promises/index.d.ts +28 -31
  169. package/dist/promises/index.js +73 -13
  170. package/dist/promises/index.js.map +1 -0
  171. package/dist/punyCode-CTWXVVFo.cjs +185 -0
  172. package/dist/punyCode-CTWXVVFo.cjs.map +1 -0
  173. package/dist/punyCode-hmiFzLWT.js +179 -0
  174. package/dist/punyCode-hmiFzLWT.js.map +1 -0
  175. package/dist/removeSpaces-BE8lfh-4.js +19 -0
  176. package/dist/removeSpaces-BE8lfh-4.js.map +1 -0
  177. package/dist/removeSpaces-DRRxNWlb.cjs +25 -0
  178. package/dist/removeSpaces-DRRxNWlb.cjs.map +1 -0
  179. package/dist/safeJsonParse-BBnQElk8.cjs +208 -0
  180. package/dist/safeJsonParse-BBnQElk8.cjs.map +1 -0
  181. package/dist/safeJsonParse-CXruaP0p.js +184 -0
  182. package/dist/safeJsonParse-CXruaP0p.js.map +1 -0
  183. package/dist/safeStableStringify-BNh3D0K0.js +88 -0
  184. package/dist/safeStableStringify-BNh3D0K0.js.map +1 -0
  185. package/dist/safeStableStringify-Cc62pfRp.cjs +106 -0
  186. package/dist/safeStableStringify-Cc62pfRp.cjs.map +1 -0
  187. package/dist/strings/index.cjs +76 -81
  188. package/dist/strings/index.cjs.map +1 -0
  189. package/dist/strings/index.d.cts +12 -0
  190. package/dist/strings/index.d.ts +10 -775
  191. package/dist/strings/index.js +59 -14
  192. package/dist/strings/index.js.map +1 -0
  193. package/dist/tailwind/index.cjs +19 -47
  194. package/dist/tailwind/index.d.cts +12 -0
  195. package/dist/tailwind/index.d.ts +11 -712
  196. package/dist/tailwind/index.js +10 -12
  197. package/dist/tailwind-DJ4cmLUw.cjs +247 -0
  198. package/dist/tailwind-DJ4cmLUw.cjs.map +1 -0
  199. package/dist/tailwind-IJvOdkZp.js +199 -0
  200. package/dist/tailwind-IJvOdkZp.js.map +1 -0
  201. package/dist/toStringArrayUnRecursive-CFs0jTEg.js +39 -0
  202. package/dist/toStringArrayUnRecursive-CFs0jTEg.js.map +1 -0
  203. package/dist/toStringArrayUnRecursive-xUaU8Ot9.cjs +51 -0
  204. package/dist/toStringArrayUnRecursive-xUaU8Ot9.cjs.map +1 -0
  205. package/dist/urls/index.cjs +129 -57
  206. package/dist/urls/index.cjs.map +1 -0
  207. package/dist/urls/index.d.cts +740 -0
  208. package/dist/urls/index.d.ts +218 -224
  209. package/dist/urls/index.js +121 -26
  210. package/dist/urls/index.js.map +1 -0
  211. package/package.json +203 -194
  212. package/dist/chunk-2AFQ33D3.cjs +0 -64
  213. package/dist/chunk-2CYDJVGM.js +0 -246
  214. package/dist/chunk-2MW4JDQ2.cjs +0 -598
  215. package/dist/chunk-2VTDXC3N.cjs +0 -1825
  216. package/dist/chunk-44XX2P34.js +0 -209
  217. package/dist/chunk-4YLBKLGS.cjs +0 -18
  218. package/dist/chunk-566CXQW7.cjs +0 -560
  219. package/dist/chunk-57EPKYID.cjs +0 -397
  220. package/dist/chunk-5MGEC3YG.js +0 -63
  221. package/dist/chunk-6EF52423.cjs +0 -249
  222. package/dist/chunk-6SCOKU3S.js +0 -109
  223. package/dist/chunk-6VUXD3CF.js +0 -119
  224. package/dist/chunk-7B76BSNK.cjs +0 -118
  225. package/dist/chunk-7Y6I2DSU.cjs +0 -101
  226. package/dist/chunk-A7S7E2EE.cjs +0 -308
  227. package/dist/chunk-AJZ6PMMZ.js +0 -16
  228. package/dist/chunk-AXGBL2IO.cjs +0 -251
  229. package/dist/chunk-B4TC6FBV.cjs +0 -678
  230. package/dist/chunk-BAV5T2E3.cjs +0 -15
  231. package/dist/chunk-BKIJBNIE.js +0 -21
  232. package/dist/chunk-BNIMTFK5.js +0 -59
  233. package/dist/chunk-BXW7YXB7.js +0 -1823
  234. package/dist/chunk-CFYZC4S6.js +0 -53
  235. package/dist/chunk-CSG4SCL3.js +0 -1587
  236. package/dist/chunk-CWQW7AKK.js +0 -676
  237. package/dist/chunk-DVMHRLKP.cjs +0 -16
  238. package/dist/chunk-EN7LVZBZ.js +0 -548
  239. package/dist/chunk-EV4Y7HCY.cjs +0 -26
  240. package/dist/chunk-F66VDYIZ.cjs +0 -18
  241. package/dist/chunk-FLJX37EL.cjs +0 -30
  242. package/dist/chunk-GKC3UDMC.cjs +0 -1623
  243. package/dist/chunk-H65I3GRZ.cjs +0 -106
  244. package/dist/chunk-HHYWB7VZ.js +0 -24
  245. package/dist/chunk-HNGGISFL.cjs +0 -65
  246. package/dist/chunk-HNSQAVSZ.cjs +0 -35
  247. package/dist/chunk-HSP6IWZK.js +0 -17
  248. package/dist/chunk-IDZS7J6T.js +0 -242
  249. package/dist/chunk-JS6R55VL.js +0 -302
  250. package/dist/chunk-JZVT5FK7.js +0 -232
  251. package/dist/chunk-KHO2SBNA.cjs +0 -16
  252. package/dist/chunk-KIDJCMNJ.js +0 -33
  253. package/dist/chunk-KOLEURVT.cjs +0 -38
  254. package/dist/chunk-L4V53MQK.cjs +0 -269
  255. package/dist/chunk-L5RDAVVH.js +0 -14
  256. package/dist/chunk-NODTV4F3.js +0 -16
  257. package/dist/chunk-NYK5K3V2.cjs +0 -211
  258. package/dist/chunk-ODUO3RTL.cjs +0 -113
  259. package/dist/chunk-ONZFBJVW.js +0 -14
  260. package/dist/chunk-PFXCTE37.js +0 -28
  261. package/dist/chunk-PPST7QAQ.js +0 -587
  262. package/dist/chunk-Q5IMYDFL.cjs +0 -33
  263. package/dist/chunk-QFFBIOJ4.js +0 -31
  264. package/dist/chunk-QNKGP5DY.js +0 -14
  265. package/dist/chunk-RRQHMOPE.cjs +0 -19
  266. package/dist/chunk-RU5OSRBU.js +0 -95
  267. package/dist/chunk-SDMPEJ4F.js +0 -35
  268. package/dist/chunk-SYNL5IKP.js +0 -115
  269. package/dist/chunk-TCDOWZQE.js +0 -16
  270. package/dist/chunk-TQPGXGKB.cjs +0 -123
  271. package/dist/chunk-TULOI4GL.js +0 -370
  272. package/dist/chunk-UBHCP4N5.cjs +0 -36
  273. package/dist/chunk-UCHF3M34.cjs +0 -56
  274. package/dist/chunk-UDA26MCU.cjs +0 -16
  275. package/dist/chunk-V3C4FYZL.cjs +0 -18
  276. package/dist/chunk-VAAHZFBF.js +0 -32
  277. package/dist/chunk-VJDDGRIK.cjs +0 -16
  278. package/dist/chunk-WVSPXFTY.js +0 -14
  279. package/dist/chunk-WYP76WXB.js +0 -101
  280. package/dist/chunk-YDE4ZBB7.cjs +0 -237
  281. package/dist/chunk-YKQEOO7C.cjs +0 -23
  282. package/dist/chunk-YSZC56SZ.js +0 -264
  283. package/dist/chunk-YWHHVDT4.js +0 -13
  284. package/dist/index.d.ts +0 -24
  285. package/dist/isPlainObject-DTJVV2Kf.d.ts +0 -536
  286. package/dist/rzl-utils.global.js +0 -10
@@ -1,826 +1,12 @@
1
1
  /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.12.0.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- import { Prettify, PickStrict } from '@rzl-zone/ts-types-plus';
11
- import { G as GetPreciseTypeOptions, I as IsNumberOptions, c as ArrayFallback, a as IsPlainObjectResult } from '../isPlainObject-DTJVV2Kf.js';
12
-
13
- /** -------------------------------------------------------
14
- * * ***Shape of the object passed to custom error message functions.***
15
- * -------------------------------------------------------
16
- * **This type describes the parameters received when `options.message`
17
- * is defined as a function in {@link OptionsAssertIs | `OptionsAssertIs`}.**
18
- * - **Parameter:**
19
- * - `currentType` ➔ the actual detected runtime type of the value.
20
- * - `validType` ➔ the required/expected type name that the value must match.
21
- * @example
22
- * ```ts
23
- * const options: OptionsAssertIs = {
24
- * message: ({ currentType, validType }) => {
25
- * return `Expected ${validType} but got ${currentType}`;
26
- * };
27
- * };
28
- * ```
29
- */
30
- type OptionsMessageFunctionAssertIs = {
31
- /** ---------------------------------------------------------------------------
32
- * * ***The actual runtime type of the value being checked.***
33
- * ---------------------------------------------------------------------------
34
- * - ***Example:***
35
- * - `"number"`, `"big-int"`, `"plain-object"`, (depends `formatCase` options).
36
- */
37
- currentType: string;
38
- /** ---------------------------------------------------------------------------
39
- * * ***The required/expected type that the value must conform to.***
40
- * ---------------------------------------------------------------------------
41
- * - ***Example:***
42
- * - `"boolean"`, `"string"`, `"big-int"`, `"plain-object"`, (will force format to `kebab-case`).
43
- */
44
- validType: string;
45
- };
46
- /** -------------------------------------------------------
47
- * * ***Custom error-message type for assertions option {@link OptionsAssertIs | `OptionsAssertIs`}.***
48
- * -------------------------------------------------------
49
- * - ***Accepts:***
50
- * - A static string message.
51
- * - A function receiving `{ currentType, validType }` and returning a string.
52
- */
53
- type OptionsMessageAssertIs = (({ currentType, validType }: OptionsMessageFunctionAssertIs) => string) | string;
54
- /** ---------------------------------------------------------------------------
55
- * * ***Base options for `assertIs*` functions.***
56
- * ---------------------------------------------------------------------------
57
- */
58
- type OptionsAssertIs = Prettify<{
59
- /** -------------------------------------------------------
60
- * * ***Custom error message for assertion failures.***
61
- * -------------------------------------------------------
62
- * **This option allows overriding the **default error message** when a value
63
- * does not match the required type.**
64
- * - If a **string** is provided:
65
- * - Must be non-empty after trimming.
66
- * - Will be used directly as the error message.
67
- * - If a **function** is provided:
68
- * - Receives an object containing:
69
- * - `currentType` ➔ the detected runtime type of the value (depends `formatCase` options, e.g., `"number"`).
70
- * - `validType` ➔ the expected type name (with format `kebab-case`, e.g., `"boolean"`, `"big-int"`, `"plain-object"`).
71
- * - **Must** return a **string**:
72
- * - **If** the **returned string is** `empty` or `whitespace`,
73
- * the **default message** will be used instead.
74
- * @example
75
- * ```ts
76
- * // Static message
77
- * { message: "Must be a boolean!" }
78
- *
79
- * // Dynamic message
80
- * {
81
- * message: ({ currentType, validType }) => {
82
- * return `Expected ${validType} but got ${currentType}`;
83
- * };
84
- * }
85
- * ```
86
- */
87
- message?: OptionsMessageAssertIs;
88
- /** -------------------------------------------------------
89
- * * ***Custom error type for assertion failures.***
90
- * -------------------------------------------------------
91
- * **This option allows overriding the default error type** that will be thrown
92
- * when a value does not match the required type.
93
- *
94
- * - **Behavior:**
95
- * - Must be one of the standard JavaScript built-in error types:
96
- * `"Error" | "EvalError" | "RangeError" | "ReferenceError" | "SyntaxError" | "TypeError" | "URIError"`
97
- * - **Default:** `"TypeError"` if not provided or if an invalid value is passed.
98
- * - The assertion function will **always throw a valid built-in error**, ensuring
99
- * fallback to `TypeError` in case of an unknown or incorrect type.
100
- * @example
101
- * ```ts
102
- * // Valid: Throw a RangeError instead of TypeError
103
- * { errorType: "RangeError" }
104
- *
105
- * // Valid: Throw a ReferenceError
106
- * { errorType: "ReferenceError" }
107
- *
108
- * // Invalid value ➔ fallback to TypeError
109
- * { errorType: "SomeUnknownError" as ErrorType }
110
- * ```
111
- */
112
- errorType?: ErrorType;
113
- } & PickStrict<GetPreciseTypeOptions, "formatCase" | "useAcronyms">, {
114
- recursive: true;
115
- }>;
116
- type ErrorType = "Error" | "EvalError" | "RangeError" | "ReferenceError" | "SyntaxError" | "TypeError" | "URIError";
117
-
118
- /** -------------------------------------------------------
119
- * * ***Type guard assertion: `assertIsBoolean`.***
120
- * -------------------------------------------------------
121
- * **This function is an **assertion function**.**
122
- * - **Behavior:**
123
- * - Validates that the given `value` is a **boolean**.
124
- * - After it returns successfully, TypeScript narrows the type of `value` to `boolean`.
125
- * - ✅ If `value` is a `boolean` ➔ execution continues normally.
126
- * - ❌ If `value` is not a `boolean` ➔ throws a built-in error with either:
127
- * - A custom error message (`options.message`), or
128
- * - A default message including the actual type.
129
- * - **⚠️ Error type selection (`options.errorType`):**
130
- * - You can override the type of error thrown when validation fails.
131
- * - Must be one of the standard JavaScript built-in errors:
132
- * - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |
133
- * [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |
134
- * [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |
135
- * [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |
136
- * [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |
137
- * [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |
138
- * [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
139
- * - **Default:** `"TypeError"` if not provided or invalid.
140
- * @param {*} value - ***The value to validate.***
141
- * @param {OptionsAssertIs} [options]
142
- * ***Optional configuration:***
143
- * - `message`: A custom error message (`string` or `function`).
144
- * - `errorType`: A custom built-in JavaScript error type to throw.
145
- * - `formatCase`: Controls how detected type names are formatted case in error messages.
146
- * - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.
147
- * @returns {boolean} Narrows `value` to `boolean` if no error is thrown.
148
- * @throws [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) | [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) | [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) | [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) | [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) if the value is not a boolean.
149
- * @example
150
- * ```ts
151
- * // ✅ Simple usage
152
- * assertIsBoolean(true);
153
- * // No error, value is boolean
154
- *
155
- * // ❌ Throws TypeError (default behavior)
156
- * // Case 1: Invalid input type — received a string instead of a boolean
157
- * assertIsBoolean("hello");
158
- * // ➔ TypeError: "Parameter input (`value`) must be of type `boolean`, but received: `number`."
159
- *
160
- * // Case 2: The new Boolean() is a Boolean object (constructor), not a primitive boolean
161
- * assertIsBoolean(new Boolean(true));
162
- * // ➔ TypeError: "Parameter input (`value`) must be of type `boolean`, but received: `boolean-constructor`."
163
- *
164
- * // ❌ Throws a TypeError with a custom string static message
165
- * assertIsBoolean(42, { message: "Must be boolean!" });
166
- * // ➔ TypeError: "Must be boolean!"
167
- *
168
- * // ❌ Throws RangeError (custom error type)
169
- * assertIsBoolean(42, { errorType: "RangeError" });
170
- * // ➔ RangeError: "Parameter input (`value`) must be of type `boolean`, but received: `number`."
171
- *
172
- * // ❌ Throws a TypeError with a custom message function and formatCase
173
- * assertIsBoolean(/regex/, {
174
- * message: ({ currentType, validType }) => {
175
- * return `Expected ${validType} but got (${currentType}).`
176
- * },
177
- * formatCase: "toPascalCaseSpace"
178
- * });
179
- * // ➔ TypeError: "Expected boolean but got (Reg Exp)."
180
- *
181
- * // ❌ Throws a TypeError with a custom useAcronyms option
182
- * // Case 1:
183
- * assertIsBoolean(new URL("https://example.com"),{
184
- * message: ({ currentType, validType }) => {
185
- * return `Expected ${validType} but got (${currentType}).`
186
- * },
187
- * });
188
- * // ➔ TypeError: "Expected boolean but got (url)."
189
- * assertIsBoolean(new URL("https://example.com"), {
190
- * useAcronyms: true,
191
- * message: ({ currentType, validType }) => {
192
- * return `Expected ${validType} but got (${currentType}).`
193
- * },
194
- * });
195
- * // ➔ TypeError: "Expected boolean but got (URL)."
196
- *
197
- * // Case 2:
198
- * assertIsBoolean(new URLSearchParams, {
199
- * formatCase: "toPascalCase",
200
- * message: ({ currentType, validType }) => {
201
- * return `Expected ${validType} but got (${currentType}).`
202
- * },
203
- * });
204
- * // ➔ TypeError: "Expected boolean but got (UrlSearchParams)."
205
- * assertIsBoolean(new URLSearchParams, {
206
- * useAcronyms: true,
207
- * formatCase: "toPascalCase",
208
- * message: ({ currentType, validType }) => {
209
- * return `Expected ${validType} but got (${currentType}).`
210
- * },
211
- * });
212
- * // ➔ TypeError: "Expected boolean but got (URLSearchParams)."
213
- * ```
214
- * -------------------------------------------------------
215
- * ✅ ***Real-world usage example***:
216
- * ```ts
217
- * const mixedValue: string | boolean | number | undefined = getUserInput();
218
- *
219
- * // Runtime assertion: throws if `mixedValue` is not a `boolean`
220
- * assertIsBoolean(mixedValue, {
221
- * errorType: "RangeError",
222
- * message: "Must be boolean!"
223
- * });
224
- *
225
- * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `boolean` here
226
- * const result: boolean = mixedValue; // ➔ Safe type assignment
227
- * ```
228
- */
229
- declare const assertIsBoolean: (value: unknown, options?: OptionsAssertIs) => asserts value is boolean;
230
-
231
- /** -------------------------------------------------------
232
- * * ***Type guard assertion: `assertIsBigInt`.***
233
- * -------------------------------------------------------
234
- * **This function is an **assertion function**.**
235
- * - **Behavior:**
236
- * - Validates that the given `value` is a **bigint**.
237
- * - After it returns successfully, TypeScript narrows the type of `value` to `bigint`.
238
- * - ✅ If `value` is a `bigint` ➔ execution continues normally.
239
- * - ❌ If `value` is not a `bigint` ➔ throws a built-in error with either:
240
- * - A custom error message (`options.message`), or
241
- * - A default message including the actual type.
242
- * - **ℹ️ Note:**
243
- * - A `bigint` refers strictly to the JavaScript `bigint` primitive type (e.g., `123n`, `0n`, `-999999999999999999999n`).
244
- * - This excludes `BigInt` objects created with `Object(BigInt(123))`.
245
- * - **⚠️ Error type selection (`options.errorType`):**
246
- * - You can override the type of error thrown when validation fails.
247
- * - Must be one of the standard JavaScript built-in errors:
248
- * - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |
249
- * [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |
250
- * [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |
251
- * [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |
252
- * [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |
253
- * [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |
254
- * [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
255
- * - **Default:** `"TypeError"` if not provided or invalid.
256
- * @param {*} value - ***The value to validate.***
257
- * @param {OptionsAssertIs} [options]
258
- * ***Optional configuration:***
259
- * - `message`: A custom error message (`string` or `function`).
260
- * - `errorType`: Built-in JavaScript error type to throw on failure (default `"TypeError"`).
261
- * - `formatCase`: Controls how detected type names are formatted case in error messages.
262
- * - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.
263
- * @returns {boolean} Narrows `value` to `bigint` if no error is thrown.
264
- * @throws [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) | [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) | [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) | [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) | [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) if the value is not a bigint.
265
- * @example
266
- * ```ts
267
- * // ✅ Simple usage
268
- * assertIsBigInt(123n);
269
- * // No error, value is bigint
270
- *
271
- * // ❌ Throws TypeError (default behavior)
272
- * assertIsBigInt(42);
273
- * // ➔ TypeError: "Parameter input (`value`) must be of type `bigint`, but received: `number`."
274
- *
275
- * // ❌ Throws a TypeError with a custom string static message
276
- * assertIsBigInt("123", { message: "Must be a bigint!" });
277
- * // ➔ TypeError: "Must be a bigint!"
278
- *
279
- * // ❌ Throws custom error type (e.g., RangeError)
280
- * assertIsBigInt(async function () {}, { errorType: "RangeError" });
281
- * // ➔ RangeError: "Parameter input (`value`) must be of type `bigint`, but received: `async-function`."
282
- *
283
- * // ❌ Throws a TypeError with a custom message function and formatCase
284
- * assertIsBigInt(/regex/, {
285
- * message: ({ currentType, validType }) => {
286
- * return `Expected ${validType} but got (${currentType}).`
287
- * },
288
- * formatCase: "toPascalCaseSpace"
289
- * });
290
- * // ➔ TypeError: "Expected bigint but got (Reg Exp)."
291
- *
292
- * // ❌ Throws a TypeError with a custom useAcronyms option
293
- * // Case 1:
294
- * assertIsBigInt(new URL("https://example.com"),{
295
- * message: ({ currentType, validType }) => {
296
- * return `Expected ${validType} but got (${currentType}).`
297
- * },
298
- * });
299
- * // ➔ TypeError: "Expected bigint but got (url)."
300
- * assertIsBigInt(new URL("https://example.com"), {
301
- * useAcronyms: true,
302
- * message: ({ currentType, validType }) => {
303
- * return `Expected ${validType} but got (${currentType}).`
304
- * },
305
- * });
306
- * // ➔ TypeError: "Expected bigint but got (URL)."
307
- *
308
- * // Case 2:
309
- * assertIsBigInt(new URLSearchParams, {
310
- * formatCase: "toPascalCase",
311
- * message: ({ currentType, validType }) => {
312
- * return `Expected ${validType} but got (${currentType}).`
313
- * },
314
- * });
315
- * // ➔ TypeError: "Expected bigint but got (UrlSearchParams)."
316
- * assertIsBigInt(new URLSearchParams, {
317
- * useAcronyms: true,
318
- * formatCase: "toPascalCase",
319
- * message: ({ currentType, validType }) => {
320
- * return `Expected ${validType} but got (${currentType}).`
321
- * },
322
- * });
323
- * // ➔ TypeError: "Expected bigint but got (URLSearchParams)."
324
- * ```
325
- * -------------------------------------------------------
326
- * ✅ ***Real-world usage example***:
327
- * ```ts
328
- * const mixedValue: string | bigint | undefined = getUserInput();
329
- *
330
- * // Runtime assertion: throws if `mixedValue` is not a `bigint`
331
- * assertIsBigInt(mixedValue, {
332
- * errorType: "RangeError",
333
- * message: "Must be bigint!"
334
- * });
335
- *
336
- * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `bigint` here
337
- * const result: bigint = mixedValue; // ➔ Safe type assignment
338
- * console.log(result + 100n); // ➔ Safe to operation
339
- * ```
340
- */
341
- declare const assertIsBigInt: (value: unknown, options?: OptionsAssertIs) => asserts value is bigint;
342
-
343
- type OptionsAssertIsNumber = OptionsAssertIs & IsNumberOptions;
344
- /** -------------------------------------------------------
345
- * * ***Type guard assertion: `assertIsNumber`.***
346
- * -------------------------------------------------------
347
- * **This function is an **assertion function**.**
348
- * - **Behavior:**
349
- * - Validates that the given `value` is a **number**.
350
- * - After it returns successfully, TypeScript narrows the type of `value` to `number`.
351
- * - ✅ If `value` is a `number` ➔ execution continues normally.
352
- * - ❌ If `value` is not a `number` ➔ throws a built-in error with either:
353
- * - A custom error message (`options.message`), or
354
- * - A default message including the actual type.
355
- * - **ℹ️ Note:**
356
- * - A `number` refers strictly to the JavaScript `number` primitive type (e.g., `42`, `3.14`, `-1`, `0`).
357
- * - This excludes `Number` objects created with `new Number(123)`.
358
- * - By default, `NaN` is **not considered** valid, you can allow it with `{ includeNaN: true }`.
359
- * - **⚠️ Error type selection (`options.errorType`):**
360
- * - You can override the type of error thrown when validation fails.
361
- * - Must be one of the standard JavaScript built-in errors:
362
- * - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |
363
- * [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |
364
- * [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |
365
- * [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |
366
- * [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |
367
- * [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |
368
- * [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
369
- * - **Default:** `"TypeError"` if not provided or invalid.
370
- * @param {*} value - ***The value to validate.***
371
- * @param {OptionsAssertIsNumber} [options]
372
- * ***Optional configuration:***
373
- * - `message`: A custom error message (`string` or `function`).
374
- * - `errorType`: Built-in JavaScript error type to throw on failure (default `"TypeError"`).
375
- * - `formatCase`: Controls how detected type names are formatted case in error messages.
376
- * - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.
377
- * - `includeNaN`: Whether to treat `NaN` as valid.
378
- * @returns {boolean} Narrows `value` to `number` if no error is thrown.
379
- * @throws [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) | [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) | [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) | [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) | [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) if the value is not a number (or is `NaN` when `includeNaN` is `false`).
380
- * @example
381
- * ```ts
382
- * // ✅ Simple usage
383
- * assertIsNumber(123);
384
- * assertIsNumber(NaN, { includeNaN: true });
385
- * // No error, value is number
386
- *
387
- * // ❌ Throws TypeError (default behavior)
388
- * // Case 1: Invalid input type — received a string instead of a number
389
- * assertIsNumber("42");
390
- * // ➔ TypeError: "Parameter input (`value`) must be of type `number`, but received: `string`."
391
- *
392
- * // Case 2: Default option includeNaN is false
393
- * assertIsNumber(NaN);
394
- * // ➔ TypeError: "Parameter input (`value`) must be of type `number`, but received: `NaN`."
395
- *
396
- * // Case 3: The new Number() is a Number object (constructor), not a primitive number
397
- * assertIsNumber(new Number("123"));
398
- * // ➔ TypeError: "Parameter input (`value`) must be of type `number`, but received: `number-constructor`."
399
- *
400
- * // ❌ Throws custom error type (e.g., RangeError)
401
- * assertIsNumber(async function () {}, { errorType: "RangeError" });
402
- * // ➔ RangeError: "Parameter input (`value`) must be of type `number`, but received: `async-function`."
403
- *
404
- * // ❌ Throws a TypeError with a custom string static message
405
- * assertIsNumber("123", { message: "Must be a number!" });
406
- * // ➔ TypeError: "Must be a number!"
407
- *
408
- * // ❌ Throws a TypeError with a custom message function and formatCase
409
- * assertIsNumber(/regex/, {
410
- * message: ({ currentType, validType }) => {
411
- * return `Expected ${validType} but got (${currentType}).`
412
- * },
413
- * formatCase: "toPascalCaseSpace"
414
- * });
415
- * // ➔ TypeError: "Expected number but got (Reg Exp)."
416
- *
417
- * // ❌ Throws a TypeError with a custom useAcronyms option
418
- * // Case 1:
419
- * assertIsNumber(new URL("https://example.com"),{
420
- * message: ({ currentType, validType }) => {
421
- * return `Expected ${validType} but got (${currentType}).`
422
- * },
423
- * });
424
- * // ➔ TypeError: "Expected number but got (url)."
425
- * assertIsNumber(new URL("https://example.com"), {
426
- * useAcronyms: true,
427
- * message: ({ currentType, validType }) => {
428
- * return `Expected ${validType} but got (${currentType}).`
429
- * },
430
- * });
431
- * // ➔ TypeError: "Expected number but got (URL)."
432
- *
433
- * // Case 2:
434
- * assertIsNumber(new URLSearchParams, {
435
- * formatCase: "toPascalCase",
436
- * message: ({ currentType, validType }) => {
437
- * return `Expected ${validType} but got (${currentType}).`
438
- * },
439
- * });
440
- * // ➔ TypeError: "Expected number but got (UrlSearchParams)."
441
- * assertIsNumber(new URLSearchParams, {
442
- * useAcronyms: true,
443
- * formatCase: "toPascalCase",
444
- * message: ({ currentType, validType }) => {
445
- * return `Expected ${validType} but got (${currentType}).`
446
- * },
447
- * });
448
- * // ➔ TypeError: "Expected number but got (URLSearchParams)."
449
- * ```
450
- * -------------------------------------------------------
451
- * ✅ ***Real-world usage example***:
452
- * ```ts
453
- * const mixedValue: string | number | undefined = getUserInput();
454
- *
455
- * // Runtime assertion: throws if `mixedValue` is not a `number`
456
- * assertIsNumber(mixedValue, {
457
- * errorType: "RangeError",
458
- * message: "Must be number!"
459
- * });
460
- *
461
- * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `number` here
462
- * const result: number = mixedValue; // ➔ Safe type assignment
463
- * console.log(result + 100); // ➔ Safe to operation
464
- * ```
465
- */
466
- declare const assertIsNumber: (value: unknown, options?: OptionsAssertIsNumber) => asserts value is number;
467
-
468
- /** -------------------------------------------------------
469
- * * ***Type guard assertion: `assertIsArray`.***
470
- * -------------------------------------------------------
471
- * **This function is an **assertion function**.**
472
- * - **Behavior:**
473
- * - Validates that the given `value` is an **array**.
474
- * - After it returns successfully, TypeScript narrows the type of `value` to `array` **(generic support)**.
475
- * - ✅ If `value` is an `array` ➔ execution continues normally.
476
- * - ❌ If `value` is not an `array` ➔ throws a built-in error with either:
477
- * - A custom error message (`options.message`), or
478
- * - A default message including the actual type.
479
- * - **⚠️ Error type selection (`options.errorType`):**
480
- * - You can override the type of error thrown when validation fails.
481
- * - Must be one of the standard JavaScript built-in errors:
482
- * - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |
483
- * [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |
484
- * [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |
485
- * [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |
486
- * [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |
487
- * [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |
488
- * [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
489
- * - **Default:** `"TypeError"` if not provided or invalid.
490
- * @template T - The input type being asserted.
491
- * @param {*} value - ***The value to validate.***
492
- * @param {OptionsAssertIs} [options]
493
- * ***Optional configuration:***
494
- * - `message`: A custom error message (`string` or `function`).
495
- * - `errorType`: Built-in JavaScript error type to throw on failure (default `"TypeError"`).
496
- * - `formatCase`: Controls how detected type names are formatted case in error messages.
497
- * - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.
498
- * @returns {boolean} Narrows `value` to an `array` **(generic support)** if no error is thrown.
499
- * @throws [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) | [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) | [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) | [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) | [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) if the value is not an array.
500
- * @example
501
- * ```ts
502
- * // ✅ Simple usage
503
- * assertIsArray([]);
504
- * assertIsArray(["123", 456]);
505
- * assertIsArray(Array.from(["abc"]));
506
- * // No error, value is array
507
- *
508
- * // ❌ Throws TypeError (default behavior)
509
- * // Case 1: Invalid input type — received a string instead of a array
510
- * assertIsArray("42");
511
- * // ➔ TypeError: "Parameter input (`value`) must be of type `array`, but received: `string`."
512
- *
513
- * // ❌ Throws custom error type (e.g., RangeError)
514
- * assertIsArray(async function () {}, { errorType: "RangeError" });
515
- * // ➔ RangeError: "Parameter input (`value`) must be of type `array`, but received: `async-function`."
516
- *
517
- * // ❌ Throws a TypeError with a custom string static message
518
- * assertIsArray("123", { message: "Must be a array!" });
519
- * // ➔ TypeError: "Must be a array!"
520
- *
521
- * // ❌ Throws a TypeError with a custom message function and formatCase
522
- * assertIsArray(/regex/, {
523
- * message: ({ currentType, validType }) => {
524
- * return `Expected ${validType} but got (${currentType}).`
525
- * },
526
- * formatCase: "toPascalCaseSpace"
527
- * });
528
- * // ➔ TypeError: "Expected array but got (Reg Exp)."
529
- *
530
- * // ❌ Throws a TypeError with a custom useAcronyms option
531
- * // Case 1:
532
- * assertIsArray(new URL("https://example.com"),{
533
- * message: ({ currentType, validType }) => {
534
- * return `Expected ${validType} but got (${currentType}).`
535
- * },
536
- * });
537
- * // ➔ TypeError: "Expected array but got (url)."
538
- * assertIsArray(new URL("https://example.com"), {
539
- * useAcronyms: true,
540
- * message: ({ currentType, validType }) => {
541
- * return `Expected ${validType} but got (${currentType}).`
542
- * },
543
- * });
544
- * // ➔ TypeError: "Expected array but got (URL)."
545
- *
546
- * // Case 2:
547
- * assertIsArray(new URLSearchParams, {
548
- * formatCase: "toPascalCase",
549
- * message: ({ currentType, validType }) => {
550
- * return `Expected ${validType} but got (${currentType}).`
551
- * },
552
- * });
553
- * // ➔ TypeError: "Expected array but got (UrlSearchParams)."
554
- * assertIsArray(new URLSearchParams, {
555
- * useAcronyms: true,
556
- * formatCase: "toPascalCase",
557
- * message: ({ currentType, validType }) => {
558
- * return `Expected ${validType} but got (${currentType}).`
559
- * },
560
- * });
561
- * // ➔ TypeError: "Expected array but got (URLSearchParams)."
562
- * ```
563
- * -------------------------------------------------------
564
- * ✅ ***Real-world usage example***:
565
- * ```ts
566
- * const mixedValue: string | number[] | undefined = getUserInput();
567
- *
568
- * // Runtime assertion: throws if `mixedValue` is not a `number[]`
569
- * assertIsArray(mixedValue, {
570
- * errorType: "RangeError",
571
- * message: "Must be array!"
572
- * });
573
- *
574
- * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `number[]` here
575
- * const result: number[] = mixedValue; // ➔ Safe type assignment
576
- * console.log(result.push(1, 2, 3)); // ➔ Safe to use array methods
577
- * ```
578
- */
579
- declare function assertIsArray(value: [], options?: OptionsAssertIs): asserts value is [];
580
- declare function assertIsArray<T>(value: T, options?: OptionsAssertIs): asserts value is ArrayFallback<T>;
581
- declare function assertIsArray(value: unknown, options?: OptionsAssertIs): asserts value is unknown[];
582
-
583
- /** -------------------------------------------------------
584
- * * ***Type guard assertion: `assertIsPlainObject`.***
585
- * -------------------------------------------------------
586
- * **This function is an **assertion function**.**
587
- * - **Behavior:**
588
- * - Validates that the given `value` is a **plain-object**.
589
- * - After it returns successfully, TypeScript narrows the type of `value` to `plain-object` **(generic support)**.
590
- * - ✅ If `value` is a `plain-object` ➔ execution continues normally.
591
- * - ❌ If `value` is not a `plain-object` ➔ throws a built-in error with either:
592
- * - A custom error message (`options.message`), or
593
- * - A default message including the actual type.
594
- * - **A valid `plain object` is:**
595
- * - Created by the `Object` constructor, or
596
- * - Has a `[[Prototype]]` of `null` (e.g. `Object.create(null)`).
597
- * - **✅ Returns `undefined` (valid) for:**
598
- * - Empty object literals: `{}`
599
- * - Objects with null prototype: `Object.create(null)`
600
- * - **❌ Returns `throws` for:**
601
- * - Arrays (`[]`, `new Array()`)
602
- * - Functions (regular, arrow, or class constructors)
603
- * - Built-in objects: `Date`, `RegExp`, `Error`, `Map`, `Set`, `WeakMap`, `WeakSet`
604
- * - Boxed primitives: `new String()`, `new Number()`, `new Boolean()`
605
- * - `null` or `undefined`
606
- * - Symbols
607
- * - Class instances
608
- * - **⚠️ Error type selection (`options.errorType`):**
609
- * - You can override the type of error thrown when validation fails.
610
- * - Must be one of the standard JavaScript built-in errors:
611
- * - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |
612
- * [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |
613
- * [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |
614
- * [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |
615
- * [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |
616
- * [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |
617
- * [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
618
- * - **Default:** `"TypeError"` if not provided or invalid.
619
- * @template T - The input type being asserted.
620
- * @param {*} value - ***The value to validate.***
621
- * @param {OptionsAssertIs} [options]
622
- * ***Optional configuration:***
623
- * - `message`: A custom error message (`string` or `function`).
624
- * - `errorType`: Built-in JavaScript error type to throw on failure (default `"TypeError"`).
625
- * - `formatCase`: Controls how detected type names are formatted case in error messages.
626
- * - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.
627
- * @returns {boolean} Narrows `value` to a `plain-object` **(generic support)** if no error is thrown.
628
- * @throws [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) | [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) | [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) | [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) | [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) if `value` is not a plain-object.
629
- * @example
630
- * ```ts
631
- * // ✅ Simple usage
632
- * assertIsPlainObject({ a: 1, b: 2 });
633
- * // No error, value is plain-object
634
- *
635
- * // ❌ Throws TypeError (default behavior)
636
- * // Case 1: Invalid input type — received a string instead of a plain-object
637
- * assertIsPlainObject("42");
638
- * // ➔ TypeError: "Parameter input (`value`) must be of type `plain-object`, but received: `string`."
639
- *
640
- * // ❌ Throws custom error type (e.g., RangeError)
641
- * assertIsPlainObject(async function () {}, { errorType: "RangeError" });
642
- * // ➔ RangeError: "Parameter input (`value`) must be of type `plain-object`, but received: `async-function`."
643
- *
644
- * // ❌ Throws a TypeError with a custom string static message
645
- * assertIsPlainObject("123", { message: "Must be a plain-object!" });
646
- * // ➔ TypeError: "Must be a plain-object!"
647
- *
648
- * // ❌ Throws a TypeError with a custom message function and formatCase
649
- * assertIsPlainObject(/regex/, {
650
- * message: ({ currentType, validType }) => {
651
- * return `Expected ${validType} but got (${currentType}).`
652
- * },
653
- * formatCase: "toPascalCaseSpace"
654
- * });
655
- * // ➔ TypeError: "Expected plain-object but got (Reg Exp)."
656
- *
657
- * // ❌ Throws a TypeError with a custom useAcronyms option
658
- * // Case 1:
659
- * assertIsPlainObject(new URL("https://example.com"),{
660
- * message: ({ currentType, validType }) => {
661
- * return `Expected ${validType} but got (${currentType}).`
662
- * },
663
- * });
664
- * // ➔ TypeError: "Expected plain-object but got (url)."
665
- * assertIsPlainObject(new URL("https://example.com"), {
666
- * useAcronyms: true,
667
- * message: ({ currentType, validType }) => {
668
- * return `Expected ${validType} but got (${currentType}).`
669
- * },
670
- * });
671
- * // ➔ TypeError: "Expected plain-object but got (URL)."
672
- *
673
- * // Case 2:
674
- * assertIsPlainObject(new URLSearchParams, {
675
- * formatCase: "toPascalCase",
676
- * message: ({ currentType, validType }) => {
677
- * return `Expected ${validType} but got (${currentType}).`
678
- * },
679
- * });
680
- * // ➔ TypeError: "Expected plain-object but got (UrlSearchParams)."
681
- * assertIsPlainObject(new URLSearchParams, {
682
- * useAcronyms: true,
683
- * formatCase: "toPascalCase",
684
- * message: ({ currentType, validType }) => {
685
- * return `Expected ${validType} but got (${currentType}).`
686
- * },
687
- * });
688
- * // ➔ TypeError: "Expected plain-object but got (URLSearchParams)."
689
- * ```
690
- * -------------------------------------------------------
691
- * ✅ ***Real-world usage with generic narrowing***:
692
- * ```ts
693
- * type User = { name: string; email: string };
694
- * const mixedValue: string | User | boolean | number | undefined = getUserInput();
695
- *
696
- * // Runtime assertion: throws if `mixedValue` is not a `plain-object`
697
- * assertIsPlainObject(mixedValue, {
698
- * errorType: "RangeError",
699
- * message: "Must be plain object!"
700
- * });
701
- *
702
- * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `User` here
703
- * const user: User = mixedValue; // ➔ Safe type assignment
704
- * console.log(user.email); // ➔ Safe to access object properties
705
- * ```
706
- */
707
- declare function assertIsPlainObject<T>(value: T, options?: OptionsAssertIs): asserts value is IsPlainObjectResult<T>;
708
-
709
- /** -------------------------------------------------------
710
- * * ***Type guard assertion: `assertIsString`.***
711
- * -------------------------------------------------------
712
- * **This function is an **assertion function**.**
713
- * - **Behavior:**
714
- * - Validates that the given `value` is a **primitive-string**.
715
- * - After it returns successfully, TypeScript narrows the type of `value` to `primitive-string`.
716
- * - ✅ If `value` is a `primitive-string` ➔ execution continues normally.
717
- * - ❌ If `value` is not a `primitive-string` ➔ throws a built-in error with either:
718
- * - A custom error message (`options.message`), or
719
- * - A default message including the actual type.
720
- * - **ℹ️ Note:**
721
- * - A "string" refers strictly to a JavaScript `primitive-string` type (e.g., `"hello"`, `""`, `"123"`).
722
- * - This function excludes `String` objects created with `new String()`.
723
- * - **⚠️ Error type selection (`options.errorType`):**
724
- * - You can override the type of error thrown when validation fails.
725
- * - Must be one of the standard JavaScript built-in errors:
726
- * - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |
727
- * [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |
728
- * [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |
729
- * [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |
730
- * [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |
731
- * [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |
732
- * [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
733
- * - **Default:** `"TypeError"` if not provided or invalid.
734
- * @param {*} value - ***The value to validate.***
735
- * @param {OptionsAssertIs} [options]
736
- * ***Optional configuration:***
737
- * - `message`: A custom error message (`string` or `function`).
738
- * - `errorType`: Built-in JavaScript error type to throw on failure (default `"TypeError"`).
739
- * - `formatCase`: Controls how detected type names are formatted case in error messages.
740
- * - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.
741
- * @returns {boolean} Narrows `value` to `string` if no error is thrown.
742
- * @throws [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) | [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) | [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) | [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) | [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) if the value is not a primitive string.
743
- * @example
744
- * ```ts
745
- * // ✅ Simple usage
746
- * assertIsString("hello");
747
- * // No error, value is string
748
- *
749
- * // ❌ Throws TypeError (default behavior)
750
- * // Case 1: Invalid input type — received a string instead of a string
751
- * assertIsString(42);
752
- * // ➔ TypeError: "Parameter input (`value`) must be of type `string`, but received: `number`."
753
- *
754
- * // Case 3: The new String() is a String object (constructor), not a primitive string
755
- * assertIsString(new String("abc"));
756
- * // ➔ TypeError: "Parameter input (`value`) must be of type `string`, but received: `string-constructor`."
757
- *
758
- * // ❌ Throws custom error type (e.g., RangeError)
759
- * assertIsString(async function () {}, { errorType: "RangeError" });
760
- * // ➔ RangeError: "Parameter input (`value`) must be of type `string`, but received: `async-function`."
761
- *
762
- * // ❌ Throws a TypeError with a custom string static message
763
- * assertIsString(123, { message: "Must be a string!" });
764
- * // ➔ TypeError: "Must be a string!"
765
- *
766
- * // ❌ Throws a TypeError with a custom message function and formatCase
767
- * assertIsString(/regex/, {
768
- * message: ({ currentType, validType }) => {
769
- * return `Expected ${validType} but got (${currentType}).`
770
- * },
771
- * formatCase: "toPascalCaseSpace"
772
- * });
773
- * // ➔ TypeError: "Expected string but got (Reg Exp)."
774
- *
775
- * // ❌ Throws a TypeError with a custom useAcronyms option
776
- * // Case 1:
777
- * assertIsString(new URL("https://example.com"),{
778
- * message: ({ currentType, validType }) => {
779
- * return `Expected ${validType} but got (${currentType}).`
780
- * },
781
- * });
782
- * // ➔ TypeError: "Expected string but got (url)."
783
- * assertIsString(new URL("https://example.com"), {
784
- * useAcronyms: true,
785
- * message: ({ currentType, validType }) => {
786
- * return `Expected ${validType} but got (${currentType}).`
787
- * },
788
- * });
789
- * // ➔ TypeError: "Expected string but got (URL)."
790
- *
791
- * // Case 2:
792
- * assertIsString(new URLSearchParams, {
793
- * formatCase: "toPascalCase",
794
- * message: ({ currentType, validType }) => {
795
- * return `Expected ${validType} but got (${currentType}).`
796
- * },
797
- * });
798
- * // ➔ TypeError: "Expected string but got (UrlSearchParams)."
799
- * assertIsString(new URLSearchParams, {
800
- * useAcronyms: true,
801
- * formatCase: "toPascalCase",
802
- * message: ({ currentType, validType }) => {
803
- * return `Expected ${validType} but got (${currentType}).`
804
- * },
805
- * });
806
- * // ➔ TypeError: "Expected string but got (URLSearchParams)."
807
- * ```
808
- * -------------------------------------------------------
809
- * ✅ ***Real-world usage with generic narrowing***:
810
- * ```ts
811
- * const mixedValue: string | boolean | undefined = getUserInput();
812
- *
813
- * // Runtime assertion: throws if `mixedValue` is not a `string`
814
- * assertIsString(mixedValue, {
815
- * errorType: "RangeError",
816
- * message: "Must be a string!"
817
- * });
818
- *
819
- * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `string` here
820
- * const result: string = mixedValue; // ➔ Safe type assignment
821
- * console.log(result.toUpperCase()); // ➔ Safe to call String.prototype methods
822
- * ```
823
- */
824
- declare const assertIsString: (value: unknown, options?: OptionsAssertIs) => asserts value is string;
825
-
2
+ * ========================================================================
3
+ * @rzl-zone/utils-js
4
+ * ------------------------------------------------------------------------
5
+ * Version: `3.12.1-beta.0`
6
+ * Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
7
+ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
8
+ * ========================================================================
9
+ */
10
+
11
+ import { a as assertIsBigInt, i as assertIsNumber, n as assertIsPlainObject, o as assertIsBoolean, r as assertIsArray, t as assertIsString } from "../index-JDrOl_19.js";
826
12
  export { assertIsArray, assertIsBigInt, assertIsBoolean, assertIsNumber, assertIsPlainObject, assertIsString };