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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/{LICENSE.md → LICENSE} +3 -3
  2. package/README.md +62 -89
  3. package/dist/.references/index.d.cts +25 -0
  4. package/dist/.references/index.d.ts +25 -0
  5. package/dist/assertIsArray-BChqwPiP.cjs +26 -0
  6. package/dist/assertIsArray-BChqwPiP.cjs.map +1 -0
  7. package/dist/assertIsArray-BfAbIUfa.js +20 -0
  8. package/dist/assertIsArray-BfAbIUfa.js.map +1 -0
  9. package/dist/assertIsBoolean-BlBct0Fc.js +1073 -0
  10. package/dist/assertIsBoolean-BlBct0Fc.js.map +1 -0
  11. package/dist/assertIsBoolean-DozdtbNi.cjs +1283 -0
  12. package/dist/assertIsBoolean-DozdtbNi.cjs.map +1 -0
  13. package/dist/assertIsString-Bvk7bUL7.cjs +26 -0
  14. package/dist/assertIsString-Bvk7bUL7.cjs.map +1 -0
  15. package/dist/assertIsString-DqV9NwbI.js +20 -0
  16. package/dist/assertIsString-DqV9NwbI.js.map +1 -0
  17. package/dist/assertions/index.cjs +37 -40
  18. package/dist/assertions/index.cjs.map +1 -0
  19. package/dist/assertions/index.d.cts +12 -0
  20. package/dist/assertions/index.d.ts +10 -824
  21. package/dist/assertions/index.js +30 -13
  22. package/dist/assertions/index.js.map +1 -0
  23. package/dist/conversions/index.cjs +34 -103
  24. package/dist/conversions/index.d.cts +12 -0
  25. package/dist/conversions/index.d.ts +10 -1791
  26. package/dist/conversions/index.js +14 -24
  27. package/dist/conversions-CBs8-REq.cjs +448 -0
  28. package/dist/conversions-CBs8-REq.cjs.map +1 -0
  29. package/dist/conversions-EMJa3g-D.js +382 -0
  30. package/dist/conversions-EMJa3g-D.js.map +1 -0
  31. package/dist/events/index.cjs +55 -31
  32. package/dist/events/index.cjs.map +1 -0
  33. package/dist/events/index.d.cts +174 -0
  34. package/dist/events/index.d.ts +31 -35
  35. package/dist/events/index.js +50 -12
  36. package/dist/events/index.js.map +1 -0
  37. package/dist/formatEnvPort-DpIXzPAZ.js +159 -0
  38. package/dist/formatEnvPort-DpIXzPAZ.js.map +1 -0
  39. package/dist/formatEnvPort-hHNvOim-.cjs +171 -0
  40. package/dist/formatEnvPort-hHNvOim-.cjs.map +1 -0
  41. package/dist/formatters/index.cjs +21 -61
  42. package/dist/formatters/index.d.cts +12 -0
  43. package/dist/formatters/index.d.ts +10 -2152
  44. package/dist/formatters/index.js +10 -18
  45. package/dist/formatters-QcZO_Cpx.js +367 -0
  46. package/dist/formatters-QcZO_Cpx.js.map +1 -0
  47. package/dist/formatters-lAYgA11L.cjs +427 -0
  48. package/dist/formatters-lAYgA11L.cjs.map +1 -0
  49. package/dist/generators/index.cjs +161 -41
  50. package/dist/generators/index.cjs.map +1 -0
  51. package/dist/generators/index.d.cts +12 -0
  52. package/dist/generators/index.d.ts +10 -338
  53. package/dist/generators/index.js +154 -14
  54. package/dist/generators/index.js.map +1 -0
  55. package/dist/index-26W7ItWx.d.ts +760 -0
  56. package/dist/index-BPPQjAfs.d.cts +2359 -0
  57. package/dist/index-BXjlgBLz.d.cts +2139 -0
  58. package/dist/index-B_Wwo91H.d.ts +2359 -0
  59. package/dist/index-CpufydcI.d.cts +704 -0
  60. package/dist/index-Czc4O526.d.ts +333 -0
  61. package/dist/index-DPs1_p5G.d.cts +760 -0
  62. package/dist/index-DRpOyBSC.d.ts +1703 -0
  63. package/dist/index-DWWvtHUn.d.cts +822 -0
  64. package/dist/index-DnM0LD0n.d.cts +333 -0
  65. package/dist/index-GUZ9fK6T.d.ts +2139 -0
  66. package/dist/index-I4fAzwXV.d.ts +704 -0
  67. package/dist/index-JDrOl_19.d.ts +822 -0
  68. package/dist/index-b66P49Qe.d.cts +1703 -0
  69. package/dist/isBigInt-B1cijjqm.cjs +20 -0
  70. package/dist/isBigInt-B1cijjqm.cjs.map +1 -0
  71. package/dist/isBigInt-C0bN0Rhu.js +14 -0
  72. package/dist/isBigInt-C0bN0Rhu.js.map +1 -0
  73. package/dist/isEmptyObject-DI42NEo0.cjs +37 -0
  74. package/dist/isEmptyObject-DI42NEo0.cjs.map +1 -0
  75. package/dist/isEmptyObject-DeLVIJpl.js +25 -0
  76. package/dist/isEmptyObject-DeLVIJpl.js.map +1 -0
  77. package/dist/isEmptyString-BTUWYTbw.js +15 -0
  78. package/dist/isEmptyString-BTUWYTbw.js.map +1 -0
  79. package/dist/isEmptyString-CCK3bP74.cjs +21 -0
  80. package/dist/isEmptyString-CCK3bP74.cjs.map +1 -0
  81. package/dist/isEmptyValue-DMSMFTU8.cjs +30 -0
  82. package/dist/isEmptyValue-DMSMFTU8.cjs.map +1 -0
  83. package/dist/isEmptyValue-fjnfQnt5.js +24 -0
  84. package/dist/isEmptyValue-fjnfQnt5.js.map +1 -0
  85. package/dist/isEqual-B1fRgEuU.cjs +111 -0
  86. package/dist/isEqual-B1fRgEuU.cjs.map +1 -0
  87. package/dist/isEqual-DhyP8fB_.js +87 -0
  88. package/dist/isEqual-DhyP8fB_.js.map +1 -0
  89. package/dist/isFinite-BYMOo0os.js +15 -0
  90. package/dist/isFinite-BYMOo0os.js.map +1 -0
  91. package/dist/isFinite-sFkps2TY.cjs +21 -0
  92. package/dist/isFinite-sFkps2TY.cjs.map +1 -0
  93. package/dist/isInteger-DS9V7l_f.js +14 -0
  94. package/dist/isInteger-DS9V7l_f.js.map +1 -0
  95. package/dist/isInteger-FTCthMre.cjs +20 -0
  96. package/dist/isInteger-FTCthMre.cjs.map +1 -0
  97. package/dist/isPlainObject-DcFGh3_5.d.ts +530 -0
  98. package/dist/isPlainObject-doTI11Ib.d.cts +530 -0
  99. package/dist/isServer-D1TXfOs3.js +14 -0
  100. package/dist/isServer-D1TXfOs3.js.map +1 -0
  101. package/dist/isServer-q-QLFCqE.cjs +20 -0
  102. package/dist/isServer-q-QLFCqE.cjs.map +1 -0
  103. package/dist/isTypedArray-47R0wdrc.js +31 -0
  104. package/dist/isTypedArray-47R0wdrc.js.map +1 -0
  105. package/dist/isTypedArray-DiCoqffZ.cjs +43 -0
  106. package/dist/isTypedArray-DiCoqffZ.cjs.map +1 -0
  107. package/dist/isURL-CQiowFq2.js +14 -0
  108. package/dist/isURL-CQiowFq2.js.map +1 -0
  109. package/dist/isURL-WZypXsax.cjs +20 -0
  110. package/dist/isURL-WZypXsax.cjs.map +1 -0
  111. package/dist/isValidDomain-BSXshgkC.cjs +1788 -0
  112. package/dist/isValidDomain-BSXshgkC.cjs.map +1 -0
  113. package/dist/isValidDomain-DwA2EN79.js +1782 -0
  114. package/dist/isValidDomain-DwA2EN79.js.map +1 -0
  115. package/dist/next/index.cjs +119 -214
  116. package/dist/next/index.cjs.map +1 -0
  117. package/dist/next/index.d.cts +226 -0
  118. package/dist/next/index.d.ts +26 -31
  119. package/dist/next/index.js +117 -212
  120. package/dist/next/index.js.map +1 -0
  121. package/dist/next/server/index.cjs +25 -40
  122. package/dist/next/server/index.cjs.map +1 -0
  123. package/dist/next/server/index.d.cts +39 -0
  124. package/dist/next/server/index.d.ts +9 -10
  125. package/dist/next/server/index.js +23 -38
  126. package/dist/next/server/index.js.map +1 -0
  127. package/dist/noop-B2mTBhW-.cjs +18 -0
  128. package/dist/noop-B2mTBhW-.cjs.map +1 -0
  129. package/dist/noop-BzktGBVz.js +12 -0
  130. package/dist/noop-BzktGBVz.js.map +1 -0
  131. package/dist/normalizeSpaces-DQHR3Tlr.cjs +29 -0
  132. package/dist/normalizeSpaces-DQHR3Tlr.cjs.map +1 -0
  133. package/dist/normalizeSpaces-WS_iERJk.js +23 -0
  134. package/dist/normalizeSpaces-WS_iERJk.js.map +1 -0
  135. package/dist/normalizeString-2WLth_Gj.js +15 -0
  136. package/dist/normalizeString-2WLth_Gj.js.map +1 -0
  137. package/dist/normalizeString-D8euBcRD.cjs +21 -0
  138. package/dist/normalizeString-D8euBcRD.cjs.map +1 -0
  139. package/dist/operations/index.cjs +65 -32
  140. package/dist/operations/index.cjs.map +1 -0
  141. package/dist/operations/index.d.cts +139 -0
  142. package/dist/operations/index.d.ts +10 -15
  143. package/dist/operations/index.js +61 -17
  144. package/dist/operations/index.js.map +1 -0
  145. package/dist/parsers/index.cjs +12 -19
  146. package/dist/parsers/index.d.cts +239 -0
  147. package/dist/parsers/index.d.ts +71 -72
  148. package/dist/parsers/index.js +10 -12
  149. package/dist/parsers-DXtpsDyj.cjs +649 -0
  150. package/dist/parsers-DXtpsDyj.cjs.map +1 -0
  151. package/dist/parsers-Dpuq-V4u.js +643 -0
  152. package/dist/parsers-Dpuq-V4u.js.map +1 -0
  153. package/dist/parsing-B43x1sxn.js +50 -0
  154. package/dist/parsing-B43x1sxn.js.map +1 -0
  155. package/dist/parsing-lRoxn1Nz.cjs +56 -0
  156. package/dist/parsing-lRoxn1Nz.cjs.map +1 -0
  157. package/dist/predicates/index.cjs +91 -296
  158. package/dist/predicates/index.d.cts +13 -0
  159. package/dist/predicates/index.d.ts +12 -2482
  160. package/dist/predicates/index.js +23 -25
  161. package/dist/predicates-DiaYA7Ps.cjs +413 -0
  162. package/dist/predicates-DiaYA7Ps.cjs.map +1 -0
  163. package/dist/predicates-gNepszvo.js +257 -0
  164. package/dist/predicates-gNepszvo.js.map +1 -0
  165. package/dist/promises/index.cjs +76 -24
  166. package/dist/promises/index.cjs.map +1 -0
  167. package/dist/promises/index.d.cts +123 -0
  168. package/dist/promises/index.d.ts +28 -31
  169. package/dist/promises/index.js +73 -13
  170. package/dist/promises/index.js.map +1 -0
  171. package/dist/punyCode-CTWXVVFo.cjs +185 -0
  172. package/dist/punyCode-CTWXVVFo.cjs.map +1 -0
  173. package/dist/punyCode-hmiFzLWT.js +179 -0
  174. package/dist/punyCode-hmiFzLWT.js.map +1 -0
  175. package/dist/removeSpaces-BE8lfh-4.js +19 -0
  176. package/dist/removeSpaces-BE8lfh-4.js.map +1 -0
  177. package/dist/removeSpaces-DRRxNWlb.cjs +25 -0
  178. package/dist/removeSpaces-DRRxNWlb.cjs.map +1 -0
  179. package/dist/safeJsonParse-BBnQElk8.cjs +208 -0
  180. package/dist/safeJsonParse-BBnQElk8.cjs.map +1 -0
  181. package/dist/safeJsonParse-CXruaP0p.js +184 -0
  182. package/dist/safeJsonParse-CXruaP0p.js.map +1 -0
  183. package/dist/safeStableStringify-BNh3D0K0.js +88 -0
  184. package/dist/safeStableStringify-BNh3D0K0.js.map +1 -0
  185. package/dist/safeStableStringify-Cc62pfRp.cjs +106 -0
  186. package/dist/safeStableStringify-Cc62pfRp.cjs.map +1 -0
  187. package/dist/strings/index.cjs +76 -81
  188. package/dist/strings/index.cjs.map +1 -0
  189. package/dist/strings/index.d.cts +12 -0
  190. package/dist/strings/index.d.ts +10 -775
  191. package/dist/strings/index.js +59 -14
  192. package/dist/strings/index.js.map +1 -0
  193. package/dist/tailwind/index.cjs +19 -47
  194. package/dist/tailwind/index.d.cts +12 -0
  195. package/dist/tailwind/index.d.ts +11 -712
  196. package/dist/tailwind/index.js +10 -12
  197. package/dist/tailwind-DJ4cmLUw.cjs +247 -0
  198. package/dist/tailwind-DJ4cmLUw.cjs.map +1 -0
  199. package/dist/tailwind-IJvOdkZp.js +199 -0
  200. package/dist/tailwind-IJvOdkZp.js.map +1 -0
  201. package/dist/toStringArrayUnRecursive-CFs0jTEg.js +39 -0
  202. package/dist/toStringArrayUnRecursive-CFs0jTEg.js.map +1 -0
  203. package/dist/toStringArrayUnRecursive-xUaU8Ot9.cjs +51 -0
  204. package/dist/toStringArrayUnRecursive-xUaU8Ot9.cjs.map +1 -0
  205. package/dist/urls/index.cjs +129 -57
  206. package/dist/urls/index.cjs.map +1 -0
  207. package/dist/urls/index.d.cts +740 -0
  208. package/dist/urls/index.d.ts +218 -224
  209. package/dist/urls/index.js +121 -26
  210. package/dist/urls/index.js.map +1 -0
  211. package/package.json +203 -194
  212. package/dist/chunk-2AFQ33D3.cjs +0 -64
  213. package/dist/chunk-2CYDJVGM.js +0 -246
  214. package/dist/chunk-2MW4JDQ2.cjs +0 -598
  215. package/dist/chunk-2VTDXC3N.cjs +0 -1825
  216. package/dist/chunk-44XX2P34.js +0 -209
  217. package/dist/chunk-4YLBKLGS.cjs +0 -18
  218. package/dist/chunk-566CXQW7.cjs +0 -560
  219. package/dist/chunk-57EPKYID.cjs +0 -397
  220. package/dist/chunk-5MGEC3YG.js +0 -63
  221. package/dist/chunk-6EF52423.cjs +0 -249
  222. package/dist/chunk-6SCOKU3S.js +0 -109
  223. package/dist/chunk-6VUXD3CF.js +0 -119
  224. package/dist/chunk-7B76BSNK.cjs +0 -118
  225. package/dist/chunk-7Y6I2DSU.cjs +0 -101
  226. package/dist/chunk-A7S7E2EE.cjs +0 -308
  227. package/dist/chunk-AJZ6PMMZ.js +0 -16
  228. package/dist/chunk-AXGBL2IO.cjs +0 -251
  229. package/dist/chunk-B4TC6FBV.cjs +0 -678
  230. package/dist/chunk-BAV5T2E3.cjs +0 -15
  231. package/dist/chunk-BKIJBNIE.js +0 -21
  232. package/dist/chunk-BNIMTFK5.js +0 -59
  233. package/dist/chunk-BXW7YXB7.js +0 -1823
  234. package/dist/chunk-CFYZC4S6.js +0 -53
  235. package/dist/chunk-CSG4SCL3.js +0 -1587
  236. package/dist/chunk-CWQW7AKK.js +0 -676
  237. package/dist/chunk-DVMHRLKP.cjs +0 -16
  238. package/dist/chunk-EN7LVZBZ.js +0 -548
  239. package/dist/chunk-EV4Y7HCY.cjs +0 -26
  240. package/dist/chunk-F66VDYIZ.cjs +0 -18
  241. package/dist/chunk-FLJX37EL.cjs +0 -30
  242. package/dist/chunk-GKC3UDMC.cjs +0 -1623
  243. package/dist/chunk-H65I3GRZ.cjs +0 -106
  244. package/dist/chunk-HHYWB7VZ.js +0 -24
  245. package/dist/chunk-HNGGISFL.cjs +0 -65
  246. package/dist/chunk-HNSQAVSZ.cjs +0 -35
  247. package/dist/chunk-HSP6IWZK.js +0 -17
  248. package/dist/chunk-IDZS7J6T.js +0 -242
  249. package/dist/chunk-JS6R55VL.js +0 -302
  250. package/dist/chunk-JZVT5FK7.js +0 -232
  251. package/dist/chunk-KHO2SBNA.cjs +0 -16
  252. package/dist/chunk-KIDJCMNJ.js +0 -33
  253. package/dist/chunk-KOLEURVT.cjs +0 -38
  254. package/dist/chunk-L4V53MQK.cjs +0 -269
  255. package/dist/chunk-L5RDAVVH.js +0 -14
  256. package/dist/chunk-NODTV4F3.js +0 -16
  257. package/dist/chunk-NYK5K3V2.cjs +0 -211
  258. package/dist/chunk-ODUO3RTL.cjs +0 -113
  259. package/dist/chunk-ONZFBJVW.js +0 -14
  260. package/dist/chunk-PFXCTE37.js +0 -28
  261. package/dist/chunk-PPST7QAQ.js +0 -587
  262. package/dist/chunk-Q5IMYDFL.cjs +0 -33
  263. package/dist/chunk-QFFBIOJ4.js +0 -31
  264. package/dist/chunk-QNKGP5DY.js +0 -14
  265. package/dist/chunk-RRQHMOPE.cjs +0 -19
  266. package/dist/chunk-RU5OSRBU.js +0 -95
  267. package/dist/chunk-SDMPEJ4F.js +0 -35
  268. package/dist/chunk-SYNL5IKP.js +0 -115
  269. package/dist/chunk-TCDOWZQE.js +0 -16
  270. package/dist/chunk-TQPGXGKB.cjs +0 -123
  271. package/dist/chunk-TULOI4GL.js +0 -370
  272. package/dist/chunk-UBHCP4N5.cjs +0 -36
  273. package/dist/chunk-UCHF3M34.cjs +0 -56
  274. package/dist/chunk-UDA26MCU.cjs +0 -16
  275. package/dist/chunk-V3C4FYZL.cjs +0 -18
  276. package/dist/chunk-VAAHZFBF.js +0 -32
  277. package/dist/chunk-VJDDGRIK.cjs +0 -16
  278. package/dist/chunk-WVSPXFTY.js +0 -14
  279. package/dist/chunk-WYP76WXB.js +0 -101
  280. package/dist/chunk-YDE4ZBB7.cjs +0 -237
  281. package/dist/chunk-YKQEOO7C.cjs +0 -23
  282. package/dist/chunk-YSZC56SZ.js +0 -264
  283. package/dist/chunk-YWHHVDT4.js +0 -13
  284. package/dist/index.d.ts +0 -24
  285. package/dist/isPlainObject-DTJVV2Kf.d.ts +0 -536
  286. package/dist/rzl-utils.global.js +0 -10
@@ -1,2154 +1,12 @@
1
1
  /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.12.0.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- import { NumberFormat, CountryCode } from 'libphonenumber-js';
11
- import { OverrideTypes, ExtractStrict, Prettify, OmitStrict, AnyString } from '@rzl-zone/ts-types-plus';
12
- import { FormatOptions, Locale } from 'date-fns';
13
-
14
- type NegativeFormatOptionCustom = {
15
- /** Custom formatter function for the final formatted negative string.
16
- * If provided, it ***OVERRIDES*** style & space entirely. */
17
- custom: (formatted: string) => string;
18
- style?: never;
19
- space?: never;
20
- };
21
- type NegativeFormatOptionUnCustom = {
22
- custom?: never;
23
- /** Use style & optional spacing for negative numbers.
24
- *
25
- * @default "dash"
26
- */
27
- style?: "dash" | "brackets" | "abs";
28
- /** Whether to include space inside brackets or after dash.
29
- *
30
- * Default: false
31
- * @default false
32
- */
33
- space?: boolean;
34
- };
35
- /** ---------------------------------------------------------------------------
36
- * * ***Type for negative number formatting options.***
37
- * ---------------------------------------------------------------------------
38
- */
39
- type NegativeFormatOption = "dash" | "brackets" | "abs" | NegativeFormatOptionCustom | NegativeFormatOptionUnCustom;
40
- /** ---------------------------------------------------------------------------
41
- * * ***Type Options for {@link formatCurrency|`formatCurrency`}.***
42
- * ---------------------------------------------------------------------------
43
- */
44
- type FormatCurrencyOptions = {
45
- /** ---------------------------------------------------------------------------
46
- * * ***Prefix currency string.***
47
- * ---------------------------------------------------------------------------
48
- * **Does not auto-keep input symbols.**
49
- * - ***DefaultValue:** `""`.*
50
- * - **Example:** `"Rp "` ➔ `Rp 1.000`.
51
- *
52
- * @default ""
53
- */
54
- suffixCurrency?: string;
55
- /** ---------------------------------------------------------------------------
56
- * * ***Thousands separator.***
57
- * ---------------------------------------------------------------------------
58
- * - ***DefaultValue:** `"."`.*
59
- * - **Example:** `"."` ➔ `1.000.000`.
60
- * @default "."
61
- */
62
- separator?: string;
63
- /** ---------------------------------------------------------------------------
64
- * * ***Prefix currency string.***
65
- * ---------------------------------------------------------------------------
66
- * **Whether to show decimals, if `false`, decimals are truncated.**
67
- * - ***DefaultValue:** `false`.*
68
- * @default false
69
- */
70
- decimal?: boolean;
71
- /** ---------------------------------------------------------------------------
72
- * * ***Total decimal digits.***
73
- * ---------------------------------------------------------------------------
74
- * **If `decimal: true` & `roundedDecimal: false`, simply cuts.**
75
- * - ***DefaultValue:** `2`.*
76
- * @default 2
77
- */
78
- totalDecimal?: number;
79
- /** ---------------------------------------------------------------------------
80
- * * ***Actually append `suffixDecimal`.***
81
- * ---------------------------------------------------------------------------
82
- * - ***DefaultValue:** `true`.*
83
- * @default true
84
- */
85
- endDecimal?: boolean;
86
- /** ---------------------------------------------------------------------------
87
- * * ***Text appended after decimals.***
88
- * ---------------------------------------------------------------------------
89
- * - ***DefaultValue:** `""`.*
90
- * - **Example:**
91
- * - `".-"` ➔ `1.000,00.-`.
92
- * - `" USD"` ➔ `1.000,00 USD`.
93
- * @default ""
94
- */
95
- suffixDecimal?: string;
96
- /** ---------------------------------------------------------------------------
97
- * * ***Rounding mode for decimals.***
98
- * ---------------------------------------------------------------------------
99
- * - **Behavior:**
100
- * - `"round"` ➔ nearest.
101
- * - `"ceil"` ➔ always up.
102
- * - `"floor"` ➔ always down.
103
- * - `false` ➔ truncate.
104
- * - ***DefaultValue:** `"round"`.*
105
- * @default "round"
106
- */
107
- roundedDecimal?: "round" | "ceil" | "floor" | false;
108
- /** ---------------------------------------------------------------------------
109
- * * ***Decimal separator.***
110
- * ---------------------------------------------------------------------------
111
- * - ***DefaultValue:** `","`.*
112
- * - **Example:** `","` ➔ `1.000,10`.
113
- * @default ","
114
- */
115
- separatorDecimals?: string;
116
- /** ---------------------------------------------------------------------------
117
- * * ***Negative formatting option.***
118
- * ---------------------------------------------------------------------------
119
- * **Can be string ("dash" | "brackets" | "abs") or object with custom formatter.**
120
- * - **Behavior:**
121
- * - `"dash"` ➔ `-15.000`.
122
- * - `"brackets"` ➔ `(15.000)`.
123
- * - `"abs"` ➔ `15.000` (always positive).
124
- * - Or object:
125
- * `{
126
- * style: "dash"|"brackets"|"abs",
127
- * space: true|false,
128
- * custom: (formatted) => string
129
- * }`.
130
- * - ***DefaultValue:** `"dash"`.*
131
- *
132
- * @default "dash"
133
- */
134
- negativeFormat?: NegativeFormatOption;
135
- /** ---------------------------------------------------------------------------
136
- * * ***Applies Indian Format.***
137
- * ---------------------------------------------------------------------------
138
- * - **Behavior:**
139
- * - If `true`, formats as Indian: `12,34,567`.
140
- * - Also forces `separator: ","`, `separatorDecimals: "."`.
141
- * - ***DefaultValue:** `false`.*
142
- * @default false
143
- */
144
- indianFormat?: boolean;
145
- };
146
-
147
- /** -------------------------------------------------------
148
- * * ***Utility: `formatCurrency`.***
149
- * -------------------------------------------------------
150
- * **Formats a number or messy currency string into a
151
- * beautifully formatted currency string, with highly
152
- * customizable separators, decimal control, rounding,
153
- * currency symbols, and negative styling.**
154
- * - **✅ Highlights:**
155
- * - ***Accepts:***
156
- * - Pure numbers: `15300.95`.
157
- * - Messy currency strings from **any locale**:
158
- * - `"Rp 15.000,21"` ***(Indonesian / Euro)***.
159
- * - `"$12,345.60"` ***(US)***.
160
- * - `"CHF 12'345.60"` ***(Swiss)***.
161
- * - `"1,23,456.78"` ***(Indian)***.
162
- * - Auto extracts numeric value with smart multi-locale parsing
163
- * via ***`parseCurrencyString` utility function***.
164
- * - Strong type checks & clear errors for misconfigured options.
165
- * - **Handles:**
166
- * - Thousands separators: `.`, `,`, `'`, ` `.
167
- * - Decimal separators: `,`, `.`.
168
- * - Decimal suffix (eg. `".-"`, `" USD"`).
169
- * - Currency prefix (eg. `"Rp "`, `"$ "`).
170
- * - Rounding: `"round"`, `"ceil"`, `"floor"`, or truncate.
171
- * - Negative styling: dash `-`, brackets `( )`, absolute, or custom.
172
- * - **✅ How input is parsed:**
173
- * - Removes all non-digit except `.`, `,`, `'` and spaces.
174
- * - Detects bracket negatives: `"(15.000,10)"` ➔ `-15000.10`.
175
- * - Uses last `,` or `.` as decimal separator (others are thousands).
176
- * - Ignores currency symbols like `Rp`, `$` (must re-apply with `suffixCurrency`).
177
- * - **ℹ️ Note:**
178
- * - Always re-apply symbols via `suffixCurrency`.
179
- * - `parseCurrencyString` smartly detects last decimal,
180
- * so `"1.121.234,56"` and `"1,121,234.56"` both parsed correctly.
181
- * @param {string|number} value
182
- * ***The input value to format, examples:***
183
- * - `"Rp 15.000,21"`.
184
- * - `"$12,345.60"`.
185
- * - `"CHF 12'345.60"`.
186
- * - `15300.95`.
187
- * @param {FormatCurrencyOptions} [options] ***Optional configuration object.***
188
- * @param {FormatCurrencyOptions["separator"]} [options.separator]
189
- * ***Thousands separator:***
190
- * - `{ separator: "." }` ➔ `1.000.000`.
191
- * - *DefaultValue: `"."`.*
192
- * @param {FormatCurrencyOptions["separatorDecimals"]} [options.separatorDecimals]
193
- * ***Decimal separator:***
194
- * - `{ separatorDecimals: "," }` ➔ `1.000,10`.
195
- * - *DefaultValue: `","`.*
196
- * @param {FormatCurrencyOptions["suffixCurrency"]} [options.suffixCurrency]
197
- * ***Prefix currency string:***
198
- * - Does **not auto-keep input symbols**.
199
- * - Must set manually e.g: `{ suffixCurrency: "Rp " }`.
200
- * - `{ suffixCurrency: "Rp " }` ➔ `Rp 1.000`.
201
- * - *DefaultValue: `""`.*
202
- * @param {FormatCurrencyOptions["decimal"]} [options.decimal]
203
- * ***Whether to show decimals. If `false`, decimals are truncated:***
204
- * - If `false`, cut the decimal.
205
- * - *DefaultValue: `false`.*
206
- * @param {FormatCurrencyOptions["totalDecimal"]} [options.totalDecimal]
207
- * ***Total decimal digits:***
208
- * - If `decimal: true` & `roundedDecimal: false`, simply cuts.
209
- * - *DefaultValue: `2`.*
210
- * @param {FormatCurrencyOptions["separatorDecimals"]} [options.suffixDecimal]
211
- * ***Text appended after decimals:***
212
- * - E.g: (`".-"`, `" USD"`).
213
- * - Example 1: `".-"` ➔ `1.000,00.-`.
214
- * - Example 2: `" USD"` ➔ `1.000,00 USD`.
215
- * - *DefaultValue: `""`.*
216
- * @param {FormatCurrencyOptions["endDecimal"]} [options.endDecimal]
217
- * ***Actually append `suffixDecimal`:***
218
- * - *DefaultValue: `true`.*
219
- * @param {FormatCurrencyOptions["roundedDecimal"]} [options.roundedDecimal]
220
- * ***Rounding mode:***
221
- * - `"round"` ➔ nearest.
222
- * - `"ceil"` ➔ always up.
223
- * - `"floor"` ➔ always down.
224
- * - `false` ➔ truncate.
225
- * - *DefaultValue: `"round"`.*
226
- * @param {FormatCurrencyOptions["negativeFormat"]} [options.negativeFormat]
227
- * ***How to format negatives:***
228
- * - `"dash"` ➔ `-15.000`.
229
- * - `"brackets"` ➔ `(15.000)`.
230
- * - `"abs"` ➔ `15.000` (always positive).
231
- * - Or object: `{ style: "dash" | "brackets" | "abs", space: true | false, custom: (formatted) => string }`.
232
- * - *DefaultValue: `"dash"`.*
233
- * @param {FormatCurrencyOptions["indianFormat"]} [options.indianFormat]
234
- * ***Applies Indian Format:***
235
- * - If `true`, formats as Indian: `12,34,567`.
236
- * - Also forces `separator: ","`, `separatorDecimals: "."`.
237
- * @returns {string}
238
- * ***Nicely formatted currency string, examples:***
239
- * - `"15.000,10"`.
240
- * - `"Rp 15.000,10.-"`.
241
- * - `"15'000.10 USD"`.
242
- * - `"12,34,567.89"`.
243
- * @throws **{@link TypeError | `TypeError`}** ***If:***
244
- * - The `value` is not string or number.
245
- * - Cannot parse to valid number.
246
- * - Options have invalid types.
247
- * @example
248
- * // --- Number input (default, decimals off) ---
249
- * formatCurrency(1234567.89);
250
- * // ➔ "1.234.567"
251
- *
252
- * // --- Decimals enabled ---
253
- * formatCurrency(1234567.89, { decimal: true });
254
- * // ➔ "1.234.567,89"
255
- *
256
- * // --- Indian format ---
257
- * formatCurrency(1234567.89, { decimal: true, indianFormat: true });
258
- * // ➔ "12,34,567.89"
259
- *
260
- * // --- String input (Indonesian style) ---
261
- * formatCurrency("Rp 15.000,21", { decimal: true });
262
- * // ➔ "15.000,21"
263
- *
264
- * // --- String input (US style) ---
265
- * formatCurrency("$12,345.60", { decimal: true });
266
- * // ➔ "12.345,60"
267
- *
268
- * // --- String input (Swiss style) ---
269
- * formatCurrency("CHF 12'345.60", { decimal: true });
270
- * // ➔ "12'345,60"
271
- *
272
- * // --- String input (Indian style) ---
273
- * formatCurrency("1,23,456.78", { decimal: true, indianFormat: true });
274
- * // ➔ "12,34,567.78"
275
- *
276
- * // --- Negative numbers (dash) ---
277
- * formatCurrency(-1234.56, { decimal: true });
278
- * // ➔ "-1.234,56"
279
- *
280
- * // --- Negative numbers (brackets) ---
281
- * formatCurrency(-1234.56, {
282
- * decimal: true,
283
- * negativeFormat: "brackets"
284
- * });
285
- * // ➔ "(1.234,56)"
286
- *
287
- * // --- Negative numbers (custom object style) ---
288
- * formatCurrency(-1234.56, {
289
- * decimal: true,
290
- * negativeFormat: { style: "brackets", space: true }
291
- * });
292
- * // ➔ "( 1.234,56 )"
293
- *
294
- * // --- Negative numbers (custom function) ---
295
- * formatCurrency(-1234.56, {
296
- * decimal: true,
297
- * negativeFormat: { custom: (val) => `NEGATIVE[${val}]` }
298
- * });
299
- * // ➔ "NEGATIVE[1.234,56]"
300
- *
301
- * // --- With prefix currency ---
302
- * formatCurrency(1234.56, {
303
- * decimal: true,
304
- * suffixCurrency: "Rp "
305
- * });
306
- * // ➔ "Rp 1.234,56"
307
- *
308
- * // --- With suffix decimal ---
309
- * formatCurrency(1234.56, {
310
- * decimal: true,
311
- * suffixDecimal: ".-"
312
- * });
313
- * // ➔ "1.234,56.-"
314
- *
315
- * // --- With suffix currency + suffix decimal ---
316
- * formatCurrency(1234.56, {
317
- * decimal: true,
318
- * suffixCurrency: "Rp ",
319
- * suffixDecimal: ".-"
320
- * });
321
- * // ➔ "Rp 1.234,56.-"
322
- *
323
- * // --- Custom separators ---
324
- * formatCurrency(1234567.89, {
325
- * decimal: true,
326
- * separator: "'",
327
- * separatorDecimals: "."
328
- * });
329
- * // ➔ "1'234'567.89"
330
- *
331
- * // --- Rounding: ceil ---
332
- * formatCurrency(1234.561, {
333
- * decimal: true,
334
- * roundedDecimal: "ceil"
335
- * });
336
- * // ➔ "1.234,57"
337
- *
338
- * // --- Rounding: floor ---
339
- * formatCurrency(1234.569, {
340
- * decimal: true,
341
- * roundedDecimal: "floor"
342
- * });
343
- * // ➔ "1.234,56"
344
- *
345
- * // --- Rounding: truncate (false) ---
346
- * formatCurrency(1234.569, {
347
- * decimal: true,
348
- * roundedDecimal: false
349
- * });
350
- * // ➔ "1.234,56"
351
- *
352
- * // --- Force no decimals (decimal: false) ---
353
- * formatCurrency(1234.567, { decimal: false });
354
- * // ➔ "1.235"
355
- *
356
- * // --- Edge case: messy input with dots & commas ---
357
- * formatCurrency("1.121.234,561", {
358
- * decimal: true,
359
- * totalDecimal: 2,
360
- * roundedDecimal: "ceil",
361
- * suffixCurrency: "Rp ",
362
- * negativeFormat: { style: "brackets" }
363
- * });
364
- * // ➔ "(Rp 1.121.234,57)"
365
- *
366
- * // --- Edge case: integer string input ---
367
- * formatCurrency("1.121.234", {
368
- * decimal: true,
369
- * suffixCurrency: "Rp ",
370
- * roundedDecimal: "ceil"
371
- * });
372
- * // ➔ "Rp 1.121.234,00"
373
- */
374
- declare const formatCurrency: (value: string | number, options?: FormatCurrencyOptions) => string;
375
-
376
- /** ----------------------------------------------------------
377
- * * ***Utility: `formatNumber`.***
378
- * ----------------------------------------------------------
379
- * **Formats a number or numeric string by adding a custom separator
380
- * every three digits (thousands separator), and intelligently flips
381
- * the decimal separator according to the chosen separator.**
382
- * - **Features:**
383
- * - Converts a number to string before formatting.
384
- * - Defaults to using `,` as the thousands separator.
385
- * - If `.` is used as the separator, the decimal will automatically
386
- * become `,`, and vice versa.
387
- * - Handles input with existing formatting (e.g. "1,234,567.89") and normalizes it.
388
- * - Supports custom separators, including spaces.
389
- * - Preserves decimals even if more than 2 digits.
390
- * @param {string | number} value - The numeric value or string to format, can be plain numbers, or already formatted strings like `"1,234,567.89"`.
391
- * @param {string} [separator=","] - The thousands separator to use, examples: `","` ***(default)***, `"."`, `" "`, etc.
392
- * @returns {string} The formatted string with thousands separators and
393
- * appropriate decimal separator.
394
- * @throws **{@link TypeError | `TypeError`}** if `value` is not a string or number, or `separator` is not a string.
395
- * @example
396
- * formatNumber(1000000);
397
- * // ➔ "1,000,000"
398
- * formatNumber("987654321");
399
- * // ➔ "987,654,321"
400
- * formatNumber(1234567.89);
401
- * // ➔ "1,234,567.89"
402
- * formatNumber("1234567,89");
403
- * // ➔ "1,234,567.89"
404
- * formatNumber("1234567.892");
405
- * // ➔ "1,234,567.892"
406
- * formatNumber("1234567.89", ".");
407
- * // ➔ "1.234.567,89"
408
- * formatNumber("1234567,89", ",");
409
- * // ➔ "1,234,567.89"
410
- * formatNumber("987654321", " ");
411
- * // ➔ "987 654 321"
412
- * formatNumber("1,234,567.89");
413
- * // ➔ "1,234,567.89"
414
- * formatNumber("1.234.567,89", ",");
415
- * // ➔ "1,234,567.89"
416
- * formatNumber("1.234.567,893", ".");
417
- * // ➔ "1.234.567,893"
418
- * formatNumber("1234.56", ".");
419
- * // ➔ "1.234,56"
420
- * formatNumber("1234,56", ",");
421
- * // ➔ "1,234.56"
422
- */
423
- declare const formatNumber: (value: string | number, separator?: string) => string;
424
-
425
- /** -------------------------------------------------------
426
- * * ***Output format mode for {@link formatPhoneNumber|`formatPhoneNumber`}.***
427
- * -------------------------------------------------------
428
- * - `'E.164'` ➔ `+6281234567890`
429
- * - `'RFC3966'` ➔ `tel:+62-812-3456-7890`
430
- * - `'NATIONAL'` ➔ `0812 3456 7890`
431
- * - `'INTERNATIONAL'` ➔ `+62 812 3456 7890`
432
- */
433
- type OutputFormat = ExtractStrict<NumberFormat, "INTERNATIONAL" | "NATIONAL" | "RFC3966" | "E.164">;
434
- /** -------------------------------------------------------
435
- * * ***Single input value for {@link formatPhoneNumber|`formatPhoneNumber`}.***
436
- * -------------------------------------------------------
437
- * - **Accepts:**
438
- * - `string` — e.g. `"0812 3456 7890"`
439
- * - `number` — e.g. `81234567890`
440
- * - `null` or `undefined` — represents no input
441
- * - **ℹ️ Notes**
442
- * - The function normalizes all **non-digit characters** (spaces, dots, dashes,
443
- * parentheses, etc.) before validation/formatting.
444
- * - When you pass a `number`, any **leading zeros are lost by JavaScript**.
445
- * - Prefer using a `string` if the number may begin with `0`.
446
- * - E.164 international standard allows **up to 15 digits** (not counting `+`).
447
- */
448
- type ValueFormatPhoneNumber = string | number | null | undefined;
449
- /** -------------------------------------------------------
450
- * * ***Base option set for {@link formatPhoneNumber|`formatPhoneNumber`}.***
451
- * -------------------------------------------------------
452
- * **All properties are optional.**
453
- * @description
454
- * Defaults apply when a property is omitted or `undefined`.
455
- *
456
- * **⚠️ Overload-aware notes:**
457
- * - If `checkValidOnly` is `true`, **all other properties are ignored**.
458
- * - If `takeNumberOnly` is `true`, **all formatting properties are ignored**.
459
- * - The leading `+` is **recommended** but not required;
460
- * the regex will still validate numbers without `+`
461
- * as long as the digit count ≤ **15**.
462
- */
463
- type FormatPhoneNumberMain = {
464
- /** -------------------------------------------------------
465
- * * ***Separator for formatted output.***
466
- * -------------------------------------------------------
467
- * **Defines the string used to separate groups of digits**
468
- * in the formatted phone number.
469
- * - **Default:** `" "`.
470
- * - **Executed only when:**
471
- * - Parameter options `checkValidOnly` and `takeNumberOnly` are both `false`.
472
- * - (This option is ignored if either `checkValidOnly` or `takeNumberOnly` is `true`.)
473
- * - **Behavior:**
474
- * - The formatter inserts this separator between number blocks
475
- * according to the selected `outputFormat`.
476
- * @default " "
477
- * @example
478
- * ```ts
479
- * // Using dash as separator
480
- * formatPhoneNumber("081234567890", { defaultCountry: "ID", separator: "-" });
481
- * // ➔ "+62 812-3456-7890"
482
- *
483
- * // Using space as separator
484
- * formatPhoneNumber("(151) 2345-6789", { defaultCountry: "DE", separator: " " });
485
- * // ➔ "+49 1512 3456789"
486
- * ```
487
- */
488
- separator?: string;
489
- /** -------------------------------------------------------
490
- * * ***Output format style for the returned phone number.***
491
- * -------------------------------------------------------
492
- * **Determines how the formatted phone number string is returned.**
493
- *
494
- * - **Default:** `"INTERNATIONAL"`.
495
- * - **Applicable only when:**
496
- * - Parameter options `checkValidOnly` and `takeNumberOnly`
497
- * are both **`false`**.
498
- * - (Ignored if either of those options is `true`.)
499
- *
500
- * - **Supported values (from {@link NumberFormat}):**
501
- * - `"NATIONAL"` – Local/national format, e.g. `0812 3456 7890`.
502
- * - `"INTERNATIONAL"` – International format with leading plus, e.g. `+62 812 3456 7890`.
503
- * - `"E.164"` – Compact E.164 format, e.g. `+6281234567890`.
504
- * - `"RFC3966"` – RFC 3966 URI format, e.g. `tel:+62-812-3456-7890`.
505
- *
506
- * @default "INTERNATIONAL"
507
- * @example
508
- * ```ts
509
- * // Returns a national-format string
510
- * formatPhoneNumber("+62 81234567890", { outputFormat: "NATIONAL" });
511
- * // ➔ "0812 3456 7890"
512
- *
513
- * // Returns an E.164-format string
514
- * formatPhoneNumber("+62 81234567890", { outputFormat: "E.164" });
515
- * // ➔ "+6281234567890"
516
- * ```
517
- */
518
- outputFormat?: OutputFormat;
519
- /** -------------------------------------------------------
520
- * * ***Prepend a plus sign and country calling code.***
521
- * -------------------------------------------------------
522
- * **Forces the returned phone number to start with a leading `+`
523
- * followed by the detected country calling code (e.g. `+63`, `+1`).**
524
- * - **Default:** `true`.
525
- * - **Executed only when:**
526
- * - Parameter options `outputFormat` is set to `"INTERNATIONAL"`.
527
- * - (This option is ignored for `"NATIONAL"`, `"E.164"` or `"RFC3966"` formats.).
528
- * - **Applicable when:**
529
- * - You want to guarantee that the result
530
- * always contains a plus sign and country code, regardless of
531
- * the selected `outputFormat`.
532
- * - **Behavior:**
533
- * - When `true`, the formatter ensures the output begins with
534
- * a `+` and the correct country code.
535
- * - When `false`, the output follows the chosen `outputFormat`
536
- * without forcing a `+` prefix.
537
- * @default true
538
- * @example
539
- * ```ts
540
- * // Automatically adds +63 (default: `true`) even if input is local format
541
- * formatPhoneNumber("09171234567", {
542
- * country: "PH",
543
- * prependPlusCountryCode: true
544
- * });
545
- * // ➔ "+63 917 123 4567"
546
- *
547
- * formatPhoneNumber("09171234567", {
548
- * country: "PH",
549
- * prependPlusCountryCode: false
550
- * });
551
- * // ➔ "63 917 123 4567"
552
- *
553
- * // Leaves number in national format (no plus sign)
554
- * formatPhoneNumber("+63 9171234567", {
555
- * country: "PH",
556
- * prependPlusCountryCode: false,
557
- * outputFormat: "NATIONAL"
558
- * });
559
- * // ➔ "0917 123 4567"
560
- * ```
561
- */
562
- prependPlusCountryCode?: boolean;
563
- /** -------------------------------------------------------
564
- * * ***Characters before the country code (e.g. `"("`).***
565
- * -------------------------------------------------------
566
- * **Adds a custom string that appears **immediately before** the
567
- * international country calling code when formatting.**
568
- * - **Default:** `""` (empty string).
569
- * - **Behavior:**
570
- * - **Active only when:**
571
- * - `checkValidOnly` is **false**,
572
- * - `takeNumberOnly` is **false**, **and**
573
- * - `outputFormat` is `"INTERNATIONAL"`.
574
- * - **Ignored if:**
575
- * - The value is an empty string (after trimming),
576
- * - `checkValidOnly` or `takeNumberOnly` is `true`,
577
- * - `outputFormat` is not `"INTERNATIONAL"`,
578
- * - `closingNumberCountry` is `undefined` or an empty string (after trimming).
579
- * - **Invalid input:**
580
- * - Returns no effect if the phone number is invalid or not compatible
581
- * with the selected `defaultCountry`.
582
- * @default ""
583
- * @example
584
- * ```ts
585
- * formatPhoneNumber("+63 9171234567", {
586
- * outputFormat: "INTERNATIONAL",
587
- * openingNumberCountry: "(",
588
- * closingNumberCountry: ")"
589
- * });
590
- * // ➔ "(+63) 917 123 4567"
591
- * ```
592
- */
593
- openingNumberCountry?: string;
594
- /** -------------------------------------------------------
595
- * * ***Characters after the country code (e.g. `")"`).***
596
- * -------------------------------------------------------
597
- * **Adds a custom string that appears **immediately after** the
598
- * international country calling code when formatting.**
599
- * - **Default:** `""` (empty string).
600
- * - **Behavior:**
601
- * - **Active only when:**
602
- * - `checkValidOnly` is **false**,
603
- * - `takeNumberOnly` is **false**, **and**
604
- * - `outputFormat` is `"INTERNATIONAL"`.
605
- * - **Ignored if:**
606
- * - The value is an empty string (after trimming),
607
- * - `checkValidOnly` or `takeNumberOnly` is `true`,
608
- * - `outputFormat` is not `"INTERNATIONAL"`,
609
- * - `openingNumberCountry` is `undefined` or an empty string (after trimming).
610
- * - **Invalid input:**
611
- * Returns no effect if the phone number is invalid or not compatible
612
- * with the selected `defaultCountry`.
613
- * @default ""
614
- * @example
615
- * ```ts
616
- * formatPhoneNumber("+63 9171234567", {
617
- * outputFormat: "INTERNATIONAL",
618
- * openingNumberCountry: "(",
619
- * closingNumberCountry: ")"
620
- * });
621
- * // ➔ "(+63) 917 123 4567"
622
- * ```
623
- */
624
- closingNumberCountry?: string;
625
- /** -------------------------------------------------------
626
- * * ***Return only a boolean validity flag.***
627
- * -------------------------------------------------------
628
- * - ***Behavior:***
629
- * - **Exclusive mode:**
630
- * - ⚠️ When `true`, all formatting options and `takeNumberOnly` must be omitted or are ignored.
631
- * - Conflicts with `takeNumberOnly`:
632
- * - ⚠️ When `checkValidOnly` is `true` and all formatting options and `takeNumberOnly` must be
633
- * omitted or are ignored.
634
- * - But if mistake passing props:
635
- * - ⚠️ When `checkValidOnly` is `true` and other of formatting options was passing:
636
- * - If `takeNumberOnly` is `true` or `false`:
637
- * - Will return a `boolean` because `checkValidOnly` is prioritize first.
638
- * - Output:
639
- * - Boolean ➔ (`true` or `false`).
640
- * - ***DefaultValue: false***
641
- * @default false
642
- * @example
643
- * ```ts
644
- * // Returns `true` if valid number and number with country code (no need `defaultCountry`)
645
- * formatPhoneNumber("+63 912-123-4567", { checkValidOnly: true });
646
- * // ➔ true
647
- *
648
- * // Returns `true` if valid number and number without country code but with `defaultCountry`
649
- * formatPhoneNumber("213-373-4253", { defaultCountry: "US", checkValidOnly: true });
650
- * // ➔ true
651
- *
652
- * // Returns `false` if without country code.
653
- * formatPhoneNumber("213-373-4253", { checkValidOnly: true });
654
- * // ➔ false
655
- *
656
- * // Returns `false` for invalid number.
657
- * formatPhoneNumber("abcd", { checkValidOnly: true });
658
- * // ➔ false
659
- * ```
660
- */
661
- checkValidOnly?: boolean;
662
- /** -------------------------------------------------------
663
- * * ***Return only the digits of the phone number (local number only).***
664
- * -------------------------------------------------------
665
- * **Returns a string containing only numeric characters** from the **local number**,
666
- * ignoring any country code, spaces, plus signs, or separators.
667
- * - **Default:** `false`
668
- * - **Behavior:**
669
- * - **Exclusive mode:**
670
- * - ⚠️ When set to `true`, all formatting options
671
- * (`outputFormat`, `prependPlusCountryCode`, etc.)
672
- * and `checkValidOnly` **must be omitted** or will be **ignored**.
673
- * - **Conflict handling with `checkValidOnly`:**
674
- * - If both `takeNumberOnly` and `checkValidOnly` are `true`,
675
- * `checkValidOnly` takes priority and the function
676
- * returns a `boolean`.
677
- * - If `checkValidOnly` is `false` (or not provided),
678
- * and `takeNumberOnly` is `true`,
679
- * the function returns a **numeric string of the local number**.
680
- * - **Invalid input:**
681
- * - If the input is invalid or cannot be parsed
682
- * (e.g. not matching the `defaultCountry`),
683
- * the function returns an **empty string** (`""`).
684
- * - **Output example:**
685
- * - Valid input ➔ `"81234567890"` // country code removed
686
- * - Invalid input ➔ `""`
687
- * @default false
688
- * @example
689
- * ```ts
690
- * // Returns only digits of the local number with country code (no need `defaultCountry`)
691
- * formatPhoneNumber("+63 912-123-4567", { takeNumberOnly: true });
692
- * // ➔ "09121234567"
693
- *
694
- * // Returns only digits of the local number without country code but with `defaultCountry`
695
- * formatPhoneNumber("213-373-4253", { defaultCountry: "US", takeNumberOnly: true });
696
- * // ➔ "2133734253"
697
- *
698
- * // Returns empty string if without country code.
699
- * formatPhoneNumber("213-373-4253", { takeNumberOnly: true });
700
- * // ➔ ""
701
- *
702
- * // Returns empty string for invalid number.
703
- * formatPhoneNumber("abcd", { takeNumberOnly: true });
704
- * // ➔ ""
705
- * ```
706
- */
707
- takeNumberOnly?: boolean;
708
- /** -------------------------------------------------------
709
- * * ***A "country code" is a two-letter ISO ([`ISO-3166-1 alpha-2`](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)) country code (like `"US"` | `"ID"` | `"DE"`).***
710
- * -------------------------------------------------------
711
- * **Used to interpret numbers without an explicit `+<countryCode>`.**
712
- * - ***Behavior:***
713
- * - Required if the input without country code (`+`).
714
- * - Ignored if the input already starts with `+`.
715
- * - ***Examples:***
716
- * - `"ID"` ➔ Indonesian.
717
- * - `"US"` ➔ United States.
718
- * - `"GB"` ➔ United Kingdom.
719
- * - ***DefaultValue: `undefined`***.
720
- * @example
721
- * formatPhoneNumber("081234567890", { defaultCountry: "ID" });
722
- * @default undefined
723
- */
724
- defaultCountry?: CountryCode;
725
- };
726
- /** -------------------------------------------------------
727
- * * ***Specialized options for the `transformPhoneNumber` variant of {@link formatPhoneNumber|`formatPhoneNumber`}.***
728
- * -------------------------------------------------------
729
- * **Ensures that `checkValidOnly` and `takeNumberOnly` are both
730
- * forced to `false` when transforming/formatting.**
731
- *
732
- * This type is intended for scenarios where you **must** receive a formatted
733
- * string as output and never a `boolean` or digit-only result.
734
- *
735
- * **Example Output:** `+62 812 3456 7890`
736
- */
737
- type FormatPhoneNumberTransform = OverrideTypes<FormatPhoneNumberMain, {
738
- /** -------------------------------------------------------
739
- * * ***Return only a boolean validity flag.***
740
- * -------------------------------------------------------
741
- * - ***Behavior:***
742
- * - **Exclusive mode:**
743
- * - ⚠️ When `true`, all formatting options and `takeNumberOnly` must be omitted or are ignored.
744
- * - Conflicts with `takeNumberOnly`:
745
- * - ⚠️ When `checkValidOnly` is `true` and all formatting options and `takeNumberOnly` must be
746
- * omitted or are ignored.
747
- * - But if mistake passing props:
748
- * - ⚠️ When `checkValidOnly` is `true` and other of formatting options was passing:
749
- * - If `takeNumberOnly` is `true` or `false`:
750
- * - Will return a `boolean` because `checkValidOnly` is prioritize first.
751
- * - Output:
752
- * - Boolean ➔ (`true` or `false`).
753
- * - ***DefaultValue: false***
754
- * @default false
755
- * @requires `false` or `undefined`
756
- */
757
- checkValidOnly?: never;
758
- /** -------------------------------------------------------
759
- * * ***Return only the digits of the phone number (local number only).***
760
- * -------------------------------------------------------
761
- * **Returns a string containing only numeric characters** from the **local number**,
762
- * ignoring any country code, spaces, plus signs, or separators.
763
- * - **Default:** `false`
764
- * - **Behavior:**
765
- * - **Exclusive mode:**
766
- * - ⚠️ When set to `true`, all formatting options
767
- * (`outputFormat`, `prependPlusCountryCode`, etc.)
768
- * and `checkValidOnly` **must be omitted** or will be **ignored**.
769
- * - **Conflict handling with `checkValidOnly`:**
770
- * - If both `takeNumberOnly` and `checkValidOnly` are `true`,
771
- * `checkValidOnly` takes priority and the function
772
- * returns a `boolean`.
773
- * - If `checkValidOnly` is `false` (or not provided),
774
- * and `takeNumberOnly` is `true`,
775
- * the function returns a **numeric string of the local number**.
776
- * - **Invalid input:**
777
- * - If the input is invalid or cannot be parsed
778
- * (e.g. not matching the `defaultCountry`),
779
- * the function returns an **empty string** (`""`).
780
- * - **Output example:**
781
- * - Valid input ➔ `"81234567890"` // country code removed
782
- * - Invalid input ➔ `""`
783
- * @default false
784
- * @requires `false` or `undefined`
785
- */
786
- takeNumberOnly?: never;
787
- }>;
788
- type NeverForRestFormatPhoneNumberTransform = {
789
- /** -------------------------------------------------------
790
- * * ***Not used in this mode **`(Never allowed in this mode)`**.***
791
- * -------------------------------------------------------
792
- * - ***Behavior:***
793
- * - **Exclusive mode:**
794
- * - ⚠️ When `true`, all formatting options must be omitted or are ignored.
795
- * - Conflicts with `takeNumberOnly` and `checkValidOnly`:
796
- * - If both `takeNumberOnly` and `checkValidOnly` are `true`,
797
- * `checkValidOnly` takes priority and the function
798
- * returns a `boolean`.
799
- * - If `checkValidOnly` is `false` (or not provided),
800
- * and `takeNumberOnly` is `true`,
801
- * the function returns a **numeric string of the local number**.
802
- * @requires `undefined`
803
- */
804
- separator?: never;
805
- /** -------------------------------------------------------
806
- * * ***Not used in this mode **`(Never allowed in this mode)`**.***
807
- * -------------------------------------------------------
808
- * - ***Behavior:***
809
- * - **Exclusive mode:**
810
- * - ⚠️ When `true`, all formatting options must be omitted or are ignored.
811
- * - Conflicts with `takeNumberOnly` and `checkValidOnly`:
812
- * - If both `takeNumberOnly` and `checkValidOnly` are `true`,
813
- * `checkValidOnly` takes priority and the function
814
- * returns a `boolean`.
815
- * - If `checkValidOnly` is `false` (or not provided),
816
- * and `takeNumberOnly` is `true`,
817
- * the function returns a **numeric string of the local number**.
818
- *
819
- * @requires `undefined`
820
- */
821
- openingNumberCountry?: never;
822
- /** -------------------------------------------------------
823
- * * ***Not used in this mode **`(Never allowed in this mode)`**.***
824
- * -------------------------------------------------------
825
- * - ***Behavior:***
826
- * - **Exclusive mode:**
827
- * - ⚠️ When `true`, all formatting options must be omitted or are ignored.
828
- * - Conflicts with `takeNumberOnly` and `checkValidOnly`:
829
- * - If both `takeNumberOnly` and `checkValidOnly` are `true`,
830
- * `checkValidOnly` takes priority and the function
831
- * returns a `boolean`.
832
- * - If `checkValidOnly` is `false` (or not provided),
833
- * and `takeNumberOnly` is `true`,
834
- * the function returns a **numeric string of the local number**.
835
- *
836
- * @requires `undefined`
837
- */
838
- closingNumberCountry?: never;
839
- };
840
- /** -------------------------------------------------------
841
- * * ***Options subset for **validity-check mode** of
842
- * {@link formatPhoneNumber|`formatPhoneNumber`}.***
843
- * -------------------------------------------------------
844
- * Only `checkValidOnly` is allowed.
845
- * All formatting-related properties are **intentionally disallowed**
846
- * to avoid mixing validation with formatting.
847
- *
848
- * **Example Usage:**
849
- * ```ts
850
- * formatPhoneNumber("+6281234567890", { checkValidOnly: true }) // boolean
851
- * ```
852
- */
853
- type FormatPhoneNumberCheckValidOnly = Prettify<OverrideTypes<FormatPhoneNumberMain, {
854
- /** -------------------------------------------------------
855
- * * ***Return only a boolean validity flag.***
856
- * -------------------------------------------------------
857
- * - ***Behavior:***
858
- * - **Exclusive mode:**
859
- * - ⚠️ When `true`, all formatting options and `takeNumberOnly` must be omitted or are ignored.
860
- * - Conflicts with `takeNumberOnly`:
861
- * - ⚠️ When `checkValidOnly` is `true` and all formatting options and `takeNumberOnly` must be
862
- * omitted or are ignored.
863
- * - But if mistake passing props:
864
- * - ⚠️ When `checkValidOnly` is `true` and other of formatting options was passing:
865
- * - If `takeNumberOnly` is `true` or `false`:
866
- * - Will return a `boolean` because `checkValidOnly` is prioritize first.
867
- * - Output:
868
- * - Boolean ➔ (`true` or `false`).
869
- * - ***DefaultValue: false***
870
- * @default false
871
- */
872
- checkValidOnly: true;
873
- /** -------------------------------------------------------
874
- * * ***Return only the digits of the phone number (local number only).***
875
- * -------------------------------------------------------
876
- * **Returns a string containing only numeric characters** from the **local number**,
877
- * ignoring any country code, spaces, plus signs, or separators.
878
- * - **Default:** `false`
879
- * - **Behavior:**
880
- * - **Exclusive mode:**
881
- * - ⚠️ When set to `true`, all formatting options
882
- * (`outputFormat`, `prependPlusCountryCode`, etc.)
883
- * and `checkValidOnly` **must be omitted** or will be **ignored**.
884
- * - **Conflict handling with `checkValidOnly`:**
885
- * - If both `takeNumberOnly` and `checkValidOnly` are `true`,
886
- * `checkValidOnly` takes priority and the function
887
- * returns a `boolean`.
888
- * - If `checkValidOnly` is `false` (or not provided),
889
- * and `takeNumberOnly` is `true`,
890
- * the function returns a **numeric string of the local number**.
891
- * - **Invalid input:**
892
- * - If the input is invalid or cannot be parsed
893
- * (e.g. not matching the `defaultCountry`),
894
- * the function returns an **empty string** (`""`).
895
- * - **Output example:**
896
- * - Valid input ➔ `"81234567890"` // country code removed
897
- * - Invalid input ➔ `""`
898
- * @default false
899
- * @requires `false` or `undefined`
900
- */
901
- takeNumberOnly?: false;
902
- } & NeverForRestFormatPhoneNumberTransform>>;
903
- /** -------------------------------------------------------
904
- * * ***Options subset for calling {@link formatPhoneNumber|`formatPhoneNumber`} in
905
- * **digits-only mode**.***
906
- * -------------------------------------------------------
907
- * **Only `takeNumberOnly` is allowed; all other formatting options are
908
- * intentionally disallowed.**
909
- *
910
- * Use this when you want a pure numeric string without any separators or country
911
- * decorations, but still want the function to normalize the input.
912
- *
913
- * **Example Output:** `"6281234567890"`
914
- */
915
- type FormatPhoneNumberTakeNumberOnly = Prettify<OverrideTypes<FormatPhoneNumberMain, {
916
- /** -------------------------------------------------------
917
- * * ***Return only a boolean validity flag.***
918
- * -------------------------------------------------------
919
- * - ***Behavior:***
920
- * - **Exclusive mode:**
921
- * - ⚠️ When `true`, all formatting options and `takeNumberOnly` must be omitted or are ignored.
922
- * - Conflicts with `takeNumberOnly`:
923
- * - ⚠️ When `checkValidOnly` is `true` and all formatting options and `takeNumberOnly` must be
924
- * omitted or are ignored.
925
- * - But if mistake passing props:
926
- * - ⚠️ When `checkValidOnly` is `true` and other of formatting options was passing:
927
- * - If `takeNumberOnly` is `true` or `false`:
928
- * - Will return a `boolean` because `checkValidOnly` is prioritize first.
929
- * - Output:
930
- * - Boolean ➔ (`true` or `false`).
931
- * - ***DefaultValue: false***
932
- * @default false
933
- * @requires `false` or `undefined`
934
- */
935
- checkValidOnly?: false;
936
- /** -------------------------------------------------------
937
- * * ***Return only the digits of the phone number (local number only).***
938
- * -------------------------------------------------------
939
- * **Returns a string containing only numeric characters** from the **local number**,
940
- * ignoring any country code, spaces, plus signs, or separators.
941
- * - **Default:** `false`
942
- * - **Behavior:**
943
- * - **Exclusive mode:**
944
- * - ⚠️ When set to `true`, all formatting options
945
- * (`outputFormat`, `prependPlusCountryCode`, etc.)
946
- * and `checkValidOnly` **must be omitted** or will be **ignored**.
947
- * - **Conflict handling with `checkValidOnly`:**
948
- * - If both `takeNumberOnly` and `checkValidOnly` are `true`,
949
- * `checkValidOnly` takes priority and the function
950
- * returns a `boolean`.
951
- * - If `checkValidOnly` is `false` (or not provided),
952
- * and `takeNumberOnly` is `true`,
953
- * the function returns a **numeric string of the local number**.
954
- * - **Invalid input:**
955
- * - If the input is invalid or cannot be parsed
956
- * (e.g. not matching the `defaultCountry`),
957
- * the function returns an **empty string** (`""`).
958
- * - **Output example:**
959
- * - Valid input ➔ `"81234567890"` // country code removed
960
- * - Invalid input ➔ `""`
961
- * @default false
962
- */
963
- takeNumberOnly: true;
964
- } & NeverForRestFormatPhoneNumberTransform>>;
965
- /** -------------------------------------------------------
966
- * * ***Options subset for calling {@link formatPhoneNumber|`formatPhoneNumber`} force to **Validity-check Mode**.***
967
- * -------------------------------------------------------
968
- */
969
- type FormatPhoneNumberAllPassing = OverrideTypes<FormatPhoneNumberMain, {
970
- /** -------------------------------------------------------
971
- * * ***Return only a boolean validity flag.***
972
- * -------------------------------------------------------
973
- * - ***Behavior:***
974
- * - **Exclusive mode:**
975
- * - ⚠️ When `true`, all formatting options and `takeNumberOnly` must be omitted or are ignored.
976
- * - Conflicts with `takeNumberOnly`:
977
- * - ⚠️ When `checkValidOnly` is `true` and all formatting options and `takeNumberOnly` must be
978
- * omitted or are ignored.
979
- * - But if mistake passing props:
980
- * - ⚠️ When `checkValidOnly` is `true` and other of formatting options was passing:
981
- * - If `takeNumberOnly` is `true` or `false`:
982
- * - Will return a `boolean` because `checkValidOnly` is prioritize first.
983
- * - Output:
984
- * - Boolean ➔ (`true` or `false`).
985
- * - ***DefaultValue: false***
986
- * @default false
987
- */
988
- checkValidOnly: true;
989
- /** -------------------------------------------------------
990
- * * ***Return only the digits of the phone number (local number only).***
991
- * -------------------------------------------------------
992
- * **Returns a string containing only numeric characters** from the **local number**,
993
- * ignoring any country code, spaces, plus signs, or separators.
994
- * - **Default:** `false`
995
- * - **Behavior:**
996
- * - **Exclusive mode:**
997
- * - ⚠️ When set to `true`, all formatting options
998
- * (`outputFormat`, `prependPlusCountryCode`, etc.)
999
- * and `checkValidOnly` **must be omitted** or will be **ignored**.
1000
- * - **Conflict handling with `checkValidOnly`:**
1001
- * - If both `takeNumberOnly` and `checkValidOnly` are `true`,
1002
- * `checkValidOnly` takes priority and the function
1003
- * returns a `boolean`.
1004
- * - If `checkValidOnly` is `false` (or not provided),
1005
- * and `takeNumberOnly` is `true`,
1006
- * the function returns a **numeric string of the local number**.
1007
- * - **Invalid input:**
1008
- * - If the input is invalid or cannot be parsed
1009
- * (e.g. not matching the `defaultCountry`),
1010
- * the function returns an **empty string** (`""`).
1011
- * - **Output example:**
1012
- * - Valid input ➔ `"81234567890"` // country code removed
1013
- * - Invalid input ➔ `""`
1014
- * @default false
1015
- * @requires `false` or `undefined`
1016
- */
1017
- takeNumberOnly: true;
1018
- }>;
1019
- /** -------------------------------------------------------
1020
- * * ***Options subset for calling {@link formatPhoneNumber|`formatPhoneNumber`} force to **Validity-check Mode**.***
1021
- * -------------------------------------------------------
1022
- */
1023
- type FormatPhoneNumberAllPassingValidOnly = OverrideTypes<FormatPhoneNumberMain, {
1024
- /** -------------------------------------------------------
1025
- * * ***Return only a boolean validity flag.***
1026
- * -------------------------------------------------------
1027
- * - ***Behavior:***
1028
- * - **Exclusive mode:**
1029
- * - ⚠️ When `true`, all formatting options and `takeNumberOnly` must be omitted or are ignored.
1030
- * - Conflicts with `takeNumberOnly`:
1031
- * - ⚠️ When `checkValidOnly` is `true` and all formatting options and `takeNumberOnly` must be
1032
- * omitted or are ignored.
1033
- * - But if mistake passing props:
1034
- * - ⚠️ When `checkValidOnly` is `true` and other of formatting options was passing:
1035
- * - If `takeNumberOnly` is `true` or `false`:
1036
- * - Will return a `boolean` because `checkValidOnly` is prioritize first.
1037
- * - Output:
1038
- * - Boolean ➔ (`true` or `false`).
1039
- * - ***DefaultValue: false***
1040
- * @default false
1041
- */
1042
- checkValidOnly: true;
1043
- /** -------------------------------------------------------
1044
- * * ***Return only the digits of the phone number (local number only).***
1045
- * -------------------------------------------------------
1046
- * **Returns a string containing only numeric characters** from the **local number**,
1047
- * ignoring any country code, spaces, plus signs, or separators.
1048
- * - **Default:** `false`
1049
- * - **Behavior:**
1050
- * - **Exclusive mode:**
1051
- * - ⚠️ When set to `true`, all formatting options
1052
- * (`outputFormat`, `prependPlusCountryCode`, etc.)
1053
- * and `checkValidOnly` **must be omitted** or will be **ignored**.
1054
- * - **Conflict handling with `checkValidOnly`:**
1055
- * - If both `takeNumberOnly` and `checkValidOnly` are `true`,
1056
- * `checkValidOnly` takes priority and the function
1057
- * returns a `boolean`.
1058
- * - If `checkValidOnly` is `false` (or not provided),
1059
- * and `takeNumberOnly` is `true`,
1060
- * the function returns a **numeric string of the local number**.
1061
- * - **Invalid input:**
1062
- * - If the input is invalid or cannot be parsed
1063
- * (e.g. not matching the `defaultCountry`),
1064
- * the function returns an **empty string** (`""`).
1065
- * - **Output example:**
1066
- * - Valid input ➔ `"81234567890"` // country code removed
1067
- * - Invalid input ➔ `""`
1068
- * @default false
1069
- * @requires `false` or `undefined`
1070
- */
1071
- takeNumberOnly?: false;
1072
- }>;
1073
- /** -------------------------------------------------------
1074
- * * ***Options subset for calling {@link formatPhoneNumber|`formatPhoneNumber`} force to **Digits-only Mode**.***
1075
- * -------------------------------------------------------
1076
- */
1077
- type FormatPhoneNumberAllPassingTakeOnly = OverrideTypes<FormatPhoneNumberMain, {
1078
- /** -------------------------------------------------------
1079
- * * ***Return only a boolean validity flag.***
1080
- * -------------------------------------------------------
1081
- * - ***Behavior:***
1082
- * - **Exclusive mode:**
1083
- * - ⚠️ When `true`, all formatting options and `takeNumberOnly` must be omitted or are ignored.
1084
- * - Conflicts with `takeNumberOnly`:
1085
- * - ⚠️ When `checkValidOnly` is `true` and all formatting options and `takeNumberOnly` must be
1086
- * omitted or are ignored.
1087
- * - But if mistake passing props:
1088
- * - ⚠️ When `checkValidOnly` is `true` and other of formatting options was passing:
1089
- * - If `takeNumberOnly` is `true` or `false`:
1090
- * - Will return a `boolean` because `checkValidOnly` is prioritize first.
1091
- * - Output:
1092
- * - Boolean ➔ (`true` or `false`).
1093
- * - ***DefaultValue: false***
1094
- * @default false
1095
- * @requires `false` or `undefined`
1096
- */
1097
- checkValidOnly?: false;
1098
- /** -------------------------------------------------------
1099
- * * ***Return only the digits of the phone number (local number only).***
1100
- * -------------------------------------------------------
1101
- * **Returns a string containing only numeric characters** from the **local number**,
1102
- * ignoring any country code, spaces, plus signs, or separators.
1103
- * - **Default:** `false`
1104
- * - **Behavior:**
1105
- * - **Exclusive mode:**
1106
- * - ⚠️ When set to `true`, all formatting options
1107
- * (`outputFormat`, `prependPlusCountryCode`, etc.)
1108
- * and `checkValidOnly` **must be omitted** or will be **ignored**.
1109
- * - **Conflict handling with `checkValidOnly`:**
1110
- * - If both `takeNumberOnly` and `checkValidOnly` are `true`,
1111
- * `checkValidOnly` takes priority and the function
1112
- * returns a `boolean`.
1113
- * - If `checkValidOnly` is `false` (or not provided),
1114
- * and `takeNumberOnly` is `true`,
1115
- * the function returns a **numeric string of the local number**.
1116
- * - **Invalid input:**
1117
- * - If the input is invalid or cannot be parsed
1118
- * (e.g. not matching the `defaultCountry`),
1119
- * the function returns an **empty string** (`""`).
1120
- * - **Output example:**
1121
- * - Valid input ➔ `"81234567890"` // country code removed
1122
- * - Invalid input ➔ `""`
1123
- * @default false
1124
- */
1125
- takeNumberOnly: true;
1126
- }>;
1127
-
1128
- /** -------------------------------------------------------
1129
- * * ***Utility: `formatPhoneNumber`.***
1130
- * -------------------------------------------------------
1131
- * **Formats a phone number into a customizable local or international style.**
1132
- * - **Type:** ***`Formatting Number`.***
1133
- * - **Can also:**
1134
- * - Return only digits string when **digits-only mode** (`takeNumberOnly`):
1135
- * - Return empty-string (""), if invalid number phone.
1136
- * - Return boolean when **validity-check mode** (`checkValidOnly`):
1137
- * - ***Return `true` if:***
1138
- * - A phone number is "valid" when it has valid length, and the actual phone number digits match the
1139
- * regular expressions for its country (parameter options `defaultCountry`).
1140
- * - **E.164 compliance:**
1141
- * - Optional leading `+` is recommended but **not required**.
1142
- * - If Without leading `+`, you must passing `defaultCountry`.
1143
- * @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.
1144
- * @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.
1145
- * @param {ValueFormatPhoneNumber} value
1146
- * ***Phone number to format, accepts:***
1147
- * - `string` (recommended to preserve leading zeros).
1148
- * - `number` (leading zeros will be lost).
1149
- * - `null` or `undefined` (returns empty string).
1150
- * @param {FormatPhoneNumberMain} [options]
1151
- * ***Main options object controlling:***
1152
- * - `separator` (**string**): Group separator, default `" "`.
1153
- * - `plusNumberCountry` (**string**): Country code with optional leading `+`.
1154
- * - `openingNumberCountry` (**string**): Characters before the country code, e.g. `"("`.
1155
- * - `closingNumberCountry` (**string**): Characters after the country code, e.g. `")"`.
1156
- * - `checkValidOnly` (**boolean**): Return only validity.
1157
- * - `takeNumberOnly` (**boolean**): Return digits only.
1158
- * - `defaultCountry` (**string** - **`<ISO-3166-1 alpha-2>`**): Used to interpret numbers without an explicit `+<countryCode>`.
1159
- * @returns {string|boolean} Formatted phone number string, digits-only string, or boolean.
1160
- * @overload
1161
- * @param {ValueFormatPhoneNumber} value The phone number input (string or number).
1162
- * @param {FormatPhoneNumberCheckValidOnly} [options] With `checkValidOnly: true`.
1163
- * Return a **validity-check mode** when `checkValidOnly: true`.
1164
- * @returns {boolean} A boolean indicating whether the input is a valid phone number.
1165
- * @overload
1166
- * @param {ValueFormatPhoneNumber} value The phone number input (string or number).
1167
- * @param {FormatPhoneNumberTransform} [options] With `takeNumberOnly: true`.
1168
- * Return **digits-only mode** when `takeNumberOnly: true`.
1169
- * @returns {string} A string of digits only.
1170
- * @overload
1171
- * @param {ValueFormatPhoneNumber} value The phone number input (string or number).
1172
- * @param {FormatPhoneNumberTakeNumberOnly} [options] Options to customize format output (country code, separator, etc).
1173
- * Return a **formatted phone number string** with custom formatting and (`checkValidOnly: false`, `takeNumberOnly: false`).
1174
- * @returns {string} Formatting number. return a string of digits only with formatter.
1175
- * @example
1176
- * 1. ***Formatting Phone Number String:***
1177
- * ```ts
1178
- * formatPhoneNumber("081234567890");
1179
- * // ➔ "0812 3456 7890"
1180
- * formatPhoneNumber("081234567890", {
1181
- * separator: "-",
1182
- * plusNumberCountry: "+44",
1183
- * openingNumberCountry: "(",
1184
- * closingNumberCountry: ")"
1185
- * });
1186
- * // ➔ "(+44) 8123-4567-890"
1187
- * ```
1188
- * 2. ***Digits-Only Mode:***
1189
- * ```ts
1190
- * formatPhoneNumber("(0812) 3456-7890", {
1191
- * takeNumberOnly: true,
1192
- * defaultCountry: "ID"
1193
- * });
1194
- * // ➔ "081234567890"
1195
- * formatPhoneNumber("(0812) 3456-7890", { takeNumberOnly: true });
1196
- * // ➔ ""
1197
- * formatPhoneNumber("(63) 917 123 4567", {
1198
- * takeNumberOnly: true,
1199
- * defaultCountry: "PH"
1200
- * });
1201
- * // ➔ "0917 123 4567"
1202
- * formatPhoneNumber("(63) 4567-8901", {
1203
- * takeNumberOnly: true,
1204
- * defaultCountry: "PH"
1205
- * });
1206
- * // ➔ "" // is not valid number from PH.
1207
- * formatPhoneNumber("(63) 917 123 4567", { takeNumberOnly: true });
1208
- * // ➔ ""
1209
- * formatPhoneNumber("49 (151) 2345 6789", {
1210
- * takeNumberOnly: true,
1211
- * defaultCountry: "DE"
1212
- * });
1213
- * // ➔ "015123456789"
1214
- * formatPhoneNumber("49 (151) 2345 6789", { takeNumberOnly: true });
1215
- * // ➔ ""
1216
- * ```
1217
- * 3. ***Validity-Check Mode:***
1218
- * ```ts
1219
- * formatPhoneNumber("+6281234567890", { checkValidOnly: true });
1220
- * // ➔ true
1221
- * formatPhoneNumber("0812-3456-7890", {
1222
- * checkValidOnly: true,
1223
- * defaultCountry: "ID"
1224
- * });
1225
- * // ➔ true
1226
- * formatPhoneNumber("0812 3456 7890", { checkValidOnly: true });
1227
- * // ➔ false
1228
- * formatPhoneNumber("(0812) 3456-7890", {
1229
- * checkValidOnly: true,
1230
- * defaultCountry: "ID"
1231
- * });
1232
- * // ➔ true
1233
- * formatPhoneNumber("(0812) 3456-7890", { checkValidOnly: true});
1234
- * // ➔ false
1235
- * formatPhoneNumber("+44 20 7946 0958", { checkValidOnly: true });
1236
- * // ➔ true
1237
- * formatPhoneNumber("+1 (800) 123-4567", { checkValidOnly: true });
1238
- * // ➔ true
1239
- * formatPhoneNumber("+62.812.3456.7890", { checkValidOnly: true });
1240
- * // ➔ true
1241
- * formatPhoneNumber("+62(812)3456-7890", { checkValidOnly: true });
1242
- * // ➔ true
1243
- * formatPhoneNumber("+62abc123", { checkValidOnly: true });
1244
- * // ➔ false
1245
- * formatPhoneNumber("invalid@@@", { checkValidOnly: true });
1246
- * // ➔ false
1247
- * formatPhoneNumber("0812-3456-hello", { checkValidOnly: true });
1248
- * // ➔ false
1249
- * ```
1250
- */
1251
- declare function formatPhoneNumber(value: ValueFormatPhoneNumber, options?: FormatPhoneNumberTransform): string;
1252
- /** -------------------------------------------------------
1253
- * * ***Utility: `formatPhoneNumber`.***
1254
- * -------------------------------------------------------
1255
- * **Formats a phone number into a customizable local or international style.**
1256
- * - **Type:** ***`Digits-only Mode`.***
1257
- * - **Can also:**
1258
- * - Return only digits string when **digits-only mode** (`takeNumberOnly`).
1259
- * - Return boolean when **validity-check mode** (`checkValidOnly`) using a
1260
- * regex for international-style phone numbers:
1261
- * - ***Valid if:***
1262
- * - Only contains digits, optional leading `+`, spaces, parentheses `()`,
1263
- * hyphens `-`, or dots `.`.
1264
- * - Digits-only length < 16.
1265
- * - **E.164 compliance:**
1266
- * - Optional leading `+` is recommended but **not required**.
1267
- * - If Without leading `+`, you must passing `defaultCountry`.
1268
- * @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.
1269
- * @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.
1270
- * @param {ValueFormatPhoneNumber} value
1271
- * Phone number to format. Accepts:
1272
- * - `string` (recommended to preserve leading zeros)
1273
- * - `number` (leading zeros will be lost)
1274
- * - `null` or `undefined` (returns empty string).
1275
- * @param {FormatPhoneNumberTakeNumberOnly} [options] Options to customize format output (country code, separator, etc).
1276
- * @returns {string} Digits-only mode, return string a digits-only.
1277
- * @example
1278
- * ```ts
1279
- * formatPhoneNumber("(0812) 3456-7890", {
1280
- * takeNumberOnly: true,
1281
- * defaultCountry: "ID"
1282
- * });
1283
- * // ➔ "081234567890"
1284
- * formatPhoneNumber("(0812) 3456-7890", { takeNumberOnly: true });
1285
- * // ➔ ""
1286
- * formatPhoneNumber("(63) 917 123 4567", {
1287
- * takeNumberOnly: true,
1288
- * defaultCountry: "PH"
1289
- * });
1290
- * // ➔ "0917 123 4567"
1291
- * formatPhoneNumber("(63) 4567-8901", {
1292
- * takeNumberOnly: true,
1293
- * defaultCountry: "PH"
1294
- * });
1295
- * // ➔ "" // is not valid number from PH.
1296
- * formatPhoneNumber("(63) 917 123 4567", { takeNumberOnly: true });
1297
- * // ➔ ""
1298
- * formatPhoneNumber("49 (151) 2345 6789", {
1299
- * takeNumberOnly: true,
1300
- * defaultCountry: "DE"
1301
- * });
1302
- * // ➔ "015123456789"
1303
- * formatPhoneNumber("49 (151) 2345 6789", { takeNumberOnly: true });
1304
- * // ➔ ""
1305
- * ```
1306
- */
1307
- declare function formatPhoneNumber(value: ValueFormatPhoneNumber, options?: FormatPhoneNumberTakeNumberOnly): string;
1308
- /** -------------------------------------------------------
1309
- * * ***Utility: `formatPhoneNumber`.***
1310
- * -------------------------------------------------------
1311
- * **Formats a phone number into a customizable local or international style.**
1312
- * - **Type:** ***`Validity-check Mode`.***
1313
- * - **Can also:**
1314
- * - Return only digits string when **digits-only mode** (`takeNumberOnly`).
1315
- * - Return boolean when **validity-check mode** (`checkValidOnly`) using a
1316
- * regex for international-style phone numbers:
1317
- * - ***Valid if:***
1318
- * - Only contains digits, optional leading `+`, spaces, parentheses `()`,
1319
- * hyphens `-`, or dots `.`.
1320
- * - Digits-only length < 16.
1321
- * - **E.164 compliance:**
1322
- * - Optional leading `+` is recommended but **not required**.
1323
- * - If Without leading `+`, you must passing `defaultCountry`.
1324
- * @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.
1325
- * @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.
1326
- * @param {ValueFormatPhoneNumber} value
1327
- * Phone number to format. Accepts:
1328
- * - `string` (recommended to preserve leading zeros).
1329
- * - `number` (leading zeros will be lost).
1330
- * - `null` or `undefined` (returns empty string).
1331
- * @param {FormatPhoneNumberTakeNumberOnly} [options] Options to customize format output (country code, separator, etc).
1332
- * @returns {boolean} Validity-check mode, return a boolean.
1333
- * @example
1334
- * ```ts
1335
- * formatPhoneNumber("+6281234567890", { checkValidOnly: true });
1336
- * // ➔ true
1337
- * formatPhoneNumber("0812-3456-7890", {
1338
- * checkValidOnly: true,
1339
- * defaultCountry: "ID"
1340
- * });
1341
- * // ➔ true
1342
- * formatPhoneNumber("0812 3456 7890", { checkValidOnly: true });
1343
- * // ➔ false
1344
- * formatPhoneNumber("(0812) 3456-7890", {
1345
- * checkValidOnly: true,
1346
- * defaultCountry: "ID"
1347
- * });
1348
- * // ➔ true
1349
- * formatPhoneNumber("(0812) 3456-7890", { checkValidOnly: true});
1350
- * // ➔ false
1351
- * formatPhoneNumber("+44 20 7946 0958", { checkValidOnly: true });
1352
- * // ➔ true
1353
- * formatPhoneNumber("+1 (800) 123-4567", { checkValidOnly: true });
1354
- * // ➔ true
1355
- * formatPhoneNumber("+62.812.3456.7890", { checkValidOnly: true });
1356
- * // ➔ true
1357
- * formatPhoneNumber("+62(812)3456-7890", { checkValidOnly: true });
1358
- * // ➔ true
1359
- * formatPhoneNumber("+62abc123", { checkValidOnly: true });
1360
- * // ➔ false
1361
- * formatPhoneNumber("invalid@@@", { checkValidOnly: true });
1362
- * // ➔ false
1363
- * formatPhoneNumber("0812-3456-hello", { checkValidOnly: true });
1364
- * // ➔ false
1365
- * ```
1366
- */
1367
- declare function formatPhoneNumber(value: ValueFormatPhoneNumber, options?: FormatPhoneNumberCheckValidOnly): boolean;
1368
- /** -------------------------------------------------------
1369
- * * ***Utility: `formatPhoneNumber`.***
1370
- * -------------------------------------------------------
1371
- * **Formats a phone number into a customizable local or international style.**
1372
- * - **Type:** ***Forced to `Validity-check Mode`***, because `checkValidOnly` has set to `true`.
1373
- * - **Can also:**
1374
- * - Return only digits string when **digits-only mode** (`takeNumberOnly`).
1375
- * - Return boolean when **validity-check mode** (`checkValidOnly`) using a
1376
- * regex for international-style phone numbers:
1377
- * - ***Valid if:***
1378
- * - Only contains digits, optional leading `+`, spaces, parentheses `()`,
1379
- * hyphens `-`, or dots `.`.
1380
- * - Digits-only length < 16.
1381
- * - **E.164 compliance:**
1382
- * - Optional leading `+` is recommended but **not required**.
1383
- * - If Without leading `+`, you must passing `defaultCountry`.
1384
- * @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.
1385
- * @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.
1386
- * @param {ValueFormatPhoneNumber} value
1387
- * Phone number to format. Accepts:
1388
- * - `string` (recommended to preserve leading zeros).
1389
- * - `number` (leading zeros will be lost).
1390
- * - `null` or `undefined` (returns empty string).
1391
- * @param {FormatPhoneNumberTakeNumberOnly} [options] Options to customize format output (country code, separator, etc).
1392
- * @returns {boolean} Validity-check mode, return a boolean.
1393
- * @example
1394
- * ```ts
1395
- * formatPhoneNumber("+6281234567890", {
1396
- * // Formatting Phone Number Options
1397
- * separator: "-",
1398
- * // Validity-check Mode
1399
- * checkValidOnly: true,
1400
- * });
1401
- * // ➔ true
1402
- * formatPhoneNumber("0812-3456-7890", {
1403
- * defaultCountry: "ID",
1404
- * // Formatting Phone Number Options
1405
- * separator: "-",
1406
- * // Validity-check Mode
1407
- * checkValidOnly: true,
1408
- * });
1409
- * // ➔ true
1410
- * formatPhoneNumber("0812 3456 7890", {
1411
- * // Formatting Phone Number Options
1412
- * separator: "-",
1413
- * // Validity-check Mode
1414
- * checkValidOnly: true,
1415
- * });
1416
- * // ➔ false
1417
- * formatPhoneNumber("(0812) 3456-7890", {
1418
- * defaultCountry: "ID",
1419
- * // Formatting Phone Number Options
1420
- * separator: "-",
1421
- * // Validity-check Mode
1422
- * checkValidOnly: true,
1423
- * });
1424
- * // ➔ true
1425
- * formatPhoneNumber("(0812) 3456-7890", {
1426
- * // Formatting Phone Number Options
1427
- * separator: "-",
1428
- * // Validity-check Mode
1429
- * checkValidOnly: true
1430
- * });
1431
- * // ➔ false
1432
- * formatPhoneNumber("+44 20 7946 0958", {
1433
- * // Formatting Phone Number Options
1434
- * separator: "-",
1435
- * // Validity-check Mode
1436
- * checkValidOnly: true
1437
- * });
1438
- * // ➔ true
1439
- * formatPhoneNumber("+1 (800) 123-4567", {
1440
- * // Formatting Phone Number Options
1441
- * separator: "-",
1442
- * // Validity-check Mode
1443
- * checkValidOnly: true
1444
- * });
1445
- * // ➔ true
1446
- * formatPhoneNumber("+62.812.3456.7890", {
1447
- * // Formatting Phone Number Options
1448
- * separator: "-",
1449
- * // Validity-check Mode
1450
- * checkValidOnly: true
1451
- * });
1452
- * // ➔ true
1453
- * formatPhoneNumber("+62(812)3456-7890", {
1454
- * // Formatting Phone Number Options
1455
- * separator: "-",
1456
- * // Validity-check Mode
1457
- * checkValidOnly: true
1458
- * });
1459
- * // ➔ true
1460
- * formatPhoneNumber("+62abc123", {
1461
- * // Formatting Phone Number Options
1462
- * separator: "-",
1463
- * // Validity-check Mode
1464
- * checkValidOnly: true
1465
- * });
1466
- * // ➔ false
1467
- * formatPhoneNumber("invalid@@@", {
1468
- * // Formatting Phone Number Options
1469
- * separator: "-",
1470
- * // Validity-check Mode
1471
- * checkValidOnly: true
1472
- * });
1473
- * // ➔ false
1474
- * formatPhoneNumber("0812-3456-hello", {
1475
- * // Formatting Phone Number Options
1476
- * separator: "-",
1477
- * // Validity-check Mode
1478
- * checkValidOnly: true
1479
- * });
1480
- * // ➔ false
1481
- * ```
1482
- */
1483
- declare function formatPhoneNumber(value: ValueFormatPhoneNumber, options?: FormatPhoneNumberAllPassingValidOnly): boolean;
1484
- /** -------------------------------------------------------
1485
- * * ***Utility: `formatPhoneNumber`.***
1486
- * -------------------------------------------------------
1487
- * **Formats a phone number into a customizable local or international style.**
1488
- * - **Type:** ***Forced to `Digits-only Mode`***, because `takeNumberOnly` has set to `true`.
1489
- * - **Can also:**
1490
- * - Return only digits string when **digits-only mode** (`takeNumberOnly`).
1491
- * - Return boolean when **validity-check mode** (`checkValidOnly`) using a
1492
- * regex for international-style phone numbers:
1493
- * - ***Valid if:***
1494
- * - Only contains digits, optional leading `+`, spaces, parentheses `()`,
1495
- * hyphens `-`, or dots `.`.
1496
- * - Digits-only length < 16.
1497
- * - **E.164 compliance:**
1498
- * - Optional leading `+` is recommended but **not required**.
1499
- * - If Without leading `+`, you must passing `defaultCountry`.
1500
- * @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.
1501
- * @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.
1502
- * @param {ValueFormatPhoneNumber} value
1503
- * Phone number to format. Accepts:
1504
- * - `string` (recommended to preserve leading zeros)
1505
- * - `number` (leading zeros will be lost)
1506
- * - `null` or `undefined` (returns empty string).
1507
- * @param {FormatPhoneNumberTakeNumberOnly} [options] Options to customize format output (country code, separator, etc).
1508
- * @returns {string} Digits-only mode, return string a digits-only.
1509
- * @example
1510
- * ```ts
1511
- * formatPhoneNumber("(0812) 3456-7890", {
1512
- * defaultCountry: "ID",
1513
- * // Formatting Phone Number Options
1514
- * separator: "-",
1515
- * // Digits-only Mode
1516
- * takeNumberOnly: true,
1517
- * });
1518
- * // ➔ "081234567890"
1519
- * formatPhoneNumber("(0812) 3456-7890", {
1520
- * // Formatting Phone Number Options
1521
- * separator: "-",
1522
- * // Digits-only Mode
1523
- * takeNumberOnly: true,
1524
- * });
1525
- * // ➔ ""
1526
- * formatPhoneNumber("(63) 917 123 4567", {
1527
- * defaultCountry: "PH",
1528
- * // Formatting Phone Number Options
1529
- * separator: "-",
1530
- * // Digits-only Mode
1531
- * takeNumberOnly: true,
1532
- * });
1533
- * // ➔ "0917 123 4567"
1534
- * formatPhoneNumber("(63) 4567-8901", {
1535
- * defaultCountry: "PH",
1536
- * // Formatting Phone Number Options
1537
- * separator: "-",
1538
- * // Digits-only Mode
1539
- * takeNumberOnly: true,
1540
- * });
1541
- * // ➔ "" // is not valid number from PH.
1542
- * formatPhoneNumber("(63) 917 123 4567", { takeNumberOnly: true });
1543
- * // ➔ ""
1544
- * formatPhoneNumber("49 (151) 2345 6789", {
1545
- * defaultCountry: "DE",
1546
- * // Formatting Phone Number Options
1547
- * separator: "-",
1548
- * // Digits-only Mode
1549
- * takeNumberOnly: true,
1550
- * });
1551
- * // ➔ "015123456789"
1552
- * formatPhoneNumber("49 (151) 2345 6789", {
1553
- * // Formatting Phone Number Options
1554
- * separator: "-",
1555
- * // Digits-only Mode
1556
- * takeNumberOnly: true,
1557
- * });
1558
- * // ➔ ""
1559
- * ```
1560
- */
1561
- declare function formatPhoneNumber(value: ValueFormatPhoneNumber, options?: FormatPhoneNumberAllPassingTakeOnly): string;
1562
- /** -------------------------------------------------------
1563
- * * ***Utility: `formatPhoneNumber`.***
1564
- * -------------------------------------------------------
1565
- * **Formats a phone number into a customizable local or international style.**
1566
- * - **Type:** ***Forced to `Validity-check Mode`***, because `checkValidOnly` and `takeNumberOnly` has set to `true`,
1567
- * but `checkValidOnly` will prioritize one.
1568
- * - **Can also:**
1569
- * - Return only digits string when **digits-only mode** (`takeNumberOnly`).
1570
- * - Return boolean when **validity-check mode** (`checkValidOnly`) using a
1571
- * regex for international-style phone numbers:
1572
- * - ***Valid if:***
1573
- * - Only contains digits, optional leading `+`, spaces, parentheses `()`,
1574
- * hyphens `-`, or dots `.`.
1575
- * - Digits-only length < 16.
1576
- * - **E.164 compliance:**
1577
- * - Optional leading `+` is recommended but **not required**.
1578
- * - If Without leading `+`, you must passing `defaultCountry`.
1579
- * @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.
1580
- * @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.
1581
- * @param {ValueFormatPhoneNumber} value
1582
- * Phone number to format. Accepts:
1583
- * - `string` (recommended to preserve leading zeros).
1584
- * - `number` (leading zeros will be lost).
1585
- * - `null` or `undefined` (returns empty string).
1586
- * @param {FormatPhoneNumberTakeNumberOnly} [options] Options to customize format output (country code, separator, etc).
1587
- * @returns {boolean} Validity-check mode, return a boolean.
1588
- * @example
1589
- * ```ts
1590
- * formatPhoneNumber("+6281234567890", {
1591
- * // Formatting Phone Number Options
1592
- * separator: "-",
1593
- * // Validity-check Mode
1594
- * checkValidOnly: true,
1595
- * // Digits-only Mode
1596
- * takeNumberOnly: true,
1597
- * });
1598
- * // ➔ true
1599
- * formatPhoneNumber("0812-3456-7890", {
1600
- * defaultCountry: "ID",
1601
- * // Formatting Phone Number Options
1602
- * separator: "-",
1603
- * // Validity-check Mode
1604
- * checkValidOnly: true,
1605
- * // Digits-only Mode
1606
- * takeNumberOnly: true,
1607
- * });
1608
- * // ➔ true
1609
- * formatPhoneNumber("0812 3456 7890", {
1610
- * // Formatting Phone Number Options
1611
- * separator: "-",
1612
- * // Validity-check Mode
1613
- * checkValidOnly: true,
1614
- * // Digits-only Mode
1615
- * takeNumberOnly: true,
1616
- * });
1617
- * // ➔ false
1618
- * formatPhoneNumber("(0812) 3456-7890", {
1619
- * defaultCountry: "ID",
1620
- * // Formatting Phone Number Options
1621
- * separator: "-",
1622
- * // Validity-check Mode
1623
- * checkValidOnly: true,
1624
- * // Digits-only Mode
1625
- * takeNumberOnly: true,
1626
- * });
1627
- * // ➔ true
1628
- * formatPhoneNumber("(0812) 3456-7890", {
1629
- * // Formatting Phone Number Options
1630
- * separator: "-",
1631
- * // Validity-check Mode
1632
- * checkValidOnly: true,
1633
- * // Digits-only Mode
1634
- * takeNumberOnly: true,
1635
- * });
1636
- * // ➔ false
1637
- * formatPhoneNumber("+44 20 7946 0958", {
1638
- * // Formatting Phone Number Options
1639
- * separator: "-",
1640
- * // Validity-check Mode
1641
- * checkValidOnly: true,
1642
- * // Digits-only Mode
1643
- * takeNumberOnly: true,
1644
- * });
1645
- * // ➔ true
1646
- * formatPhoneNumber("+1 (800) 123-4567", {
1647
- * // Formatting Phone Number Options
1648
- * separator: "-",
1649
- * // Validity-check Mode
1650
- * checkValidOnly: true,
1651
- * // Digits-only Mode
1652
- * takeNumberOnly: true,
1653
- * });
1654
- * // ➔ true
1655
- * formatPhoneNumber("+62.812.3456.7890", {
1656
- * // Formatting Phone Number Options
1657
- * separator: "-",
1658
- * // Validity-check Mode
1659
- * checkValidOnly: true,
1660
- * // Digits-only Mode
1661
- * takeNumberOnly: true,
1662
- * });
1663
- * // ➔ true
1664
- * formatPhoneNumber("+62(812)3456-7890", {
1665
- * // Formatting Phone Number Options
1666
- * separator: "-",
1667
- * // Validity-check Mode
1668
- * checkValidOnly: true,
1669
- * // Digits-only Mode
1670
- * takeNumberOnly: true,
1671
- * });
1672
- * // ➔ true
1673
- * formatPhoneNumber("+62abc123", {
1674
- * // Formatting Phone Number Options
1675
- * separator: "-",
1676
- * // Validity-check Mode
1677
- * checkValidOnly: true,
1678
- * // Digits-only Mode
1679
- * takeNumberOnly: true,
1680
- * });
1681
- * // ➔ false
1682
- * formatPhoneNumber("invalid@@@", {
1683
- * // Formatting Phone Number Options
1684
- * separator: "-",
1685
- * // Validity-check Mode
1686
- * checkValidOnly: true,
1687
- * // Digits-only Mode
1688
- * takeNumberOnly: true,
1689
- * });
1690
- * // ➔ false
1691
- * formatPhoneNumber("0812-3456-hello", {
1692
- * // Formatting Phone Number Options
1693
- * separator: "-",
1694
- * // Validity-check Mode
1695
- * checkValidOnly: true,
1696
- * // Digits-only Mode
1697
- * takeNumberOnly: true,
1698
- * });
1699
- * // ➔ false
1700
- * ```
1701
- */
1702
- declare function formatPhoneNumber(value: ValueFormatPhoneNumber, options?: FormatPhoneNumberAllPassing): boolean;
1703
-
1704
- type CensorEmailOptions = {
1705
- /** ----------------------------------------------------------
1706
- * * ***Censorship Mode.***
1707
- * ----------------------------------------------------------
1708
- * - **Valid value:**
1709
- * - `"fixed"` (default) – Deterministic censorship based on a hash of the email, same input always produces the same output.
1710
- * - `"random"` – Each character is randomly replaced every time the function is called.
1711
- */
1712
- mode?: "random" | "fixed";
1713
- };
1714
- /** ----------------------------------------------------------
1715
- * * ***Utility: `censorEmail`.***
1716
- * ----------------------------------------------------------
1717
- * **Censors an email by replacing characters with `"*"` while supporting random or fixed mode.**
1718
- * - **This function replaces parts of an email with asterisks to protect privacy.**
1719
- * - **Modes:**
1720
- * - `"fixed"` (default) – Deterministic censorship based on a hash of the email, same input always produces the same output.
1721
- * - `"random"` – Each character is randomly replaced every time the function is called.
1722
- * - **ℹ️ Note:**
1723
- * - Invalid emails or non-string input will return an empty-string (`""`).
1724
- * @param {string | null | undefined} email - The email address to censor.
1725
- * @param {CensorEmailOptions} [options={}] - Options object for mode.
1726
- * @returns {string} The censored email, or an empty string if input is invalid.
1727
- * @throws **{@link TypeError | `TypeError`}** if `options` is not a plain object or `mode` is invalid.
1728
- * @example
1729
- * // Fixed mode (default, deterministic)
1730
- * censorEmail("john.doe@gmail.com");
1731
- * // ➔ "j**n.**e@g***l.com"
1732
- *
1733
- * // Fixed mode explicitly
1734
- * censorEmail("john.doe@gmail.com", { mode: "fixed" });
1735
- * // ➔ "j**n.**e@g***l.com"
1736
- *
1737
- * // Random mode (output may vary each time)
1738
- * censorEmail("john.doe@gmail.com", { mode: "random" });
1739
- * // ➔ "j*hn.***e@g***l.com" (random)
1740
- *
1741
- * // Invalid email returns empty string
1742
- * censorEmail("invalid-email");
1743
- * // ➔ ""
1744
- */
1745
- declare const censorEmail: (email: string | null | undefined, options?: CensorEmailOptions) => string;
1746
-
1747
- type ChunkStringOptions = {
1748
- /** ***The separator string to insert between characters or words.***
1749
- *
1750
- * - Used when inserting separators every `limiter` characters.
1751
- * - Default is a single space `" "`.
1752
- *
1753
- * @default " "
1754
- */
1755
- separator?: string;
1756
- /** ***Determines whether counting for `limiter` resets after each space.***
1757
- *
1758
- * - If `true`, the string is treated as words separated by spaces,
1759
- * and separators are applied within words, then words are grouped.
1760
- * - If `false` ***(default)***, counting is continuous across the whole string,
1761
- * treating spaces as normal characters.
1762
- *
1763
- * @default false
1764
- */
1765
- reCountAfterSpace?: boolean;
1766
- };
1767
- /** ----------------------------------------------
1768
- * * ***Utility: `chunkString`.***
1769
- * ----------------------------------------------
1770
- * **Chunks a string by inserting a separator every `limiter` characters.**
1771
- * - **This function handles two main behaviors based on `reCountAfterSpace`:**
1772
- * 1. ***If `reCountAfterSpace` is `false` (default):***
1773
- * - The separator is inserted strictly every `limiter` characters throughout the entire string, regardless of spaces, spaces are treated as regular characters in the count.
1774
- * - Example: `chunkString("1234567890", 3, "-")` ➔ `"123-456-789-0"`.
1775
- * - Example: `chunkString("Hello World", 3, "-")` ➔ `"Hel-lo -Wor-ld"`.
1776
- * 2. ***If `reCountAfterSpace` is `true`:***
1777
- * - The function first processes the input string to replace any multiple consecutive spaces with a
1778
- * single space (e.g., "A B" becomes "A B").
1779
- * Then, it treats the string as a sequence of "words" (segments separated by single spaces).
1780
- * - Each word is processed independently:
1781
- * - if a word's length exceeds the `limiter`, separators are inserted internally within that word.
1782
- * - Words are then grouped. Each group will contain `limiter` number of words.
1783
- * - Words within the same group are joined by the specified `separator`.
1784
- * - Finally, these groups are joined by a single space, preserving the original word separation
1785
- * structure between groups.
1786
- * @param {string} subject - ***The target string to chunk.****
1787
- * @param {number} limiter
1788
- * ***The interval (number of characters) for inserting separators, behavior:***
1789
- * - If `reCountAfterSpace = false`, it counts characters.
1790
- * - If `reCountAfterSpace = true`, it counts both characters within words and words per group.
1791
- * @param {ChunkStringOptions} [options={}] - ***Optional settings for separator and counting behavior.***
1792
- * @returns {string} Return the formatted string with separators.
1793
- * @example
1794
- * // Basic usage
1795
- * chunkString("1234567890", 3);
1796
- * // ➔ "123 456 789 0"
1797
- *
1798
- * // Basic usage `reCountAfterSpace = false` (default)
1799
- * chunkString("1234567890", 3, { separator: "-");
1800
- * // ➔ "123-456-789-0"
1801
- * chunkString("HelloWorld", 2, { separator: "_", reCountAfterSpace: false });
1802
- * // ➔ "He_ll_oW_or_ld"
1803
- *
1804
- * // Usage with reCountAfterSpace = true:
1805
- * // Multiple spaces are normalized to single spaces before processing.
1806
- * chunkString("AB CD EF GH", 2, { separator: "-", reCountAfterSpace: true });
1807
- * // ➔ "AB-CD EF-GH" (after normalization to "AB CD EF GH")
1808
- * // Words "AB" and "CD" form a group and are joined by "-", "EF" and "GH" form another group.
1809
- * // The groups "AB-CD" and "EF-GH" are then joined by a space.
1810
- *
1811
- * // Another usage with reCountAfterSpace = true:
1812
- * chunkString("ABC DEF GHI JKL", 3, { separator: "-", reCountAfterSpace: true });
1813
- * // ➔ "ABC-DEF-GHI JKL"
1814
- * // Words "ABC", "DEF", "GHI" form a group and are joined by "-".
1815
- * // The word "JKL" forms its own group (as it's the last word and completes no other group).
1816
- * // The groups "ABC-DEF-GHI" and "JKL" are then joined by a space.
1817
- */
1818
- declare function chunkString(subject: string, limiter: number, options?: ChunkStringOptions): string;
1819
-
1820
- type TruncateStringOptions = {
1821
- /** ***Maximum length of the truncated string **(default: `10`)**.***
1822
- *
1823
- * @default 10
1824
- */
1825
- length?: number;
1826
- /** ***String to append if truncation occurs.***
1827
- *
1828
- * - Will be trimmed first; defaults to `"..."` if empty.
1829
- *
1830
- * @default "..."
1831
- */
1832
- ending?: string;
1833
- /** ***Whether to trim the input string before truncation ***(default: `true`)***.***
1834
- *
1835
- * @default true
1836
- */
1837
- trim?: boolean;
1838
- };
1839
- /** ----------------------------------------------------------
1840
- * * ***Utility: `truncateString`.***
1841
- * ----------------------------------------------------------
1842
- * **Features:**
1843
- * - Truncates a string to a specified length and optionally appends an ending.
1844
- * - Supports trimming the input before truncation.
1845
- * - If truncation occurs, trailing spaces before the ending are removed.
1846
- * - The `ending` parameter is always trimmed first; if empty, it defaults to `"..."`.
1847
- * @param {string|null|undefined} text
1848
- * ***The input string to truncate, behavior:***
1849
- * - If `null`, `undefined`, or empty after trim, returns `""`.
1850
- * @param {TruncateStringOptions} [options]
1851
- * ***Optional settings:***
1852
- * - `length` (number, default 10): Maximum length of the truncated string.
1853
- * - `ending` (string, default `"..."`): String to append if truncation occurs.
1854
- * - `trim` (boolean, default `true`): Whether to trim the input before truncation.
1855
- * @returns {string} The truncated string with optional trimming and ending, returns `""` if input is empty or length < 1.
1856
- * @throws **{@link TypeError | `TypeError`}** if `options.length` is not a finite number, or if `options.ending` is not a string, or if `options.trim` is not a boolean.
1857
- * @example
1858
- * truncateString("hello world", { length: 5 });
1859
- * // ➔ "hello..."
1860
- * truncateString("hello world", { length: 5, ending: "---" });
1861
- * // ➔ "hello---"
1862
- * truncateString("hello world", { length: 5, ending: " " });
1863
- * // ➔ "hello..." (ending trimmed to default)
1864
- * truncateString("hello world", { length: 5, ending: " !!! " });
1865
- * // ➔ "hello!!!" (ending trimmed)
1866
- * truncateString(" long data string ", { length: 8, ending: "...", trim: true });
1867
- * // ➔ "long dat..."
1868
- * truncateString(" long data string ", { length: 8, ending: "...", trim: false });
1869
- * // ➔ " long ..."
1870
- * truncateString(null, { length: 5 });
1871
- * // ➔ ""
1872
- */
1873
- declare const truncateString: (text: string | null | undefined, options?: TruncateStringOptions) => string;
1874
-
1875
- /** ----------------------------------------------------------------------
1876
- * * ***Options for formatting dates with `date-fns/format`.***
1877
- * ----------------------------------------------------------------------
1878
- *
1879
- * Extends the base **{@link FormatOptions | *`FormatOptions`*}** (without **`locale`**) with extra options
1880
- * for handling output formatting, localization, and parsing non-standard inputs.
1881
- *
1882
- * @private ***types for {@link formatDateFns}.***
1883
- */
1884
- type FormatDateFnsOptions = Prettify<OmitStrict<FormatOptions, "locale", true, false> & {
1885
- /** ------------------------------------------------------------
1886
- * * ***Output format string passed to `date-fns/format`.***
1887
- * ------------------------------------------------------------
1888
- * - **Behavior:**
1889
- * - Determines how the date will be rendered.
1890
- * - Uses the full power of `date-fns` tokens.
1891
- * - ***Default Value***: `"dd MMM yyyy - HH:mm:ss"`.
1892
- * @example
1893
- * "dd MMMM yyyy, HH:mm:ss" // ➔ "03 September 2025, 10:25:42"
1894
- * @default "dd MMM yyyy - HH:mm:ss"
1895
- */
1896
- format?: string;
1897
- /** ------------------------------------------------------------
1898
- * * ***Locale used for formatting.***
1899
- * ------------------------------------------------------------
1900
- * - **Behavior:**
1901
- * - If `string`: only accepts `"id"` (Indonesian) or `"en"` (English) - **(default)**.
1902
- * - If `Locale`: accepts a locale object from `date-fns/locale`.
1903
- * - ***Default Value***: `"en"`.
1904
- * ```ts
1905
- * import { ar } from "date-fns/locale";
1906
- *
1907
- * formatDateFns(new Date(), {
1908
- * locale: ar,
1909
- * format: "dd MMMM yyyy"
1910
- * });
1911
- * // ➔ "03 سبتمبر 2025"
1912
- * ```
1913
- * @default "en"
1914
- */
1915
- locale?: "id" | "en" | AnyString | Locale;
1916
- /** ------------------------------------------------------------
1917
- * * ***Input locale used when parsing non-standard string dates.***
1918
- * ------------------------------------------------------------
1919
- * - **Behavior:**
1920
- * - Required if `date` is a **localized string**
1921
- * (e.g. `"03 Mei 2025 10:25:42"` in Indonesian).
1922
- * - Same accepted types as `locale` parameter.
1923
- * - ***Default Value***: `"en"`.
1924
- * ```ts
1925
- * import { ar } from "date-fns/locale";
1926
- *
1927
- * formatDateFns("03 مايو 2025 10:25:42", {
1928
- * inputFormat: "dd MMMM yyyy HH:mm:ss",
1929
- * inputLocale: ar,
1930
- * format: "PPpp"
1931
- * });
1932
- * // ➔ "May 3, 2025 at 10:25:42 AM"
1933
- * ```
1934
- * @default "en"
1935
- */
1936
- inputLocale?: "id" | "en" | AnyString | Locale;
1937
- /** ------------------------------------------------------------
1938
- * * ***Input format string for parsing non-ISO string dates.***
1939
- * ------------------------------------------------------------
1940
- * - **Behavior:**
1941
- * - Required if `date` is **not ISO-8601** and not a native `Date`.
1942
- * - Works together with `inputLocale` parameter.
1943
- * - ***Default Value***: `undefined`.
1944
- * @default undefined
1945
- * @example
1946
- * "dd MMMM yyyy HH:mm:ss" // ➔ "03 May 2025 10:25:42"
1947
- */
1948
- inputFormat?: string;
1949
- }>;
1950
-
1951
- /** ----------------------------------------------------------
1952
- * * ***Utility: `formatDateFns`.***
1953
- * ----------------------------------------------------------
1954
- * **Formats a date into a human-readable string using `date-fns`.**
1955
- * - **Features:**
1956
- * - Supports custom output formats using `date-fns/format`.
1957
- * - Can parse localized non-ISO strings via `inputFormat` & `inputLocale`.
1958
- * - Supports `locale` as `"id"`, `"en"` or `date-fns` `Locale` objects (like `id` or `enUS`).
1959
- * - Returns `null` if the date is invalid, not provided, or parsing fails.
1960
- * @param {string | Date | null | undefined} date
1961
- * ***The date input to format, can be:***
1962
- * - A `Date` object.
1963
- * - An ISO string (e.g. `"2024-01-01T12:00:00Z"`).
1964
- * - A localized string (requires `inputFormat` + `inputLocale`).
1965
- * @param {FormatDateFnsOptions} [options] ***Options for formatting and parsing.***
1966
- * @param {FormatDateFnsOptions["format"]} [options.format="dd MMM yyyy - HH:mm:ss"]
1967
- * ***The output format string (passed to `date-fns/format`), e.g:***
1968
- * - `"dd MMMM yyyy, HH:mm:ss" ➔ "14 Juli 2025, 17:25:42"`.
1969
- * @param {FormatDateFnsOptions["locale"]} [options.locale="id"]
1970
- * The output locale. If string, only `"id"` (Indonesian) or `"en"` (English)
1971
- * is recognized. Or you can pass a `date-fns` `Locale` object.
1972
- * - Example:
1973
- * ```ts
1974
- * import { ar } from "date-fns/locale";
1975
- * formatDateFns(new Date(), { locale: ar, format: "PPPppp" });
1976
- * ```
1977
- * @param {FormatDateFnsOptions["inputLocale"]} [options.inputLocale]
1978
- * Required if `date` is a localized non-ISO string. Used with `inputFormat`.
1979
- * - Example for Indonesian string:
1980
- * ```ts
1981
- * formatDateFns("14 Juli 2025 10:25:42", { inputFormat: "dd MMMM yyyy HH:mm:ss", inputLocale: "id" });
1982
- * ```
1983
- * @param {FormatDateFnsOptions["inputFormat"]} [options.inputFormat]
1984
- * The format string to parse `date` if it is a non-ISO string.
1985
- * Required together with `inputLocale`.
1986
- * @returns {string | null} A formatted date string or `null` if input is invalid.
1987
- * @example
1988
- * formatDateFns(new Date());
1989
- * // ➔ "14 Jul 2025 - 17:25:42"
1990
- * formatDateFns("2025-07-14T10:25:42Z", { format: "dd/MM/yyyy", locale: "en" });
1991
- * // ➔ "14/07/2025"
1992
- * formatDateFns("14 Juli 2025 10:25:42", {
1993
- * inputFormat: "dd MMMM yyyy HH:mm:ss",
1994
- * inputLocale: "id",
1995
- * format: "yyyy-MM-dd"
1996
- * });
1997
- * // ➔ "2025-07-14"
1998
- * formatDateFns(null);
1999
- * // ➔ null
2000
- */
2001
- declare const formatDateFns: (date: string | Date | null | undefined, options?: FormatDateFnsOptions) => string | null;
2002
-
2003
- /** -------------------------------------------------------------
2004
- * * ***Supported IETF BCP-47 locale codes for Intl API.***
2005
- * -------------------------------------------------------------
2006
- * **This type ensures proper autocompletion & validation in TS
2007
- * but does not restrict at runtime (must validate separately).**
2008
- * - **Includes:**
2009
- * - Major global locales (`en-US`, `fr-FR`, `zh-CN`, `etc`)
2010
- * - Regional & minor locales (`mi-NZ`, `rw-RW`, `bi-VU`, `etc`)
2011
- * - Useful for `Intl.DateTimeFormat`, `Intl.NumberFormat`, `etc`.
2012
- * - Still allows fallback via `({} & string)` for arbitrary locales.
2013
- * @example
2014
- * const locale: SupportedLocales = "fr-CA";
2015
- * new Intl.DateTimeFormat(locale).format(new Date());
2016
- */
2017
- type SupportedLocales = "en-US" | "en-GB" | "en-AU" | "en-CA" | "en-NZ" | "en-ZA" | "en-IN" | "en-IE" | "en-SG" | "en-HK" | "en-PH" | "en-MY" | "en-PK" | "en-KE" | "en-TZ" | "en-NG" | "en-LK" | "en-BW" | "en-ZM" | "id-ID" | "ms-MY" | "th-TH" | "vi-VN" | "tl-PH" | "ms-BN" | "zh-CN" | "zh-HK" | "zh-TW" | "zh-SG" | "zh-MO" | "ja-JP" | "ko-KR" | "fr-FR" | "fr-CA" | "fr-BE" | "fr-CH" | "fr-LU" | "fr-MA" | "fr-SN" | "fr-CM" | "fr-CI" | "fr-HT" | "fr-DZ" | "fr-TN" | "fr-ML" | "fr-NC" | "fr-PF" | "fr-GP" | "fr-MQ" | "fr-GF" | "de-DE" | "de-AT" | "de-CH" | "de-LU" | "de-LI" | "es-ES" | "es-MX" | "es-AR" | "es-CL" | "es-CO" | "es-PE" | "es-UY" | "es-VE" | "es-CR" | "es-EC" | "es-GT" | "es-HN" | "es-NI" | "es-PA" | "es-PR" | "es-SV" | "es-BO" | "es-PY" | "es-DO" | "es-CU" | "es-GQ" | "pt-BR" | "pt-PT" | "pt-MZ" | "pt-AO" | "pt-GW" | "pt-CV" | "pt-ST" | "it-IT" | "it-CH" | "it-SM" | "it-VA" | "nl-NL" | "nl-BE" | "nl-SR" | "nl-AW" | "nl-CW" | "ru-RU" | "uk-UA" | "kk-KZ" | "uz-UZ" | "ky-KG" | "tt-RU" | "ba-RU" | "cv-RU" | "sah-RU" | "pl-PL" | "cs-CZ" | "sk-SK" | "hu-HU" | "sl-SI" | "sv-SE" | "da-DK" | "no-NO" | "fi-FI" | "is-IS" | "ro-RO" | "bg-BG" | "hr-HR" | "sr-RS" | "mk-MK" | "bs-BA" | "me-ME" | "sq-AL" | "sq-XK" | "el-GR" | "el-CY" | "tr-TR" | "tr-CY" | "he-IL" | "ar-SA" | "ar-AE" | "ar-EG" | "ar-MA" | "ar-JO" | "ar-LB" | "ar-QA" | "ar-KW" | "ar-OM" | "ar-BH" | "ar-IQ" | "ar-LY" | "ar-TN" | "ar-YE" | "ar-SY" | "ar-PS" | "ar-SD" | "ar-DZ" | "ar-MR" | "ar-DJ" | "ar-SO" | "lt-LT" | "lv-LV" | "et-EE" | "hi-IN" | "bn-BD" | "pa-IN" | "ta-IN" | "te-IN" | "ml-IN" | "gu-IN" | "kn-IN" | "mr-IN" | "or-IN" | "as-IN" | "ne-IN" | "fa-IR" | "ur-PK" | "ps-AF" | "dv-MV" | "sw-KE" | "sw-TZ" | "zu-ZA" | "af-ZA" | "xh-ZA" | "ss-SZ" | "ts-ZA" | "tn-BW" | "ny-MW" | "lo-LA" | "mt-MT" | "ga-IE" | "cy-GB" | "ne-NP" | "si-LK" | "am-ET" | "om-ET" | "ti-ER" | "km-KH" | "my-MM" | "mn-MN" | "tg-TJ" | "tk-TM" | "hy-AM" | "ka-GE" | "az-AZ" | "be-BY" | "mo-MD" | "ro-MD" | "ht-HT" | "jw-ID" | "su-ID" | "to-TO" | "sm-WS" | "mi-NZ" | "bi-VU" | "fj-FJ" | "ty-PF" | "pau-PW" | "niu-NU" | "ck-CK" | "rw-RW" | "ln-CD" | "kg-CD" | "ha-NE" | "yo-NG" | "ig-NG" | "ak-GH" | "lg-UG" | "bo-CN" | "dz-BT" | "iu-CA" | "kl-GL" | "cv-RU" | "pap-AW" | "chr-US" | "haw-US" | "gv-IM" | "gd-GB" | "br-FR" | "co-FR" | "rm-CH" | "wa-BE" | "lb-LU" | "fur-IT" | "sc-IT" | "vec-IT" | "nap-IT" | "gsw-CH" | "rha-CH" | ({} & string);
2018
-
2019
- /** ----------------------------------------------------------------
2020
- * * ***Options for formatting dates with `Intl.DateTimeFormat`.***
2021
- * ----------------------------------------------------------------
2022
- * **Extends the native
2023
- * **{@link Intl.DateTimeFormatOptions | `Intl.DateTimeFormatOptions`}** with
2024
- * an additional `locale` property that is validated against **{@link SupportedLocales | `SupportedLocales`}**.**
2025
- * @private ***types for {@link formatDateIntl}.***
2026
- */
2027
- type FormatDateIntlOptions = Intl.DateTimeFormatOptions & {
2028
- /** ------------------------------------------------------------
2029
- * * ***Locale for date formatting.***
2030
- * ------------------------------------------------------------
2031
- * - **Behavior:**
2032
- * - Must be a valid [***BCP-47 locale***](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument),
2033
- * validated against {@link SupportedLocales | **`SupportedLocales`**}.
2034
- * - If `locale` is `undefined` or an empty string (after trimming),
2035
- * it will **default to `"en-US"`**.
2036
- * @default "en-US"
2037
- * @example
2038
- * { year: "numeric", month: "long" }
2039
- * // Unset locale, default locale ➔ "en-US"
2040
- * { locale: "fr-FR", ...}
2041
- * // Explicit locale
2042
- * { locale: " ", ...}
2043
- * // Empty string locale ➔ defaults to "en-US"
2044
- * { locale: " en-GB ", ...}
2045
- * // Value will trimming ➔ "en-GB"
2046
- *
2047
- */
2048
- locale?: SupportedLocales;
2049
- };
2050
-
2051
- /** ----------------------------------------------------------
2052
- * * ***Utility: `formatDateIntl`.***
2053
- * ----------------------------------------------------------
2054
- * **Formats a date using the `Intl.DateTimeFormat` API.**
2055
- * - **Features:**
2056
- * - Supports custom locales (type-safe `SupportedLocales`).
2057
- * - Accepts additional `Intl.DateTimeFormatOptions` like `timeZone`, `hour12`, etc.
2058
- * - Defaults to `"en-US"` if `locale` is not provided or is an empty string.
2059
- * - Returns `null` if the date is invalid, not provided, or options are invalid.
2060
- * @param {string | Date | null | undefined} date
2061
- * ***The date to format.***
2062
- * - Can be a `Date` object or an ISO string.
2063
- * - If invalid or not provided, returns `null`.
2064
- * @param {FormatDateIntlOptions} [options] ***Optional formatting options for `Intl.DateTimeFormat`, use `locale` to specify the language & region format.***
2065
- * @returns {string | null}
2066
- * - Formatted date string.
2067
- * - Returns `null` if date is invalid or options are of wrong type.
2068
- * @example
2069
- * formatDateIntl(new Date());
2070
- * // ➔ "7/14/2025"
2071
- * formatDateIntl("2025-07-14T00:00:00Z", { locale: "fr-FR", dateStyle: "long" });
2072
- * // ➔ "14 juillet 2025"
2073
- * formatDateIntl(null);
2074
- * // ➔ null
2075
- * formatDateIntl(new Date(), { timeZone: "UTC", hour: "2-digit", minute: "2-digit" });
2076
- * // ➔ "01:30 AM"
2077
- */
2078
- declare const formatDateIntl: (date: string | Date | null | undefined, options?: FormatDateIntlOptions) => string | null;
2079
-
2080
- /** ----------------------------------------------------------
2081
- * * ***Utility: `formatDateTime`.***
2082
- * ----------------------------------------------------------
2083
- * **Formats a date and time into a custom string format.**
2084
- * - **Features:**
2085
- * - Supports only `YYYY`, `MM`, `DD`, `hh`, `mm`, and `ss` as placeholders.
2086
- * - Uses a simple string replace (no locale).
2087
- * - Returns `null` if the date is invalid or not provided.
2088
- * - Defaults to `"YYYY-MM-DD hh:mm:ss"` format if none is specified.
2089
- * @param {string | Date | null| undefined} date - The date to format.
2090
- * @param {string} [format="YYYY-MM-DD hh:mm:ss"] - The desired date format, if format is `null` or `undefined` will force to defaultValue, defaultValue is: `"YYYY-MM-DD hh:mm:ss"`.
2091
- * @returns {string | null} The formatted date string or `null` if invalid.
2092
- * @example
2093
- * formatDateTime(new Date());
2094
- * // ➔ "2024-02-09 14:30:45" (example output with current time)
2095
- * formatDateTime("2023-07-01T14:30:45");
2096
- * // ➔ "2023-07-01 14:30:45"
2097
- * formatDateTime("2023-07-01T14:30:45", "DD/MM/YYYY");
2098
- * // ➔ "01/07/2023"
2099
- * formatDateTime("2023-07-01T14:30:45", "YYYY/MM/DD hh-mm-ss");
2100
- * // ➔ "2023/07/01 14-30-45"
2101
- * formatDateTime("2023-07-01T14:30:45", "hh:mm");
2102
- * // ➔ "14:30"
2103
- * formatDateTime("2023-07-01T14:30:45", "DATE: YYYY.MM.DD");
2104
- * // ➔ "DATE: 2023.07.01"
2105
- * formatDateTime("2023-07-01T14:30:45", "Year: YYYY, Time: hh:mm:ss");
2106
- * // ➔ "Year: 2023, Time: 14:30:45"
2107
- * formatDateTime("2023-07-01T14:30:45", "YYYY-MM");
2108
- * // ➔ "2023-07"
2109
- * formatDateTime("2023-07-01T14:30:45", "YYYYYYYY");
2110
- * // ➔ "20232023"
2111
- * formatDateTime("2023-07-01T14:30:45", "hh:mm:ss:ss");
2112
- * // ➔ "14:30:45:45"
2113
- * formatDateTime("invalid-date");
2114
- * // ➔ null
2115
- * formatDateTime(null);
2116
- * // ➔ null
2117
- * formatDateTime(undefined);
2118
- * // ➔ null
2119
- */
2120
- declare const formatDateTime: (date: string | Date | null | undefined, format?: string) => string | null;
2121
-
2122
- /** ----------------------------------------------------------
2123
- * * ***Utility: `getGMTOffset`.***
2124
- * ----------------------------------------------------------
2125
- * **Returns the formatted GMT offset (e.g., `+0700`, `-0500`) for a given date.**
2126
- * - **Features:**
2127
- * - If `date` is **not provided** or empty string, it defaults to the current date/time.
2128
- * - If `date` is **invalid** or of wrong type (like object or number), it returns `"0"`.
2129
- * - The returned string follows the **GMT offset format** (`±HHMM`), where:
2130
- * - `±` is `+` if ahead of UTC, `-` if behind.
2131
- * - `HH` is two-digit hours.
2132
- * - `MM` is two-digit minutes.
2133
- * @param {string | Date | null} [date]
2134
- * ***The date to get the GMT offset from.***
2135
- * - Accepts `Date` object or ISO date string (e.g., `"2024-01-01T12:00:00Z"`).
2136
- * - If `null`, `undefined`, or empty string, uses current system date.
2137
- * - If invalid date or wrong type (like `123` or `{}`), returns `"0"`.
2138
- * @returns {string} The GMT offset string in format `±HHMM`,
2139
- * e.g. `"+0700"`, `"-0530"`, or `"0"` if invalid.
2140
- * @example
2141
- * getGMTOffset();
2142
- * // ➔ "+0700" (depends on your system timezone)
2143
- * getGMTOffset(new Date("2024-02-09T12:00:00Z"));
2144
- * // ➔ "+0000"
2145
- * getGMTOffset("2024-02-09");
2146
- * // ➔ "+0700" (depends on your system timezone)
2147
- * getGMTOffset("invalid-date");
2148
- * // ➔ "0"
2149
- * getGMTOffset(123);
2150
- * // ➔ "0"
2151
- */
2152
- declare const getGMTOffset: (date?: string | Date | null) => string;
2153
-
2
+ * ========================================================================
3
+ * @rzl-zone/utils-js
4
+ * ------------------------------------------------------------------------
5
+ * Version: `3.12.1-beta.0`
6
+ * Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
7
+ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
8
+ * ========================================================================
9
+ */
10
+
11
+ import { a as truncateString, c as formatPhoneNumber, i as formatDateFns, l as formatNumber, n as formatDateTime, o as chunkString, r as formatDateIntl, s as censorEmail, t as getGMTOffset, u as formatCurrency } from "../index-GUZ9fK6T.js";
2154
12
  export { censorEmail, chunkString, formatCurrency, formatDateFns, formatDateIntl, formatDateTime, formatNumber, formatPhoneNumber, getGMTOffset, truncateString };