@rzl-zone/utils-js 3.13.1-beta.0 → 3.14.0-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 (281) hide show
  1. package/README.md +7 -6
  2. package/dist/.references/index.d.cts +2 -1
  3. package/dist/.references/index.d.ts +2 -1
  4. package/dist/AbortError-DK6kpzbu.cjs +26 -0
  5. package/dist/AbortError-DK6kpzbu.cjs.map +1 -0
  6. package/dist/AbortError-DVT8lAKn.js +20 -0
  7. package/dist/AbortError-DVT8lAKn.js.map +1 -0
  8. package/dist/{assertIsArray-DrLORH0Y.js → assertIsArray-CG7L7vlt.js} +3 -3
  9. package/dist/assertIsArray-CG7L7vlt.js.map +1 -0
  10. package/dist/{assertIsArray-CqIFmlgj.cjs → assertIsArray-CtCRD-_G.cjs} +5 -5
  11. package/dist/assertIsArray-CtCRD-_G.cjs.map +1 -0
  12. package/dist/assertIsPlainObject-DPZLj-Ho.cjs +26 -0
  13. package/dist/assertIsPlainObject-DPZLj-Ho.cjs.map +1 -0
  14. package/dist/assertIsPlainObject-j9bDqNLo.js +20 -0
  15. package/dist/assertIsPlainObject-j9bDqNLo.js.map +1 -0
  16. package/dist/{assertIsString-1iLqxrN0.js → assertIsString-CHIwE12y.js} +4 -4
  17. package/dist/assertIsString-CHIwE12y.js.map +1 -0
  18. package/dist/{assertIsString-DGDLC-XD.cjs → assertIsString-CjE9kbQ_.cjs} +6 -6
  19. package/dist/assertIsString-CjE9kbQ_.cjs.map +1 -0
  20. package/dist/assertions/index.cjs +14 -12
  21. package/dist/assertions/index.cjs.map +1 -1
  22. package/dist/assertions/index.d.cts +2 -2
  23. package/dist/assertions/index.d.ts +2 -2
  24. package/dist/assertions/index.js +10 -8
  25. package/dist/assertions/index.js.map +1 -1
  26. package/dist/conversions/index.cjs +6 -6
  27. package/dist/conversions/index.d.cts +2 -2
  28. package/dist/conversions/index.d.ts +2 -2
  29. package/dist/conversions/index.js +6 -6
  30. package/dist/conversions-BFz6MKaV.cjs +449 -0
  31. package/dist/conversions-BFz6MKaV.cjs.map +1 -0
  32. package/dist/{conversions-CA_3PTAH.js → conversions-Ben5p5Ts.js} +43 -40
  33. package/dist/conversions-Ben5p5Ts.js.map +1 -0
  34. package/dist/errors/index.cjs +13 -0
  35. package/dist/errors/index.d.cts +180 -0
  36. package/dist/errors/index.d.ts +180 -0
  37. package/dist/errors/index.js +11 -0
  38. package/dist/events/index.cjs +10 -9
  39. package/dist/events/index.cjs.map +1 -1
  40. package/dist/events/index.d.cts +185 -100
  41. package/dist/events/index.d.ts +185 -100
  42. package/dist/events/index.js +9 -8
  43. package/dist/events/index.js.map +1 -1
  44. package/dist/formatter-ekJQF_bA-BepnCBkQ.cjs +67 -0
  45. package/dist/formatter-ekJQF_bA-BepnCBkQ.cjs.map +1 -0
  46. package/dist/formatter-ekJQF_bA-xLD9mGk4.js +55 -0
  47. package/dist/formatter-ekJQF_bA-xLD9mGk4.js.map +1 -0
  48. package/dist/formatters/index.cjs +2 -2
  49. package/dist/formatters/index.d.cts +2 -2
  50. package/dist/formatters/index.d.ts +2 -2
  51. package/dist/formatters/index.js +2 -2
  52. package/dist/{formatters-Bm3a_akj.js → formatters-BAbGsnYA.js} +78 -71
  53. package/dist/formatters-BAbGsnYA.js.map +1 -0
  54. package/dist/formatters-zd0Gs4Cs.cjs +436 -0
  55. package/dist/formatters-zd0Gs4Cs.cjs.map +1 -0
  56. package/dist/generators/index.cjs +37 -31
  57. package/dist/generators/index.cjs.map +1 -1
  58. package/dist/generators/index.d.cts +2 -2
  59. package/dist/generators/index.d.ts +2 -2
  60. package/dist/generators/index.js +29 -23
  61. package/dist/generators/index.js.map +1 -1
  62. package/dist/hasOwnProp-CVIhlD1i.js +47 -0
  63. package/dist/hasOwnProp-CVIhlD1i.js.map +1 -0
  64. package/dist/hasOwnProp-D9Tpgokd.cjs +53 -0
  65. package/dist/hasOwnProp-D9Tpgokd.cjs.map +1 -0
  66. package/dist/{index-CakviK5E.d.cts → index-9JsU_wMu.d.ts} +1375 -937
  67. package/dist/{index-BqkYm8qT.d.ts → index-BP3sUrAx.d.ts} +242 -133
  68. package/dist/{index-CJx0EFQ4.d.cts → index-BVovC-yK.d.cts} +229 -200
  69. package/dist/index-C1X6ha9s.d.cts +1041 -0
  70. package/dist/index-CcPQZ41G.d.cts +1103 -0
  71. package/dist/index-CjpbuJF4.d.ts +2424 -0
  72. package/dist/index-CssrQyHh.d.cts +2424 -0
  73. package/dist/index-DZHiYYR7.d.cts +2179 -0
  74. package/dist/index-DZHiYYR7.d.ts +2179 -0
  75. package/dist/index-DlyDmXUo.d.ts +1103 -0
  76. package/dist/index-Dm4a___O.d.ts +1041 -0
  77. package/dist/{index-D5nTp1kV.d.ts → index-Dwduk7ez.d.cts} +1375 -937
  78. package/dist/{index-uaHl0X-r.d.cts → index-I5V6RbZM.d.cts} +1592 -790
  79. package/dist/{index-Bm5odgLW.d.ts → index-hOqBIL7F.d.ts} +1592 -790
  80. package/dist/{index-hOCUw-B9.d.ts → index-jyuOZMX7.d.ts} +229 -200
  81. package/dist/{index-BqkYm8qT.d.cts → index-lI0b7iUz.d.cts} +242 -133
  82. package/dist/{isBigInt-f6yY2fAV.js → isBigInt-Cez32M69.js} +2 -2
  83. package/dist/isBigInt-Cez32M69.js.map +1 -0
  84. package/dist/{isBigInt-CqZNWVtI.cjs → isBigInt-YgpNKTbA.cjs} +2 -2
  85. package/dist/isBigInt-YgpNKTbA.cjs.map +1 -0
  86. package/dist/{isEmptyString-Ga77_3Q1.js → isEmptyString-C9QLWjx2.js} +4 -4
  87. package/dist/isEmptyString-C9QLWjx2.js.map +1 -0
  88. package/dist/{isEmptyString-DNMPmS-H.cjs → isEmptyString-O4TFe1Ao.cjs} +5 -5
  89. package/dist/isEmptyString-O4TFe1Ao.cjs.map +1 -0
  90. package/dist/isEmptyValue-CFExALXZ.cjs +54 -0
  91. package/dist/isEmptyValue-CFExALXZ.cjs.map +1 -0
  92. package/dist/isEmptyValue-kCjnLjbN.js +36 -0
  93. package/dist/isEmptyValue-kCjnLjbN.js.map +1 -0
  94. package/dist/{isFinite-Crw95XV8.cjs → isFinite-B_hHbDpa.cjs} +6 -6
  95. package/dist/isFinite-B_hHbDpa.cjs.map +1 -0
  96. package/dist/{isFinite-BJO7Dt6B.js → isFinite-ZvNhyHlF.js} +5 -5
  97. package/dist/isFinite-ZvNhyHlF.js.map +1 -0
  98. package/dist/{isInteger-B75voxys.js → isInteger-aZgzTTZG.js} +4 -4
  99. package/dist/isInteger-aZgzTTZG.js.map +1 -0
  100. package/dist/{isInteger-CSMNm--9.cjs → isInteger-dnc6W63Z.cjs} +4 -4
  101. package/dist/isInteger-dnc6W63Z.cjs.map +1 -0
  102. package/dist/isNumber-BCWD4dW0.js +20 -0
  103. package/dist/isNumber-BCWD4dW0.js.map +1 -0
  104. package/dist/isNumber-BkzwAe50.cjs +26 -0
  105. package/dist/isNumber-BkzwAe50.cjs.map +1 -0
  106. package/dist/isPlainObject-CAe_ElKO.d.cts +331 -0
  107. package/dist/isPlainObject-CJvRG4Je.d.ts +331 -0
  108. package/dist/{isServer-BHOSvBhV.js → isServer-CQzrX5e0.js} +2 -2
  109. package/dist/isServer-CQzrX5e0.js.map +1 -0
  110. package/dist/{isServer-HA13Dzo2.cjs → isServer-DhFaedeT.cjs} +2 -2
  111. package/dist/isServer-DhFaedeT.cjs.map +1 -0
  112. package/dist/{isEqual-D8W3Wizi.cjs → isTypedArray-DjADSu8q.cjs} +45 -13
  113. package/dist/isTypedArray-DjADSu8q.cjs.map +1 -0
  114. package/dist/{isEqual-ekId-j5b.js → isTypedArray-DxsPKrLh.js} +29 -9
  115. package/dist/isTypedArray-DxsPKrLh.js.map +1 -0
  116. package/dist/{isValidDomain-BqyLVi7S.js → isValidDomain-CDtNOhMc.js} +13 -54
  117. package/dist/isValidDomain-CDtNOhMc.js.map +1 -0
  118. package/dist/{isValidDomain-ByrOfQsh.cjs → isValidDomain-D_x7uNIu.cjs} +16 -69
  119. package/dist/isValidDomain-D_x7uNIu.cjs.map +1 -0
  120. package/dist/{assertIsBoolean-DDhQ2D-k.js → logger-CLWnKRKE.js} +657 -587
  121. package/dist/logger-CLWnKRKE.js.map +1 -0
  122. package/dist/{assertIsBoolean-CEx4KbHg.cjs → logger-CUacYy3D.cjs} +658 -612
  123. package/dist/logger-CUacYy3D.cjs.map +1 -0
  124. package/dist/{noop-CkwxErJ2.cjs → noop-CjEbNsJL.cjs} +2 -2
  125. package/dist/noop-CjEbNsJL.cjs.map +1 -0
  126. package/dist/{noop-D_Ots__Z.js → noop-qxrcogt5.js} +2 -2
  127. package/dist/noop-qxrcogt5.js.map +1 -0
  128. package/dist/{normalizeSpaces-88yaixiu.cjs → normalizeSpaces-D0_Z4qnO.cjs} +6 -9
  129. package/dist/normalizeSpaces-D0_Z4qnO.cjs.map +1 -0
  130. package/dist/{normalizeSpaces-Cat8CHtt.js → normalizeSpaces-DAsxzBEQ.js} +4 -7
  131. package/dist/normalizeSpaces-DAsxzBEQ.js.map +1 -0
  132. package/dist/operations/index.cjs +152 -22
  133. package/dist/operations/index.cjs.map +1 -1
  134. package/dist/operations/index.d.cts +257 -35
  135. package/dist/operations/index.d.ts +257 -35
  136. package/dist/operations/index.js +142 -13
  137. package/dist/operations/index.js.map +1 -1
  138. package/dist/parsers/index.cjs +2 -2
  139. package/dist/parsers/index.d.cts +238 -180
  140. package/dist/parsers/index.d.ts +238 -180
  141. package/dist/parsers/index.js +2 -2
  142. package/dist/{parsers-BLHzVoh-.js → parsers-BBAE_xVM.js} +9 -8
  143. package/dist/parsers-BBAE_xVM.js.map +1 -0
  144. package/dist/{parsers-xAQmKCgS.cjs → parsers-i8WEeMJl.cjs} +10 -9
  145. package/dist/parsers-i8WEeMJl.cjs.map +1 -0
  146. package/dist/{parsing-BYo6U0EG.js → parsing-D9tbKQ0v.js} +3 -3
  147. package/dist/parsing-D9tbKQ0v.js.map +1 -0
  148. package/dist/{parsing-CuezVd0e.cjs → parsing-DGjB8cwr.cjs} +4 -4
  149. package/dist/parsing-DGjB8cwr.cjs.map +1 -0
  150. package/dist/predicates/index.cjs +43 -43
  151. package/dist/predicates/index.d.cts +3 -3
  152. package/dist/predicates/index.d.ts +3 -3
  153. package/dist/predicates/index.js +14 -14
  154. package/dist/{predicates-BMTIIYx8.js → predicates-C0dova7l.js} +45 -40
  155. package/dist/predicates-C0dova7l.js.map +1 -0
  156. package/dist/{predicates-ZmZpelMh.cjs → predicates-Dd7To7B4.cjs} +89 -84
  157. package/dist/predicates-Dd7To7B4.cjs.map +1 -0
  158. package/dist/promises/index.cjs +27 -26
  159. package/dist/promises/index.cjs.map +1 -1
  160. package/dist/promises/index.d.cts +227 -75
  161. package/dist/promises/index.d.ts +227 -75
  162. package/dist/promises/index.js +27 -26
  163. package/dist/promises/index.js.map +1 -1
  164. package/dist/{punyCode-WZ6-GaTM.cjs → punyCode-DHTLhGdD.cjs} +12 -12
  165. package/dist/punyCode-DHTLhGdD.cjs.map +1 -0
  166. package/dist/{punyCode-COTqgXMJ.js → punyCode-Deb1Mrkc.js} +12 -12
  167. package/dist/punyCode-Deb1Mrkc.js.map +1 -0
  168. package/dist/{removeSpaces-CQJvw1yU.js → removeSpaces-BPnsdRN0.js} +4 -4
  169. package/dist/removeSpaces-BPnsdRN0.js.map +1 -0
  170. package/dist/{removeSpaces-BeGkktUl.cjs → removeSpaces-CN3pxBz_.cjs} +7 -7
  171. package/dist/removeSpaces-CN3pxBz_.cjs.map +1 -0
  172. package/dist/rzl-utils.global.js +13 -13
  173. package/dist/safeJsonParse-D1FLVTEM.cjs +209 -0
  174. package/dist/safeJsonParse-D1FLVTEM.cjs.map +1 -0
  175. package/dist/{safeJsonParse-D8H3wCv7.js → safeJsonParse-DEVKNDSn.js} +29 -28
  176. package/dist/safeJsonParse-DEVKNDSn.js.map +1 -0
  177. package/dist/safeStableStringify-C5HHKUdn.cjs +125 -0
  178. package/dist/safeStableStringify-C5HHKUdn.cjs.map +1 -0
  179. package/dist/{safeStableStringify-BLwA1VC-.js → safeStableStringify-DfwxmiWn.js} +20 -13
  180. package/dist/safeStableStringify-DfwxmiWn.js.map +1 -0
  181. package/dist/strings/index.cjs +26 -30
  182. package/dist/strings/index.cjs.map +1 -1
  183. package/dist/strings/index.d.cts +2 -2
  184. package/dist/strings/index.d.ts +2 -2
  185. package/dist/strings/index.js +13 -17
  186. package/dist/strings/index.js.map +1 -1
  187. package/dist/tailwind/index.cjs +3 -3
  188. package/dist/tailwind/index.d.cts +3 -3
  189. package/dist/tailwind/index.d.ts +3 -3
  190. package/dist/tailwind/index.js +3 -3
  191. package/dist/{tailwind-CjxdO7aL.cjs → tailwind-BG7B0cDs.cjs} +59 -53
  192. package/dist/tailwind-BG7B0cDs.cjs.map +1 -0
  193. package/dist/{tailwind-RSE3obLb.js → tailwind-tJNnFPsF.js} +38 -32
  194. package/dist/tailwind-tJNnFPsF.js.map +1 -0
  195. package/dist/{toStringArrayUnRecursive-NreW1dyV.js → toStringArrayUnRecursive-D0WbLIRz.js} +9 -9
  196. package/dist/toStringArrayUnRecursive-D0WbLIRz.js.map +1 -0
  197. package/dist/toStringArrayUnRecursive-QLoaNX_-.cjs +51 -0
  198. package/dist/toStringArrayUnRecursive-QLoaNX_-.cjs.map +1 -0
  199. package/dist/urls/index.cjs +3 -3
  200. package/dist/urls/index.d.cts +635 -443
  201. package/dist/urls/index.d.ts +635 -443
  202. package/dist/urls/index.js +3 -3
  203. package/dist/{urls-CLVfEB7O.js → urls-EoWslGgg.js} +50 -41
  204. package/dist/urls-EoWslGgg.js.map +1 -0
  205. package/dist/urls-NCzPepe2.cjs +308 -0
  206. package/dist/urls-NCzPepe2.cjs.map +1 -0
  207. package/package.json +6 -6
  208. package/dist/assertIsArray-CqIFmlgj.cjs.map +0 -1
  209. package/dist/assertIsArray-DrLORH0Y.js.map +0 -1
  210. package/dist/assertIsBoolean-CEx4KbHg.cjs.map +0 -1
  211. package/dist/assertIsBoolean-DDhQ2D-k.js.map +0 -1
  212. package/dist/assertIsString-1iLqxrN0.js.map +0 -1
  213. package/dist/assertIsString-DGDLC-XD.cjs.map +0 -1
  214. package/dist/conversions-Bxa01uIl.cjs +0 -446
  215. package/dist/conversions-Bxa01uIl.cjs.map +0 -1
  216. package/dist/conversions-CA_3PTAH.js.map +0 -1
  217. package/dist/formatters-Bm3a_akj.js.map +0 -1
  218. package/dist/formatters-Bt6QuhxK.cjs +0 -429
  219. package/dist/formatters-Bt6QuhxK.cjs.map +0 -1
  220. package/dist/index--h04HuBE.d.cts +0 -765
  221. package/dist/index--h04HuBE.d.ts +0 -765
  222. package/dist/index-Ap8U-8Qx.d.cts +0 -947
  223. package/dist/index-BAeeggeh.d.cts +0 -1716
  224. package/dist/index-BAeeggeh.d.ts +0 -1716
  225. package/dist/index-CMglhpFG.d.ts +0 -947
  226. package/dist/isBigInt-CqZNWVtI.cjs.map +0 -1
  227. package/dist/isBigInt-f6yY2fAV.js.map +0 -1
  228. package/dist/isEmptyObject-BYNnSKzw.js +0 -25
  229. package/dist/isEmptyObject-BYNnSKzw.js.map +0 -1
  230. package/dist/isEmptyObject-C2lQyFZS.cjs +0 -37
  231. package/dist/isEmptyObject-C2lQyFZS.cjs.map +0 -1
  232. package/dist/isEmptyString-DNMPmS-H.cjs.map +0 -1
  233. package/dist/isEmptyString-Ga77_3Q1.js.map +0 -1
  234. package/dist/isEmptyValue-D7-6WWS9.js +0 -24
  235. package/dist/isEmptyValue-D7-6WWS9.js.map +0 -1
  236. package/dist/isEmptyValue-DZaDHEIw.cjs +0 -30
  237. package/dist/isEmptyValue-DZaDHEIw.cjs.map +0 -1
  238. package/dist/isEqual-D8W3Wizi.cjs.map +0 -1
  239. package/dist/isEqual-ekId-j5b.js.map +0 -1
  240. package/dist/isFinite-BJO7Dt6B.js.map +0 -1
  241. package/dist/isFinite-Crw95XV8.cjs.map +0 -1
  242. package/dist/isInteger-B75voxys.js.map +0 -1
  243. package/dist/isInteger-CSMNm--9.cjs.map +0 -1
  244. package/dist/isPlainObject-ByfuseCf.d.cts +0 -339
  245. package/dist/isPlainObject-ByfuseCf.d.ts +0 -339
  246. package/dist/isServer-BHOSvBhV.js.map +0 -1
  247. package/dist/isServer-HA13Dzo2.cjs.map +0 -1
  248. package/dist/isTypedArray-CWlHRz_O.cjs +0 -43
  249. package/dist/isTypedArray-CWlHRz_O.cjs.map +0 -1
  250. package/dist/isTypedArray-CmnQ7Yx9.js +0 -31
  251. package/dist/isTypedArray-CmnQ7Yx9.js.map +0 -1
  252. package/dist/isValidDomain-BqyLVi7S.js.map +0 -1
  253. package/dist/isValidDomain-ByrOfQsh.cjs.map +0 -1
  254. package/dist/noop-CkwxErJ2.cjs.map +0 -1
  255. package/dist/noop-D_Ots__Z.js.map +0 -1
  256. package/dist/normalizeSpaces-88yaixiu.cjs.map +0 -1
  257. package/dist/normalizeSpaces-Cat8CHtt.js.map +0 -1
  258. package/dist/parsers-BLHzVoh-.js.map +0 -1
  259. package/dist/parsers-xAQmKCgS.cjs.map +0 -1
  260. package/dist/parsing-BYo6U0EG.js.map +0 -1
  261. package/dist/parsing-CuezVd0e.cjs.map +0 -1
  262. package/dist/predicates-BMTIIYx8.js.map +0 -1
  263. package/dist/predicates-ZmZpelMh.cjs.map +0 -1
  264. package/dist/punyCode-COTqgXMJ.js.map +0 -1
  265. package/dist/punyCode-WZ6-GaTM.cjs.map +0 -1
  266. package/dist/removeSpaces-BeGkktUl.cjs.map +0 -1
  267. package/dist/removeSpaces-CQJvw1yU.js.map +0 -1
  268. package/dist/safeJsonParse-BznDD3fi.cjs +0 -208
  269. package/dist/safeJsonParse-BznDD3fi.cjs.map +0 -1
  270. package/dist/safeJsonParse-D8H3wCv7.js.map +0 -1
  271. package/dist/safeStableStringify-4b-E_UHM.cjs +0 -106
  272. package/dist/safeStableStringify-4b-E_UHM.cjs.map +0 -1
  273. package/dist/safeStableStringify-BLwA1VC-.js.map +0 -1
  274. package/dist/tailwind-CjxdO7aL.cjs.map +0 -1
  275. package/dist/tailwind-RSE3obLb.js.map +0 -1
  276. package/dist/toStringArrayUnRecursive-D-jHROts.cjs +0 -51
  277. package/dist/toStringArrayUnRecursive-D-jHROts.cjs.map +0 -1
  278. package/dist/toStringArrayUnRecursive-NreW1dyV.js.map +0 -1
  279. package/dist/urls-C6BvhrrV.cjs +0 -299
  280. package/dist/urls-C6BvhrrV.cjs.map +0 -1
  281. package/dist/urls-CLVfEB7O.js.map +0 -1
@@ -2,17 +2,19 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/utils-js
4
4
  * ------------------------------------------------------------------------
5
- * Version: `3.13.1-beta.0`
5
+ * Version: `3.14.0-beta.0`
6
6
  * Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
7
7
  * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
8
8
  * ========================================================================
9
9
  */
10
10
 
11
- import { CustomPromiseType } from "@rzl-zone/ts-types-plus";
11
+ import { o as CustomPromiseType } from "../index-DZHiYYR7.js";
12
12
  /** -------------------------------------------------------------
13
13
  * * ***Utility Class: `CustomPromise`.***
14
- * -------------------------------------------------------------
14
+ * --------------------------------------------------------------
15
15
  * **A strongly typed extension of the native {@link Promise | **`Promise`**}.**
16
+ *
17
+ * ---
16
18
  * 1. **Behaves exactly like a normal Promise** for `then`/`catch`
17
19
  * and `await` semantics.
18
20
  * 2. **Stores the final resolution or rejection internally** so
@@ -20,104 +22,254 @@ import { CustomPromiseType } from "@rzl-zone/ts-types-plus";
20
22
  * 3. **Adds a `finish` method** which runs once after settlement
21
23
  * with access to both the fulfilled value *and* the rejection
22
24
  * reason (only one will be defined).
25
+ *
26
+ * ---
23
27
  * - **Key Differences from a Native `Promise`:**
24
- * - Every call to `then`/`catch` returns **`CustomPromise`**
25
- * again, so the `finish` method remains available on the
26
- * entire chain.
27
- * - `finish` provides a tuple-like callback:
28
- * - `val` defined when fulfilled.
29
- * - `err` defined when rejected.
28
+ * - Every call to `then`/`catch` returns **`CustomPromise`**
29
+ * again, so the `finish` method remains available on the
30
+ * entire chain.
31
+ * - `finish` provides a tuple-like callback:
32
+ * - `val` defined when fulfilled.
33
+ * - `err` defined when rejected.
34
+ *
35
+ * ---
30
36
  * @template Success Type of the resolved value.
31
37
  * @template Error Type of the rejection reason (default `unknown`).
38
+ *
39
+ * ---
32
40
  * @example
33
- * ```ts
34
- * import { CustomPromise, type CustomPromiseType } from "@rzl-zone/utils-js/promises";
41
+ * ```ts
42
+ * import { CustomPromise, type CustomPromiseType } from "@rzl-zone/utils-js/promises";
35
43
  *
36
- * type User = { id: number; name: string };
37
- * type ApiError = { message: string };
44
+ * type User = { id: number; name: string };
45
+ * type ApiError = { message: string };
38
46
  *
39
- * function fetchUser(): CustomPromiseType<User, ApiError> {
40
- * return new CustomPromise<User, ApiError>((resolve, reject) => {
41
- * setTimeout(
42
- * () =>
43
- * void (Math.random() > 0.5
44
- * ? resolve({ id: 1, name: "Alice" })
45
- * : reject({ message: "Random failure" })),
46
- * 500
47
- * );
48
- * });
49
- * }
47
+ * function fetchUser(): CustomPromiseType<User, ApiError> {
48
+ * return new CustomPromise<User, ApiError>((resolve, reject) => {
49
+ * setTimeout(
50
+ * () =>
51
+ * void (Math.random() > 0.5
52
+ * ? resolve({ id: 1, name: "Alice" })
53
+ * : reject({ message: "Random failure" })),
54
+ * 500
55
+ * );
56
+ * });
57
+ * }
50
58
  *
51
- * fetchUser()
52
- * .then(user => {
53
- * console.log("SUCCESS:", user);
54
- * return user;
55
- * })
56
- * .catch(err => {
57
- * console.error("ERROR:", err);
58
- * throw err;
59
- * })
60
- * .finish((val, err) => {
61
- * // Runs once after settle, regardless of outcome
62
- * console.log("FINISH:", { val, err });
63
- * });
64
- * ```
59
+ * fetchUser()
60
+ * .then(user => {
61
+ * console.log("SUCCESS:", user);
62
+ * return user;
63
+ * })
64
+ * .catch(err => {
65
+ * console.error("ERROR:", err);
66
+ * throw err;
67
+ * })
68
+ * .finish((val, err) => {
69
+ * // Runs once after settle, regardless of outcome
70
+ * console.log("FINISH:", { val, err });
71
+ * });
72
+ * ```
65
73
  * ---
66
74
  * - **Implementation Notes:**
67
- * - Uses `Object.setPrototypeOf` to preserve the prototype chain
68
- * for environments targeting ES5 or when subclassing Promise.
69
- * - Internal `_value` and `_error` are updated as soon as the
70
- * executor resolves or rejects, guaranteeing `finish` receives
71
- * the final state even when added after settlement.
75
+ * - Uses `Object.setPrototypeOf` to preserve the prototype chain
76
+ * for environments targeting ES5 or when subclassing Promise.
77
+ * - Internal settlement state is tracked automatically,
78
+ * allowing `finish` to access the final result even
79
+ * when registered after settlement.
72
80
  */
73
- declare class CustomPromise<Success, Error = unknown> extends Promise<Success> implements CustomPromiseType<Success, Error> {
74
- private _value?;
75
- private _error?;
76
- private _finish;
77
- constructor(executor: (resolve: (v: Success) => void, reject: (e: Error) => void) => void);
78
- override then<TResult1 = Success, TResult2 = never>(onfulfilled?: ((value: Success) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: Error) => TResult2 | PromiseLike<TResult2>) | null): CustomPromise<TResult1 | TResult2, Error>;
79
- override catch<TResult = never>(onrejected?: ((reason: Error) => TResult | PromiseLike<TResult>) | null): CustomPromise<Success | TResult, Error>;
80
- /**
81
- * Registers a callback to be invoked **exactly once** when the
82
- * promise settles, with access to both the resolved value and
83
- * the rejection reason.
84
- *
85
- * If the promise is already settled when `finish` is called,
86
- * the callback executes immediately on the same tick.
87
- *
88
- * @param cb Callback receiving the final `(value, error)`.
81
+ declare class CustomPromise<Success, Failure = unknown> extends Promise<Success> implements CustomPromiseType<Success, Failure> {
82
+ /** ------------------------------------------------------------
83
+ * * ***Constructor: `CustomPromise`.***
84
+ * -------------------------------------------------------------
85
+ * **Creates a new `CustomPromise` instance using a custom executor.**
86
+ *
87
+ * ---
88
+ * - **Behavior:**
89
+ * - Behaves similarly to the native
90
+ * ***`Promise`*** constructor.
91
+ * - Receives custom `resolve` and `reject`
92
+ * functions through the executor callback.
93
+ * - Stores the resolved value or rejection reason
94
+ * internally for use by `finish`.
95
+ * - Preserves the `CustomPromise` prototype chain
96
+ * for subclassed promise behavior.
97
+ * - Ensures chained `then` and `catch`
98
+ * operations continue returning
99
+ * ***`CustomPromise`*** instances.
100
+ *
101
+ * ---
102
+ * @param {(resolve, reject) => void} executor
103
+ * ***Executor function responsible for controlling the asynchronous operation lifecycle.***
104
+ *
105
+ * @param {(value: Success) => void} executor.resolve
106
+ * ***Function used to resolve the promise with a value.***
107
+ *
108
+ * @param {(error: Error) => void} executor.reject
109
+ * ***Function used to reject the promise with an error.***
110
+ *
111
+ * ---
112
+ * @throws **{@link Error | `Error`}**
113
+ * Any uncaught exception thrown inside the executor
114
+ * automatically rejects the promise.
115
+ *
116
+ * ---
117
+ * @example
118
+ * ```ts
119
+ * const promise = new CustomPromise<string>(
120
+ * (resolve) => {
121
+ * setTimeout(
122
+ * () => resolve("Done"),
123
+ * 1000
124
+ * );
125
+ * }
126
+ * );
127
+ * ```
128
+ * ---
129
+ * @example
130
+ * ```ts
131
+ * const promise = new CustomPromise<
132
+ * string,
133
+ * Error
134
+ * >((resolve, reject) => {
135
+ * Math.random() > 0.5
136
+ * ? resolve("Success")
137
+ * : reject(
138
+ * new Error("Failed")
139
+ * );
140
+ * });
141
+ * ```
142
+ */
143
+ constructor(executor: (resolve: (value: Success) => void, reject: (error: Failure) => void) => void);
144
+ /** ---------------------------------------------------------------
145
+ * * ***Overrides `Promise.then()` while preserving the
146
+ * `CustomPromise` prototype chain.***
147
+ * ----------------------------------------------------------------
148
+ * **Registers callbacks for both fulfillment and rejection.**
149
+ *
150
+ * ---
151
+ * Unlike the native `Promise`, this override ensures the returned
152
+ * value remains a ***`CustomPromise`*** so additional methods
153
+ * such as `finish()` continue to be available throughout the chain.
154
+ *
155
+ * ---
156
+ * @template TResult1
157
+ * ***Result type returned by the fulfillment handler.***
158
+ *
159
+ * @template TResult2
160
+ * ***Result type returned by the rejection handler.***
161
+ *
162
+ * ---
163
+ * @param onfulfilled
164
+ * ***Callback executed when the promise resolves successfully.***
165
+ *
166
+ * @param onfulfilled.value
167
+ * ***Resolved value from the current promise.***
168
+ *
169
+ * @param onrejected
170
+ * ***Callback executed when the promise is rejected.***
171
+ *
172
+ * @param onrejected.reason
173
+ * ***Rejection reason from the current promise.***
174
+ *
175
+ * ---
176
+ * @returns A new ***`CustomPromise`*** containing the transformed result.
177
+ */
178
+ override then<TResult1 = Success, TResult2 = never>(onfulfilled?: ((value: Success) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: Failure) => TResult2 | PromiseLike<TResult2>) | null): CustomPromise<TResult1 | TResult2, Failure>;
179
+ /** ---------------------------------------------------------------
180
+ * * ***Overrides `Promise.catch()` while preserving the
181
+ * `CustomPromise` prototype chain.***
182
+ * ----------------------------------------------------------------
183
+ * **Registers a callback for promise rejection handling.**
184
+ *
185
+ * ---
186
+ * Unlike the native `Promise`, this override ensures the returned
187
+ * value remains a ***`CustomPromise`*** so additional methods
188
+ * such as `finish()` continue to be available throughout the chain.
189
+ *
190
+ * ---
191
+ * @template TResult
192
+ * ***Result type returned by the rejection handler.***
193
+ *
194
+ * ---
195
+ * @param onrejected
196
+ * ***Callback executed when the promise is rejected.***
197
+ *
198
+ * @param onrejected.reason
199
+ * ***Rejection reason from the current promise.***
200
+ *
201
+ * ---
202
+ * @returns A new ***`CustomPromise`*** containing either the
203
+ * original success value or the transformed rejection result.
204
+ */
205
+ override catch<TResult = never>(onrejected?: ((reason: Failure) => TResult | PromiseLike<TResult>) | null): CustomPromise<Success | TResult, Failure>;
206
+ /** ---------------------------------------------------------------
207
+ * * ***Registers a callback to be invoked exactly once when the
208
+ * promise settles.***
209
+ * ----------------------------------------------------------------
210
+ * *If the promise is already settled when `finish()` is called,
211
+ * the callback executes immediately on the same tick.*
212
+ *
213
+ * ---
214
+ * @param callback
215
+ * ***Callback receiving the final settlement result.***
216
+ *
217
+ * @param callback.value
218
+ * ***Resolved value when the promise is fulfilled.***
219
+ *
220
+ * @param callback.error
221
+ * ***Rejection reason when the promise is rejected.***
222
+ *
223
+ * ---
89
224
  * @returns `this` for fluent chaining.
90
225
  */
91
- finish(cb: (val?: Success, err?: Error) => void): this;
226
+ finish(callback: (value?: Success, error?: Failure) => void): this;
92
227
  }
93
228
  /** ------------------------------------------------------------
94
229
  * * ***Utility: `delay`.***
95
- * ------------------------------------------------------------
230
+ * -------------------------------------------------------------
96
231
  * **Creates a Promise-based delay that resolves after a given number
97
232
  * of milliseconds, optionally supports cancellation with `AbortSignal`.**
233
+ *
234
+ * ---
98
235
  * - **Behavior:**
99
- * - Validates `milliSeconds` is a non-zero, non-negative integer.
100
- * - Validates `signal` is an `AbortSignal` instance when provided.
101
- * - Cleans up event listeners and timers properly.
236
+ * - Validates `milliSeconds` is a non-zero, non-negative integer.
237
+ * - Validates `signal` is an `AbortSignal` instance when provided.
238
+ * - Cleans up event listeners and timers properly.
239
+ *
240
+ * ---
102
241
  * @param {number} [milliSeconds=1000]
103
242
  * The duration of the delay in milliseconds, default is `1000`.
104
243
  * @param {AbortSignal} [signal]
105
244
  * An optional `AbortSignal` that can cancel the delay.
106
- * @returns {Promise<void>}
107
- * A promise that resolves after the specified delay or
108
- * rejects with an `AbortError` if aborted.
245
+ *
246
+ * ---
109
247
  * @throws **{@link TypeError | `TypeError`}** while validates `milliSeconds` and `signal`:
110
248
  * - If `milliSeconds` **is not a valid** an `integer-number`, `NaN`, `negative-number`, or `≤ 0`.
111
249
  * - If `signal` **is not a valid** an`AbortSignal`.
112
- * @throws **{@link DOMException | `DOMException`}** if the delay is aborted using the signal, rejects with `AbortError`.
113
- * @example
114
- * // Waits for 2 seconds
115
- * await delay(2000);
250
+ * @throws **{@link AbortError | `AbortError`}** if the delay is aborted using the provided signal.
116
251
  *
117
- * // Delay with AbortSignal
118
- * const controller = new AbortController();
119
- * delay(5000, controller.signal).catch(err => console.log(err.name)); // "AbortError"
120
- * controller.abort();
252
+ * ---
253
+ * @returns {Promise<void>}
254
+ * A promise that resolves after the specified delay or
255
+ * rejects with an `AbortError` if aborted.
256
+ *
257
+ * ---
258
+ * @example
259
+ * 1. #### Waits for 2 seconds:
260
+ * ```ts
261
+ * await delay(2000);
262
+ * ```
263
+ * ---
264
+ * 2. #### Delay with AbortSignal:
265
+ * ```ts
266
+ * const controller = new AbortController();
267
+ * delay(5000, controller.signal).catch(err => {
268
+ * console.log(err.name)
269
+ * // ➔ "AbortError:['@rzl-zone/utils-js/promises:delay']"
270
+ * });
271
+ * controller.abort();
272
+ * ```
121
273
  */
122
274
  declare const delay: (milliSeconds?: number, signal?: AbortSignal) => Promise<void>;
123
275
  export { CustomPromise, type CustomPromiseType, delay };
@@ -2,14 +2,15 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/utils-js
4
4
  * ------------------------------------------------------------------------
5
- * Version: `3.13.1-beta.0`
5
+ * Version: `3.14.0-beta.0`
6
6
  * Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
7
7
  * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
8
8
  * ========================================================================
9
9
  */
10
- import { E as isNull, r as getPreciseType } from "../assertIsBoolean-DDhQ2D-k.js";
11
- import { t as safeStableStringify } from "../safeStableStringify-BLwA1VC-.js";
12
- import { t as isInteger } from "../isInteger-B75voxys.js";
10
+ import { i as getPreciseType, t as createMessage, x as isNull } from "../logger-CLWnKRKE.js";
11
+ import { t as safeStableStringify } from "../safeStableStringify-DfwxmiWn.js";
12
+ import { t as isInteger } from "../isInteger-aZgzTTZG.js";
13
+ import { t as AbortError } from "../AbortError-DVT8lAKn.js";
13
14
  var CustomPromise = class extends Promise {
14
15
  _value;
15
16
  _error;
@@ -21,14 +22,14 @@ var CustomPromise = class extends Promise {
21
22
  resolveOuter = resolve;
22
23
  rejectOuter = reject;
23
24
  });
24
- executor((v) => {
25
- this._value = v;
26
- resolveOuter(v);
27
- this._finish.forEach((f) => f(v, void 0));
28
- }, (e) => {
29
- this._error = e;
30
- rejectOuter(e);
31
- this._finish.forEach((f) => f(void 0, e));
25
+ executor(async (val) => {
26
+ this._value = await val;
27
+ resolveOuter(val);
28
+ this._finish.forEach(async (fn) => fn(await val, void 0));
29
+ }, async (err) => {
30
+ this._error = await err;
31
+ rejectOuter(err);
32
+ this._finish.forEach(async (fn) => fn(void 0, await err));
32
33
  });
33
34
  Object.setPrototypeOf(this, new.target.prototype);
34
35
  }
@@ -38,21 +39,15 @@ var CustomPromise = class extends Promise {
38
39
  catch(onrejected) {
39
40
  return super.catch(onrejected);
40
41
  }
41
- finish(cb) {
42
- if (this._value !== void 0 || this._error !== void 0) cb(this._value, this._error);
43
- else this._finish.push(cb);
42
+ finish(callback) {
43
+ if (this._value !== void 0 || this._error !== void 0) callback(this._value, this._error);
44
+ else this._finish.push(callback);
44
45
  return this;
45
46
  }
46
47
  };
47
- var AbortError = class extends Error {
48
- constructor(message = "The operation was aborted", name = "AbortError") {
49
- super(message);
50
- this.name = name;
51
- }
52
- };
53
48
  const delay = (milliSeconds = 1e3, signal) => {
54
- if (!isInteger(milliSeconds) || milliSeconds <= 0) throw new TypeError(`First parameter (\`milliSeconds\`) must be of type \`number\` and value must be a \`non-zero\`, \`non-NaN\`, \`non-negative\`, and \`integer-number\`, but received: \`${getPreciseType(milliSeconds)}\`, with value: \`${safeStableStringify(milliSeconds, { keepUndefined: true })}\`.`);
55
- if (isNull(signal) || signal && !(signal instanceof AbortSignal)) throw new TypeError("Second parameter (`signal`) must be an `instance of AbortSignal` if provided.");
49
+ if (!isInteger(milliSeconds) || milliSeconds <= 0) throw new TypeError(errorMsg(`First parameter (\`milliSeconds\`) must be of type \`number\` and value must be a \`non-zero\`, \`non-NaN\`, \`non-negative\`, and \`integer-number\`, but received: \`${getPreciseType(milliSeconds)}\`, with value: \`${safeStableStringify(milliSeconds, { keepUndefined: true })}\`.`));
50
+ if (isNull(signal) || signal && !(signal instanceof AbortSignal)) throw new TypeError(errorMsg("Second parameter (`signal`) must be an `instance of AbortSignal` if provided."));
56
51
  return new Promise((resolve, reject) => {
57
52
  const timer = setTimeout(() => {
58
53
  cleanup();
@@ -64,11 +59,17 @@ const delay = (milliSeconds = 1e3, signal) => {
64
59
  };
65
60
  const onAbort = () => {
66
61
  cleanup();
67
- reject(new AbortError("Function `delay` from `@rzl-zone/utils-js` was aborted.", "AbortError"));
62
+ reject(new AbortError("Function `delay` from `@rzl-zone/utils-js` was aborted.", { suffix: ":['@rzl-zone/utils-js/promises:delay']" }));
68
63
  };
69
- if (signal) if (signal.aborted) onAbort();
70
- else signal.addEventListener("abort", onAbort, { once: true });
64
+ if (signal) {
65
+ if (signal.aborted) {
66
+ onAbort();
67
+ return;
68
+ }
69
+ signal.addEventListener("abort", onAbort, { once: true });
70
+ }
71
71
  });
72
72
  };
73
+ const errorMsg = (msg) => createMessage("delay", msg);
73
74
  export { CustomPromise, delay };
74
75
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/promises/CustomPromise.ts","../../src/promises/delay.ts"],"sourcesContent":["import type { CustomPromiseType } from \"@rzl-zone/ts-types-plus\";\n\nexport type { CustomPromiseType };\n\n/** -------------------------------------------------------------\n * * ***Utility Class: `CustomPromise`.***\n * -------------------------------------------------------------\n * **A strongly typed extension of the native {@link Promise | **`Promise`**}.**\n * 1. **Behaves exactly like a normal Promise** for `then`/`catch`\n * and `await` semantics.\n * 2. **Stores the final resolution or rejection internally** so\n * it can be retrieved by a custom `finish` handler.\n * 3. **Adds a `finish` method** which runs once after settlement\n * with access to both the fulfilled value *and* the rejection\n * reason (only one will be defined).\n * - **Key Differences from a Native `Promise`:**\n * - Every call to `then`/`catch` returns **`CustomPromise`**\n * again, so the `finish` method remains available on the\n * entire chain.\n * - `finish` provides a tuple-like callback:\n * - `val` → defined when fulfilled.\n * - `err` → defined when rejected.\n * @template Success Type of the resolved value.\n * @template Error Type of the rejection reason (default `unknown`).\n * @example\n * ```ts\n * import { CustomPromise, type CustomPromiseType } from \"@rzl-zone/utils-js/promises\";\n *\n * type User = { id: number; name: string };\n * type ApiError = { message: string };\n *\n * function fetchUser(): CustomPromiseType<User, ApiError> {\n * return new CustomPromise<User, ApiError>((resolve, reject) => {\n * setTimeout(\n * () =>\n * void (Math.random() > 0.5\n * ? resolve({ id: 1, name: \"Alice\" })\n * : reject({ message: \"Random failure\" })),\n * 500\n * );\n * });\n * }\n *\n * fetchUser()\n * .then(user => {\n * console.log(\"SUCCESS:\", user);\n * return user;\n * })\n * .catch(err => {\n * console.error(\"ERROR:\", err);\n * throw err;\n * })\n * .finish((val, err) => {\n * // Runs once after settle, regardless of outcome\n * console.log(\"FINISH:\", { val, err });\n * });\n * ```\n * ---\n * - **Implementation Notes:**\n * - Uses `Object.setPrototypeOf` to preserve the prototype chain\n * for environments targeting ES5 or when subclassing Promise.\n * - Internal `_value` and `_error` are updated as soon as the\n * executor resolves or rejects, guaranteeing `finish` receives\n * the final state even when added after settlement.\n */\nexport class CustomPromise<Success, Error = unknown>\n extends Promise<Success>\n implements CustomPromiseType<Success, Error>\n{\n private _value?: Success;\n private _error?: Error;\n private _finish: Array<(v?: Success, e?: Error) => void> = [];\n\n constructor(\n executor: (\n resolve: (v: Success) => void,\n reject: (e: Error) => void\n ) => void\n ) {\n let resolveOuter!: (v: Success) => void;\n let rejectOuter!: (e: Error) => void;\n\n super((resolve, reject) => {\n resolveOuter = resolve;\n rejectOuter = reject;\n });\n\n executor(\n (v) => {\n this._value = v;\n resolveOuter(v);\n this._finish.forEach((f) => f(v, undefined));\n },\n (e) => {\n this._error = e;\n rejectOuter(e);\n this._finish.forEach((f) => f(undefined, e));\n }\n );\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n override then<TResult1 = Success, TResult2 = never>(\n onfulfilled?: ((value: Success) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: Error) => TResult2 | PromiseLike<TResult2>) | null\n ): CustomPromise<TResult1 | TResult2, Error> {\n return super.then(onfulfilled, onrejected) as unknown as CustomPromise<\n TResult1 | TResult2,\n Error\n >;\n }\n\n override catch<TResult = never>(\n onrejected?: ((reason: Error) => TResult | PromiseLike<TResult>) | null\n ): CustomPromise<Success | TResult, Error> {\n return super.catch(onrejected) as unknown as CustomPromise<\n Success | TResult,\n Error\n >;\n }\n\n /**\n * Registers a callback to be invoked **exactly once** when the\n * promise settles, with access to both the resolved value and\n * the rejection reason.\n *\n * If the promise is already settled when `finish` is called,\n * the callback executes immediately on the same tick.\n *\n * @param cb Callback receiving the final `(value, error)`.\n * @returns `this` for fluent chaining.\n */\n finish(cb: (val?: Success, err?: Error) => void): this {\n if (this._value !== undefined || this._error !== undefined) {\n cb(this._value, this._error);\n } else {\n this._finish.push(cb);\n }\n return this;\n }\n}\n","import { isNull } from \"@/predicates/is/isNull\";\nimport { isInteger } from \"@/predicates/is/isInteger\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\n/** -------------------------------------------------------------------\n * * ***Custom `AbortError` for cross-runtime delay cancellation.***\n * -------------------------------------------------------------------\n */\nclass AbortError extends Error {\n constructor(\n message: string = \"The operation was aborted\",\n name: string = \"AbortError\"\n ) {\n super(message);\n this.name = name;\n }\n}\n\n/** ------------------------------------------------------------\n * * ***Utility: `delay`.***\n * ------------------------------------------------------------\n * **Creates a Promise-based delay that resolves after a given number\n * of milliseconds, optionally supports cancellation with `AbortSignal`.**\n * - **Behavior:**\n * - Validates `milliSeconds` is a non-zero, non-negative integer.\n * - Validates `signal` is an `AbortSignal` instance when provided.\n * - Cleans up event listeners and timers properly.\n * @param {number} [milliSeconds=1000]\n * The duration of the delay in milliseconds, default is `1000`.\n * @param {AbortSignal} [signal]\n * An optional `AbortSignal` that can cancel the delay.\n * @returns {Promise<void>}\n * A promise that resolves after the specified delay or\n * rejects with an `AbortError` if aborted.\n * @throws **{@link TypeError | `TypeError`}** while validates `milliSeconds` and `signal`:\n * - If `milliSeconds` **is not a valid** an `integer-number`, `NaN`, `negative-number`, or `≤ 0`.\n * - If `signal` **is not a valid** an`AbortSignal`.\n * @throws **{@link DOMException | `DOMException`}** if the delay is aborted using the signal, rejects with `AbortError`.\n * @example\n * // Waits for 2 seconds\n * await delay(2000);\n *\n * // Delay with AbortSignal\n * const controller = new AbortController();\n * delay(5000, controller.signal).catch(err => console.log(err.name)); // \"AbortError\"\n * controller.abort();\n */\nexport const delay = (\n milliSeconds: number = 1000,\n signal?: AbortSignal\n): Promise<void> => {\n if (!isInteger(milliSeconds) || milliSeconds <= 0) {\n throw new TypeError(\n `First parameter (\\`milliSeconds\\`) must be of type \\`number\\` and value must be a \\`non-zero\\`, \\`non-NaN\\`, \\`non-negative\\`, and \\`integer-number\\`, but received: \\`${getPreciseType(\n milliSeconds\n )}\\`, with value: \\`${safeStableStringify(milliSeconds, {\n keepUndefined: true\n })}\\`.`\n );\n }\n\n if (isNull(signal) || (signal && !(signal instanceof AbortSignal))) {\n throw new TypeError(\n \"Second parameter (`signal`) must be an `instance of AbortSignal` if provided.\"\n );\n }\n\n return new Promise<void>((resolve, reject) => {\n const timer = setTimeout(() => {\n cleanup();\n resolve();\n }, milliSeconds);\n\n const cleanup = () => {\n clearTimeout(timer);\n if (signal) signal.removeEventListener(\"abort\", onAbort);\n };\n\n const onAbort = () => {\n cleanup();\n reject(\n new AbortError(\n \"Function `delay` from `@rzl-zone/utils-js` was aborted.\",\n \"AbortError\"\n )\n );\n };\n\n if (signal) {\n if (signal.aborted) {\n onAbort();\n } else {\n signal.addEventListener(\"abort\", onAbort, { once: true });\n }\n }\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,IAAa,gBAAb,cACU,QAEV;CACE,AAAQ;CACR,AAAQ;CACR,AAAQ,UAAmD,CAAC;CAE5D,YACE,UAIA;EACA,IAAI;EACJ,IAAI;EAEJ,OAAO,SAAS,WAAW;GACzB,eAAe;GACf,cAAc;EAChB,CAAC;EAED,UACG,MAAM;GACL,KAAK,SAAS;GACd,aAAa,CAAC;GACd,KAAK,QAAQ,SAAS,MAAM,EAAE,GAAG,MAAS,CAAC;EAC7C,IACC,MAAM;GACL,KAAK,SAAS;GACd,YAAY,CAAC;GACb,KAAK,QAAQ,SAAS,MAAM,EAAE,QAAW,CAAC,CAAC;EAC7C,CACF;EAEA,OAAO,eAAe,MAAM,IAAI,OAAO,SAAS;CAClD;CAEA,AAAS,KACP,aACA,YAC2C;EAC3C,OAAO,MAAM,KAAK,aAAa,UAAU;CAI3C;CAEA,AAAS,MACP,YACyC;EACzC,OAAO,MAAM,MAAM,UAAU;CAI/B;;;;;;;;;;;;CAaA,OAAO,IAAgD;EACrD,IAAI,KAAK,WAAW,UAAa,KAAK,WAAW,QAC/C,GAAG,KAAK,QAAQ,KAAK,MAAM;OAE3B,KAAK,QAAQ,KAAK,EAAE;EAEtB,OAAO;CACT;AACF;;;;;;;;ACpIA,IAAM,aAAN,cAAyB,MAAM;CAC7B,YACE,UAAkB,6BAClB,OAAe,cACf;EACA,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,SACX,eAAuB,KACvB,WACkB;CAClB,IAAI,CAAC,UAAU,YAAY,KAAK,gBAAgB,GAC9C,MAAM,IAAI,UACR,0KAA0K,eACxK,YACF,EAAE,oBAAoB,oBAAoB,cAAc,EACtD,eAAe,KACjB,CAAC,EAAE,IACL;CAGF,IAAI,OAAO,MAAM,KAAM,UAAU,EAAE,kBAAkB,cACnD,MAAM,IAAI,UACR,+EACF;CAGF,OAAO,IAAI,SAAe,SAAS,WAAW;EAC5C,MAAM,QAAQ,iBAAiB;GAC7B,QAAQ;GACR,QAAQ;EACV,GAAG,YAAY;EAEf,MAAM,gBAAgB;GACpB,aAAa,KAAK;GAClB,IAAI,QAAQ,OAAO,oBAAoB,SAAS,OAAO;EACzD;EAEA,MAAM,gBAAgB;GACpB,QAAQ;GACR,OACE,IAAI,WACF,2DACA,YACF,CACF;EACF;EAEA,IAAI,QACF,IAAI,OAAO,SACT,QAAQ;OAER,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;CAG9D,CAAC;AACH"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/promises/CustomPromise.ts","../../src/promises/delay.ts"],"sourcesContent":["import type { CustomPromiseType } from \"@rzl-zone/ts-types-plus\";\n\nexport type { CustomPromiseType };\n\n/** -------------------------------------------------------------\n * * ***Utility Class: `CustomPromise`.***\n * --------------------------------------------------------------\n * **A strongly typed extension of the native {@link Promise | **`Promise`**}.**\n *\n * ---\n * 1. **Behaves exactly like a normal Promise** for `then`/`catch`\n * and `await` semantics.\n * 2. **Stores the final resolution or rejection internally** so\n * it can be retrieved by a custom `finish` handler.\n * 3. **Adds a `finish` method** which runs once after settlement\n * with access to both the fulfilled value *and* the rejection\n * reason (only one will be defined).\n *\n * ---\n * - **Key Differences from a Native `Promise`:**\n * - Every call to `then`/`catch` returns **`CustomPromise`**\n * again, so the `finish` method remains available on the\n * entire chain.\n * - `finish` provides a tuple-like callback:\n * - `val` ➔ defined when fulfilled.\n * - `err` ➔ defined when rejected.\n *\n * ---\n * @template Success Type of the resolved value.\n * @template Error Type of the rejection reason (default `unknown`).\n *\n * ---\n * @example\n * ```ts\n * import { CustomPromise, type CustomPromiseType } from \"@rzl-zone/utils-js/promises\";\n *\n * type User = { id: number; name: string };\n * type ApiError = { message: string };\n *\n * function fetchUser(): CustomPromiseType<User, ApiError> {\n * return new CustomPromise<User, ApiError>((resolve, reject) => {\n * setTimeout(\n * () =>\n * void (Math.random() > 0.5\n * ? resolve({ id: 1, name: \"Alice\" })\n * : reject({ message: \"Random failure\" })),\n * 500\n * );\n * });\n * }\n *\n * fetchUser()\n * .then(user => {\n * console.log(\"SUCCESS:\", user);\n * return user;\n * })\n * .catch(err => {\n * console.error(\"ERROR:\", err);\n * throw err;\n * })\n * .finish((val, err) => {\n * // Runs once after settle, regardless of outcome\n * console.log(\"FINISH:\", { val, err });\n * });\n * ```\n * ---\n * - **Implementation Notes:**\n * - Uses `Object.setPrototypeOf` to preserve the prototype chain\n * for environments targeting ES5 or when subclassing Promise.\n * - Internal settlement state is tracked automatically,\n * allowing `finish` to access the final result even\n * when registered after settlement.\n */\nexport class CustomPromise<Success, Failure = unknown>\n extends Promise<Success>\n implements CustomPromiseType<Success, Failure>\n{\n /** ------------------------------------------------------------\n *\n * @internal\n * Stores the resolved value after promise settlement.\n *\n * -------------------------------------------------------------\n */\n private _value?: Success;\n /** ------------------------------------------------------------\n *\n * @internal\n * Stores the rejection reason after promise settlement.\n *\n * -------------------------------------------------------------\n */\n private _error?: Failure;\n /** ------------------------------------------------------------\n *\n * @internal\n * Stores registered `finish` callbacks until the\n * promise settles.\n *\n * -------------------------------------------------------------\n */\n private _finish: Array<(v?: Success, e?: Failure) => void> = [];\n\n /** ------------------------------------------------------------\n * * ***Constructor: `CustomPromise`.***\n * -------------------------------------------------------------\n * **Creates a new `CustomPromise` instance using a custom executor.**\n *\n * ---\n * - **Behavior:**\n * - Behaves similarly to the native\n * ***`Promise`*** constructor.\n * - Receives custom `resolve` and `reject`\n * functions through the executor callback.\n * - Stores the resolved value or rejection reason\n * internally for use by `finish`.\n * - Preserves the `CustomPromise` prototype chain\n * for subclassed promise behavior.\n * - Ensures chained `then` and `catch`\n * operations continue returning\n * ***`CustomPromise`*** instances.\n *\n * ---\n * @param {(resolve, reject) => void} executor\n * ***Executor function responsible for controlling the asynchronous operation lifecycle.***\n *\n * @param {(value: Success) => void} executor.resolve\n * ***Function used to resolve the promise with a value.***\n *\n * @param {(error: Error) => void} executor.reject\n * ***Function used to reject the promise with an error.***\n *\n * ---\n * @throws **{@link Error | `Error`}**\n * Any uncaught exception thrown inside the executor\n * automatically rejects the promise.\n *\n * ---\n * @example\n * ```ts\n * const promise = new CustomPromise<string>(\n * (resolve) => {\n * setTimeout(\n * () => resolve(\"Done\"),\n * 1000\n * );\n * }\n * );\n * ```\n * ---\n * @example\n * ```ts\n * const promise = new CustomPromise<\n * string,\n * Error\n * >((resolve, reject) => {\n * Math.random() > 0.5\n * ? resolve(\"Success\")\n * : reject(\n * new Error(\"Failed\")\n * );\n * });\n * ```\n */\n constructor(\n executor: (\n /**\n * * ***Function used to resolve the promise with a value.***\n */\n resolve: (value: Success) => void,\n\n /**\n * * ***Function used to reject the promise with an error.***\n */\n reject: (error: Failure) => void\n ) => void\n ) {\n let resolveOuter: (v: Success) => void;\n let rejectOuter: (e: Failure) => void;\n\n super((resolve, reject) => {\n resolveOuter = resolve;\n rejectOuter = reject;\n });\n\n executor(\n async (val) => {\n this._value = await val;\n resolveOuter(val);\n this._finish.forEach(async (fn) => fn(await val, undefined));\n },\n async (err) => {\n this._error = await err;\n rejectOuter(err);\n this._finish.forEach(async (fn) => fn(undefined, await err));\n }\n );\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n /** ---------------------------------------------------------------\n * * ***Overrides `Promise.then()` while preserving the\n * `CustomPromise` prototype chain.***\n * ----------------------------------------------------------------\n * **Registers callbacks for both fulfillment and rejection.**\n *\n * ---\n * Unlike the native `Promise`, this override ensures the returned\n * value remains a ***`CustomPromise`*** so additional methods\n * such as `finish()` continue to be available throughout the chain.\n *\n * ---\n * @template TResult1\n * ***Result type returned by the fulfillment handler.***\n *\n * @template TResult2\n * ***Result type returned by the rejection handler.***\n *\n * ---\n * @param onfulfilled\n * ***Callback executed when the promise resolves successfully.***\n *\n * @param onfulfilled.value\n * ***Resolved value from the current promise.***\n *\n * @param onrejected\n * ***Callback executed when the promise is rejected.***\n *\n * @param onrejected.reason\n * ***Rejection reason from the current promise.***\n *\n * ---\n * @returns A new ***`CustomPromise`*** containing the transformed result.\n */\n override then<TResult1 = Success, TResult2 = never>(\n onfulfilled?:\n | ((\n /**\n * * ***Resolved value from the current promise.***\n */\n value: Success\n ) => TResult1 | PromiseLike<TResult1>)\n | null,\n onrejected?:\n | ((\n /**\n * * ***Rejection reason from the current promise.***\n */\n reason: Failure\n ) => TResult2 | PromiseLike<TResult2>)\n | null\n ): CustomPromise<TResult1 | TResult2, Failure> {\n return super.then(onfulfilled, onrejected) as unknown as CustomPromise<\n TResult1 | TResult2,\n Failure\n >;\n }\n\n /** ---------------------------------------------------------------\n * * ***Overrides `Promise.catch()` while preserving the\n * `CustomPromise` prototype chain.***\n * ----------------------------------------------------------------\n * **Registers a callback for promise rejection handling.**\n *\n * ---\n * Unlike the native `Promise`, this override ensures the returned\n * value remains a ***`CustomPromise`*** so additional methods\n * such as `finish()` continue to be available throughout the chain.\n *\n * ---\n * @template TResult\n * ***Result type returned by the rejection handler.***\n *\n * ---\n * @param onrejected\n * ***Callback executed when the promise is rejected.***\n *\n * @param onrejected.reason\n * ***Rejection reason from the current promise.***\n *\n * ---\n * @returns A new ***`CustomPromise`*** containing either the\n * original success value or the transformed rejection result.\n */\n override catch<TResult = never>(\n onrejected?:\n | ((\n /**\n * * ***Rejection reason from the current promise.***\n */\n reason: Failure\n ) => TResult | PromiseLike<TResult>)\n | null\n ): CustomPromise<Success | TResult, Failure> {\n return super.catch(onrejected) as unknown as CustomPromise<\n Success | TResult,\n Failure\n >;\n }\n\n /** ---------------------------------------------------------------\n * * ***Registers a callback to be invoked exactly once when the\n * promise settles.***\n * ----------------------------------------------------------------\n * *If the promise is already settled when `finish()` is called,\n * the callback executes immediately on the same tick.*\n *\n * ---\n * @param callback\n * ***Callback receiving the final settlement result.***\n *\n * @param callback.value\n * ***Resolved value when the promise is fulfilled.***\n *\n * @param callback.error\n * ***Rejection reason when the promise is rejected.***\n *\n * ---\n * @returns `this` for fluent chaining.\n */\n finish(\n callback: (\n /**\n * * ***Resolved value when the promise is fulfilled.***\n */\n value?: Success,\n\n /**\n * * ***Rejection reason when the promise is rejected.***\n */\n error?: Failure\n ) => void\n ): this {\n if (this._value !== undefined || this._error !== undefined) {\n callback(this._value, this._error);\n } else {\n this._finish.push(callback);\n }\n return this;\n }\n}\n","import { createMessage } from \"@/_private/logger\";\n\nimport { AbortError } from \"@/errors/AbortError\";\nimport { isNull } from \"@/predicates/is/isNull\";\nimport { isInteger } from \"@/predicates/is/isInteger\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\n/** ------------------------------------------------------------\n * * ***Utility: `delay`.***\n * -------------------------------------------------------------\n * **Creates a Promise-based delay that resolves after a given number\n * of milliseconds, optionally supports cancellation with `AbortSignal`.**\n *\n * ---\n * - **Behavior:**\n * - Validates `milliSeconds` is a non-zero, non-negative integer.\n * - Validates `signal` is an `AbortSignal` instance when provided.\n * - Cleans up event listeners and timers properly.\n *\n * ---\n * @param {number} [milliSeconds=1000]\n * The duration of the delay in milliseconds, default is `1000`.\n * @param {AbortSignal} [signal]\n * An optional `AbortSignal` that can cancel the delay.\n *\n * ---\n * @throws **{@link TypeError | `TypeError`}** while validates `milliSeconds` and `signal`:\n * - If `milliSeconds` **is not a valid** an `integer-number`, `NaN`, `negative-number`, or `≤ 0`.\n * - If `signal` **is not a valid** an`AbortSignal`.\n * @throws **{@link AbortError | `AbortError`}** if the delay is aborted using the provided signal.\n *\n * ---\n * @returns {Promise<void>}\n * A promise that resolves after the specified delay or\n * rejects with an `AbortError` if aborted.\n *\n * ---\n * @example\n * 1. #### Waits for 2 seconds:\n * ```ts\n * await delay(2000);\n * ```\n * ---\n * 2. #### Delay with AbortSignal:\n * ```ts\n * const controller = new AbortController();\n * delay(5000, controller.signal).catch(err => {\n * console.log(err.name)\n * // ➔ \"AbortError:['@rzl-zone/utils-js/promises:delay']\"\n * });\n * controller.abort();\n * ```\n */\nexport const delay = (\n milliSeconds: number = 1000,\n signal?: AbortSignal\n): Promise<void> => {\n if (!isInteger(milliSeconds) || milliSeconds <= 0) {\n throw new TypeError(\n errorMsg(\n `First parameter (\\`milliSeconds\\`) must be of type \\`number\\` and value must be a \\`non-zero\\`, \\`non-NaN\\`, \\`non-negative\\`, and \\`integer-number\\`, but received: \\`${getPreciseType(\n milliSeconds\n )}\\`, with value: \\`${safeStableStringify(milliSeconds, {\n keepUndefined: true\n })}\\`.`\n )\n );\n }\n\n if (isNull(signal) || (signal && !(signal instanceof AbortSignal))) {\n throw new TypeError(\n errorMsg(\n \"Second parameter (`signal`) must be an `instance of AbortSignal` if provided.\"\n )\n );\n }\n\n return new Promise<void>((resolve, reject) => {\n const timer = setTimeout(() => {\n cleanup();\n resolve();\n }, milliSeconds);\n\n const cleanup = () => {\n clearTimeout(timer);\n if (signal) signal.removeEventListener(\"abort\", onAbort);\n };\n\n const onAbort = () => {\n cleanup();\n reject(\n new AbortError(\n \"Function `delay` from `@rzl-zone/utils-js` was aborted.\",\n {\n suffix: \":['@rzl-zone/utils-js/promises:delay']\"\n }\n )\n );\n };\n\n if (signal) {\n if (signal.aborted) {\n onAbort();\n return;\n }\n\n signal.addEventListener(\"abort\", onAbort, { once: true });\n }\n });\n};\n\n/**\n * @internal ***`Not part of the public API.`***\n */\nconst errorMsg = (msg: string) => createMessage(\"delay\", msg);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,IAAa,gBAAb,cACU,QAEV;;;;;;;;CAQE,AAAQ;;;;;;;;CAQR,AAAQ;;;;;;;;;CASR,AAAQ,UAAqD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+D9D,YACE,UAWA;EACA,IAAI;EACJ,IAAI;EAEJ,OAAO,SAAS,WAAW;GACzB,eAAe;GACf,cAAc;EAChB,CAAC;EAED,SACE,OAAO,QAAQ;GACb,KAAK,SAAS,MAAM;GACpB,aAAa,GAAG;GAChB,KAAK,QAAQ,QAAQ,OAAO,OAAO,GAAG,MAAM,KAAK,MAAS,CAAC;EAC7D,GACA,OAAO,QAAQ;GACb,KAAK,SAAS,MAAM;GACpB,YAAY,GAAG;GACf,KAAK,QAAQ,QAAQ,OAAO,OAAO,GAAG,QAAW,MAAM,GAAG,CAAC;EAC7D,CACF;EAEA,OAAO,eAAe,MAAM,IAAI,OAAO,SAAS;CAClD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCA,AAAS,KACP,aAQA,YAQ6C;EAC7C,OAAO,MAAM,KAAK,aAAa,UAAU;CAI3C;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BA,AAAS,MACP,YAQ2C;EAC3C,OAAO,MAAM,MAAM,UAAU;CAI/B;;;;;;;;;;;;;;;;;;;;;CAsBA,OACE,UAWM;EACN,IAAI,KAAK,WAAW,UAAa,KAAK,WAAW,QAC/C,SAAS,KAAK,QAAQ,KAAK,MAAM;OAEjC,KAAK,QAAQ,KAAK,QAAQ;EAE5B,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC/RA,MAAa,SACX,eAAuB,KACvB,WACkB;CAClB,IAAI,CAAC,UAAU,YAAY,KAAK,gBAAgB,GAC9C,MAAM,IAAI,UACR,SACE,0KAA0K,eACxK,YACF,EAAE,oBAAoB,oBAAoB,cAAc,EACtD,eAAe,KACjB,CAAC,EAAE,IACL,CACF;CAGF,IAAI,OAAO,MAAM,KAAM,UAAU,EAAE,kBAAkB,cACnD,MAAM,IAAI,UACR,SACE,+EACF,CACF;CAGF,OAAO,IAAI,SAAe,SAAS,WAAW;EAC5C,MAAM,QAAQ,iBAAiB;GAC7B,QAAQ;GACR,QAAQ;EACV,GAAG,YAAY;EAEf,MAAM,gBAAgB;GACpB,aAAa,KAAK;GAClB,IAAI,QAAQ,OAAO,oBAAoB,SAAS,OAAO;EACzD;EAEA,MAAM,gBAAgB;GACpB,QAAQ;GACR,OACE,IAAI,WACF,2DACA,EACE,QAAQ,yCACV,CACF,CACF;EACF;EAEA,IAAI,QAAQ;GACV,IAAI,OAAO,SAAS;IAClB,QAAQ;IACR;GACF;GAEA,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;EAC1D;CACF,CAAC;AACH;;;;AAKA,MAAM,YAAY,QAAgB,cAAc,SAAS,GAAG"}
@@ -2,14 +2,14 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/utils-js
4
4
  * ------------------------------------------------------------------------
5
- * Version: `3.13.1-beta.0`
5
+ * Version: `3.14.0-beta.0`
6
6
  * Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
7
7
  * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
8
8
  * ========================================================================
9
9
  */
10
10
  "use strict";
11
- const require_assertIsBoolean = require('./assertIsBoolean-CEx4KbHg.cjs');
12
- const require_assertIsString = require('./assertIsString-DGDLC-XD.cjs');
11
+ const require_logger = require('./logger-CUacYy3D.cjs');
12
+ const require_assertIsString = require('./assertIsString-CjE9kbQ_.cjs');
13
13
  const maxInt = 2147483647;
14
14
  const base = 36, tMin = 1, tMax = 26, skew = 38, damp = 700;
15
15
  const initialBias = 72, initialN = 128, delimiter = "-";
@@ -44,7 +44,7 @@ function mapDomain(domain, fn) {
44
44
  return result + map(labels, fn).join(".");
45
45
  }
46
46
  function ucs2decode(input) {
47
- require_assertIsString.assertIsString(input, { message: ({ currentType, validType }) => `Utils \`punycodeUtilsJS.ucs2.decode\`, parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.` });
47
+ require_assertIsString.assertIsString(input, { message: ({ currentType, validType }) => require_logger.createMessage("punycodeUtilsJS.ucs2.decode", `Parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
48
48
  const output = [];
49
49
  let counter = 0;
50
50
  const length = input.length;
@@ -62,7 +62,7 @@ function ucs2decode(input) {
62
62
  return output;
63
63
  }
64
64
  const ucs2encode = (points) => {
65
- if (!Array.isArray(points) || !points.every((p) => typeof p === "number" && Number.isFinite(p))) throw new TypeError(`Utils \`punycodeUtilsJS.ucs2.encode\`, parameter \`points\` must be an array of numbers, but received: \`${require_assertIsBoolean.getPreciseType(points)}\`.`);
65
+ if (!Array.isArray(points) || !points.every((p) => typeof p === "number" && Number.isFinite(p))) throw new TypeError(require_logger.createMessage("punycodeUtilsJS.ucs2.encode", `Parameter \`points\` must be an array of numbers, but received: \`${require_logger.getPreciseType(points)}\`.`));
66
66
  return String.fromCodePoint(...points);
67
67
  };
68
68
  function basicToDigit(codePoint) {
@@ -85,7 +85,7 @@ function adapt(delta, numPoints, firstTime) {
85
85
  return floor(k + 36 * delta / (delta + skew));
86
86
  }
87
87
  function decode(input) {
88
- require_assertIsString.assertIsString(input, { message: ({ currentType, validType }) => `Utils \`punycodeUtilsJS.decode\`, parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.` });
88
+ require_assertIsString.assertIsString(input, { message: ({ currentType, validType }) => require_logger.createMessage("punycodeUtilsJS.decode", `Parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
89
89
  const output = [];
90
90
  const inputLength = input.length;
91
91
  let i = 0, n = initialN, bias = initialBias;
@@ -96,7 +96,7 @@ function decode(input) {
96
96
  output.push(input.charCodeAt(j));
97
97
  }
98
98
  for (let index = basic > 0 ? basic + 1 : 0; index < inputLength;) {
99
- const oldi = i;
99
+ const oldIdx = i;
100
100
  let w = 1;
101
101
  for (let k = base;; k += base) {
102
102
  if (index >= inputLength) error("invalid-input");
@@ -111,7 +111,7 @@ function decode(input) {
111
111
  w *= baseMinusT;
112
112
  }
113
113
  const out = output.length + 1;
114
- bias = adapt(i - oldi, out, oldi === 0);
114
+ bias = adapt(i - oldIdx, out, oldIdx === 0);
115
115
  if (floor(i / out) > maxInt - n) error("overflow");
116
116
  n += floor(i / out);
117
117
  i %= out;
@@ -120,7 +120,7 @@ function decode(input) {
120
120
  return String.fromCodePoint(...output);
121
121
  }
122
122
  function encode(input) {
123
- require_assertIsString.assertIsString(input, { message: ({ currentType, validType }) => `Utils \`punycodeUtilsJS.encode\`, parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.` });
123
+ require_assertIsString.assertIsString(input, { message: ({ currentType, validType }) => require_logger.createMessage("punycodeUtilsJS.encode", `Parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
124
124
  const output = [];
125
125
  const points = ucs2decode(input);
126
126
  const inputLength = points.length;
@@ -158,11 +158,11 @@ function encode(input) {
158
158
  return output.join("");
159
159
  }
160
160
  function toUnicode(input) {
161
- require_assertIsString.assertIsString(input, { message: ({ currentType, validType }) => `Utils \`punycodeUtilsJS.toUnicode\`, parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.` });
161
+ require_assertIsString.assertIsString(input, { message: ({ currentType, validType }) => require_logger.createMessage("punycodeUtilsJS.toUnicode", `Parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
162
162
  return mapDomain(input, (str) => regexPunycode.test(str) ? decode(str.slice(4).toLowerCase()) : str);
163
163
  }
164
164
  function toASCII(input) {
165
- require_assertIsString.assertIsString(input, { message: ({ currentType, validType }) => `Utils \`punycodeUtilsJS.toASCII\`, parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.` });
165
+ require_assertIsString.assertIsString(input, { message: ({ currentType, validType }) => require_logger.createMessage("punycodeUtilsJS.toASCII", `Parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
166
166
  return mapDomain(input, (str) => regexNonASCII.test(str) ? "xn--" + encode(str) : str);
167
167
  }
168
168
  const punycodeUtilsJS = {
@@ -182,4 +182,4 @@ Object.defineProperty(exports, 'punycodeUtilsJS', {
182
182
  return punycodeUtilsJS;
183
183
  }
184
184
  });
185
- //# sourceMappingURL=punyCode-WZ6-GaTM.cjs.map
185
+ //# sourceMappingURL=punyCode-DHTLhGdD.cjs.map