@rzl-zone/utils-js 3.12.0 → 3.12.1-beta.1

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 +69 -96
  3. package/dist/.references/index.d.cts +25 -0
  4. package/dist/.references/index.d.ts +25 -0
  5. package/dist/assertIsArray-DJXkjHZs.cjs +26 -0
  6. package/dist/assertIsArray-DJXkjHZs.cjs.map +1 -0
  7. package/dist/assertIsArray-bTA3XLjq.js +20 -0
  8. package/dist/assertIsArray-bTA3XLjq.js.map +1 -0
  9. package/dist/assertIsBoolean-C8WEXVr2.cjs +1283 -0
  10. package/dist/assertIsBoolean-C8WEXVr2.cjs.map +1 -0
  11. package/dist/assertIsBoolean-DR1SaXPD.js +1073 -0
  12. package/dist/assertIsBoolean-DR1SaXPD.js.map +1 -0
  13. package/dist/assertIsString-BiHQSrB2.cjs +26 -0
  14. package/dist/assertIsString-BiHQSrB2.cjs.map +1 -0
  15. package/dist/assertIsString-CEB07_83.js +20 -0
  16. package/dist/assertIsString-CEB07_83.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-BNIh_tCH.js +380 -0
  28. package/dist/conversions-BNIh_tCH.js.map +1 -0
  29. package/dist/conversions-D_Kh0a_C.cjs +446 -0
  30. package/dist/conversions-D_Kh0a_C.cjs.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 +176 -0
  34. package/dist/events/index.d.ts +164 -166
  35. package/dist/events/index.js +50 -12
  36. package/dist/events/index.js.map +1 -0
  37. package/dist/formatEnvPort-B3OLxQk9.cjs +171 -0
  38. package/dist/formatEnvPort-B3OLxQk9.cjs.map +1 -0
  39. package/dist/formatEnvPort-ByFVLjSV.js +159 -0
  40. package/dist/formatEnvPort-ByFVLjSV.js.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--1m_vpE8.js +369 -0
  46. package/dist/formatters--1m_vpE8.js.map +1 -0
  47. package/dist/formatters-Cbij0XLU.cjs +429 -0
  48. package/dist/formatters-Cbij0XLU.cjs.map +1 -0
  49. package/dist/generators/index.cjs +165 -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 +158 -14
  54. package/dist/generators/index.js.map +1 -0
  55. package/dist/index-59zbLcPr.d.ts +340 -0
  56. package/dist/index-B6tawc8L.d.cts +1716 -0
  57. package/dist/index-C267akkJ.d.ts +2158 -0
  58. package/dist/index-CeBC2Vvl.d.cts +2361 -0
  59. package/dist/index-CgRDTI6f.d.ts +822 -0
  60. package/dist/index-CoiUBVmr.d.ts +720 -0
  61. package/dist/index-D4fcasfZ.d.cts +720 -0
  62. package/dist/index-DDrSQKIc.d.ts +1716 -0
  63. package/dist/index-DsGxO31H.d.cts +765 -0
  64. package/dist/index-Hg1qJkjl.d.ts +765 -0
  65. package/dist/index-Qm3iFwd0.d.cts +2158 -0
  66. package/dist/index-UPp94Agr.d.ts +2361 -0
  67. package/dist/index-gBA_8SuF.d.cts +340 -0
  68. package/dist/index-jyDqzicx.d.cts +822 -0
  69. package/dist/isBigInt-C4krUeAw.cjs +20 -0
  70. package/dist/isBigInt-C4krUeAw.cjs.map +1 -0
  71. package/dist/isBigInt-DKe0M6hp.js +14 -0
  72. package/dist/isBigInt-DKe0M6hp.js.map +1 -0
  73. package/dist/isEmptyObject-DCipFwxJ.js +25 -0
  74. package/dist/isEmptyObject-DCipFwxJ.js.map +1 -0
  75. package/dist/isEmptyObject-ZkSwRC_D.cjs +37 -0
  76. package/dist/isEmptyObject-ZkSwRC_D.cjs.map +1 -0
  77. package/dist/isEmptyString-BXzKAC2j.js +15 -0
  78. package/dist/isEmptyString-BXzKAC2j.js.map +1 -0
  79. package/dist/isEmptyString-UiiUsSQj.cjs +21 -0
  80. package/dist/isEmptyString-UiiUsSQj.cjs.map +1 -0
  81. package/dist/isEmptyValue-BQzcjVaL.cjs +30 -0
  82. package/dist/isEmptyValue-BQzcjVaL.cjs.map +1 -0
  83. package/dist/isEmptyValue-jqOr7OHD.js +24 -0
  84. package/dist/isEmptyValue-jqOr7OHD.js.map +1 -0
  85. package/dist/isEqual-BX49cF9m.js +87 -0
  86. package/dist/isEqual-BX49cF9m.js.map +1 -0
  87. package/dist/isEqual-BvumA3RA.cjs +111 -0
  88. package/dist/isEqual-BvumA3RA.cjs.map +1 -0
  89. package/dist/isFinite-BCnaDpod.js +15 -0
  90. package/dist/isFinite-BCnaDpod.js.map +1 -0
  91. package/dist/isFinite-D24ZaE6c.cjs +21 -0
  92. package/dist/isFinite-D24ZaE6c.cjs.map +1 -0
  93. package/dist/isInteger-Caeuz0rB.cjs +20 -0
  94. package/dist/isInteger-Caeuz0rB.cjs.map +1 -0
  95. package/dist/isInteger-naMbJsxJ.js +14 -0
  96. package/dist/isInteger-naMbJsxJ.js.map +1 -0
  97. package/dist/isPlainObject-BF-2-phb.d.cts +339 -0
  98. package/dist/isPlainObject-DxNDL8XU.d.ts +339 -0
  99. package/dist/isServer-BJHVnixd.cjs +20 -0
  100. package/dist/isServer-BJHVnixd.cjs.map +1 -0
  101. package/dist/isServer-Da3o3XSs.js +14 -0
  102. package/dist/isServer-Da3o3XSs.js.map +1 -0
  103. package/dist/isTypedArray-DuNA8tK6.js +31 -0
  104. package/dist/isTypedArray-DuNA8tK6.js.map +1 -0
  105. package/dist/isTypedArray-TJptiw2b.cjs +43 -0
  106. package/dist/isTypedArray-TJptiw2b.cjs.map +1 -0
  107. package/dist/isURL-C-kSk6KJ.js +14 -0
  108. package/dist/isURL-C-kSk6KJ.js.map +1 -0
  109. package/dist/isURL-DeUPO_oR.cjs +20 -0
  110. package/dist/isURL-DeUPO_oR.cjs.map +1 -0
  111. package/dist/isValidDomain-BB9IGhJs.cjs +1845 -0
  112. package/dist/isValidDomain-BB9IGhJs.cjs.map +1 -0
  113. package/dist/isValidDomain-DoE98yhJ.js +1827 -0
  114. package/dist/isValidDomain-DoE98yhJ.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 +220 -0
  118. package/dist/next/index.d.ts +203 -214
  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 +34 -35
  125. package/dist/next/server/index.js +23 -38
  126. package/dist/next/server/index.js.map +1 -0
  127. package/dist/noop-B13_ii35.cjs +18 -0
  128. package/dist/noop-B13_ii35.cjs.map +1 -0
  129. package/dist/noop-ubqAIbHD.js +12 -0
  130. package/dist/noop-ubqAIbHD.js.map +1 -0
  131. package/dist/normalizeSpaces-Bg2IZW7W.js +23 -0
  132. package/dist/normalizeSpaces-Bg2IZW7W.js.map +1 -0
  133. package/dist/normalizeSpaces-ZXnR4Qzp.cjs +29 -0
  134. package/dist/normalizeSpaces-ZXnR4Qzp.cjs.map +1 -0
  135. package/dist/normalizeString-BDdkaXui.js +15 -0
  136. package/dist/normalizeString-BDdkaXui.js.map +1 -0
  137. package/dist/normalizeString-BE6ELqEb.cjs +21 -0
  138. package/dist/normalizeString-BE6ELqEb.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 +129 -134
  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 +234 -235
  148. package/dist/parsers/index.js +10 -12
  149. package/dist/parsers-BSBPgvsq.js +643 -0
  150. package/dist/parsers-BSBPgvsq.js.map +1 -0
  151. package/dist/parsers-OqDeffqc.cjs +649 -0
  152. package/dist/parsers-OqDeffqc.cjs.map +1 -0
  153. package/dist/parsing-Cao8b358.js +50 -0
  154. package/dist/parsing-Cao8b358.js.map +1 -0
  155. package/dist/parsing-DOGSCH6N.cjs +56 -0
  156. package/dist/parsing-DOGSCH6N.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-Bj6meyXV.js +256 -0
  162. package/dist/predicates-Bj6meyXV.js.map +1 -0
  163. package/dist/predicates-D0ubqgqy.cjs +412 -0
  164. package/dist/predicates-D0ubqgqy.cjs.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 +116 -119
  169. package/dist/promises/index.js +73 -13
  170. package/dist/promises/index.js.map +1 -0
  171. package/dist/punyCode-8SrbMWfM.js +179 -0
  172. package/dist/punyCode-8SrbMWfM.js.map +1 -0
  173. package/dist/punyCode-D-Qu6nj6.cjs +185 -0
  174. package/dist/punyCode-D-Qu6nj6.cjs.map +1 -0
  175. package/dist/removeSpaces-Bmc5DX4F.js +19 -0
  176. package/dist/removeSpaces-Bmc5DX4F.js.map +1 -0
  177. package/dist/removeSpaces-CWIvhZHg.cjs +25 -0
  178. package/dist/removeSpaces-CWIvhZHg.cjs.map +1 -0
  179. package/dist/rzl-utils.global.js +20 -9
  180. package/dist/safeJsonParse-BP38mwlj.js +184 -0
  181. package/dist/safeJsonParse-BP38mwlj.js.map +1 -0
  182. package/dist/safeJsonParse-Sms2CJf4.cjs +208 -0
  183. package/dist/safeJsonParse-Sms2CJf4.cjs.map +1 -0
  184. package/dist/safeStableStringify-CJtP89qn.cjs +106 -0
  185. package/dist/safeStableStringify-CJtP89qn.cjs.map +1 -0
  186. package/dist/safeStableStringify-CXOZ9Ub8.js +88 -0
  187. package/dist/safeStableStringify-CXOZ9Ub8.js.map +1 -0
  188. package/dist/strings/index.cjs +79 -81
  189. package/dist/strings/index.cjs.map +1 -0
  190. package/dist/strings/index.d.cts +12 -0
  191. package/dist/strings/index.d.ts +10 -775
  192. package/dist/strings/index.js +62 -14
  193. package/dist/strings/index.js.map +1 -0
  194. package/dist/tailwind/index.cjs +19 -47
  195. package/dist/tailwind/index.d.cts +12 -0
  196. package/dist/tailwind/index.d.ts +11 -712
  197. package/dist/tailwind/index.js +10 -12
  198. package/dist/tailwind-B2ssevxq.js +199 -0
  199. package/dist/tailwind-B2ssevxq.js.map +1 -0
  200. package/dist/tailwind-CHIx9uxu.cjs +247 -0
  201. package/dist/tailwind-CHIx9uxu.cjs.map +1 -0
  202. package/dist/toStringArrayUnRecursive-C4zYCja7.cjs +51 -0
  203. package/dist/toStringArrayUnRecursive-C4zYCja7.cjs.map +1 -0
  204. package/dist/toStringArrayUnRecursive-DJGtPsFb.js +39 -0
  205. package/dist/toStringArrayUnRecursive-DJGtPsFb.js.map +1 -0
  206. package/dist/urls/index.cjs +130 -57
  207. package/dist/urls/index.cjs.map +1 -0
  208. package/dist/urls/index.d.cts +737 -0
  209. package/dist/urls/index.d.ts +699 -708
  210. package/dist/urls/index.js +122 -26
  211. package/dist/urls/index.js.map +1 -0
  212. package/package.json +203 -194
  213. package/dist/chunk-2AFQ33D3.cjs +0 -64
  214. package/dist/chunk-2CYDJVGM.js +0 -246
  215. package/dist/chunk-2MW4JDQ2.cjs +0 -598
  216. package/dist/chunk-2VTDXC3N.cjs +0 -1825
  217. package/dist/chunk-44XX2P34.js +0 -209
  218. package/dist/chunk-4YLBKLGS.cjs +0 -18
  219. package/dist/chunk-566CXQW7.cjs +0 -560
  220. package/dist/chunk-57EPKYID.cjs +0 -397
  221. package/dist/chunk-5MGEC3YG.js +0 -63
  222. package/dist/chunk-6EF52423.cjs +0 -249
  223. package/dist/chunk-6SCOKU3S.js +0 -109
  224. package/dist/chunk-6VUXD3CF.js +0 -119
  225. package/dist/chunk-7B76BSNK.cjs +0 -118
  226. package/dist/chunk-7Y6I2DSU.cjs +0 -101
  227. package/dist/chunk-A7S7E2EE.cjs +0 -308
  228. package/dist/chunk-AJZ6PMMZ.js +0 -16
  229. package/dist/chunk-AXGBL2IO.cjs +0 -251
  230. package/dist/chunk-B4TC6FBV.cjs +0 -678
  231. package/dist/chunk-BAV5T2E3.cjs +0 -15
  232. package/dist/chunk-BKIJBNIE.js +0 -21
  233. package/dist/chunk-BNIMTFK5.js +0 -59
  234. package/dist/chunk-BXW7YXB7.js +0 -1823
  235. package/dist/chunk-CFYZC4S6.js +0 -53
  236. package/dist/chunk-CSG4SCL3.js +0 -1587
  237. package/dist/chunk-CWQW7AKK.js +0 -676
  238. package/dist/chunk-DVMHRLKP.cjs +0 -16
  239. package/dist/chunk-EN7LVZBZ.js +0 -548
  240. package/dist/chunk-EV4Y7HCY.cjs +0 -26
  241. package/dist/chunk-F66VDYIZ.cjs +0 -18
  242. package/dist/chunk-FLJX37EL.cjs +0 -30
  243. package/dist/chunk-GKC3UDMC.cjs +0 -1623
  244. package/dist/chunk-H65I3GRZ.cjs +0 -106
  245. package/dist/chunk-HHYWB7VZ.js +0 -24
  246. package/dist/chunk-HNGGISFL.cjs +0 -65
  247. package/dist/chunk-HNSQAVSZ.cjs +0 -35
  248. package/dist/chunk-HSP6IWZK.js +0 -17
  249. package/dist/chunk-IDZS7J6T.js +0 -242
  250. package/dist/chunk-JS6R55VL.js +0 -302
  251. package/dist/chunk-JZVT5FK7.js +0 -232
  252. package/dist/chunk-KHO2SBNA.cjs +0 -16
  253. package/dist/chunk-KIDJCMNJ.js +0 -33
  254. package/dist/chunk-KOLEURVT.cjs +0 -38
  255. package/dist/chunk-L4V53MQK.cjs +0 -269
  256. package/dist/chunk-L5RDAVVH.js +0 -14
  257. package/dist/chunk-NODTV4F3.js +0 -16
  258. package/dist/chunk-NYK5K3V2.cjs +0 -211
  259. package/dist/chunk-ODUO3RTL.cjs +0 -113
  260. package/dist/chunk-ONZFBJVW.js +0 -14
  261. package/dist/chunk-PFXCTE37.js +0 -28
  262. package/dist/chunk-PPST7QAQ.js +0 -587
  263. package/dist/chunk-Q5IMYDFL.cjs +0 -33
  264. package/dist/chunk-QFFBIOJ4.js +0 -31
  265. package/dist/chunk-QNKGP5DY.js +0 -14
  266. package/dist/chunk-RRQHMOPE.cjs +0 -19
  267. package/dist/chunk-RU5OSRBU.js +0 -95
  268. package/dist/chunk-SDMPEJ4F.js +0 -35
  269. package/dist/chunk-SYNL5IKP.js +0 -115
  270. package/dist/chunk-TCDOWZQE.js +0 -16
  271. package/dist/chunk-TQPGXGKB.cjs +0 -123
  272. package/dist/chunk-TULOI4GL.js +0 -370
  273. package/dist/chunk-UBHCP4N5.cjs +0 -36
  274. package/dist/chunk-UCHF3M34.cjs +0 -56
  275. package/dist/chunk-UDA26MCU.cjs +0 -16
  276. package/dist/chunk-V3C4FYZL.cjs +0 -18
  277. package/dist/chunk-VAAHZFBF.js +0 -32
  278. package/dist/chunk-VJDDGRIK.cjs +0 -16
  279. package/dist/chunk-WVSPXFTY.js +0 -14
  280. package/dist/chunk-WYP76WXB.js +0 -101
  281. package/dist/chunk-YDE4ZBB7.cjs +0 -237
  282. package/dist/chunk-YKQEOO7C.cjs +0 -23
  283. package/dist/chunk-YSZC56SZ.js +0 -264
  284. package/dist/chunk-YWHHVDT4.js +0 -13
  285. package/dist/index.d.ts +0 -24
  286. package/dist/isPlainObject-DTJVV2Kf.d.ts +0 -536
@@ -0,0 +1,1716 @@
1
+ /*!
2
+ * ========================================================================
3
+ * @rzl-zone/utils-js
4
+ * ------------------------------------------------------------------------
5
+ * Version: `3.12.1-beta.1`
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 { AndArr, AnyFunction, Extends, FixNeverArrayRecursive, IfExtends, IfNotExtends, IntlObjects, IsAny, KeepNull, KeepUndef, NormalizeEmptyArraysRecursive, Nullish, NumberRangeUnion, OrArr, Prettify, RemoveEmptyArrayElements, TypedArray, WebApiObjects } from "@rzl-zone/ts-types-plus";
12
+ type NormalizeInputToNumberArrayUnRecursive<T> = T extends string | bigint | boolean | number | Nullish ? T : HasNonNumberLikeNonNullish<T>;
13
+ /** Detects whether `T` contains any number-like type (`string | number | bigint`).
14
+ *
15
+ * @template T Input type.
16
+ * @returns `true` if `T` contains number-like, otherwise `false`.
17
+ */
18
+ type HasNumberLike<T> = [Extract<T, string | bigint | number>] extends [never] ? false : true;
19
+ /** Detects whether `T` contains a string type.
20
+ *
21
+ * - Useful for identifying values that may fail parsing to number (`undefined` when `R=false`).
22
+ *
23
+ * @template T Input type.
24
+ * @returns `true` if `T` contains `string`, otherwise `false`.
25
+ */
26
+ type HasString<T> = [Extract<T, string>] extends [never] ? false : true;
27
+ /** Detects whether `T` contains non-number-like, non-nullish values (`objects`, `arrays`, `symbols`, `functions`, `etc`.).
28
+ *
29
+ * @template T Input type.
30
+ * @returns `true` if such types exist, otherwise `false`.
31
+ */
32
+ type HasNonNumberLikeNonNullish<T> = [Exclude<T, string | bigint | number | Nullish>] extends [never] ? false : true;
33
+ /** -------------------------------------------------------
34
+ * * ***Computes the return type of {@link toNumberArrayUnRecursive|`toNumberArrayUnRecursive`}
35
+ * based on input type `T` and option `R`.***
36
+ * -------------------------------------------------------
37
+ *
38
+ * **Behavior:**
39
+ * - If `R = true` (`removeInvalidValueNumber: true`):
40
+ * - If `T` is only `null | undefined` ➔ returns `[]`.
41
+ * - If `T` contains number-like (`string | number | bigint`) ➔ returns `number[]`.
42
+ * - Otherwise ➔ returns `[]`.
43
+ * - If `R = false` (`removeInvalidValueNumber: false`):
44
+ * - Preserves `null[]` or `undefined[]` if input is purely nullish.
45
+ * - Otherwise returns an array of:
46
+ * - `number` if `T` includes number-like.
47
+ * - `undefined` if parsing fails (string or invalid non-number-like).
48
+ * - Original `null` / `undefined` from input.
49
+ * @template T Input element type.
50
+ * @template R Flag indicating whether invalid values should be removed (`true`) or kept (`false`).
51
+ *
52
+ */
53
+ type ToNumberArrayUnRecursiveReturn<T, R extends boolean> = R extends true ? [Exclude<T, null | undefined>] extends [never] ? [] : HasNumberLike<T> extends true ? number[] : [] : [Exclude<T, null>] extends [never] ? null[] : [Exclude<T, undefined>] extends [never] ? undefined[] : Array<(HasNumberLike<T> extends true ? number : never) | (HasString<T> extends true ? undefined : never) | (HasNonNumberLikeNonNullish<T> extends true ? undefined : never) | KeepNull<T> | KeepUndef<T>>;
54
+ /** -------------------------------------------------------
55
+ * * ***Options for {@link toNumberArrayUnRecursive|`toNumberArrayUnRecursive`}.***
56
+ * -------------------------------------------------------
57
+ *
58
+ * @template T Flag indicating whether invalid values should be removed.
59
+ */
60
+ type ToNumberArrayUnRecursiveOptions<T extends boolean> = {
61
+ /** If true, removes invalid number values (`NaN`, non-numeric strings, `null`, `undefined`) from the result, defaultValue: `true`.
62
+ *
63
+ * @default true
64
+ */
65
+ removeInvalidValueNumber?: T;
66
+ };
67
+ /** -------------------------------------------------------
68
+ * * ***Utility: `toNumberArrayUnRecursive`.***
69
+ * -------------------------------------------------------
70
+ * **Converts a flat array of strings, numbers, nulls, or undefineds into numbers.**
71
+ * - **Behavior:**
72
+ * - Only supports **flat arrays** (non-recursive).
73
+ * - Valid inputs: `string`, `number`, `null`, `undefined`.
74
+ * - `BigInt` will be converted to `number`.
75
+ * - Other values ➔ coerced into `undefined`.
76
+ * - Invalid values can be **removed** (`removeInvalidValueNumber: true`) or **kept** (`false`).
77
+ * - **ℹ️ Note:**
78
+ * - *For recursive / nested arrays, use ***`toNumberDeep` utility function*** instead.*
79
+ * @template T - Element type of the input array.
80
+ * @template R - Whether invalid values should be removed (`true`) or kept (`false`).
81
+ * @param {Array<T> | readonly T[] | null | undefined} [array] - The array to convert, returns `undefined` if not an array.
82
+ * @param {ToNumberArrayUnRecursiveOptions<RemoveInvalidValue>} [options] - Options to control transformation behavior, defaults to `{ removeInvalidValueNumber: true }`.
83
+ * @returns {ToNumberArrayUnRecursiveReturn<NormalizeInput<T>, RemoveInvalidValue>} A new array of string representations, with invalid values optionally removed.
84
+ * @example
85
+ * ```ts
86
+ * toNumberArrayUnRecursive(['1', 2, '3']);
87
+ * // ➔ [1, 2, 3]
88
+ * toNumberArrayUnRecursive([1, null, undefined, 'abc']);
89
+ * // ➔ [1]
90
+ * toNumberArrayUnRecursive(['1', null, undefined, 'abc'], {
91
+ * removeInvalidValueNumber: false
92
+ * });
93
+ * // ➔ [1, null, undefined, undefined]
94
+ * toNumberArrayUnRecursive(null); // ➔ undefined
95
+ * toNumberArrayUnRecursive(undefined); // ➔ undefined
96
+ * toNumberArrayUnRecursive(1); // ➔ undefined
97
+ * ```
98
+ */
99
+ declare function toNumberArrayUnRecursive(array?: null | undefined, options?: ToNumberArrayUnRecursiveOptions<boolean>): undefined;
100
+ declare function toNumberArrayUnRecursive(array?: Array<never>, options?: ToNumberArrayUnRecursiveOptions<boolean>): [];
101
+ declare function toNumberArrayUnRecursive<T, R extends boolean = true>(array?: Array<T> | readonly T[] | null, options?: ToNumberArrayUnRecursiveOptions<R>): ToNumberArrayUnRecursiveReturn<NormalizeInputToNumberArrayUnRecursive<T>, R>;
102
+ declare function toNumberArrayUnRecursive<T = unknown>(array?: T, options?: ToNumberArrayUnRecursiveOptions<boolean>): undefined;
103
+ /** Union of primitive types that can be safely converted to string. */
104
+ type AllowedToString = string | number | boolean | bigint;
105
+ /** Checks whether `T` contains any type that is allowed for conversion to string.
106
+ *
107
+ * - Returns `true` if `T` contains `string`, `number`, `boolean`, or `bigint`.
108
+ * - Otherwise returns `false`.
109
+ *
110
+ * @template T Input type to check.
111
+ */
112
+ type HasAllowed<T> = [Extract<T, AllowedToString>] extends [never] ? false : true;
113
+ /** Checks whether `T` contains any non-nullish value that is disallowed for conversion.
114
+ *
115
+ * - Disallowed non-nullish types include `objects`, `arrays`, `symbols`, `functions`, `etc`.
116
+ * - Returns `true` if such types exist, otherwise `false`.
117
+ * @template T Input type to check.
118
+ */
119
+ type HasDisallowedNonNullish<T> = [Exclude<T, AllowedToString | Nullish>] extends [never] ? false : true;
120
+ /** -------------------------------------------------------
121
+ * * ***Computes the return type of {@link toStringArrayUnRecursive|`toStringArrayUnRecursive`}
122
+ * based on input type `T` and option `R`.***
123
+ * -------------------------------------------------------
124
+ *
125
+ * **Behavior:**
126
+ * - If `R = true` (`removeInvalidValue = true`):
127
+ * - If `T` contains any allowed values ➔ `string[]`.
128
+ * - If `T` contains only nullish or disallowed types ➔ `[]`.
129
+ *
130
+ * - If `R = false` (`removeInvalidValue = false`):
131
+ * - Include `string` if `T` has allowed values.
132
+ * - Include `undefined` if `T` has disallowed non-nullish values.
133
+ * - Preserve `null` and `undefined` from original `T`.
134
+ * @template T Input element type.
135
+ * @template R Flag indicating whether invalid values should be removed (`true`) or kept (`false`).
136
+ */
137
+ type ToStringArrayUnRecursiveReturn<T, R extends boolean> = R extends true ? HasAllowed<T> extends true ? string[] : [] : Array<(HasAllowed<T> extends true ? string : never) | (HasDisallowedNonNullish<T> extends true ? undefined : never) | KeepNull<T> | KeepUndef<T>>;
138
+ /** -------------------------------------------------------
139
+ * * ***Options for {@link toStringArrayUnRecursive|`toStringArrayUnRecursive`}.***
140
+ * -------------------------------------------------------
141
+ *
142
+ * @template T Flag indicating whether invalid values should be removed.
143
+ */
144
+ type ToStringArrayUnRecursiveOptions<T extends boolean> = {
145
+ /** If true, removes invalid values (`null` and `undefined`) from the output, defaultValue: `true`.
146
+ *
147
+ * @default true
148
+ */
149
+ removeInvalidValue?: T;
150
+ };
151
+ /** ---------------------------------------------
152
+ * * ***Utility: `toStringArrayUnRecursive`.***
153
+ * ---------------------------------------------
154
+ * **Converts all values in a flat array into string representations.**
155
+ * - **Behavior:**
156
+ * - Only processes **flat arrays** (non-recursive).
157
+ * - Supports input values: `string`, `number`, `bigint`, `boolean`,
158
+ * `null`, `undefined`.
159
+ * - Invalid values (`null` and `undefined`) can be **removed** or **kept**
160
+ * depending on the option.
161
+ * - Other unsupported types will be converted to `undefined` (and removed
162
+ * if `removeInvalidValue=true`).
163
+ * - **ℹ️ Note:**
164
+ * - _For recursive / nested arrays, use ***`toStringDeep` utility function*** instead._
165
+ * @template T - Element type of the input array.
166
+ * @template R - Whether invalid values should be removed (`true`) or kept (`false`).
167
+ * @param {Array<string | number | bigint | boolean | null | undefined> | null | undefined} [array] - The array to convert, returns `undefined` if not an array.
168
+ * @param {ToStringArrayUnRecursiveOptions<RemoveInvalidValue>} [options] - Options to control transformation behavior, defaults to `{ removeInvalidValue: true }`.
169
+ * @param {RemoveInvalidValue extends true ? boolean : boolean} [options.removeInvalidValue=true] Whether to remove invalid values (`null`, `undefined`, or unsupported types), default: `true`.
170
+ * @returns {RemoveInvalidValue extends true ? string[] : (string | null | undefined)[]} A new array of string representations, with invalid values optionally removed.
171
+ * @example
172
+ * ```ts
173
+ * // Convert numbers and strings
174
+ * toStringArrayUnRecursive([1, 2, '3']);
175
+ * // ➔ ['1', '2', '3']
176
+ * // Remove null and undefined
177
+ * toStringArrayUnRecursive([1, null, undefined, 'abc'], {
178
+ * removeInvalidValue: true
179
+ * });
180
+ * // ➔ ['1', 'abc']
181
+ * // Keep null and undefined
182
+ * toStringArrayUnRecursive([1, null, undefined, 'abc'], {
183
+ * removeInvalidValue: false
184
+ * });
185
+ * // ➔ ['1', null, undefined, 'abc']
186
+ * // Convert boolean and bigint
187
+ * toStringArrayUnRecursive([true, false, 10n]);
188
+ * // ➔ ['true', 'false', '10']
189
+ * // Not an array ➔ returns undefined
190
+ * toStringArrayUnRecursive(null);
191
+ * // ➔ undefined
192
+ * toStringArrayUnRecursive(undefined);
193
+ * // ➔ undefined
194
+ * toStringArrayUnRecursive(1);
195
+ * // ➔ undefined
196
+ * toStringArrayUnRecursive("string");
197
+ * // ➔ undefined
198
+ * ```
199
+ */
200
+ declare function toStringArrayUnRecursive(array?: undefined | null, options?: ToStringArrayUnRecursiveOptions<boolean>): undefined;
201
+ declare function toStringArrayUnRecursive(array?: Array<never>, options?: ToStringArrayUnRecursiveOptions<boolean>): [];
202
+ declare function toStringArrayUnRecursive<T, R extends boolean = true>(array?: Array<T> | readonly T[] | null, options?: ToStringArrayUnRecursiveOptions<R>): ToStringArrayUnRecursiveReturn<T, R>;
203
+ declare function toStringArrayUnRecursive<T = unknown>(array?: T, options?: ToStringArrayUnRecursiveOptions<boolean>): undefined;
204
+ type ResUnFTN<Force extends false | "stringOrNumber" | "primitives" | "all" = false> = Force extends "all" ? Array<unknown[] | Record<string, unknown> | string> : Force extends "stringOrNumber" ? Array<string | boolean | bigint | symbol | null | undefined | Record<string, unknown> | AnyFunction | unknown[] | Date | RegExp | Map<unknown, unknown> | Set<unknown> | Promise<unknown>> : Force extends "primitives" ? Array<string | symbol | Record<string, unknown> | AnyFunction | unknown[] | Date | RegExp | Map<unknown, unknown> | Set<unknown> | Promise<unknown>> : Force extends false ? Array<string | number | bigint | boolean | symbol | RegExp | Record<string, unknown> | AnyFunction | Date | Map<unknown, unknown> | Set<unknown> | Promise<unknown> | unknown[] | null | undefined> : unknown[];
205
+ type ResFTN<Force extends false | "stringOrNumber" | "primitives" | "all" = false> = Force extends "all" ? Array<string | Record<string, unknown>> : Force extends "stringOrNumber" ? Array<string | boolean | bigint | symbol | null | undefined | Record<string, unknown> | AnyFunction | Date | RegExp | Promise<unknown>> : Force extends "primitives" ? Array<string | symbol | RegExp | Record<string, unknown> | AnyFunction | Date | Promise<unknown>> : Force extends false ? Array<string | number | bigint | boolean | symbol | RegExp | Record<string, unknown> | AnyFunction | Date | Promise<unknown> | null | undefined> : unknown[];
206
+ type DedupeResult<Force extends ForceToStringOptions = false, FTN extends boolean = false> = FTN extends false ? ResUnFTN<Force> : ResFTN<Force>;
207
+ type ForceToStringOptions = false | "stringOrNumber" | "primitives" | "all";
208
+ type DedupeArrayOptions<F extends ForceToStringOptions, Fl extends boolean> = {
209
+ /** Enables string conversion for comparison, default is `false`.
210
+ *
211
+ * @default false
212
+ * @type {ForceToStringOptions}
213
+ */
214
+ forceToString?: F;
215
+ /** If true, deeply flattens `Arrays`, `Maps`, and `Sets` before deduplication, default is `false`.
216
+ *
217
+ * @default false
218
+ */
219
+ flatten?: Fl;
220
+ };
221
+ /** ----------------------------------------------------------
222
+ * * ***Utility: `dedupeArray`.***
223
+ * ---------------------------------------------
224
+ * **Deduplicates values in an array (with optional flattening and deep stringification).**
225
+ * - Supports various modes for converting values to strings before deduplication:
226
+ * - `"stringOrNumber"`: Converts strings and numbers to strings.
227
+ * - `"primitives"`: Converts all primitives (string, number, boolean, bigint, null, undefined, NaN) to strings.
228
+ * - `"all"`: Converts all values (primitives, objects, Maps, Sets, Symbols, RegExp, Dates, Errors, Promises, functions)
229
+ * to strings, including nested object properties.
230
+ * - `false` (default): No conversion applied.
231
+ * - Options:
232
+ * - `forceToString`: Enables string conversion for comparison, default is `false`.
233
+ * - `flatten`: If true, deeply flattens arrays, Maps, and Sets before deduplication, default is `false`.
234
+ * @template ForceToString - `forceToString` mode.
235
+ * @template Flattening - `flatten` mode.
236
+ * @param {unknown[]} inputArray - The array to deduplicate, can be deeply nested and contain any mix of types.
237
+ * @param {DedupeArrayOptions<ForceToString, Flattening>|undefined} [options] - Options to control string conversion.
238
+ * @returns {DedupeResult<ForceToString, Flattening>} Deduplicated array with optional transformations.
239
+ * @throws **{@link TypeError | `TypeError`}** if the input is not an array, or options is not an object, or if `forceToString` is invalid.
240
+ * @example
241
+ * ```ts
242
+ * dedupeArray(["apple", "banana", "apple"]);
243
+ * // ➔ ["apple", "banana"]
244
+ * dedupeArray([[1, 2], [1, 2]], { flatten: true });
245
+ * // ➔ [1, 2]
246
+ * dedupeArray([new Set([1, 2]), new Set([2, 3])], { flatten: true });
247
+ * // ➔ [1, 2, 3]
248
+ * dedupeArray([1, "1", 2, "2"], {
249
+ * forceToString: "stringOrNumber"
250
+ * }); // ➔ ["1", "2"]
251
+ * dedupeArray([true, "true", false, undefined], {
252
+ * forceToString: "primitives"
253
+ * }); // ➔ ["true", "false", "undefined"]
254
+ * dedupeArray([1, "1", { a: 1 }], {
255
+ * forceToString: "all"
256
+ * }); // ➔ ["1", { a: "1" }]
257
+ * dedupeArray([1, 1, [2, 2, [3, 3]]]);
258
+ * // ➔ [1, [2, [3]]]
259
+ * dedupeArray([null, undefined, null]);
260
+ * // ➔ [null, undefined]
261
+ * dedupeArray([[], [[]], [[[]]], [[]], [[[]]]]);
262
+ * // ➔ [[], [[]], [[[]]]]
263
+ * const fn = () => 1;
264
+ * dedupeArray([fn, fn, () => 1]);
265
+ * // ➔ [fn, () => 1] cause: ref () => 1 and fn is different but ref const `fn` and `fn` is same ref.
266
+ * dedupeArray([Symbol("x"), Symbol("x")]);
267
+ * // ➔ [Symbol("x")] (symbols are same by identity, so dedupe
268
+ * dedupeArray([NaN, NaN, 1, "1"]);
269
+ * // ➔ [NaN, 1, "1"]
270
+ * dedupeArray([NaN, NaN, 1, "1"], {
271
+ * forceToString: "primitives"
272
+ * }); // ➔ ["NaN", "1"]
273
+ * dedupeArray([new Date("2025-01-01"), new Date("2025-01-01")]);
274
+ * // ➔ [Date("2025-01-01")] (same time, deduped)
275
+ * dedupeArray([new Date("2025-01-01"), new Date("2025-01-01")], {
276
+ * forceToString: "all"
277
+ * }); // ➔ ["2025-01-01T00:00:00.000Z"]
278
+ * dedupeArray([/abc/, /abc/], {
279
+ * forceToString: "all"
280
+ * }); // ➔ ["/abc/"]
281
+ * dedupeArray([new Map(), new Set(), new Error("err")], {
282
+ * forceToString: "all"
283
+ * }); // ➔ ["[object Map]", "[object Set]", "Error: err"]
284
+ * dedupeArray([Promise.resolve(1), Promise.resolve(1)], {
285
+ * forceToString: "all"
286
+ * }); // ➔ ["[object Promise]"]
287
+ * dedupeArray([{ a: 1 }, { a: 1 }, { a: 2 }], {
288
+ * forceToString: "primitives"
289
+ * }); // ➔ [{ a: "1" }, { a: "2" }]
290
+ * dedupeArray([{ a: { b: 1 } }, { a: { b: 1 } }], {
291
+ * forceToString: "all"
292
+ * }); // ➔ [{ a: { b: "1" } }]
293
+ * dedupeArray("not an array");
294
+ * // ➔ Throws TypeError
295
+ * dedupeArray([1, 2, 3], {
296
+ * forceToString: "invalid"
297
+ * }); // ➔ Throws TypeError
298
+ * ```
299
+ */
300
+ declare const dedupeArray: <ForceToString extends ForceToStringOptions = false, Flattening extends boolean = false>(inputArray: unknown[], options?: DedupeArrayOptions<ForceToString, Flattening>) => DedupeResult<ForceToString, Flattening>;
301
+ type ExcludeNil<T> = Exclude<T, null | undefined>;
302
+ /** ----------------------------------------------------------
303
+ * * ***Element extractor***
304
+ * ----------------------------------------------------------
305
+ */
306
+ type ElementOf<A extends readonly unknown[]> = A extends readonly (infer U)[] ? U : never;
307
+ /** ----------------------------------------------------------
308
+ * * ***Compute `FilterNilArray`***
309
+ * ----------------------------------------------------------
310
+ *
311
+ * for a tuple/array A by using the element type (without null|undefined).
312
+ */
313
+ type FilterNilArrayFromTuple<A extends readonly unknown[]> = FilterNilArray<ExcludeNil<ElementOf<A>>>;
314
+ /** ----------------------------------------------------------
315
+ * ***Preserve `mutability`: if A is mutable (extends unknown[]), keep B; otherwise make B readonly***.
316
+ */
317
+ type PreserveMutability<A extends readonly unknown[], B> = A extends unknown[] ? B : Readonly<B>;
318
+ type IsDeepEmptyArray<T> = T extends readonly [] ? true : T extends readonly (infer U)[] ? IsDeepEmptyArray<U> : false;
319
+ type FilterNilRecursive<T> = T extends readonly (infer U)[] ? T extends (infer U)[] ? FilterNilRecursive<ExcludeEmptyArray<U>>[] : readonly FilterNilRecursive<ExcludeEmptyArray<U>>[] : Exclude<T, null | undefined>;
320
+ type ExcludeEmptyArray<T> = T extends [] ? never : T;
321
+ type NormalizerArrays<T> = NormalizeEmptyArraysRecursive<RemoveEmptyArrayElements<FilterNilRecursive<T[]>>>;
322
+ type FilterNilArray<T> = IsDeepEmptyArray<NormalizerArrays<T>> extends true ? [] : FixNeverArrayRecursive<NormalizerArrays<T>>;
323
+ /** ----------------------------------------------------------
324
+ * * ***Utility: `filterNilArray`.***
325
+ * ---------------------------------------------
326
+ * **Removes `null` and `undefined` values from an array, including nested arrays.**
327
+ * - **Behavior:**
328
+ * - Returns `undefined` if the input is explicitly `undefined` or `null`.
329
+ * - Returns `[]` if input is empty or all elements are removed after filtering.
330
+ * - Recursively filters nested arrays while preserving structure.
331
+ * - Ensures proper type inference for safer downstream operations.
332
+ * @template A - The type of elements in the array.
333
+ * @param {T[]|null|undefined} input - The array to be filtered.
334
+ * @returns {T[] | undefined} A new array with `null` and `undefined` values removed,
335
+ * or `undefined` if the input is explicitly `undefined` or `null`.
336
+ * @example
337
+ * ```ts
338
+ * filterNilArray([1, null, 2, undefined, 3]);
339
+ * // ➔ [1, 2, 3]
340
+ * filterNilArray([null, undefined]);
341
+ * // ➔ []
342
+ * filterNilArray(undefined);
343
+ * // ➔ undefined
344
+ * filterNilArray(null);
345
+ * // ➔ undefined
346
+ * filterNilArray([]); // or
347
+ * filterNilArray([[[]]]); // or
348
+ * filterNilArray([[[],undefined,null]]);
349
+ * // ➔ []
350
+ * filterNilArray([1, [null, 2, [undefined, 3]]]);
351
+ * // ➔ [1, [2, [3]]]
352
+ * ```
353
+ */
354
+ declare function filterNilArray(input: null | undefined): undefined;
355
+ declare function filterNilArray<A extends readonly unknown[]>(input: A): PreserveMutability<A, FilterNilArrayFromTuple<A>>;
356
+ declare function filterNilArray<A extends readonly unknown[]>(input: A | null | undefined): PreserveMutability<A, FilterNilArrayFromTuple<A>> | undefined;
357
+ declare function filterNilArray<A>(input: (A | null | undefined)[] | null | undefined): FilterNilArray<A> | undefined;
358
+ declare function filterNilArray(input: readonly unknown[] | null | undefined): unknown[] | undefined;
359
+ declare function filterNilArray(input: unknown[]): unknown[];
360
+ /** --------------------------------------------
361
+ * * ***Utility: `toBooleanContent`.***
362
+ * ---------------------------------------------
363
+ * **Converts a given value into a boolean (***strict***).**
364
+ * - **This is stricter than normal JS coercion:**
365
+ * - `null` and `undefined` return `false`.
366
+ * - Empty strings return `false`, non-empty strings return `true`.
367
+ * - Numbers: `0` is `false`, others `true`.
368
+ * - Booleans returned as-is.
369
+ * - Arrays: `[]` is `false`, non-empty is `true`.
370
+ * - Objects: `{}` is `false`, object with keys is `true`.
371
+ * @param {*} value - The value to be converted.
372
+ * @returns {boolean} Return `true` if the value is considered non-empty, otherwise `false`.
373
+ * @example
374
+ * toBooleanContent(null); // ➔ false
375
+ * toBooleanContent(undefined); // ➔ false
376
+ * toBooleanContent(""); // ➔ false
377
+ * toBooleanContent(" "); // ➔ false
378
+ * toBooleanContent("abc"); // ➔ true
379
+ * toBooleanContent(" asd "); // ➔ true
380
+ * toBooleanContent(0); // ➔ false
381
+ * toBooleanContent(42); // ➔ true
382
+ * toBooleanContent(NaN); // ➔ true
383
+ * toBooleanContent([]); // ➔ false
384
+ * toBooleanContent([1]); // ➔ true
385
+ * toBooleanContent({}); // ➔ false
386
+ * toBooleanContent({ a: 1 }); // ➔ true
387
+ * toBooleanContent({[Symbol("key")]: 123}); // ➔ false
388
+ */
389
+ declare const toBooleanContent: (value: unknown) => boolean;
390
+ /** -------------------------------------------------
391
+ * * ***Utility: `toBooleanContentDeep`.***
392
+ * --------------------------------------------------
393
+ * **This function does a deep inspection to determine if the input
394
+ * contains any meaningful / non-empty value.**
395
+ * @description
396
+ * It is stricter than JavaScript's normal truthy checks because it looks *inside*
397
+ * nested arrays & objects (recursively checks).
398
+ * - **Rules:**
399
+ * - `null` and `undefined` return `false`
400
+ * - Empty strings `""` return `false`
401
+ * - `0` returns `false`
402
+ * - Empty arrays `[]` or empty objects `{}` return `false`
403
+ * - Checks deeply nested arrays/objects — if any value inside is "non-empty", returns `true`
404
+ * @param {*} value - The value to check.
405
+ * @returns {boolean} Return `true` if the value or anything nested inside is non-empty, otherwise `false`.
406
+ * @example
407
+ * toBooleanContentDeep(null); // ➔ false
408
+ * toBooleanContentDeep(""); // ➔ false
409
+ * toBooleanContentDeep(0); // ➔ false
410
+ * toBooleanContentDeep([]); // ➔ false
411
+ * toBooleanContentDeep({}); // ➔ false
412
+ * toBooleanContentDeep([[], {}]); // ➔ false
413
+ * toBooleanContentDeep("abc"); // ➔ true
414
+ * toBooleanContentDeep(42); // ➔ true
415
+ * toBooleanContentDeep(NaN); // ➔ true
416
+ * toBooleanContentDeep([0, "", 5]); // ➔ true
417
+ * toBooleanContentDeep([NaN, "", 0]); // ➔ true
418
+ * toBooleanContentDeep([0, "", null]); // ➔ false
419
+ * toBooleanContentDeep({ a: 0 }); // ➔ false
420
+ * toBooleanContentDeep({ a: 1 }); // ➔ true
421
+ * toBooleanContentDeep({ a: { b: [] }}); // ➔ false
422
+ * toBooleanContentDeep({ a: { b: "x" }}); // ➔ true
423
+ * toBooleanContentDeep({[Symbol("key")]: 123}); // ➔false
424
+ */
425
+ declare const toBooleanContentDeep: (value: unknown) => boolean;
426
+ type ToBooleanExplicitOptions = {
427
+ /** Whether string comparison ignores case, _defaultValue: `false`_.
428
+ *
429
+ * @default false
430
+ */
431
+ caseInsensitive?: boolean;
432
+ /** Whether to trim whitespace before comparison, _defaultValue: `true`_.
433
+ *
434
+ * @default true
435
+ */
436
+ trimString?: boolean;
437
+ /** Whether to consider the string `"indeterminate"` as `true`, _defaultValue: `false`_.
438
+ *
439
+ * @default false
440
+ */
441
+ includeIndeterminate?: boolean;
442
+ };
443
+ /** --------------------------------------------
444
+ * * ***Utility: `toBooleanExplicit`.***
445
+ * ---------------------------------------------
446
+ * **Converts a value into a strict boolean.**
447
+ * - **Behavior:**
448
+ * - It supports various common string representations of truthy values,
449
+ * including `"true"`, `"on"`, `"yes"`, `"1"`, the number `1`, the boolean `true`,
450
+ * and optionally the string `"indeterminate"` if enabled.
451
+ * - **ℹ️ Note:**
452
+ * - Any other value, including `undefined`, `null`, `false`, `0`, and
453
+ * unrecognized strings will return `false`.
454
+ * - Supports optional `caseInsensitive` and `trimString` to customize
455
+ * string normalization.
456
+ * @param {*} value - The value to convert.
457
+ * @param {ToBooleanExplicitOptions} [options] - Options for conversion behavior.
458
+ * @param {ToBooleanExplicitOptions["caseInsensitive"]} [options.caseInsensitive=false] - Whether string comparison ignores case, default: `false`.
459
+ * @param {ToBooleanExplicitOptions["trimString"]} [options.trimString=true] - Whether to trim whitespace before comparison, default: `true`.
460
+ * @param {ToBooleanExplicitOptions["includeIndeterminate"]} [options.includeIndeterminate=false] - If `true`, the string `"indeterminate"` is considered a truthy value, defaults to `false`.
461
+ * @returns {boolean} Return `true` if the value matches a truthy representation, otherwise `false`.
462
+ * @throws **{@link TypeError | `TypeError`}** if any option provided is not a boolean.
463
+ * @example
464
+ * toBooleanExplicit(1);
465
+ * // ➔ true
466
+ * toBooleanExplicit(true);
467
+ * // ➔ true
468
+ * toBooleanExplicit("on");
469
+ * // ➔ true
470
+ * toBooleanExplicit("1");
471
+ * // ➔ true
472
+ * toBooleanExplicit(0);
473
+ * // ➔ false
474
+ * toBooleanExplicit("off");
475
+ * // ➔ false
476
+ * toBooleanExplicit("Yes");
477
+ * // ➔ false (caseInsensitive is false by default)
478
+ * toBooleanExplicit(" yes ");
479
+ * // ➔ true (whitespace trimmed by default)
480
+ * toBooleanExplicit("YES", { caseInsensitive: true });
481
+ * // ➔ true
482
+ * toBooleanExplicit("YES", { caseInsensitive: false });
483
+ * // ➔ false
484
+ * toBooleanExplicit(" YES ", { trimString: false });
485
+ * // ➔ false (whitespace not trimmed)
486
+ * toBooleanExplicit(" YES ", { trimString: true, caseInsensitive: true });
487
+ * // ➔ true
488
+ * toBooleanExplicit(" YES ", { trimString: true, caseInsensitive: false });
489
+ * // ➔ false
490
+ * toBooleanExplicit("indeterminate");
491
+ * // ➔ false (default)
492
+ * toBooleanExplicit("indeterminate", { includeIndeterminate: true });
493
+ * // ➔ true
494
+ */
495
+ declare const toBooleanExplicit: (value: unknown, options?: ToBooleanExplicitOptions) => boolean;
496
+ /** --------------------------------------------
497
+ * * ***Utility: `toBooleanLoose`.***
498
+ * ---------------------------------------------
499
+ * **Converts a given value into a boolean (loose).**
500
+ * - **This follows JavaScript's typical truthy/falsy rules with some tweaks:**
501
+ * - `null` and `undefined` return `false`.
502
+ * - Empty strings return `false`, non-empty strings return `true`.
503
+ * - Numbers: `0` is `false`, others `true`.
504
+ * - Booleans returned as-is.
505
+ * - Arrays: `[]` is `false`, non-empty is `true`.
506
+ * - Other objects: uses `Boolean(value)`, so `{}` is `true`.
507
+ * @param {*} value - The value to be converted.
508
+ * @returns {boolean} Return `true` if the value is truthy, otherwise `false`.
509
+ * @example
510
+ * toBooleanLoose(null); // ➔ false
511
+ * toBooleanLoose(""); // ➔ false
512
+ * toBooleanLoose("abc"); // ➔ true
513
+ * toBooleanLoose(0); // ➔ false
514
+ * toBooleanLoose(42); // ➔ true
515
+ * toBooleanLoose([]); // ➔ false
516
+ * toBooleanLoose([1]); // ➔ true
517
+ * toBooleanLoose({}); // ➔ true
518
+ * toBooleanLoose({ a: 1 }); // ➔ true
519
+ */
520
+ declare const toBooleanLoose: (value: unknown) => boolean;
521
+ /** -------------------------------------------------------------
522
+ * * ***Utility: `parseCurrencyString`.***
523
+ * ---------------------------------------------
524
+ * **Parses a human-friendly currency string into a JavaScript number.**
525
+ * - **Supports multi-locale formats:**
526
+ * - ***US:*** `"15,000.10"` ➔ `15300.10`.
527
+ * - ***Swiss:*** `"15'000.10"` ➔ `15300.10`.
528
+ * - ***French:*** `"15 000,10"` ➔ `15300.10`.
529
+ * - ***Indian:*** `"1,23,456.78"` ➔ `123456.78`.
530
+ * - ***European:*** `"151.000,10"` ➔ `151300.10`.
531
+ * - ***Compact:*** `"15300000,10"` ➔ `15300000.10`.
532
+ * - **Features:**
533
+ * - Strips symbols automatically: `"Rp"`, `"$"`, `"EUR"`, `etc`.
534
+ * - Handles bracket negatives: `"(15.000,10)"` ➔ `-15300.10`.
535
+ * - Normalizes decimal separator (last dot or comma).
536
+ * - Detects non-breaking spaces (`\u00A0`, `\u202F`) often in European data.
537
+ * - Fallback to `0` for empty, invalid, or non-numeric strings.
538
+ * - **How it parses internally:**
539
+ * 1. Removes all characters except digits, `.`, `,`, `'`, `space`,
540
+ * `\u00A0`, `\u202F`.
541
+ * 2. Detects bracket (...) as negative.
542
+ * 3. If Indian style (`1,23,456`) detected by multiple ,`\d{2}`, removes all commas.
543
+ * 4. Otherwise:
544
+ * - If multiple dots & no commas ➔ thousands: removes all `.`.
545
+ * - If multiple commas & no dots ➔ thousands: removes all `,`.
546
+ * - If mixed, treats last `,` or `.` as decimal.
547
+ * 5. Converts final decimal to `.` for JS float.
548
+ * - **Gotchas:**
549
+ * - If both `.` and `,` are present, last occurrence is used as decimal.
550
+ * - For strings like `"1.121.234,56"` ➔ decimal is `,`.
551
+ * - For `"1,121,234.56"` ➔ decimal is `.`.
552
+ * - For `"15300000,2121"` ➔ decimal becomes `.` internally.
553
+ * - **ℹ️ Note:**
554
+ * - You can use this function as a first step to **sanitize currency inputs**
555
+ * before storing into database or doing math.
556
+ * - Always pair this with your formatter for consistent output display.
557
+ * @param {string|null|undefined} input
558
+ * ***Any messy currency string, may contain:***
559
+ * * Currency symbols (`Rp`,`$`, `CHF`, `EUR`).
560
+ * * Thousands separators (`.`, `,`, `'`, `space`, `\u00A0`, `\u202F`).
561
+ * * Various decimal formats (`,` or `.`).
562
+ * * Bracket negative: `"(15.000,10)"`.
563
+ * @returns {number} JavaScript float representation, will return `0` for invalid, empty, or non-string input.
564
+ * @example
565
+ * ```ts
566
+ * parseCurrencyString("Rp 15.300.000,21");
567
+ * // ➔ 15300000.21
568
+ * parseCurrencyString("15 300 000,21");
569
+ * // ➔ 15300000.21
570
+ * parseCurrencyString("CHF 15'300'000.21");
571
+ * // ➔ 15300000.21
572
+ * parseCurrencyString("$15,300,000.21");
573
+ * // ➔ 15300000.21
574
+ * parseCurrencyString("(15.000,10)");
575
+ * // ➔ -15000.10
576
+ * parseCurrencyString("1,23,456.78");
577
+ * // ➔ 123456.78
578
+ * parseCurrencyString("15300000,2121");
579
+ * // ➔ 15300000.2121
580
+ * parseCurrencyString("USD 15 300 000.21");
581
+ * // ➔ 15300000.21
582
+ * parseCurrencyString("");
583
+ * // ➔ 0
584
+ * parseCurrencyString("abc");
585
+ * // ➔ 0
586
+ * ```
587
+ */
588
+ declare const parseCurrencyString: (input: string | null | undefined) => number;
589
+ /** ----------------------------------------------------------
590
+ * * ***Utility: `convertType`.***
591
+ * ---------------------------------------------
592
+ * **Converts a value from a string to its corresponding JavaScript primitive type.**
593
+ * - **Supported conversions for string inputs (case-insensitive, trimmed):**
594
+ * - `"true"` ➔ `true` (***boolean***).
595
+ * - `"false"` ➔ `false` (***boolean***).
596
+ * - `"null"` ➔ `null` (***null***).
597
+ * - `"yes"` ➔ `true` (***boolean***).
598
+ * - `"no"` ➔ `false` (***boolean***).
599
+ * - `"nan"` or `"NaN"` ➔ `NaN` (***number***).
600
+ * - `"undefined"` ➔ `undefined` (***undefined***).
601
+ * - Numeric strings with optional thousands separators (e.g. `"3,567,890.14"`) ➔ `3567890.14` ***as a `number` type***.
602
+ * - Strings containing only whitespace are converted to empty string `""`.
603
+ * - Non-string inputs are returned unchanged.
604
+ * - Strings not matching any special case are trimmed and returned as-is.
605
+ * @param {*} value - The value to convert, usually a string or other type.
606
+ * @returns {*} The converted JavaScript primitive (***`boolean`***, ***`number`***, ***`null`***, ***`undefined`***, ***`NaN`***) or the original value if no conversion applies.
607
+ * @example
608
+ * convertType("true"); // ➔ true
609
+ * convertType(" 42 "); // ➔ 42
610
+ * convertType("FALSE"); // ➔ false
611
+ * convertType(" null "); // ➔ null
612
+ * convertType(" "); // ➔ ""
613
+ * convertType(" Hello World "); // ➔ "Hello World"
614
+ * convertType("NaN"); // ➔ NaN
615
+ * convertType(100); // ➔ 100
616
+ * convertType(NaN); // ➔ NaN
617
+ * convertType({}); // ➔ {}
618
+ */
619
+ declare const convertType: (value: unknown) => unknown;
620
+ /** --------------------------------------------------
621
+ * * ***Options for cleaning and transforming parsed JSON data.***
622
+ * --------------------------------------------------
623
+ *
624
+ * Type Options Validation for Function: {@link cleanParsedData | `cleanParsedData`}, {@link parseCustomDate | `parseCustomDate`} and {@link safeJsonParse | `safeJsonParse`}.
625
+ */
626
+ type ParseParsedDataOptions = {
627
+ /** --------------------------------------------------
628
+ * * ***Convert numeric strings to numbers (e.g., `"42"` ➔ `42`), defaultValue: `false`.***
629
+ * --------------------------------------------------
630
+ *
631
+ * @default false
632
+ */
633
+ convertNumbers?: boolean;
634
+ /** --------------------------------------------------
635
+ * * ***Convert numeric strings `"NaN"` to `NaN` (e.g., `"NaN"` ➔ `NaN`), defaultValue: `false`.***
636
+ * --------------------------------------------------
637
+ *
638
+ * @default false
639
+ */
640
+ convertNaN?: boolean;
641
+ /** --------------------------------------------------
642
+ * * ***Convert `"true"` / `"false"` strings to boolean values, defaultValue: `false`.***
643
+ * --------------------------------------------------
644
+ *
645
+ * @default false
646
+ */
647
+ convertBooleans?: boolean;
648
+ /** --------------------------------------------------
649
+ * * ***Convert valid date strings into `Date` objects, defaultValue: `false`.***
650
+ * --------------------------------------------------
651
+ *
652
+ * @default false
653
+ */
654
+ convertDates?: boolean;
655
+ /** --------------------------------------------------
656
+ * * ***Custom date formats to be parsed (e.g., `["DD/MM/YYYY", "MM/DD/YYYY"]`), defaultValue: `[]`.***
657
+ * --------------------------------------------------
658
+ *
659
+ * @default []
660
+ */
661
+ customDateFormats?: string[];
662
+ /** --------------------------------------------------
663
+ * * ***Remove `null` values from objects and arrays, defaultValue: `false`.***
664
+ * --------------------------------------------------
665
+ *
666
+ * @default false
667
+ */
668
+ removeNulls?: boolean;
669
+ /** --------------------------------------------------
670
+ * * ***Remove `undefined` values from objects and arrays, defaultValue: `false`.***
671
+ * --------------------------------------------------
672
+ *
673
+ * - ***Behavior:***
674
+ * - `false` (**default**): replaces `undefined` with `null`.
675
+ * - `true`: removes keys with `undefined` values.
676
+ *
677
+ * @default false
678
+ */
679
+ removeUndefined?: boolean;
680
+ /** --------------------------------------------------
681
+ * * ***Remove empty objects `{}` from the final output, defaultValue: `false`.***
682
+ * --------------------------------------------------
683
+ *
684
+ * @default false
685
+ */
686
+ removeEmptyObjects?: boolean;
687
+ /** --------------------------------------------------
688
+ * * ***Remove empty arrays `[]` from the final output, defaultValue: `false`.***
689
+ * --------------------------------------------------
690
+ *
691
+ * @default false
692
+ */
693
+ removeEmptyArrays?: boolean;
694
+ /** --------------------------------------------------
695
+ * * ***Removes values that do not match selected conversions, defaultValue: `false`.***
696
+ * --------------------------------------------------
697
+ *
698
+ * @default false
699
+ */
700
+ strictMode?: boolean;
701
+ /** --------------------------------------------------
702
+ * * ***Enable error logging if JSON parsing fails, defaultValue: `false`.***
703
+ * --------------------------------------------------
704
+ *
705
+ * @default false
706
+ */
707
+ loggingOnFail?: boolean;
708
+ /** --------------------------------------------------
709
+ * * ***Custom error handler function.***
710
+ * --------------------------------------------------
711
+ *
712
+ * - ***Behavior:***
713
+ * - If provided, it will be called with the error.
714
+ * - If not provided, defaults to `undefined` in type, but internally a no-op function is used.
715
+ *
716
+ * @param error - Error instance thrown during fail on execution.
717
+ * @default undefined
718
+ */
719
+ onError?: (error: Error) => void;
720
+ /** --------------------------------------------------
721
+ * * ***Whether to check symbol properties when checking empty objects.***
722
+ * --------------------------------------------------
723
+ *
724
+ * @default false
725
+ */
726
+ checkSymbols?: boolean;
727
+ };
728
+ /** --------------------------------------------------
729
+ * * ***Utility: `cleanParsedData`.***
730
+ * ---------------------------------------------
731
+ * **Cleans parsed JSON data based on provided options.**
732
+ * @template T - Expected output type.
733
+ * @param {*} data - The parsed JSON data.
734
+ * @param {ParseParsedDataOptions} [options] - The cleaning options.
735
+ * @returns {T | null | undefined} The cleaned data.
736
+ * - ***⚠️ Notice:*** _If data is JSON string, we recommend use ***`safeJsonParse` utility function*** for more safe._
737
+ * - ***⚠️ Note:*** _If using **`convertDates`** **options**, result may contain Date objects, you may need type assertions in strict TypeScript settings._
738
+ * @example
739
+ * ```ts
740
+ * // 1: Convert numbers and remove nulls
741
+ * const result = cleanParsedData({ age: "25", name: null }, {
742
+ * convertNumbers: true,
743
+ * removeNulls: true
744
+ * });
745
+ * console.log(result); // ➔ { age: 25 }
746
+ * // 2: Convert boolean strings
747
+ * const result = cleanParsedData({ isActive: "true" }, {
748
+ * convertBooleans: true
749
+ * });
750
+ * console.log(result); // ➔ { isActive: true }
751
+ * ```
752
+ */
753
+ declare const cleanParsedData: <T = unknown>(data: T, options?: ParseParsedDataOptions) => T | undefined | null;
754
+ /** --------------------------------------------------
755
+ * * ***Utility: `parseCustomDate`.***
756
+ * ---------------------------------------------
757
+ * **Parses custom date formats like "DD/MM/YYYY" or "MM/DD/YYYY".**
758
+ * @param {string} dateString - Date string to parse.
759
+ * @param {string} format - Date format to match.
760
+ * @returns {Date | null} Returns a `Date` object if valid, otherwise `null`.
761
+ * @throws **{@link TypeError | `TypeError`}** if `dateString` **(first parameter)** and `format` **(second parameter)** is not a string or empty-string.
762
+ * @example
763
+ * // Valid: European format (DD/MM/YYYY)
764
+ * const date1 = parseCustomDate("03/09/2025", "DD/MM/YYYY");
765
+ * console.log(date1); // ➔ Date { Wed Sep 03 2025 ... }
766
+ *
767
+ * // Valid: US format (MM/DD/YYYY)
768
+ * const date2 = parseCustomDate("09/03/2025", "MM/DD/YYYY");
769
+ * console.log(date2); // ➔ Date { Wed Sep 03 2025 ... }
770
+ *
771
+ * // Invalid: wrong format
772
+ * const date3 = parseCustomDate("2025-09-03", "DD/MM/YYYY");
773
+ * console.log(date3); // ➔ null
774
+ *
775
+ * // Invalid: non-date string
776
+ * const date4 = parseCustomDate("hello", "DD/MM/YYYY");
777
+ * console.log(date4); // ➔ null
778
+ *
779
+ * // Throws: wrong parameter types or empty-string
780
+ * parseCustomDate(123, "DD/MM/YYYY");
781
+ * // ➔ TypeError: Parameter `dateString` and `format` must be of type `string`...
782
+ */
783
+ declare const parseCustomDate: (dateString: string, format: string) => Date | null;
784
+ type NonJsonParsableType = Omit<Exclude<unknown, string | null | undefined>, string>;
785
+ type Contains<T, U> = [Extract<T, U>] extends [never] ? false : true;
786
+ /**
787
+ * ***The value type for the overload function {@link safeJsonParse | `safeJsonParse`}.***
788
+ */
789
+ type UnknownValue = {
790
+ undefined: true;
791
+ };
792
+ /**
793
+ * ***The narrows type result for {@link safeJsonParse | `safeJsonParse`}.***
794
+ */
795
+ type SafeJsonParseResult<TData, T> = IfNotExtends<T, NonJsonParsableType> extends true ? T extends never ? undefined : T extends void ? undefined : T extends number ? undefined : Contains<T, string> extends true ? Contains<T, null & string> extends true ? TData | null | undefined : TData | undefined : IfExtends<T, null> extends true ? null : IfNotExtends<T, NonJsonParsableType> extends true ? TData | null | undefined : undefined : Contains<T, string> extends true ? IsAny<T> extends true ? TData | undefined | null : TData | undefined : undefined;
796
+ /** --------------------------------------------------
797
+ * * ***Utility: `safeJsonParse`.***
798
+ * ---------------------------------------------
799
+ * **Safely parses JSON while handling errors and applying transformations.**
800
+ * - **Supports generics** to ensure accurate return type inference.
801
+ * - Always provide both `<TData, TInput>` for best results.
802
+ * - ℹ️ ***Scroll down for full generic behavior explanation.***
803
+ * - Automatically parses valid JSON strings into `objects`, `arrays`, `numbers`, etc.
804
+ * - Supports data transformation via options (e.g., convert strings to `numbers`, `booleans`, or `dates`).
805
+ * - **Returns:**
806
+ * 1. `null` ➔ if input is explicitly `null`.
807
+ * 2. `undefined` ➔ if input is `undefined`, not a `string`, or if parsing fails.
808
+ * 3. Parsed and cleaned result (`TData`) ➔ if input is a valid JSON string.
809
+ * - ⚠️ **JSON.stringify note**:
810
+ * - _If the input JSON string was created using `JSON.stringify()`, any properties with `undefined`
811
+ * values would have been automatically removed or converted to `null` depending on the serializer, example:_
812
+ * ```ts
813
+ * JSON.stringify({ a: undefined, b: 1 }); // ➔ '{"b":1}'
814
+ * JSON.parse('{"a": undefined, "b": 1}') // ❌ invalid JSON
815
+ * ```
816
+ * _Therefore, if you see `undefined` in raw input, it will likely throw unless pre-cleaned or replaced with `null`._
817
+ *
818
+ * ```ts
819
+ * safeJsonParse('{"name": "John", "score": undefined}');
820
+ * // result ➔ { name: "John", score: null } <- because `undefined` is not valid JSON, gets replaced to null.
821
+ * ```
822
+ * - ℹ️ **Additionally:**
823
+ * - This function normalizes single quotes (`'`) to double quotes (`"`) before parsing,
824
+ * so JSON strings using single quotes will be converted to valid JSON format, example:
825
+ * ```ts
826
+ * safeJsonParse("{'name': 'John', 'age': 30}");
827
+ * // result ➔ { name: "John", age: 30 }
828
+ *
829
+ * safeJsonParse("{'string\\'s': 'abc', \"quote's\": 'It\\'s awesome!', 'aNumber\\'s': 123, 'keyWith\\'Backslash\\'s': 'value\\'s'}");
830
+ * // result ➔ { "string's": "abc", "quote's": "It's awesome!", "aNumber's": 123, "keyWith'Backslash's": "value's" }
831
+ * ```
832
+ * @template TData - The expected output type after parsing and cleaning.
833
+ * @template TInput - The input value type, used for advanced type inference and return typing.
834
+ * @param {TInput} [value] - The JSON string or value to parse.
835
+ * @param {ParseParsedDataOptions} [options] - Options to clean, convert types, enable strict mode,
836
+ * support custom date formats, enable logging, or handle errors via callback.
837
+ * @returns {SafeJsonParseResult<TData, TInput>} Parsed and optionally cleaned result, or `null`/`undefined`.
838
+ * @throws **{@link TypeError | `TypeError`}** if `options` is provided but not a valid object.
839
+ * @example
840
+ * 1. ***Basic parse with number & boolean conversion:***
841
+ * ```ts
842
+ * const result = safeJsonParse(30);
843
+ * // result ➔ undefined
844
+ * const result = safeJsonParse(30, {
845
+ * convertNumbers: true
846
+ * });
847
+ * // result ➔ 30
848
+ *
849
+ * const result = safeJsonParse('{"age": "30", "isActive": "true"}', {
850
+ * convertNumbers: true,
851
+ * convertBooleans: true
852
+ * });
853
+ * // result ➔ { age: 30, isActive: true }
854
+ * ```
855
+ * 2. ***Handling `undefined` in input string (manually written, not JSON.stringify):***
856
+ * ```ts
857
+ * const result = safeJsonParse('{"score": undefined}');
858
+ * // result ➔ { score: null } <- because `undefined` is not valid JSON, gets replaced
859
+ * ```
860
+ *
861
+ * 3. ***Handling `NaN` in input string (manually written, not JSON.stringify):***
862
+ * ```ts
863
+ * const value = NaN; // <- value is NaN or "NaN";
864
+ * const result = safeJsonParse(value);
865
+ * // result ➔ undefined <- will return as undefined, because options `convertNaN` is false (default),
866
+ * const result2 = safeJsonParse(value, { convertNaN: true });
867
+ * // result2 ➔ NaN <- will return as undefined because options `convertNaN` is false,
868
+ *
869
+ * const result4 = safeJsonParse('{"strNan": "NaN", "pureNan": NaN}');
870
+ * // NaN will convert to string (NaN ➔ "NaN") because options `convertNaN` is false (default),
871
+ * // result4 ➔ { strNan: "NaN", pureNan: "NaN" }
872
+ *
873
+ * const result3 = safeJsonParse('{"strNan": "NaN", "pureNan": NaN}', {
874
+ * convertNaN: true
875
+ * });
876
+ * // String "NaN" will convert to NaN ("NaN" ➔ NaN) because options `convertNaN` is true,
877
+ * // result3 ➔ { strNan: NaN, pureNan: NaN }
878
+ * ```
879
+ *
880
+ * 4. ***Strict mode (removes invalid values):***
881
+ * ```ts
882
+ * const result = safeJsonParse('{"name": " ", "score": "99abc"}', {
883
+ * convertNumbers: true,
884
+ * strictMode: true
885
+ * });
886
+ * // result ➔ {}
887
+ *
888
+ * const result2 = safeJsonParse('{"name": " ", "score": undefined}');
889
+ * // result2 ➔ { name: "",score: null }
890
+ * ```
891
+ *
892
+ * 5. ***Custom date format parsing:***
893
+ * ```ts
894
+ * const result = safeJsonParse('{"birthday": "25/12/2000"}', {
895
+ * convertDates: true,
896
+ * customDateFormats: ["DD/MM/YYYY"]
897
+ * });
898
+ * // result ➔ { birthday: new Date("2000-12-25T00:00:00.000Z") }
899
+ * ```
900
+ *
901
+ * 6. ***Invalid JSON with custom error handling:***
902
+ * ```ts
903
+ * safeJsonParse("{invalid}", {
904
+ * loggingOnFail: true,
905
+ * onError: (err) => console.log("Custom handler:", err.message)
906
+ * });
907
+ * // ➔ Logs parsing error and invokes handler
908
+ * ```
909
+ *
910
+ * 7. ***Null or non-string input returns null/undefined (default options):***
911
+ * ```ts
912
+ * safeJsonParse(123); // ➔ undefined
913
+ * safeJsonParse(null); // ➔ null
914
+ * safeJsonParse(undefined); // ➔ undefined
915
+ * ```
916
+ *
917
+ * 8. ***Generic usage: Provide both output and input type to ensure correct return typing:***
918
+ * ```ts
919
+ * type UserType = { name: string };
920
+ *
921
+ * const obj = JSON.stringify({
922
+ * name: "John"
923
+ * });
924
+ *
925
+ * const toParse = isAuth() ? obj : null;
926
+ * const toParse2 = isAuth() ? obj : undefined;
927
+ *
928
+ * // * `Without Generic`:
929
+ * const parsed = safeJsonParse(toParse);
930
+ * //- runtime: { name: "John" } | undefined | null
931
+ * //- type: Record<string, unknown> | undefined | null
932
+ * const parsed2 = safeJsonParse(toParse);
933
+ * //- runtime: { name: "John" } | undefined
934
+ * //- type: Record<string, unknown> | undefined
935
+ *
936
+ * // * `With Generic`:
937
+ * const parsed = safeJsonParse<UserType>(toParse);
938
+ * //- runtime: { name: "John" } | undefined | null
939
+ * //- type: undefined <- (⚠️ unexpected!)
940
+ * const parsed2 = safeJsonParse<UserType>(toParse);
941
+ * //- runtime: { name: "John" } | undefined
942
+ * //- type: undefined <- (⚠️ unexpected!)
943
+ * const parsed = safeJsonParse<UserType, typeof toParse>(toParse);
944
+ * //- runtime: { name: "John" } | null | undefined
945
+ * //- type: UserType | null | undefined
946
+ * const parsed2 = safeJsonParse<UserType, typeof toParse>(toParse);
947
+ * //- runtime: { name: "John" } | undefined
948
+ * //- type: UserType | undefined
949
+ * ```
950
+ * @note
951
+ * ⚠️ **Generic Behavior:**
952
+ * - This function supports advanced generic inference for clean, type-safe return values.
953
+ * - If only the first generic (`TData`) is provided and the second (`TInput`) is omitted,
954
+ * then `TInput` defaults to `undefined`, resulting in a return type of `undefined`.
955
+ * - To ensure correct return typing, **always pass both generics** when `value` is dynamic,
956
+ * nullable, or unioned: `safeJsonParse<TData, typeof value>(value)`.
957
+ * - This makes the returned type exactly match your expectation: `TData | null | undefined`.
958
+ */
959
+ declare function safeJsonParse<TData extends Record<string, any> = Record<string, unknown>, TInput extends UnknownValue = UnknownValue>(value: TInput, options?: ParseParsedDataOptions): IsAny<TInput> extends true ? TData | null | undefined : undefined;
960
+ declare function safeJsonParse<TData extends Record<string, any> = Record<string, unknown>, TInput extends string | null | undefined | unknown = undefined>(value: TInput, options?: ParseParsedDataOptions): SafeJsonParseResult<TData, TInput>;
961
+ /** ----------------------------------------------------------
962
+ * * ***Utility: `extractDigits`.***
963
+ * ---------------------------------------------
964
+ * **Extracts digits from a string or number input.**
965
+ * - **Behavior:**
966
+ * - Converts the input to a string, trims whitespace, and removes any characters that are not digits (`0-9`).
967
+ * - Returns the cleaned numeric value as a `number`.
968
+ * - If the input is a `null`, `undefined`, results in no digits, or not a `string` (or empty-string) or `number`, it safely return `0`.
969
+ * @param {*} [value]
970
+ * **The value to process.**
971
+ * - Accepts a string, number, `null`, or `undefined`.
972
+ * @returns {number} The numeric value after extracting digits (returns `0` if input is invalid or contains no digits).
973
+ * @example
974
+ * extractDigits(12345); // ➔ 12345
975
+ * extractDigits("9A8B7C6X1"); // ➔ 98761
976
+ * extractDigits("123abc456"); // ➔ 123456
977
+ * extractDigits("$1,234.56"); // ➔ 123456
978
+ * extractDigits(NaN); // ➔ 0
979
+ * extractDigits(null); // ➔ 0
980
+ * extractDigits(undefined); // ➔ 0
981
+ * extractDigits(Infinity); // ➔ 0
982
+ * extractDigits(-Infinity); // ➔ 0
983
+ * extractDigits({}); // ➔ 0
984
+ * extractDigits([]); // ➔ 0
985
+ * extractDigits(""); // ➔ 0
986
+ * extractDigits(" "); // ➔ 0
987
+ * extractDigits("abc"); // ➔ 0
988
+ * extractDigits(" 00a "); // ➔ 0
989
+ */
990
+ declare const extractDigits: (value: unknown) => number;
991
+ type Prev = [never, NumberRangeUnion<1, 30>];
992
+ type DotPath<T, Prefix extends string = "", Depth extends number = NumberRangeUnion<1, 30>> = Depth extends never ? never : T extends (infer U)[] ? U extends object ? DotPath<U, `${Prefix}`, Prev[Depth]> : never : T extends object ? { [K in Extract<keyof T, string>]: T[K] extends object ? DotPath<T[K], `${Prefix}${K}.`, Prev[Depth]> | `${Prefix}${K}` : `${Prefix}${K}` }[Extract<keyof T, string>] : never;
993
+ type KeysToRemove<T, K extends readonly ConfigRemoveObjectPaths<T>[]> = K[number] extends {
994
+ key: infer Key;
995
+ } ? Key extends string ? Key : never : never;
996
+ type RemoveNested<T, K extends string> = T extends Array<infer U> ? RemoveNested<U, K>[] : T extends object ? K extends `${infer Head}.${infer Rest}` ? Head extends keyof T ? { [P in keyof T]: P extends Head ? RemoveNested<T[P], Rest> : T[P] } : T : SafeRemove<T, K> : T;
997
+ type SafeRemove<T, K extends string> = K extends keyof T ? Omit<T, K> : T;
998
+ type ChangeNeverArrayToArrayDeep<T> = T extends never[] ? [] : T extends Array<infer U> ? ChangeNeverArrayToArrayDeep<U>[] : T extends object ? { [K in keyof T]: ChangeNeverArrayToArrayDeep<T[K]> } : T;
999
+ /**
1000
+ * ***Types options for {@link removeObjectPaths | `removeObjectPaths`}.***
1001
+ */
1002
+ type ConfigRemoveObjectPaths<T> = {
1003
+ /** ------------------------------------------------------------------------
1004
+ * * ***The dot-notation path to the property that should be removed.
1005
+ * Can target deeply nested properties (e.g., `"left.data.sensitive"`).***
1006
+ * ------------------------------------------------------------------------
1007
+ * **This is resolved relative to the root object `T`, and supports
1008
+ * any valid **{@link DotPath | `DotPath`}** path within it.**
1009
+ *
1010
+ * @example
1011
+ * const obj = {
1012
+ * left: { data: { sensitive: "secret", id: 1 } },
1013
+ * right: { data: { debug: true, keep: "yes" } },
1014
+ * };
1015
+ *
1016
+ * // Removes "left.data.sensitive" and "right.data.debug"
1017
+ * const result = removeObjectPaths(obj, [
1018
+ * { key: "left.data.sensitive" },
1019
+ * { key: "right.data.debug" },
1020
+ * ]);
1021
+ * console.log(result);
1022
+ * // {
1023
+ * // left: { data: { id: 1 } },
1024
+ * // right: { data: { keep: "yes" } },
1025
+ * // };
1026
+ */
1027
+ key: DotPath<T>;
1028
+ /** ------------------------------------------------------------------------
1029
+ * * ***When `true`, removes the specified property from **all matching nested levels**,
1030
+ * including occurrences inside arrays, defaults to `false` for single-level removal.***
1031
+ * ------------------------------------------------------------------------
1032
+ * **Useful if the target property might appear multiple times across different
1033
+ * branches or array elements.**
1034
+ * @default false
1035
+ * @example
1036
+ * const obj = {
1037
+ * items: [
1038
+ * { data: { sensitive: "one", keep: true } },
1039
+ * { data: { sensitive: "two", keep: true } },
1040
+ * { other: { sensitive: "other" } },
1041
+ * ]
1042
+ * };
1043
+ *
1044
+ * // Removes all "data.sensitive" occurrences inside items[]
1045
+ * const result = removeObjectPaths(obj, [{ key: "items.data.sensitive", deep: true }]);
1046
+ * console.log(result);
1047
+ * // {
1048
+ * // items: [
1049
+ * // { data: { keep: true } },
1050
+ * // { data: { keep: true } },
1051
+ * // { other: { sensitive: "other" } },
1052
+ * // ]
1053
+ * // };
1054
+ */
1055
+ deep?: boolean;
1056
+ };
1057
+ /**
1058
+ * ***Narrows types result for {@link removeObjectPaths | `removeObjectPaths`}.***
1059
+ */
1060
+ type ResultRemoveObjectPaths<T, K extends readonly ConfigRemoveObjectPaths<T>[]> = Prettify<RemoveNested<ChangeNeverArrayToArrayDeep<T>, KeysToRemove<T, K>>, {
1061
+ recursive: true;
1062
+ }> extends never ? T : Prettify<RemoveNested<ChangeNeverArrayToArrayDeep<T>, KeysToRemove<T, K>>, {
1063
+ recursive: true;
1064
+ }>;
1065
+ /** ------------------------------------------------------------------------
1066
+ * * ***Utility: `removeObjectPaths`.***
1067
+ * ------------------------------------------------------------------------
1068
+ * **Deletes multiple keys (shallow or deeply nested) from an object.**
1069
+ * - **Features:**
1070
+ * - Removes one or more keys from an object based on their paths (supports dot notation for nested properties).
1071
+ * - Can delete deeply from all matching nested levels (even inside arrays) when `deep: true`.
1072
+ * - By default does **not mutate** the original object. Clones it first.
1073
+ * Set `deepClone = false` to mutate in place (useful for performance on large data).
1074
+ * - Ensures type safety on `key` paths via `DotPath<T>`, reducing accidental invalid paths.
1075
+ * - **Behavior:**
1076
+ * - When `deep: false` (default), only deletes the direct property at the specified path.
1077
+ * - When `deep: true`, searches deeply and recursively deletes the key from all levels,
1078
+ * including inside arrays of objects (applies the *same* path repeatedly).
1079
+ * - Skips deletion if the specified path does not exist — no error is thrown.
1080
+ * - **Edge Handling:**
1081
+ * - If `object` is `null` or not an object, returns an empty object.
1082
+ * - If `keysToDelete` is not an array of `{ key, deep? }` objects, throws a `TypeError`.
1083
+ * - Ignores invalid intermediate paths (will skip those branches without throwing).
1084
+ * @template T - The shape of the input object, used for type-safe dot paths.
1085
+ * @param {Record<string, unknown>} object - ***The object to remove keys from, must be an object or will return `{}`.***
1086
+ * @param {ConfigRemoveObjectPaths<T>[]} keysToDelete
1087
+ * ***An array of instructions:***
1088
+ * - `key`: A string path using dot notation (e.g. `"user.profile.name"`).
1089
+ * - `deep`: If `true`, will recursively remove all instances of the key path at any depth, defaultValue: `false`.
1090
+ * @param {boolean|undefined} [deepClone=true]
1091
+ * ***Whether to deep clone the original object before modifying.***
1092
+ * - `true` (default): returns a *new object* with the specified keys removed.
1093
+ * - `false`: modifies the original object in place and returns it.
1094
+ * @returns {Partial<T>}
1095
+ * - A new object with specified keys removed if `deepClone` is `true`.
1096
+ * - The *same mutated object* if `deepClone` is `false`.
1097
+ * @throws **{@link TypeError | `TypeError`}** if `keysToDelete` is not an array of `{ key, deep? }` objects.
1098
+ * @example
1099
+ * // Shallow deletion
1100
+ * removeObjectPaths(
1101
+ * { a: 1, b: 2, c: { d: 3 } },
1102
+ * [{ key: "b" }]
1103
+ * );
1104
+ * // ➔ { a: 1, c: { d: 3 } }
1105
+ *
1106
+ * // Nested deletion (shallow, removes only exact path)
1107
+ * removeObjectPaths(
1108
+ * { user: { profile: { name: "Alice", age: 30 } } },
1109
+ * [{ key: "user.profile.age" }]
1110
+ * );
1111
+ * // ➔ { user: { profile: { name: "Alice" } } }
1112
+ *
1113
+ * // Deep deletion (recursively removes key from all levels and arrays)
1114
+ * removeObjectPaths(
1115
+ * { items: [{ price: 10 }, { price: 20, details: { price: 30 } }] },
1116
+ * [{ key: "price", deep: true }]
1117
+ * );
1118
+ * // ➔ { items: [{}, { details: {} }] }
1119
+ *
1120
+ * // Without cloning: mutates original object
1121
+ * const obj = { x: 1, y: 2 };
1122
+ * removeObjectPaths(obj, [{ key: "y" }], false);
1123
+ * console.log(obj); // ➔ { x: 1 }
1124
+ *
1125
+ * // No matching path — returns unchanged object
1126
+ * removeObjectPaths({}, [{ key: "a" }]);
1127
+ * // ➔ {}
1128
+ *
1129
+ * // 🚫 Invalid usage — `keysToDelete` is not an array
1130
+ * removeObjectPaths({}, "a");
1131
+ * // ➔ throws TypeError
1132
+ *
1133
+ * // 🚫 Invalid usage — missing `key` property in array element
1134
+ * removeObjectPaths({}, [{ deep: true }]);
1135
+ * // ➔ throws TypeError
1136
+ */
1137
+ declare function removeObjectPaths<T extends Record<string, unknown>, K extends ConfigRemoveObjectPaths<T>[]>(object: T, keysToDelete: K, deepClone?: boolean): ResultRemoveObjectPaths<T, K>;
1138
+ /** -------------------------------------------------
1139
+ * * ***Type Options for **{@link safeStableStringify | `safeStableStringify`}**.***
1140
+ * -------------------------------------------------
1141
+ */
1142
+ type SafeStableStringifyOptions = {
1143
+ /** -------------------------------------------------
1144
+ * * ***Whether to sort **object keys** alphabetically (recursively).***
1145
+ * -------------------------------------------------
1146
+ *
1147
+ * - `true` (default): object keys are sorted to ensure stable output.
1148
+ * - `false`: preserves original insertion order of keys.
1149
+ *
1150
+ * @default true
1151
+ */
1152
+ sortKeys?: boolean;
1153
+ /** -------------------------------------------------
1154
+ * * ***Whether to sort **primitive values inside arrays**.***
1155
+ * -------------------------------------------------
1156
+ *
1157
+ * - `true`: primitive values in arrays are sorted to ensure stable output.
1158
+ * - `false` (default): arrays retain their original order; objects and nested arrays are not reordered.
1159
+ *
1160
+ * @default false
1161
+ */
1162
+ sortArray?: boolean;
1163
+ /** -------------------------------------------------
1164
+ * * ***Whether to pretty-print JSON output with 2-space indentation.***
1165
+ * -------------------------------------------------
1166
+ *
1167
+ * - `true`: output is formatted with indentation and newlines.
1168
+ * - `false` (default): produces compact single-line JSON.
1169
+ *
1170
+ * @default false
1171
+ */
1172
+ pretty?: boolean;
1173
+ /** -------------------------------------------------
1174
+ * * ***Preserve `undefined` values instead of converting them to `null`.***
1175
+ * -------------------------------------------------
1176
+ * **Controls how the internal `deepProcess` step rewrites values
1177
+ * **before** the final `JSON.stringify` call.**
1178
+ * - **Default (`false`):**
1179
+ * * Every `undefined` value (object properties **and** array elements)
1180
+ * is replaced with `null` **before** serialization, because this happens
1181
+ * first, the key is **not removed** by `JSON.stringify`.
1182
+ * - **`true`** – Leaves `undefined` untouched so the final
1183
+ * `JSON.stringify` call behaves natively:
1184
+ * * Object properties with `undefined` are **removed**.
1185
+ * * Array elements that are `undefined` become `null`.
1186
+ * @default false
1187
+ * @example
1188
+ * // ✅ keepUndefined = true: behaves like native JSON.stringify
1189
+ * safeStableStringify({ a: undefined }, { keepUndefined: true });
1190
+ * // ➔ '{}' // key removed
1191
+ *
1192
+ * // ✅ Default (false): convert undefined to null, key kept
1193
+ * safeStableStringify({ a: undefined });
1194
+ * // ➔ '{"a":null}' // key present, value null
1195
+ *
1196
+ * // Arrays
1197
+ * safeStableStringify([undefined]);
1198
+ * // ➔ '[null]' // same, but via pre-replacement
1199
+ * safeStableStringify([undefined], { keepUndefined: true });
1200
+ * // ➔ '[null]' // element becomes null
1201
+ */
1202
+ keepUndefined?: boolean;
1203
+ };
1204
+ /** --------------------------------------------
1205
+ * * ***Utility: `safeStableStringify`.***
1206
+ * ---------------------------------------------
1207
+ * **Safely converts a JavaScript value into a stable, JSON-compatible string.**
1208
+ * - **This function is an enhanced version of `JSON.stringify` with additional guarantees:**
1209
+ * - ***Features:***
1210
+ * - Recursively sorts object keys **only if** `sortKeys` is `true` (default: `true`), to ensure stable
1211
+ * key order.
1212
+ * - If `sortKeys` is `false`, preserves the original insertion order of object keys.
1213
+ * - Optionally sorts array primitive values **only if** `sortArray` is `true` (default: `false`).
1214
+ * - Only primitive values in arrays are sorted.
1215
+ * - Objects and nested arrays keep their original position and are appended after sorted primitives.
1216
+ * - If `sortArray` is `false`, arrays retain their original order.
1217
+ * - Converts JavaScript special values for JSON safety:
1218
+ * - `undefined`, `NaN`, `Infinity`, `-Infinity` ➔ `null`.
1219
+ * - `BigInt` ➔ string (JSON does not support BigInt).
1220
+ * - Converts boxed primitives box into their primitive equivalents:
1221
+ * - `new Number(42)` ➔ `Number(42)` ➔ `42`.
1222
+ * - `new String("hi")` ➔ `String("hi")` ➔ `"hi"`.
1223
+ * - `new Boolean(true)` ➔ `Boolean(true)` ➔ `true`.
1224
+ * - Functions and Symbols are removed.
1225
+ * - Circular references are replaced with the string `"[Circular]"`.
1226
+ * - Serializes:
1227
+ * - `Date` ➔ ISO string (`date.toISOString()`).
1228
+ * - `Set` ➔ `{ set: [values...] }` (values are recursively processed).
1229
+ * - `Map` ➔ `{ map: [ [key, value], ... ] }` (values are recursively processed).
1230
+ * - Compared to `JSON.stringify`, this ensures **stable output**:
1231
+ * - Same object structure always produces the same string.
1232
+ * - Useful for deep equality checks, hashing, caching keys, or snapshot tests.
1233
+ * - Controls how `undefined` is handled **before** the final `JSON.stringify` call, by `keepUndefined`
1234
+ * options, default: `false`.
1235
+ * - **false**: All `undefined` values (object properties and array elements) are replaced
1236
+ * with `null`, so object keys remain.
1237
+ * - **true**: Leaves `undefined` values as-is, and handling by native `JSON.stringify` then:
1238
+ * 1. Removes object properties that are `undefined`.
1239
+ * 2. Converts `undefined` array elements to `null`.
1240
+ * - Use `true` when you need native removal of keys or to preserve sparse arrays
1241
+ * exactly as `JSON.stringify` would.
1242
+ * @param {*} value
1243
+ * ***Any JavaScript value to serialize, can be:***
1244
+ * - Primitives (`number`, `string`, `boolean`, `bigint`, `null`, `undefined`).
1245
+ * - Boxed primitives (`new Number()`, `new String()`, `new Boolean()`).
1246
+ * - Arrays, plain objects, nested structures.
1247
+ * - Date, Map, Set.
1248
+ * - Circular structures.
1249
+ * @param {SafeStableStringifyOptions} [options]
1250
+ * ***Configuration options for `safeStableStringify`:***
1251
+ * - `keepUndefined` (boolean) – Control how `undefined` is handled **before** the final `JSON.stringify`
1252
+ * call, default: `false`.
1253
+ * - `sortKeys` (boolean) – Whether to sort object keys alphabetically (recursively), default: `true`.
1254
+ * - `sortArray` (boolean) – Whether to sort primitive values inside arrays, default: `false`.
1255
+ * - `pretty` (boolean) – Whether to pretty-print JSON output with 2-space indentation, default: `false`.
1256
+ * @returns {string}
1257
+ * A stable JSON string representation of the input value.
1258
+ * @throws **{@link TypeError | `TypeError`}** if `sortKeys`, `sortArray`, or `pretty` are not strictly boolean.
1259
+ * @example
1260
+ * ```ts
1261
+ * // Basic object key sorting
1262
+ * safeStableStringify({ b: 2, a: 1 });
1263
+ * // ➔ '{"a":1,"b":2}'
1264
+ *
1265
+ * // Disable key sorting (preserve insertion order)
1266
+ * safeStableStringify({ b: 2, a: 1 }, {
1267
+ * sortKeys:false
1268
+ * });
1269
+ * // ➔ '{"b":2,"a":1}'
1270
+ *
1271
+ * // Sorting arrays with sortArray
1272
+ * safeStableStringify([3, 1, 2], {
1273
+ * sortArray:true
1274
+ * });
1275
+ * // ➔ '[1,2,3]'
1276
+ *
1277
+ * // keepUndefined = true (native removal of keys)
1278
+ * safeStableStringify({ a: undefined }, { keepUndefined: true });
1279
+ * // ➔ '{}' // key `a` is removed, like native JSON.stringify
1280
+ *
1281
+ * // Default keepUndefined = false (convert to null, keep key)
1282
+ * safeStableStringify({ a: undefined });
1283
+ * // ➔ '{"a":null}'
1284
+ *
1285
+ * // Nested object + sortArray=true
1286
+ * safeStableStringify({ z: [3, 1, 2], x: { d: 4, c: 3 } }, {
1287
+ * sortKeys:true,
1288
+ * sortArray:true
1289
+ * });
1290
+ * // ➔ '{"x":{"c":3,"d":4},"z":[1,2,3]}'
1291
+ *
1292
+ * // sortKeys=false and sortArray=true
1293
+ * safeStableStringify({ z: [3, 1, 2], x: { d: 4, c: 3 } }, {
1294
+ * sortKeys:false,
1295
+ * sortArray:true
1296
+ * });
1297
+ * // ➔ '{"z":[1,2,3],"x":{"d":4,"c":3}}'
1298
+ *
1299
+ * // Pretty print output
1300
+ * safeStableStringify([3, 1, 2], {
1301
+ * sortArray:true,
1302
+ * pretty:true
1303
+ * });
1304
+ * // ➔ `[
1305
+ * // 1,
1306
+ * // 2,
1307
+ * // 3
1308
+ * // ]`
1309
+ *
1310
+ * // Boxed primitives converted to primitive
1311
+ * safeStableStringify({ n: new Number(42), s: new String("hi"), b: new Boolean(true) });
1312
+ * // ➔ '{"n":42,"s":"hi","b":true}'
1313
+ *
1314
+ * // Handles Date, BigInt, Map and Set
1315
+ * safeStableStringify({
1316
+ * time: new Date("2025-01-01"),
1317
+ * big: BigInt(9007199254740991),
1318
+ * data: new Map([["key", new Set([1, 2])]])
1319
+ * });
1320
+ * // ➔ '{"big":"9007199254740991","data":{"map":[["key",{"set":[1,2]}]]},"time":"2025-01-01T00:00:00.000Z"}'
1321
+ *
1322
+ * // Functions and symbols are removed
1323
+ * safeStableStringify({ f: () => {}, s: Symbol("wow") });
1324
+ * // ➔ '{}'
1325
+ *
1326
+ * // undefined, NaN, Infinity convert to null (keepUndefined = false or keepUndefined = true)
1327
+ * safeStableStringify([undefined, NaN, Infinity, -Infinity]);
1328
+ * // ➔ '[null,null,null,null]'
1329
+ *
1330
+ * // Circular reference
1331
+ * const obj = { name: "A" };
1332
+ * obj.self = obj;
1333
+ * safeStableStringify(obj);
1334
+ * // ➔ '{"name":"A","self":"[Circular]"}'
1335
+ *
1336
+ * // Complex nested sortArray with objects
1337
+ * const arr = [9, 7, [4, 2, 3], { z: [5, 1, 6] }];
1338
+ * safeStableStringify(arr, { sortArray: true, sortKeys: true });
1339
+ * // ➔ '[7,9,[2,3,4],{"z":[1,5,6]}]'
1340
+ * ```
1341
+ */
1342
+ declare const safeStableStringify: (value: unknown, options?: SafeStableStringifyOptions) => string;
1343
+ /** ----------------------------------------------------------
1344
+ * * Normalize leaked `never[]` into literal empty array `[]`.
1345
+ * ----------------------------------------------------------
1346
+ */
1347
+ type FixNeverArray$1<T, RemoveEmptyArrays extends boolean> = [T] extends [never[]] ? RemoveEmptyArrays extends true ? OrArr<[Extends<T, undefined>, Extends<undefined, T>]> extends true ? undefined : never : [] : T;
1348
+ /** ----------------------------------------------------------
1349
+ * * Simplify object type to remove unnecessary TypeScript wrappers.
1350
+ * ----------------------------------------------------------
1351
+ */
1352
+ type Simplify$1<T> = T extends object ? { [K in keyof T]: T[K] } : T;
1353
+ /** ----------------------------------------------------------
1354
+ * * Deeply convert all numbers and strings to `number | undefined`,
1355
+ * * recursively handling arrays, tuples, Sets, Maps, TypedArrays,
1356
+ * * and objects. Special types like Date remain unchanged.
1357
+ * ----------------------------------------------------------
1358
+ *
1359
+ * @template T - Input type to convert
1360
+ * @template RemoveEmptyObjects - Whether to remove empty objects
1361
+ * @template RemoveEmptyArrays - Whether to remove empty arrays
1362
+ * @template IsRoot - Internal flag for root level
1363
+ */
1364
+ type ConvertedDeepNumberInternal<T, RemoveEmptyObjects extends boolean, RemoveEmptyArrays extends boolean, IsRoot extends boolean> = [T] extends [null | undefined] ? IsRoot extends true ? undefined : never : T extends Date | boolean | Boolean ? number : T extends string | String | Number | number | `${number}` ? number | undefined : AndArr<[Extends<RemoveEmptyArrays, true>, Extends<T, undefined[]>]> extends true ? never : T extends readonly (infer E)[] ? OrArr<[Extends<RemoveEmptyArrays, true>, AndArr<[Extends<RemoveEmptyArrays, true>, Extends<IsRoot, true>]>]> extends true ? FixNeverArray$1<Exclude<ConvertedDeepNumberInternal<E, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>, RemoveEmptyArrays>[] | undefined : FixNeverArray$1<Exclude<ConvertedDeepNumberInternal<E, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>[], RemoveEmptyArrays> : T extends Set<infer V> ? AndArr<[Extends<RemoveEmptyArrays, true>]> extends true ? FixNeverArray$1<Exclude<ConvertedDeepNumberInternal<V, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>[], RemoveEmptyArrays> : FixNeverArray$1<Exclude<ConvertedDeepNumberInternal<V, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>[], RemoveEmptyArrays> : T extends Map<infer K, infer V> ? FixNeverArray$1<[Exclude<ConvertedDeepNumberInternal<K, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>, Exclude<ConvertedDeepNumberInternal<V, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>][], RemoveEmptyArrays> : T extends Buffer ? FixNeverArray$1<Exclude<ConvertedDeepNumberInternal<string, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>[], RemoveEmptyArrays> : T extends TypedArray ? FixNeverArray$1<Exclude<ConvertedDeepNumberInternal<string, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>[], RemoveEmptyArrays> : T extends Record<PropertyKey, unknown> ? _ConvertedObjectInternal$1<T, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> : never;
1365
+ /** ----------------------------------------------------------
1366
+ * * Internal object conversion utility.
1367
+ * * Removes empty objects/arrays based on flags.
1368
+ * ----------------------------------------------------------
1369
+ */
1370
+ type _ConvertedObjectInternal$1<O extends Record<PropertyKey, unknown> | string | number, RemoveEmptyObjects extends boolean, RemoveEmptyArrays extends boolean, IsRoot extends boolean> = { [K in keyof O as Exclude<ConvertedDeepNumberInternal<O[K], RemoveEmptyObjects, RemoveEmptyArrays, false>, undefined> extends infer Convert ? [Convert] extends [never] ? never : undefined extends ConvertedDeepNumberInternal<O[K], RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> ? never : RemoveEmptyArrays extends true ? Convert extends readonly unknown[] ? [Convert] extends [[]] ? never : K : K : K : never]: Exclude<ConvertedDeepNumberInternal<O[K], RemoveEmptyObjects, RemoveEmptyArrays, false>, undefined> } & { [K in keyof O as Exclude<ConvertedDeepNumberInternal<O[K], RemoveEmptyObjects, RemoveEmptyArrays, false>, undefined> extends infer Convert ? [Convert] extends [never] ? never : undefined extends ConvertedDeepNumberInternal<O[K], RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> ? RemoveEmptyArrays extends true ? Convert extends readonly unknown[] ? [Convert] extends [[]] ? never : K : K : K : never : never]?: Exclude<ConvertedDeepNumberInternal<O[K], RemoveEmptyObjects, RemoveEmptyArrays, false>, undefined> } extends infer M ? RemoveEmptyObjects extends true ? keyof M extends never ? IsRoot extends true ? {} : never : _ProcessedObject$1<M, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> : Simplify$1<M> : never;
1371
+ type AllPropsAreNumber$1<O> = { [K in keyof O]: O[K] extends number | Number ? true : O[K] extends Record<string, unknown> ? AllPropsAreNumber$1<O[K]> : false }[keyof O] extends false ? false : true;
1372
+ type _ProcessedObject$1<M, RemoveEmptyObjects extends boolean, RemoveEmptyArrays extends boolean, IsRoot extends boolean> = M extends unknown[] ? ConvertedDeepNumberInternal<M, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> : Prettify<Simplify$1<{ [K in keyof M]: M[K] extends Record<string, unknown> ? AllPropsAreNumber$1<M[K]> extends true ? { [ChildKey in keyof M[K]]: M[K][ChildKey] extends number | Number ? M[K][ChildKey] | undefined : _ProcessedObject$1<M[K][ChildKey], RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> } | undefined : AndArr<[Extends<RemoveEmptyArrays, true>, Extends<RemoveEmptyObjects, true>]> extends true ? { [ChildKey in keyof M[K]]: _ProcessChild$1<M[K][ChildKey], RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> } | undefined : { [ChildKey in keyof M[K]]: _ProcessChild$1<M[K][ChildKey], RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> } : M[K] extends unknown[] ? ConvertedDeepNumberInternal<M[K], RemoveEmptyObjects, RemoveEmptyArrays, false> : _ProcessedObject$1<M[K], RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> }>, {
1373
+ recursive: true;
1374
+ }>;
1375
+ type _ProcessChild$1<T, RemoveEmptyObjects extends boolean, RemoveEmptyArrays extends boolean, IsRoot extends boolean> = T extends number | number[] ? ConvertedDeepNumberInternal<T, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> : T extends Record<string, unknown> ? _ProcessedObject$1<T, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> : _ProcessedObject$1<T, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>;
1376
+ /** ----------------------------------------------------------
1377
+ * * Public type: Deeply converts numbers/strings to `number | undefined`,
1378
+ * * applies empty object/array removal, preserves special types.
1379
+ * ----------------------------------------------------------
1380
+ *
1381
+ * **Narrows types result for {@link toNumberDeep | `toNumberDeep`}.***
1382
+ */
1383
+ type ConvertedDeepNumber<T, RemoveEmptyObjects extends boolean = false, RemoveEmptyArrays extends boolean = false> = [unknown] extends [T] ? unknown : FixNeverArray$1<ConvertedDeepNumberInternal<T, RemoveEmptyObjects, RemoveEmptyArrays, true>, RemoveEmptyArrays>;
1384
+ /**
1385
+ * ***Types options for {@link toNumberDeep | `toNumberDeep`}.***
1386
+ */
1387
+ type ToNumberDeepOptions<RemoveEmptyObjects extends boolean = false, RemoveEmptyArrays extends boolean = false> = {
1388
+ /** Whether to remove empty objects (`{}`) from the result.
1389
+ *
1390
+ * - `true` ➔ remove empty objects recursively.
1391
+ * - `false` **(default)** ➔ keep empty objects as-is.
1392
+ *
1393
+ * @default false
1394
+ */
1395
+ removeEmptyObjects?: RemoveEmptyObjects;
1396
+ /** Whether to remove empty arrays (`[]`) from the result.
1397
+ *
1398
+ * - `true` ➔ remove empty arrays recursively.
1399
+ * - `false` **(default)** ➔ keep empty arrays as-is.
1400
+ *
1401
+ * @default false
1402
+ */
1403
+ removeEmptyArrays?: RemoveEmptyArrays;
1404
+ };
1405
+ /** --------------------------------------------------
1406
+ * * ***Utility: `toNumberDeep`.***
1407
+ * ---------------------------------------------------
1408
+ * **Converts deeply nested arrays, objects, buffers, sets, maps, or typed arrays into numbers while preserving structure.**
1409
+ * - **Features:**
1410
+ * - Converts numeric strings, number to numbers:
1411
+ * - `3.5` ➔ `3.5`.
1412
+ * - `"3.5"` ➔ `3.5`.
1413
+ * - Converts boolean to number:
1414
+ * - `true` ➔ `1`.
1415
+ * - `false` ➔ `0`.
1416
+ * - Converts Date to getTime (timestamp) `Date ➔ number`, if invalid Date value will return `0`:
1417
+ * - `new Date("invalid")` ➔ `0`.
1418
+ * - `new Date("11-09-2025 22:04:11")` ➔ `1762700651000`.
1419
+ * - Converts `Buffer`, `TypedArray`, `Set`, `Map`, and `arrays` recursively to `arrays of numbers`.
1420
+ * - Converts boxed primitives box into their primitive equivalents then convert to number:
1421
+ * - For `new String` we convert everything to number (behavior JS of new String):
1422
+ * - `new String(123)` ➔ `.valueOf()` ➔ `"123"` ➔ `Number("123")` ➔ `123`.
1423
+ * - `new String("123")` ➔ `.valueOf()` ➔ `"123"` ➔ `Number("123")` ➔ `123`.
1424
+ * - `new String(true)` ➔ `.valueOf()` ➔ `"true"` ➔ `Number(true)` ➔ `1`.
1425
+ * - `new String(false)` ➔ `.valueOf()` ➔ `"false"` ➔ `Number(false)` ➔ `0`.
1426
+ * - If result from `valueOf()` is `NaN` or `Infinity` ***(will removing)***:
1427
+ * - `new String("hi")` ➔ `.valueOf()` ➔ `"hi"` ➔ `Number("hi")` ➔ `NaN` ***(remove)***.
1428
+ * - `new String(()=>{})` ➔ `.valueOf()` ➔ `"()=>{}"` ➔ `Number("()=>{}")` ➔ `NaN` ***(remove)***.
1429
+ * - For `new Boolean` we convert to boolean (behavior JS of new Boolean) then convert to number:
1430
+ * - `new Boolean(true)` ➔ `.valueOf()` ➔ `true` ➔ `Number(true)` ➔ `1`.
1431
+ * - `new Boolean(false)` ➔ `.valueOf()` ➔ `false` ➔ `Number(false)` ➔ `0`.
1432
+ * - Special behavior JS of new Boolean, return `false` **(convert to number: `0`)**
1433
+ * for `false`, (`0` / `-0`), `""` (empty-string),
1434
+ * `null`, `undefined`, `NaN`, otherwise `true` **(convert to number: `1`)**.
1435
+ * - For `new Number`:
1436
+ * - `new Number(42)` ➔ `.valueOf()` ➔ `42`.
1437
+ * - `new Number("42")` ➔ `.valueOf()` ➔ `42`.
1438
+ * - `new Number(null)` ➔ `.valueOf()` ➔ `0` (`null` is `0` behavior JS of new Number).
1439
+ * - If result from `valueOf()` is `NaN` or `Infinity` ***(will removing)***:
1440
+ * - `new Number(NaN)` ➔ `.valueOf()` ➔ `NaN` ***(remove)***.
1441
+ * - `new Number(undefined)` ➔ `.valueOf()` ➔ `NaN` ***(remove)***.
1442
+ * - `new Number(Infinity)` ➔ `.valueOf()` ➔ `Infinity` ***(remove)***.
1443
+ * - `new Number(-Infinity)` ➔ `.valueOf()` ➔ `-Infinity` ***(remove)***.
1444
+ * - Recursively processes `nested objects`, `arrays`, `buffers`, `sets`, `maps`, and `typed arrays`.
1445
+ * - Removes `empty-string`, `non-numeric strings`.
1446
+ * - Removes `null`, `undefined`, `NaN`, `Infinity`, `-Infinity`.
1447
+ * - Removes `unsupported` types like `functions` , `RegExp`, `symbols`, and `BigInt`.
1448
+ * - Can optionally remove empty arrays (`[]`) and/or empty objects (`{}`) **recursively**.
1449
+ * @template T - The input type.
1450
+ * @template RemoveEmptyObjects - Whether to remove empty objects.
1451
+ * @template RemoveEmptyArrays - Whether to remove empty arrays.
1452
+ * @param {*} input - The input value to convert.
1453
+ * @param {ToNumberDeepOptions<RemoveEmptyObjects, RemoveEmptyArrays>} [options] - Conversion options.
1454
+ * @returns {ConvertedDeepNumber<T, RemoveEmptyObjects, RemoveEmptyArrays>|undefined} The converted value, return `undefined` if the input is entirely empty or filtered out by options.
1455
+ * @example
1456
+ * ```ts
1457
+ * toNumberDeep("123");
1458
+ * // ➔ 123
1459
+ * toNumberDeep("abc");
1460
+ * // ➔ undefined
1461
+ * toNumberDeep([NaN, "10", "xyz"]);
1462
+ * // ➔ [10]
1463
+ * toNumberDeep({ a: "1", b: [null, "2"] });
1464
+ * // ➔ { a: 1, b: [2] }
1465
+ * toNumberDeep(Buffer.from([0, 1, 2]));
1466
+ * // ➔ [0, 1, 2]
1467
+ * toNumberDeep(new Set(["1", "2"]));
1468
+ * // ➔ [1, 2]
1469
+ * toNumberDeep(new Map([["a", "1"], ["b", "2"]]));
1470
+ * // ➔ [["a", 1], ["b", 2]]
1471
+ * toNumberDeep(new Int16Array([1, 2, 3]));
1472
+ * // ➔ [1, 2, 3]
1473
+ * toNumberDeep(new Date("2025-08-16T00:00:00Z"));
1474
+ * // ➔ 1755552000000
1475
+ * toNumberDeep({ a: {}, b: [] }, { removeEmptyObjects: true });
1476
+ * // ➔ { b: [] }
1477
+ * toNumberDeep({ a: {}, b: [] }, { removeEmptyArrays: true });
1478
+ * // ➔ { a: {} }
1479
+ * toNumberDeep({ x: {}, y: [], z: [{ a: {}, b: [] }] }, {
1480
+ * removeEmptyObjects: true, removeEmptyArrays: true
1481
+ * });
1482
+ * // ➔ { z: [] }
1483
+ * ```
1484
+ */
1485
+ declare function toNumberDeep(input?: null | undefined, options?: ToNumberDeepOptions<boolean, boolean>): undefined;
1486
+ declare function toNumberDeep<T, RemoveEmptyObjects extends boolean = false, RemoveEmptyArrays extends boolean = false>(input: T, options?: ToNumberDeepOptions<RemoveEmptyObjects, RemoveEmptyArrays>): ConvertedDeepNumber<T, RemoveEmptyObjects, RemoveEmptyArrays>;
1487
+ /** ----------------------------------------------------------
1488
+ * * Normalize leaked `never[]` into literal empty array `[]`.
1489
+ * ---------------------------------------------------------- */
1490
+ type FixNeverArray<T, RemoveEmptyArrays extends boolean> = [T] extends [never[]] ? RemoveEmptyArrays extends true ? OrArr<[Extends<T, undefined>, Extends<undefined, T>]> extends true ? undefined : never : [] : T;
1491
+ /** ----------------------------------------------------------
1492
+ * * Simplify object type to remove unnecessary TypeScript wrappers.
1493
+ * ---------------------------------------------------------- */
1494
+ type Simplify<T> = T extends object ? { [K in keyof T]: T[K] } : T;
1495
+ /** ----------------------------------------------------------
1496
+ * * Deeply convert all numbers and numeric strings to `string`,
1497
+ * * recursively handling arrays, tuples, Sets, Maps, TypedArrays,
1498
+ * * Buffer, and objects. Special types like Date remain unchanged.
1499
+ * ---------------------------------------------------------- */
1500
+ type ConvertedDeepStringInternal<T, RemoveEmptyObjects extends boolean, RemoveEmptyArrays extends boolean, IsRoot extends boolean> = [T] extends [null | undefined] ? IsRoot extends true ? undefined : never : T extends string | boolean | String | Boolean | Date | RegExp | WebApiObjects | IntlObjects | {
1501
+ [Symbol.toStringTag]: "Proxy";
1502
+ } | typeof Reflect ? string : T extends Number | number | `${number}` ? string | undefined : AndArr<[Extends<RemoveEmptyArrays, true>, Extends<T, undefined[]>]> extends true ? never : T extends readonly (infer E)[] ? OrArr<[Extends<RemoveEmptyArrays, true>, AndArr<[Extends<RemoveEmptyArrays, true>, Extends<IsRoot, true>]>]> extends true ? FixNeverArray<Exclude<ConvertedDeepStringInternal<E, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>, RemoveEmptyArrays>[] | undefined : FixNeverArray<Exclude<ConvertedDeepStringInternal<E, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>[], RemoveEmptyArrays> : T extends Set<infer V> ? AndArr<[Extends<RemoveEmptyArrays, true>]> extends true ? FixNeverArray<Exclude<ConvertedDeepStringInternal<V, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>, RemoveEmptyArrays> : FixNeverArray<Exclude<ConvertedDeepStringInternal<V, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>[], RemoveEmptyArrays> : T extends Map<infer K, infer V> ? FixNeverArray<[Exclude<ConvertedDeepStringInternal<K, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>, Exclude<ConvertedDeepStringInternal<V, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>][], RemoveEmptyArrays> : T extends Buffer ? FixNeverArray<Exclude<ConvertedDeepStringInternal<string, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>[], RemoveEmptyArrays> : T extends TypedArray ? FixNeverArray<Exclude<ConvertedDeepStringInternal<string, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>, undefined>[], RemoveEmptyArrays> : T extends Record<PropertyKey, unknown> ? _ConvertedObjectInternal<T, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> : never;
1503
+ /** ----------------------------------------------------------
1504
+ * * Internal object conversion utility.
1505
+ * * Removes empty objects/arrays based on flags.
1506
+ * ---------------------------------------------------------- */
1507
+ type _ConvertedObjectInternal<O extends Record<string | number | symbol, unknown> | string, RemoveEmptyObjects extends boolean, RemoveEmptyArrays extends boolean, IsRoot extends boolean> = { [K in keyof O as Exclude<ConvertedDeepStringInternal<O[K], RemoveEmptyObjects, RemoveEmptyArrays, false>, undefined> extends infer Convert ? [Convert] extends [never] ? never : undefined extends ConvertedDeepStringInternal<O[K], RemoveEmptyObjects, RemoveEmptyArrays, false> ? never : RemoveEmptyArrays extends true ? Convert extends readonly unknown[] ? [Convert] extends [[]] ? never : K : K : K : never]: Exclude<ConvertedDeepStringInternal<O[K], RemoveEmptyObjects, RemoveEmptyArrays, false>, undefined> } & { [K in keyof O as Exclude<ConvertedDeepStringInternal<O[K], RemoveEmptyObjects, RemoveEmptyArrays, false>, undefined> extends infer Convert ? [Convert] extends [never] ? never : undefined extends ConvertedDeepStringInternal<O[K], RemoveEmptyObjects, RemoveEmptyArrays, false> ? RemoveEmptyArrays extends true ? Convert extends readonly unknown[] ? [Convert] extends [[]] ? never : K : K : K : never : never]?: Exclude<ConvertedDeepStringInternal<O[K], RemoveEmptyObjects, RemoveEmptyArrays, false>, undefined> } extends infer M ? RemoveEmptyObjects extends true ? keyof M extends never ? IsRoot extends true ? {} : never : _ProcessedObject<M, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> : Simplify<M> : never;
1508
+ type AllPropsAreNumber<O> = { [K in keyof O]: O[K] extends number | Number ? true : O[K] extends Record<string, unknown> ? AllPropsAreNumber<O[K]> : false }[keyof O] extends false ? false : true;
1509
+ type _ProcessedObject<M, RemoveEmptyObjects extends boolean, RemoveEmptyArrays extends boolean, IsRoot extends boolean> = M extends unknown[] ? ConvertedDeepStringInternal<M, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> : Prettify<Simplify<{ [K in keyof M]: M[K] extends Record<string, unknown> ? AllPropsAreNumber<M[K]> extends true ? { [ChildKey in keyof M[K]]: M[K][ChildKey] extends number | Number ? M[K][ChildKey] | undefined : _ProcessedObject<M[K][ChildKey], RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> } | undefined : AndArr<[Extends<RemoveEmptyArrays, true>, Extends<RemoveEmptyObjects, true>]> extends true ? { [ChildKey in keyof M[K]]: _ProcessChild<M[K][ChildKey], RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> } | undefined : { [ChildKey in keyof M[K]]: _ProcessChild<M[K][ChildKey], RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> } : M[K] extends unknown[] ? ConvertedDeepStringInternal<M[K], RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> : _ProcessedObject<M[K], RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> }>, {
1510
+ recursive: true;
1511
+ }>;
1512
+ type _ProcessChild<T, RemoveEmptyObjects extends boolean, RemoveEmptyArrays extends boolean, IsRoot extends boolean> = T extends number | Number[] ? ConvertedDeepStringInternal<T, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> : T extends Record<string, unknown> ? _ProcessedObject<T, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot> : _ProcessedObject<T, RemoveEmptyObjects, RemoveEmptyArrays, IsRoot>;
1513
+ /** ----------------------------------------------------------
1514
+ * * Public type: Deeply converts numbers/strings to `string`,
1515
+ * * applies empty object/array removal, preserves special types.
1516
+ * ----------------------------------------------------------
1517
+ * ***Narrows types result for {@link toStringDeep | `toStringDeep`}.***
1518
+ */
1519
+ type ConvertedDeepString<T, RemoveEmptyObjects extends boolean = false, RemoveEmptyArrays extends boolean = false> = [unknown] extends [T] ? unknown : FixNeverArray<Simplify<ConvertedDeepStringInternal<T, RemoveEmptyObjects, RemoveEmptyArrays, true>>, RemoveEmptyArrays>;
1520
+ /**
1521
+ * ***Types options for {@link toStringDeep | `toStringDeep`}.***
1522
+ */
1523
+ type ToStringDeepOptions<RemoveEmptyObjects extends boolean = false, RemoveEmptyArrays extends boolean = false> = {
1524
+ /** Whether to remove empty objects (`{}`) from the result.
1525
+ *
1526
+ * - `true` ➔ remove empty objects recursively.
1527
+ * - `false` **(default)** ➔ keep empty objects as-is.
1528
+ *
1529
+ * @default false
1530
+ */
1531
+ removeEmptyObjects?: RemoveEmptyObjects;
1532
+ /** Whether to remove empty arrays (`[]`) from the result.
1533
+ *
1534
+ * - `true` ➔ remove empty arrays recursively.
1535
+ * - `false` **(default)** ➔ keep empty arrays as-is.
1536
+ *
1537
+ * @default false
1538
+ */
1539
+ removeEmptyArrays?: RemoveEmptyArrays;
1540
+ };
1541
+ /** --------------------------------------------------
1542
+ * * ***Utility: `toStringDeep`.***
1543
+ * ---------------------------------------------------
1544
+ * **Converts all values in an array, object, Set, Map, or deeply nested structure to string.**
1545
+ * - **Features:**
1546
+ * - Converts numbers and strings to string:
1547
+ * - `3.5` ➔ `"3.5"`.
1548
+ * - `"3.5"` ➔ `"3.5"`.
1549
+ * - Converts boolean to string:
1550
+ * - `true` ➔ `"true"`.
1551
+ * - `false` ➔ `"false"`.
1552
+ * - Converts Date to ISO string (`Date ➔ string`).
1553
+ * - Converts RegExp to string (e.g., `/abc/ ➔ "/abc/"`).
1554
+ * - Converts `Buffer`, `TypedArray`, `Set`, `Map`, and `arrays` recursively to `arrays of strings`.
1555
+ * - Converts boxed primitives box into their primitive equivalents then convert to string:
1556
+ * - For `new String` we convert everything to string (behavior JS of new String):
1557
+ * - `new String("hi")` ➔ `.valueOf()` ➔ `"hi"`.
1558
+ * - `new String(true)` ➔ `.valueOf()` ➔ `"true"`.
1559
+ * - For `new Boolean` we convert to boolean (behavior JS of new Boolean) then convert to string:
1560
+ * - `new Boolean(true)` ➔ `.valueOf()` ➔ `true` ➔ `true.toString()` ➔ `"true"`.
1561
+ * - Special behavior JS of new Boolean, return `false` **(convert to string: `"false"`)**
1562
+ * for `false`, (`0` / `-0`), `""` (empty-string), `null`, `undefined`, `NaN`, otherwise
1563
+ * `true` **(convert to string: `"true"`)**.
1564
+ * - For `new Number`:
1565
+ * - `new Number(42)` ➔ `.valueOf()` ➔ `42` ➔ `42.toString()` ➔ `"42"`.
1566
+ * - `new Number("42")` ➔ `.valueOf()` ➔ `42` ➔ `42.toString()` ➔ `"42"`.
1567
+ * - `new Number(null)` ➔ `.valueOf()` ➔ `0` (`null` is `0` behavior JS of new Number) ➔ `0.toString()` ➔ `"0"`.
1568
+ * - If result from `valueOf()` is `NaN` or `Infinity` ***(will removing)***:
1569
+ * - `new Number(NaN)` ➔ `.valueOf()` ➔ `NaN` ***(remove)***.
1570
+ * - `new Number("abc")` ➔ `.valueOf()` ➔ `NaN` ***(remove)***.
1571
+ * - `new Number(undefined)` ➔ `.valueOf()` ➔ `NaN` ***(remove)***.
1572
+ * - `new Number(Infinity)` ➔ `.valueOf()` ➔ `Infinity` ***(remove)***.
1573
+ * - `new Number(-Infinity)` ➔ `.valueOf()` ➔ `-Infinity` ***(remove)***.
1574
+ * - Recursively processes `nested objects`, `arrays`, `buffers`, `sets`, `maps`, and `typed arrays`.
1575
+ * - Removes `null`, `undefined`, `NaN`, `Infinity`, `-Infinity`.
1576
+ * - Removes `unsupported` types like `functions`, `symbols`, and `BigInt`.
1577
+ * - Can optionally remove empty arrays (`[]`) and/or empty objects (`{}`) **recursively**.
1578
+ * @template T - The input data type (`primitive`, `object`, `array`, `Set`, `Map`, or `any nested combination`).
1579
+ * @template RemoveEmptyObjects - If `true`, empty objects `{}` will be removed recursively.
1580
+ * @template RemoveEmptyArrays - If `true`, empty arrays `[]` will be removed recursively (including arrays nested in `objects` / `arrays` / `Sets` / `Maps`).
1581
+ * @param {*} input - The data to convert.
1582
+ * @param {ToStringDeepOptions<RemoveEmptyObjects, RemoveEmptyArrays>} [options] - Conversion options.
1583
+ * @returns {ConvertedDeepString<T, RemoveEmptyObjects, RemoveEmptyArrays>|undefined}
1584
+ * The transformed data, or `undefined` if the entire structure becomes empty after processing.
1585
+ * @example
1586
+ * ```ts
1587
+ * // Simple array conversion
1588
+ * toStringDeep([1, "2", 3]);
1589
+ * // ➔ ["1", "2", "3"]
1590
+ *
1591
+ * // Simple top-level conversion
1592
+ * toStringDeep(123);
1593
+ * // ➔ "123"
1594
+ * toStringDeep("123");
1595
+ * // ➔ "123"
1596
+ * toStringDeep(true);
1597
+ * // ➔ "true"
1598
+ * toStringDeep(false);
1599
+ * // ➔ "false"
1600
+ *
1601
+ * // Nested arrays
1602
+ * toStringDeep([1, ["2", [3, [null, "4", true, false]]]]);
1603
+ * // ➔ ["1", ["2", ["3", ["4", "true", "false"]]]]
1604
+ *
1605
+ * // Object with nested values
1606
+ * toStringDeep({ a: 1, b: "2", c: { d: 3, e: null, f: true, g: false } });
1607
+ * // ➔ { a: "1", b: "2", c: { d: "3", f: "true", g: "false" } }
1608
+ *
1609
+ * // Removing empty objects
1610
+ * toStringDeep({ a: {}, b: "1" }, { removeEmptyObjects: true });
1611
+ * // ➔ { b: "1" }
1612
+ *
1613
+ * // Removing empty arrays recursively
1614
+ * toStringDeep(["1", [], { a: [] }], { removeEmptyArrays: true });
1615
+ * // ➔ ["1", { a: [] }]
1616
+ *
1617
+ * // Removing both empty objects and arrays recursively
1618
+ * toStringDeep({ a: {}, b: [], c: [{ d: {}, e: [] }, "1"] }, {
1619
+ * removeEmptyObjects: true,
1620
+ * removeEmptyArrays: true
1621
+ * });
1622
+ * // ➔ { c: ["1"] }
1623
+ *
1624
+ * // Fully empty structure becomes undefined
1625
+ * toStringDeep([null, undefined, {}], {
1626
+ * removeEmptyObjects: true,
1627
+ * removeEmptyArrays: true
1628
+ * });
1629
+ * // ➔ undefined
1630
+ * ```
1631
+ */
1632
+ declare function toStringDeep(input?: null | undefined, options?: ToStringDeepOptions<boolean, boolean>): undefined;
1633
+ declare function toStringDeep<T, RemoveEmptyObjects extends boolean = false, RemoveEmptyArrays extends boolean = false>(input: T, options?: ToStringDeepOptions<RemoveEmptyObjects, RemoveEmptyArrays>): ConvertedDeepString<T, RemoveEmptyObjects, RemoveEmptyArrays>;
1634
+ /** ----------------------------------------------------------
1635
+ * * ***Utility: `toStringDeepForce`.***
1636
+ * ---------------------------------------------
1637
+ * **Recursively converts a value into a string based on the `forceToString` options.**
1638
+ * - **Rules `forceToString` options:**
1639
+ * - `"stringOrNumber"`: Converts strings and numbers to strings.
1640
+ * - `"primitives"`: Converts all primitives (number, string, boolean, bigint, undefined, null, NaN) to strings.
1641
+ * - `"all"`: Converts everything, including symbols, functions, Dates, RegExp, Maps, Sets, Errors, Promises,
1642
+ * boxed primitives box (new Number, new String, new Boolean), and deeply all object properties, to strings.
1643
+ * - `false`: Leaves everything unchanged.
1644
+ * - **Special behaviors:**
1645
+ * - `NaN` ➔ `"NaN"` only in `"primitives"` or `"all"` mode.
1646
+ * - `Date` ➔ ISO string only in `"all"` mode.
1647
+ * - ***Primitives Boxed*** (`new Number`, `new String`, `new Boolean`):
1648
+ * - For `new String` we convert everything to string (behavior JS of new String):
1649
+ * - `new String("hi")` ➔ `.valueOf()` ➔ `"hi"`.
1650
+ * - `new String(true)` ➔ `.valueOf()` ➔ `"true"`.
1651
+ * - For `new Boolean` we convert to boolean (behavior JS of new Boolean) then convert to string:
1652
+ * - `new Boolean(true)` ➔ `.valueOf()` ➔ `true` ➔ `true.toString()` ➔ `"true"`.
1653
+ * - Special behavior JS of new Boolean, return `false` **(convert to string: `"false"`)**
1654
+ * for `false`, (`0` / `-0`), `""` (empty-string), `null`, `undefined`, `NaN`, otherwise
1655
+ * `true` **(convert to string: `"true"`)**.
1656
+ * - For `new Number`:
1657
+ * - `new Number(42)` ➔ `.valueOf()` ➔ `42` ➔ `42.toString()` ➔ `"42"`.
1658
+ * - `new Number(NaN)` ➔ `.valueOf()` ➔ `NaN` ➔ `NaN.toString()` ➔ `"NaN"`.
1659
+ * - `new Number(null)` ➔ `.valueOf()` ➔ `0` (`null` is `0` behavior JS of new Number) ➔ `0.toString()` ➔ `"0"`.
1660
+ * - `new Number(undefined)` ➔ `.valueOf()` ➔ `NaN` ➔ `NaN.toString()` ➔ `"NaN"`.
1661
+ * - `new Number(Infinity)` ➔ `Infinity` ➔ `Infinity` ➔ `Infinity.toString()` ➔ `"Infinity"`.
1662
+ * - `new Number(-Infinity)` ➔ `-Infinity` ➔ `-Infinity` ➔ `-Infinity.toString()` ➔ `"-Infinity"`.
1663
+ * - `RegExp` ➔ Source string (e.g. `/abc/i`) only in `"all"` mode.
1664
+ * - `Symbol` ➔ `Symbol(description)` string only in `"all"` mode.
1665
+ * - `Map` ➔ Array of [key, value] pairs with keys/values stringified deeply (only in `"all"` mode).
1666
+ * - `Set` ➔ Array of values stringified deeply (only in `"all"` mode).
1667
+ * - `Function` ➔ Source code string (e.g. `"() => 1"`) only in `"all"` mode.
1668
+ * - `Error`, `Promise` ➔ Stringified via `.toString()` only in `"all"` mode.
1669
+ * @param {*} value
1670
+ * * ***The value to process.***
1671
+ * - ***Can be anything:***
1672
+ * - `primitive`.
1673
+ * - `array`.
1674
+ * - `object`.
1675
+ * - `function`.
1676
+ * - `etc`.
1677
+ * @param {false | "stringOrNumber" | "primitives" | "all"} forceToString - ***The mode of string conversion.***
1678
+ * @returns {unknown} A new value with the conversion applied based on `forceToString`.
1679
+ * @example
1680
+ * toStringDeepForce(42, "stringOrNumber");
1681
+ * // ➔ "42"
1682
+ * toStringDeepForce(true, "primitives");
1683
+ * // ➔ "true"
1684
+ * toStringDeepForce(null, "primitives");
1685
+ * // ➔ "null"
1686
+ * toStringDeepForce(Symbol("x"), "all");
1687
+ * // ➔ "Symbol(x)"
1688
+ * toStringDeepForce(new String("hi"), "all");
1689
+ * // ➔ "hi"
1690
+ * toStringDeepForce(new Number(42), "all");
1691
+ * // ➔ "42"
1692
+ * toStringDeepForce(new Boolean(true), "all");
1693
+ * // ➔ "true"
1694
+ * toStringDeepForce({ a: 1, b: [2, NaN] }, "primitives");
1695
+ * // ➔ { a: "1", b: ["2", "NaN"] }
1696
+ * toStringDeepForce(new Date("2025-01-01"), "all");
1697
+ * // ➔ "2025-01-01T00:00:00.000Z"
1698
+ * toStringDeepForce(() => 1, "all");
1699
+ * // ➔ "() => 1"
1700
+ * toStringDeepForce(/abc/i, "all");
1701
+ * // ➔ "/abc/i"
1702
+ * toStringDeepForce(new Map([["a", 1], ["b", 2]]), "all");
1703
+ * // ➔ [["a", "1"], ["b", "2"]]
1704
+ * toStringDeepForce(new Set([1, 2, 3]), "all");
1705
+ * // ➔ ["1", "2", "3"]
1706
+ * toStringDeepForce(new Error("Oops"), "all");
1707
+ * // ➔ "Error: Oops"
1708
+ * toStringDeepForce(Promise.resolve(1), "all");
1709
+ * // ➔ "[object Promise]"
1710
+ * toStringDeepForce({ func: () => 123 }, "all");
1711
+ * // ➔ { func: "() => 123" }
1712
+ * toStringDeepForce([1, "a", { b: 2 }], false);
1713
+ * // ➔ [1, "a", { b: 2 }]
1714
+ */
1715
+ declare function toStringDeepForce<T>(value: unknown, forceToString: false | "stringOrNumber" | "primitives" | "all"): T;
1716
+ export { dedupeArray as _, removeObjectPaths as a, parseCustomDate as c, parseCurrencyString as d, toBooleanLoose as f, filterNilArray as g, toBooleanContent as h, safeStableStringify as i, cleanParsedData as l, toBooleanContentDeep as m, toStringDeep as n, extractDigits as o, toBooleanExplicit as p, toNumberDeep as r, safeJsonParse as s, toStringDeepForce as t, convertType as u, toStringArrayUnRecursive as v, toNumberArrayUnRecursive as y };