ts-data-forge 9.0.0 → 9.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (409) hide show
  1. package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
  2. package/dist/array/impl/array-utils-creation.mjs +17 -112
  3. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  4. package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
  5. package/dist/array/impl/array-utils-element-access.mjs +22 -61
  6. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  7. package/dist/array/impl/array-utils-iterators.d.mts.map +1 -1
  8. package/dist/array/impl/array-utils-iterators.mjs +9 -63
  9. package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
  10. package/dist/array/impl/array-utils-modification.mjs +78 -78
  11. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  12. package/dist/array/impl/array-utils-reducing-value.mjs +95 -89
  13. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  14. package/dist/array/impl/array-utils-search.mjs +100 -92
  15. package/dist/array/impl/array-utils-search.mjs.map +1 -1
  16. package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
  17. package/dist/array/impl/array-utils-set-op.mjs +31 -141
  18. package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
  19. package/dist/array/impl/array-utils-size.d.mts.map +1 -1
  20. package/dist/array/impl/array-utils-size.mjs +4 -8
  21. package/dist/array/impl/array-utils-size.mjs.map +1 -1
  22. package/dist/array/impl/array-utils-slice-clamped.mjs +11 -12
  23. package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
  24. package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
  25. package/dist/array/impl/array-utils-slicing.mjs +44 -96
  26. package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
  27. package/dist/array/impl/array-utils-transformation.d.mts +1 -1
  28. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
  29. package/dist/array/impl/array-utils-transformation.mjs +150 -292
  30. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  31. package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
  32. package/dist/array/impl/array-utils-validation.mjs +18 -169
  33. package/dist/array/impl/array-utils-validation.mjs.map +1 -1
  34. package/dist/collections/imap-mapped.d.mts.map +1 -1
  35. package/dist/collections/imap-mapped.mjs +243 -330
  36. package/dist/collections/imap-mapped.mjs.map +1 -1
  37. package/dist/collections/imap.d.mts.map +1 -1
  38. package/dist/collections/imap.mjs +190 -275
  39. package/dist/collections/imap.mjs.map +1 -1
  40. package/dist/collections/iset-mapped.d.mts +1 -1
  41. package/dist/collections/iset-mapped.d.mts.map +1 -1
  42. package/dist/collections/iset-mapped.mjs +222 -444
  43. package/dist/collections/iset-mapped.mjs.map +1 -1
  44. package/dist/collections/iset.d.mts +1 -1
  45. package/dist/collections/iset.d.mts.map +1 -1
  46. package/dist/collections/iset.mjs +158 -324
  47. package/dist/collections/iset.mjs.map +1 -1
  48. package/dist/collections/queue.d.mts.map +1 -1
  49. package/dist/collections/queue.mjs +106 -178
  50. package/dist/collections/queue.mjs.map +1 -1
  51. package/dist/collections/stack.d.mts.map +1 -1
  52. package/dist/collections/stack.mjs +95 -165
  53. package/dist/collections/stack.mjs.map +1 -1
  54. package/dist/expect-type.d.mts +1 -1
  55. package/dist/expect-type.d.mts.map +1 -1
  56. package/dist/expect-type.mjs +1 -69
  57. package/dist/expect-type.mjs.map +1 -1
  58. package/dist/functional/match.mjs +9 -9
  59. package/dist/functional/match.mjs.map +1 -1
  60. package/dist/functional/optional/impl/optional-expect-to-be.mjs +13 -14
  61. package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
  62. package/dist/functional/optional/impl/optional-filter.mjs +14 -15
  63. package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
  64. package/dist/functional/optional/impl/optional-flat-map.mjs +10 -11
  65. package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
  66. package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +1 -1
  67. package/dist/functional/optional/impl/optional-from-nullable.mjs +1 -25
  68. package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
  69. package/dist/functional/optional/impl/optional-is-none.d.mts.map +1 -1
  70. package/dist/functional/optional/impl/optional-is-none.mjs +0 -19
  71. package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -1
  72. package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -1
  73. package/dist/functional/optional/impl/optional-is-optional.mjs +1 -23
  74. package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
  75. package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -1
  76. package/dist/functional/optional/impl/optional-is-some.mjs +0 -20
  77. package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
  78. package/dist/functional/optional/impl/optional-map.mjs +13 -14
  79. package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
  80. package/dist/functional/optional/impl/optional-none.mjs +0 -16
  81. package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
  82. package/dist/functional/optional/impl/optional-or-else.mjs +10 -11
  83. package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
  84. package/dist/functional/optional/impl/optional-some.d.mts.map +1 -1
  85. package/dist/functional/optional/impl/optional-some.mjs +2 -21
  86. package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
  87. package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -1
  88. package/dist/functional/optional/impl/optional-to-nullable.mjs +1 -27
  89. package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
  90. package/dist/functional/optional/impl/optional-unwrap-or.mjs +9 -10
  91. package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
  92. package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -1
  93. package/dist/functional/optional/impl/optional-unwrap-throw.mjs +4 -32
  94. package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
  95. package/dist/functional/optional/impl/optional-unwrap.mjs +4 -4
  96. package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
  97. package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -1
  98. package/dist/functional/optional/impl/optional-zip.mjs +1 -35
  99. package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
  100. package/dist/functional/optional/impl/tag.mjs +2 -3
  101. package/dist/functional/optional/impl/tag.mjs.map +1 -1
  102. package/dist/functional/pipe.d.mts.map +1 -1
  103. package/dist/functional/pipe.mjs +9 -34
  104. package/dist/functional/pipe.mjs.map +1 -1
  105. package/dist/functional/result/impl/result-err.d.mts.map +1 -1
  106. package/dist/functional/result/impl/result-err.mjs +2 -27
  107. package/dist/functional/result/impl/result-err.mjs.map +1 -1
  108. package/dist/functional/result/impl/result-expect-to-be.mjs +13 -15
  109. package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
  110. package/dist/functional/result/impl/result-flat-map.mjs +16 -16
  111. package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
  112. package/dist/functional/result/impl/result-fold.mjs +16 -16
  113. package/dist/functional/result/impl/result-fold.mjs.map +1 -1
  114. package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -1
  115. package/dist/functional/result/impl/result-from-promise.mjs +4 -31
  116. package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
  117. package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -1
  118. package/dist/functional/result/impl/result-from-throwable.mjs +8 -38
  119. package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
  120. package/dist/functional/result/impl/result-is-err.d.mts.map +1 -1
  121. package/dist/functional/result/impl/result-is-err.mjs +0 -19
  122. package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
  123. package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -1
  124. package/dist/functional/result/impl/result-is-ok.mjs +0 -19
  125. package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
  126. package/dist/functional/result/impl/result-is-result.d.mts.map +1 -1
  127. package/dist/functional/result/impl/result-is-result.mjs +1 -23
  128. package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
  129. package/dist/functional/result/impl/result-map-err.mjs +16 -16
  130. package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
  131. package/dist/functional/result/impl/result-map.mjs +16 -16
  132. package/dist/functional/result/impl/result-map.mjs.map +1 -1
  133. package/dist/functional/result/impl/result-ok.d.mts.map +1 -1
  134. package/dist/functional/result/impl/result-ok.mjs +2 -27
  135. package/dist/functional/result/impl/result-ok.mjs.map +1 -1
  136. package/dist/functional/result/impl/result-or-else.mjs +10 -12
  137. package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
  138. package/dist/functional/result/impl/result-swap.d.mts.map +1 -1
  139. package/dist/functional/result/impl/result-swap.mjs +4 -22
  140. package/dist/functional/result/impl/result-swap.mjs.map +1 -1
  141. package/dist/functional/result/impl/result-to-optional.d.mts.map +1 -1
  142. package/dist/functional/result/impl/result-to-optional.mjs +0 -27
  143. package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
  144. package/dist/functional/result/impl/result-unwrap-err-or.mjs +9 -11
  145. package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
  146. package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +1 -1
  147. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +13 -40
  148. package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
  149. package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -1
  150. package/dist/functional/result/impl/result-unwrap-err.mjs +4 -32
  151. package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
  152. package/dist/functional/result/impl/result-unwrap-ok-or.mjs +9 -11
  153. package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
  154. package/dist/functional/result/impl/result-unwrap-ok.mjs +4 -4
  155. package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
  156. package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -1
  157. package/dist/functional/result/impl/result-unwrap-throw.mjs +4 -35
  158. package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
  159. package/dist/functional/result/impl/result-zip.d.mts.map +1 -1
  160. package/dist/functional/result/impl/result-zip.mjs +1 -34
  161. package/dist/functional/result/impl/result-zip.mjs.map +1 -1
  162. package/dist/functional/result/impl/tag.mjs +2 -3
  163. package/dist/functional/result/impl/tag.mjs.map +1 -1
  164. package/dist/functional/ternary-result/impl/tag.mjs +3 -5
  165. package/dist/functional/ternary-result/impl/tag.mjs.map +1 -1
  166. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -1
  167. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +2 -15
  168. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
  169. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +13 -13
  170. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
  171. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +27 -26
  172. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
  173. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +21 -22
  174. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
  175. package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +1 -1
  176. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +4 -20
  177. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
  178. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -1
  179. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +7 -25
  180. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
  181. package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts.map +1 -1
  182. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +0 -17
  183. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -1
  184. package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +1 -1
  185. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +0 -19
  186. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -1
  187. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +1 -1
  188. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +1 -25
  189. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -1
  190. package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +1 -1
  191. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +0 -18
  192. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
  193. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +13 -15
  194. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
  195. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +18 -18
  196. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
  197. package/dist/functional/ternary-result/impl/ternary-result-map.mjs +21 -22
  198. package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
  199. package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -1
  200. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +2 -16
  201. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
  202. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +9 -9
  203. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
  204. package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +1 -1
  205. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +4 -22
  206. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -1
  207. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +9 -9
  208. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -1
  209. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +1 -1
  210. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +12 -27
  211. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
  212. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +1 -1
  213. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +4 -19
  214. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -1
  215. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +9 -9
  216. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -1
  217. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +4 -5
  218. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
  219. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -1
  220. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +15 -27
  221. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
  222. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +9 -9
  223. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -1
  224. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +1 -1
  225. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +10 -24
  226. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
  227. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +1 -1
  228. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +4 -19
  229. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
  230. package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -1
  231. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +3 -19
  232. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
  233. package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -1
  234. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +14 -45
  235. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
  236. package/dist/functional/ternary-result/impl/variant-name.d.mts +1 -1
  237. package/dist/functional/ternary-result/impl/variant-name.d.mts.map +1 -1
  238. package/dist/functional/ternary-result/impl/variant-name.mjs +8 -9
  239. package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -1
  240. package/dist/guard/has-key.d.mts.map +1 -1
  241. package/dist/guard/has-key.mjs +0 -41
  242. package/dist/guard/has-key.mjs.map +1 -1
  243. package/dist/guard/is-length-bounded-string.d.mts.map +1 -1
  244. package/dist/guard/is-length-bounded-string.mjs +0 -157
  245. package/dist/guard/is-length-bounded-string.mjs.map +1 -1
  246. package/dist/guard/is-non-empty-string.d.mts +1 -1
  247. package/dist/guard/is-non-empty-string.d.mts.map +1 -1
  248. package/dist/guard/is-non-empty-string.mjs +1 -38
  249. package/dist/guard/is-non-empty-string.mjs.map +1 -1
  250. package/dist/guard/is-non-null-object.d.mts.map +1 -1
  251. package/dist/guard/is-non-null-object.mjs +1 -35
  252. package/dist/guard/is-non-null-object.mjs.map +1 -1
  253. package/dist/guard/is-primitive.d.mts.map +1 -1
  254. package/dist/guard/is-primitive.mjs +12 -43
  255. package/dist/guard/is-primitive.mjs.map +1 -1
  256. package/dist/guard/is-record.d.mts.map +1 -1
  257. package/dist/guard/is-record.mjs +0 -86
  258. package/dist/guard/is-record.mjs.map +1 -1
  259. package/dist/guard/is-type.d.mts.map +1 -1
  260. package/dist/guard/is-type.mjs +12 -399
  261. package/dist/guard/is-type.mjs.map +1 -1
  262. package/dist/guard/key-is-in.d.mts.map +1 -1
  263. package/dist/guard/key-is-in.mjs +0 -40
  264. package/dist/guard/key-is-in.mjs.map +1 -1
  265. package/dist/iterator/range.mjs +16 -16
  266. package/dist/iterator/range.mjs.map +1 -1
  267. package/dist/json/json.d.mts.map +1 -1
  268. package/dist/json/json.mjs +52 -340
  269. package/dist/json/json.mjs.map +1 -1
  270. package/dist/number/branded-types/finite-number.d.mts +3 -3
  271. package/dist/number/branded-types/finite-number.mjs +135 -154
  272. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  273. package/dist/number/branded-types/int.d.mts +4 -4
  274. package/dist/number/branded-types/int.mjs +205 -245
  275. package/dist/number/branded-types/int.mjs.map +1 -1
  276. package/dist/number/branded-types/int16.d.mts +15 -15
  277. package/dist/number/branded-types/int16.mjs +116 -123
  278. package/dist/number/branded-types/int16.mjs.map +1 -1
  279. package/dist/number/branded-types/int32.d.mts +11 -11
  280. package/dist/number/branded-types/int32.mjs +116 -123
  281. package/dist/number/branded-types/int32.mjs.map +1 -1
  282. package/dist/number/branded-types/negative-finite-number.d.mts +4 -4
  283. package/dist/number/branded-types/negative-finite-number.mjs +129 -144
  284. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  285. package/dist/number/branded-types/negative-int.d.mts +5 -5
  286. package/dist/number/branded-types/negative-int.mjs +94 -113
  287. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  288. package/dist/number/branded-types/negative-safe-int.d.mts +5 -5
  289. package/dist/number/branded-types/negative-safe-int.mjs +103 -124
  290. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  291. package/dist/number/branded-types/non-negative-finite-number.d.mts +5 -5
  292. package/dist/number/branded-types/non-negative-finite-number.mjs +136 -142
  293. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  294. package/dist/number/branded-types/non-negative-int16.d.mts +16 -16
  295. package/dist/number/branded-types/non-negative-int16.mjs +109 -118
  296. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  297. package/dist/number/branded-types/non-negative-int32.d.mts +12 -12
  298. package/dist/number/branded-types/non-negative-int32.mjs +110 -119
  299. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  300. package/dist/number/branded-types/non-positive-finite-number.d.mts +3 -3
  301. package/dist/number/branded-types/non-positive-finite-number.mjs +120 -124
  302. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  303. package/dist/number/branded-types/non-positive-int.d.mts +4 -4
  304. package/dist/number/branded-types/non-positive-int.mjs +167 -212
  305. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  306. package/dist/number/branded-types/non-positive-safe-int.d.mts +4 -4
  307. package/dist/number/branded-types/non-positive-safe-int.mjs +95 -106
  308. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  309. package/dist/number/branded-types/non-zero-finite-number.d.mts +4 -4
  310. package/dist/number/branded-types/non-zero-finite-number.mjs +114 -123
  311. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  312. package/dist/number/branded-types/non-zero-int.d.mts +2 -2
  313. package/dist/number/branded-types/non-zero-int.mjs +72 -83
  314. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  315. package/dist/number/branded-types/non-zero-int16.d.mts +7 -7
  316. package/dist/number/branded-types/non-zero-int16.mjs +96 -107
  317. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  318. package/dist/number/branded-types/non-zero-int32.d.mts +5 -5
  319. package/dist/number/branded-types/non-zero-int32.mjs +97 -108
  320. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  321. package/dist/number/branded-types/non-zero-safe-int.d.mts +2 -2
  322. package/dist/number/branded-types/non-zero-safe-int.mjs +100 -111
  323. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  324. package/dist/number/branded-types/non-zero-uint16.d.mts +8 -8
  325. package/dist/number/branded-types/non-zero-uint16.mjs +96 -107
  326. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  327. package/dist/number/branded-types/non-zero-uint32.d.mts +6 -6
  328. package/dist/number/branded-types/non-zero-uint32.mjs +96 -107
  329. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  330. package/dist/number/branded-types/positive-finite-number.d.mts +8 -8
  331. package/dist/number/branded-types/positive-finite-number.mjs +139 -141
  332. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  333. package/dist/number/branded-types/positive-int.d.mts +11 -11
  334. package/dist/number/branded-types/positive-int.mjs +228 -271
  335. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  336. package/dist/number/branded-types/positive-int16.d.mts +19 -19
  337. package/dist/number/branded-types/positive-int16.mjs +109 -118
  338. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  339. package/dist/number/branded-types/positive-int32.d.mts +15 -15
  340. package/dist/number/branded-types/positive-int32.mjs +109 -118
  341. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  342. package/dist/number/branded-types/positive-safe-int.d.mts +11 -11
  343. package/dist/number/branded-types/positive-safe-int.mjs +244 -275
  344. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  345. package/dist/number/branded-types/positive-uint16.d.mts +17 -17
  346. package/dist/number/branded-types/positive-uint16.mjs +109 -118
  347. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  348. package/dist/number/branded-types/positive-uint32.d.mts +13 -13
  349. package/dist/number/branded-types/positive-uint32.mjs +110 -119
  350. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  351. package/dist/number/branded-types/safe-int.d.mts +4 -4
  352. package/dist/number/branded-types/safe-int.mjs +251 -292
  353. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  354. package/dist/number/branded-types/safe-uint.d.mts +8 -8
  355. package/dist/number/branded-types/safe-uint.mjs +111 -119
  356. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  357. package/dist/number/branded-types/uint.d.mts +8 -8
  358. package/dist/number/branded-types/uint.mjs +198 -225
  359. package/dist/number/branded-types/uint.mjs.map +1 -1
  360. package/dist/number/branded-types/uint16.d.mts +14 -14
  361. package/dist/number/branded-types/uint16.mjs +109 -119
  362. package/dist/number/branded-types/uint16.mjs.map +1 -1
  363. package/dist/number/branded-types/uint32.d.mts +10 -10
  364. package/dist/number/branded-types/uint32.mjs +110 -117
  365. package/dist/number/branded-types/uint32.mjs.map +1 -1
  366. package/dist/number/enum/int8.mjs +119 -145
  367. package/dist/number/enum/int8.mjs.map +1 -1
  368. package/dist/number/enum/uint8.mjs +107 -121
  369. package/dist/number/enum/uint8.mjs.map +1 -1
  370. package/dist/number/num.d.mts +2 -2
  371. package/dist/number/num.d.mts.map +1 -1
  372. package/dist/number/num.mjs +76 -537
  373. package/dist/number/num.mjs.map +1 -1
  374. package/dist/number/refined-number-utils.d.mts +1 -1
  375. package/dist/number/refined-number-utils.d.mts.map +1 -1
  376. package/dist/number/refined-number-utils.mjs +127 -263
  377. package/dist/number/refined-number-utils.mjs.map +1 -1
  378. package/dist/object/object.d.mts.map +1 -1
  379. package/dist/object/object.mjs +107 -222
  380. package/dist/object/object.mjs.map +1 -1
  381. package/dist/others/cast-mutable.d.mts.map +1 -1
  382. package/dist/others/cast-mutable.mjs +8 -37
  383. package/dist/others/cast-mutable.mjs.map +1 -1
  384. package/dist/others/cast-readonly.d.mts.map +1 -1
  385. package/dist/others/cast-readonly.mjs +8 -36
  386. package/dist/others/cast-readonly.mjs.map +1 -1
  387. package/dist/others/debounce-function.d.mts.map +1 -1
  388. package/dist/others/debounce-function.mjs +7 -16
  389. package/dist/others/debounce-function.mjs.map +1 -1
  390. package/dist/others/fast-deep-equal.d.mts.map +1 -1
  391. package/dist/others/fast-deep-equal.mjs +43 -59
  392. package/dist/others/fast-deep-equal.mjs.map +1 -1
  393. package/dist/others/if-then.d.mts.map +1 -1
  394. package/dist/others/if-then.mjs +0 -29
  395. package/dist/others/if-then.mjs.map +1 -1
  396. package/dist/others/map-nullable.mjs +9 -9
  397. package/dist/others/map-nullable.mjs.map +1 -1
  398. package/dist/others/memoize-function.mjs +12 -12
  399. package/dist/others/memoize-function.mjs.map +1 -1
  400. package/dist/others/tuple.d.mts.map +1 -1
  401. package/dist/others/tuple.mjs +0 -50
  402. package/dist/others/tuple.mjs.map +1 -1
  403. package/dist/others/unknown-to-string.d.mts.map +1 -1
  404. package/dist/others/unknown-to-string.mjs +41 -88
  405. package/dist/others/unknown-to-string.mjs.map +1 -1
  406. package/dist/promise/promise.d.mts.map +1 -1
  407. package/dist/promise/promise.mjs +4 -49
  408. package/dist/promise/promise.mjs.map +1 -1
  409. package/package.json +8 -7
@@ -2,70 +2,54 @@ import { isMap, isSet, isTypedArray, isRegExp } from '@sindresorhus/is';
2
2
  import { hasKey } from '../guard/has-key.mjs';
3
3
  import { isRecord } from '../guard/is-record.mjs';
4
4
 
5
- /**
6
- * The fastest deep equal with ES6 Map, Set and Typed arrays support.
7
- * Checks equality of Date and RegExp objects by value.
8
- *
9
- * Forked from https://github.com/epoberezkin/fast-deep-equal/blob/v3.1.3/src/index.jst
10
- */
11
5
  const fastDeepEqual = (a, b) => {
12
- if (a === b) {
13
- return true;
6
+ if (a === b) {
7
+ return true;
8
+ }
9
+ if (typeof a !== typeof b) {
10
+ return false;
11
+ }
12
+ if (Array.isArray(a)) {
13
+ return Array.isArray(b) && a.constructor === b.constructor && a.length === b.length && a.every((ai, index) => fastDeepEqual(ai, b[index]));
14
+ }
15
+ if (isRecord(a)) {
16
+ if (!isRecord(b)) {
17
+ return false;
14
18
  }
15
- if (typeof a !== typeof b) {
16
- return false;
19
+ if (a.constructor !== b.constructor) {
20
+ return false;
17
21
  }
18
- // Arrays are handled before `isRecord`, which excludes them.
19
- if (Array.isArray(a)) {
20
- return (Array.isArray(b) &&
21
- a.constructor === b.constructor &&
22
- a.length === b.length &&
23
- a.every((ai, index) => fastDeepEqual(ai, b[index])));
22
+ if (isMap(a)) {
23
+ return isMap(b) && a.size === b.size && Array.from(a.entries()).every(
24
+ ([key, value]) => b.has(key) && fastDeepEqual(value, b.get(key))
25
+ );
24
26
  }
25
- if (isRecord(a)) {
26
- if (!isRecord(b)) {
27
- return false;
28
- }
29
- if (a.constructor !== b.constructor) {
30
- return false;
31
- }
32
- if (isMap(a)) {
33
- return (isMap(b) &&
34
- a.size === b.size &&
35
- Array.from(a.entries()).every(([key, value]) => b.has(key) && fastDeepEqual(value, b.get(key))));
36
- }
37
- if (isSet(a)) {
38
- return (isSet(b) &&
39
- a.size === b.size &&
40
- Array.from(a.entries()).every(([value]) => b.has(value)));
41
- }
42
- if (isTypedArray(a)) {
43
- return (isTypedArray(b) &&
44
- a.length === b.length &&
45
- a.every((value, index) => value === b[index]));
46
- }
47
- if (isRegExp(a)) {
48
- return isRegExp(b) && a.source === b.source && a.flags === b.flags;
49
- }
50
- if (a.valueOf !== Object.prototype.valueOf) {
51
- return a.valueOf() === b.valueOf();
52
- }
53
- if (a.toString !== Object.prototype.toString) {
54
- return a.toString() === b.toString();
55
- }
56
- const aKeys = Object.keys(a);
57
- const bKeys = Object.keys(b);
58
- return (aKeys.length === bKeys.length &&
59
- aKeys.every((key) => hasKey(b, key) &&
60
- // React-specific: avoid traversing React elements' _owner.
61
- // _owner contains circular references
62
- // and is not needed when comparing the actual elements (and not their owners)
63
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
64
- !(key === '_owner' && a['$$typeof']) &&
65
- fastDeepEqual(a[key], b[key])));
27
+ if (isSet(a)) {
28
+ return isSet(b) && a.size === b.size && Array.from(a.entries()).every(([value]) => b.has(value));
66
29
  }
67
- // true if both NaN, false otherwise
68
- return Number.isNaN(a) && Number.isNaN(b);
30
+ if (isTypedArray(a)) {
31
+ return isTypedArray(b) && a.length === b.length && a.every((value, index) => value === b[index]);
32
+ }
33
+ if (isRegExp(a)) {
34
+ return isRegExp(b) && a.source === b.source && a.flags === b.flags;
35
+ }
36
+ if (a.valueOf !== Object.prototype.valueOf) {
37
+ return a.valueOf() === b.valueOf();
38
+ }
39
+ if (a.toString !== Object.prototype.toString) {
40
+ return a.toString() === b.toString();
41
+ }
42
+ const aKeys = Object.keys(a);
43
+ const bKeys = Object.keys(b);
44
+ return aKeys.length === bKeys.length && aKeys.every(
45
+ (key) => hasKey(b, key) && // React-specific: avoid traversing React elements' _owner.
46
+ // _owner contains circular references
47
+ // and is not needed when comparing the actual elements (and not their owners)
48
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
49
+ !(key === "_owner" && a["$$typeof"]) && fastDeepEqual(a[key], b[key])
50
+ );
51
+ }
52
+ return Number.isNaN(a) && Number.isNaN(b);
69
53
  };
70
54
 
71
55
  export { fastDeepEqual };
@@ -1 +1 @@
1
- {"version":3,"file":"fast-deep-equal.mjs","sources":["../../src/others/fast-deep-equal.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAGA;;;;;AAKG;MACU,aAAa,GAAG,CAAK,CAAI,EAAE,CAAI,KAAa;AACvD,IAAA,IAAI,CAAC,KAAK,CAAC,EAAE;AACX,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,IAAI,OAAO,CAAC,KAAK,OAAO,CAAC,EAAE;AACzB,QAAA,OAAO,KAAK;IACd;;AAGA,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;AACpB,QAAA,QACE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB,YAAA,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW;AAC/B,YAAA,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;YACrB,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,KAAK,KAAK,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAEvD;AAEA,IAAA,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE;AACf,QAAA,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;AAChB,YAAA,OAAO,KAAK;QACd;QAEA,IAAI,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,EAAE;AACnC,YAAA,OAAO,KAAK;QACd;AAEA,QAAA,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE;AACZ,YAAA,QACE,KA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CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC5C,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,QAAQ,EAAE;QACtC;QAEA,MAAM,KAAK,GAAsB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAE/C,MAAM,KAAK,GAAsB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAE/C,QAAA,QACE,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;AAC7B,YAAA,KAAK,CAAC,KAAK,CACT,CAAC,GAAG,KACF,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC;;;;;gBAKd,EAAE,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC;AACpC,gBAAA,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAChC;IAEL;;AAGA,IAAA,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3C;;;;"}
1
+ {"version":3,"file":"fast-deep-equal.mjs","sources":["../../src/others/fast-deep-equal.mts"],"sourcesContent":["import { isMap, isRegExp, isSet, isTypedArray } from '@sindresorhus/is';\nimport { hasKey, isRecord } from '../guard/index.mjs';\n\n/**\n * The fastest deep equal with ES6 Map, Set and Typed arrays support.\n * Checks equality of Date and RegExp objects by value.\n *\n * Forked from https://github.com/epoberezkin/fast-deep-equal/blob/v3.1.3/src/index.jst\n */\nexport const fastDeepEqual = <T,>(a: T, b: T): boolean => {\n if (a === b) {\n return true;\n }\n\n if (typeof a !== typeof b) {\n return false;\n }\n\n // Arrays are handled before `isRecord`, which excludes them.\n if (Array.isArray(a)) {\n return (\n Array.isArray(b) &&\n a.constructor === b.constructor &&\n a.length === b.length &&\n a.every((ai, index) => fastDeepEqual(ai, b[index]))\n );\n }\n\n if (isRecord(a)) {\n if (!isRecord(b)) {\n return false;\n }\n\n if (a.constructor !== b.constructor) {\n return false;\n }\n\n if (isMap(a)) {\n return (\n isMap(b) &&\n a.size === b.size &&\n Array.from(a.entries()).every(\n ([key, value]) => b.has(key) && fastDeepEqual(value, b.get(key)),\n )\n );\n }\n\n if (isSet(a)) {\n return (\n isSet(b) &&\n a.size === b.size &&\n Array.from(a.entries()).every(([value]) => b.has(value))\n );\n }\n\n if (isTypedArray(a)) {\n return (\n isTypedArray(b) &&\n a.length === b.length &&\n a.every((value, index) => value === b[index])\n );\n }\n\n if (isRegExp(a)) {\n return isRegExp(b) && a.source === b.source && a.flags === b.flags;\n }\n\n if (a.valueOf !== Object.prototype.valueOf) {\n return a.valueOf() === b.valueOf();\n }\n\n if (a.toString !== Object.prototype.toString) {\n return a.toString() === b.toString();\n }\n\n const aKeys: readonly string[] = Object.keys(a);\n\n const bKeys: readonly string[] = Object.keys(b);\n\n return (\n aKeys.length === bKeys.length &&\n aKeys.every(\n (key) =>\n hasKey(b, key) &&\n // React-specific: avoid traversing React elements' _owner.\n // _owner contains circular references\n // and is not needed when comparing the actual elements (and not their owners)\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n !(key === '_owner' && a['$$typeof']) &&\n fastDeepEqual(a[key], b[key]),\n )\n );\n }\n\n // true if both NaN, false otherwise\n return Number.isNaN(a) && Number.isNaN(b);\n};\n"],"names":[],"mappings":";;;;AASO,MAAM,aAAA,GAAgB,CAAK,CAAA,EAAM,CAAA,KAAkB;AACxD,EAAA,IAAI,MAAM,CAAA,EAAG;AACX,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,OAAO,CAAA,KAAM,OAAO,CAAA,EAAG;AACzB,IAAA,OAAO,KAAA;AAAA,EACT;AAGA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA,EAAG;AACpB,IAAA,OACE,KAAA,CAAM,QAAQ,CAAC,CAAA,IACf,EAAE,WAAA,KAAgB,CAAA,CAAE,WAAA,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others/if-then.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,MAAM,GAAI,YAAY,OAAO,EAAE,YAAY,OAAO,KAAG,OACvC,CAAC;AAE5B;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,eAbe,OAAO,cAAc,OAAO,KAAG,OAarC,CAAC"}
1
+ {"version":3,"file":"if-then.d.mts","sourceRoot":"","sources":["../../src/others/if-then.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,MAAM,eAAgB,OAAO,cAAc,OAAO,KAAG,OACvC,CAAC;AAE5B;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,eAbe,OAAO,cAAc,OAAO,KAAG,OAarC,CAAC"}
@@ -1,33 +1,4 @@
1
- /**
2
- * Implements the logical implication (if-then) operator.
3
- *
4
- * Returns `true` if the antecedent is `false` or the consequent is `true`. In
5
- * logical terms: `antecedent → consequent` is equivalent to `¬antecedent ∨
6
- * consequent`.
7
- *
8
- * **Truth table:**
9
- *
10
- * - `true → true` = `true` (valid implication)
11
- * - `true → false` = `false` (invalid implication)
12
- * - `false → true` = `true` (vacuously true)
13
- * - `false → false` = `true` (vacuously true)
14
- *
15
- * @param antecedent - The condition (if part)
16
- * @param consequent - The result that should hold if the condition is true
17
- * (then part)
18
- * @returns `true` if the implication holds, `false` otherwise
19
- */
20
1
  const ifThen = (antecedent, consequent) => !antecedent || consequent;
21
- /**
22
- * Alias for {@link ifThen}.
23
- *
24
- * Implements the logical implication (if-then) operator.
25
- *
26
- * @param antecedent - The condition (if part)
27
- * @param consequent - The result that should hold if the condition is true
28
- * (then part)
29
- * @returns `true` if the implication holds, `false` otherwise
30
- */
31
2
  const implies = ifThen;
32
3
 
33
4
  export { ifThen, implies };
@@ -1 +1 @@
1
- {"version":3,"file":"if-then.mjs","sources":["../../src/others/if-then.mts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,MAAM,GAAG,CAAC,UAAmB,EAAE,UAAmB,KAC7D,CAAC,UAAU,IAAI;AAEjB;;;;;;;;;AASG;AACI,MAAM,OAAO,GAAG;;;;"}
1
+ {"version":3,"file":"if-then.mjs","sources":["../../src/others/if-then.mts"],"sourcesContent":["/**\n * Implements the logical implication (if-then) operator.\n *\n * Returns `true` if the antecedent is `false` or the consequent is `true`. In\n * logical terms: `antecedent → consequent` is equivalent to `¬antecedent ∨\n * consequent`.\n *\n * **Truth table:**\n *\n * - `true → true` = `true` (valid implication)\n * - `true → false` = `false` (invalid implication)\n * - `false → true` = `true` (vacuously true)\n * - `false → false` = `true` (vacuously true)\n *\n * @param antecedent - The condition (if part)\n * @param consequent - The result that should hold if the condition is true\n * (then part)\n * @returns `true` if the implication holds, `false` otherwise\n */\nexport const ifThen = (antecedent: boolean, consequent: boolean): boolean =>\n !antecedent || consequent;\n\n/**\n * Alias for {@link ifThen}.\n *\n * Implements the logical implication (if-then) operator.\n *\n * @param antecedent - The condition (if part)\n * @param consequent - The result that should hold if the condition is true\n * (then part)\n * @returns `true` if the implication holds, `false` otherwise\n */\nexport const implies = ifThen;\n"],"names":[],"mappings":"AAmBO,MAAM,MAAA,GAAS,CAAC,UAAA,EAAqB,UAAA,KAC1C,CAAC,UAAA,IAAc;AAYV,MAAM,OAAA,GAAU;;;;"}
@@ -1,14 +1,14 @@
1
1
  function mapNullable(...args) {
2
- switch (args.length) {
3
- case 2: {
4
- const [value, mapFn] = args;
5
- return value == null ? undefined : mapFn(value);
6
- }
7
- case 1: {
8
- const [mapFn] = args;
9
- return (value) => mapNullable(value, mapFn);
10
- }
2
+ switch (args.length) {
3
+ case 2: {
4
+ const [value, mapFn] = args;
5
+ return value == null ? void 0 : mapFn(value);
11
6
  }
7
+ case 1: {
8
+ const [mapFn] = args;
9
+ return (value) => mapNullable(value, mapFn);
10
+ }
11
+ }
12
12
  }
13
13
 
14
14
  export { mapNullable };
@@ -1 +1 @@
1
- {"version":3,"file":"map-nullable.mjs","sources":["../../src/others/map-nullable.mts"],"sourcesContent":[null],"names":[],"mappings":"AA8BM,SAAU,WAAW,CACzB,GAAG,IAE8B,EAAA;AAEjC,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,IAAI;AAE3B,YAAA,OAAO,KAAK,IAAI,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC;QACjD;QAEA,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI;YAEpB,OAAO,CAAC,KAA2B,KAAK,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC;QACnE;;AAEJ;;;;"}
1
+ {"version":3,"file":"map-nullable.mjs","sources":["../../src/others/map-nullable.mts"],"sourcesContent":["/**\n * Applies a function to a value if the value is not `null` or `undefined`. If\n * the value is `null` or `undefined`, it returns `undefined`.\n *\n * This function provides a safe way to transform nullable values without\n * explicit null checks. It's similar to Optional.map() but works directly with\n * TypeScript's nullable types. Supports both regular and curried usage for\n * functional composition.\n *\n * @template A - The type of the input value (excluding null/undefined)\n * @template B - The type of the value returned by the mapping function\n * @param value - The value to potentially transform (can be `A`, `null`, or\n * `undefined`)\n * @param mapFn - A function that transforms a non-nullable value of type `A` to\n * type `B`\n * @returns The result of applying `mapFn` to `value` if value is not\n * null/undefined; otherwise `undefined`\n * @see Optional - For more complex optional value handling\n * @see Result - For error handling with detailed error information\n */\nexport function mapNullable<const A, const B>(\n value: A | null | undefined,\n mapFn: (v: A) => B,\n): B | undefined;\n\n// Curried version\nexport function mapNullable<const A, const B>(\n mapFn: (v: A) => B,\n): (value: A | null | undefined) => B | undefined;\n\nexport function mapNullable<const A, const B>(\n ...args:\n | readonly [value: A | null | undefined, mapFn: (v: A) => B]\n | readonly [mapFn: (v: A) => B]\n): (B | undefined) | ((value: A | null | undefined) => B | undefined) {\n switch (args.length) {\n case 2: {\n const [value, mapFn] = args;\n\n return value == null ? undefined : mapFn(value);\n }\n\n case 1: {\n const [mapFn] = args;\n\n return (value: A | null | undefined) => mapNullable(value, mapFn);\n }\n }\n}\n"],"names":[],"mappings":"AA8BO,SAAS,eACX,IAAA,EAGiE;AACpE,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,KAAA,EAAO,KAAK,CAAA,GAAI,IAAA;AAEvB,MAAA,OAAO,KAAA,IAAS,IAAA,GAAO,MAAA,GAAY,KAAA,CAAM,KAAK,CAAA;AAAA,IAChD;AAAA,IAEA,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,KAAK,CAAA,GAAI,IAAA;AAEhB,MAAA,OAAO,CAAC,KAAA,KAAgC,WAAA,CAAY,KAAA,EAAO,KAAK,CAAA;AAAA,IAClE;AAAA;AAEJ;;;;"}
@@ -1,16 +1,16 @@
1
1
  function memoizeFunction(fn, argsToCacheKey) {
2
- const mut_cache = new Map();
3
- const defaultKey = Symbol('memoize-default-key');
4
- return (...args) => {
5
- const key = argsToCacheKey === undefined ? defaultKey : argsToCacheKey(...args);
6
- const cached = mut_cache.get(key);
7
- if (cached !== undefined) {
8
- return cached.value;
9
- }
10
- const result = fn(...args);
11
- mut_cache.set(key, { value: result });
12
- return result;
13
- };
2
+ const mut_cache = /* @__PURE__ */ new Map();
3
+ const defaultKey = /* @__PURE__ */ Symbol("memoize-default-key");
4
+ return (...args) => {
5
+ const key = argsToCacheKey === void 0 ? defaultKey : argsToCacheKey(...args);
6
+ const cached = mut_cache.get(key);
7
+ if (cached !== void 0) {
8
+ return cached.value;
9
+ }
10
+ const result = fn(...args);
11
+ mut_cache.set(key, { value: result });
12
+ return result;
13
+ };
14
14
  }
15
15
 
16
16
  export { memoizeFunction };
@@ -1 +1 @@
1
- {"version":3,"file":"memoize-function.mjs","sources":["../../src/others/memoize-function.mts"],"sourcesContent":[null],"names":[],"mappings":"AA0CM,SAAU,eAAe,CAK7B,EAAwB,EACxB,cAAqC,EAAA;AAIrC,IAAA,MAAM,SAAS,GAAG,IAAI,GAAG,EAA0B;AAEnD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,qBAAqB,CAAC;AAEhD,IAAA,OAAO,CAAC,GAAG,IAAU,KAAO;AAC1B,QAAA,MAAM,GAAG,GACP,cAAc,KAAK,SAAS,GAAG,UAAU,GAAG,cAAc,CAAC,GAAG,IAAI,CAAC;QAErE,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC;AAEjC,QAAA,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,OAAO,MAAM,CAAC,KAAK;QACrB;AAEA,QAAA,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC;QAE1B,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAErC,QAAA,OAAO,MAAM;AACf,IAAA,CAAC;AACH;;;;"}
1
+ {"version":3,"file":"memoize-function.mjs","sources":["../../src/others/memoize-function.mts"],"sourcesContent":["import { type Primitive } from 'ts-type-forge';\n\n/**\n * Creates a memoized version of a function that caches results based on input\n * arguments.\n *\n * The memoized function stores results in an internal Map and returns cached\n * values for repeated calls with the same arguments. This can significantly\n * improve performance for expensive computations or I/O operations.\n *\n * **Important considerations:**\n *\n * - The cache grows unbounded - consider memory implications for long-running\n * applications\n * - Cache keys must be primitives (string, number, boolean, symbol, null,\n * undefined, bigint)\n * - Object arguments require careful key generation to ensure uniqueness\n * - Pure functions only - memoizing functions with side effects can lead to bugs\n *\n * @template A - The tuple type of the function arguments\n * @template R - The return type of the function\n * @template K - The primitive type used as the cache key (must be valid Map\n * key)\n * @param fn - The pure function to memoize\n * @param argsToCacheKey - Function that converts arguments to a unique cache\n * key. Optional for zero-argument functions.\n * @returns A memoized version of the input function with the same signature\n *\n * @see https://en.wikipedia.org/wiki/Memoization\n */\nexport function memoizeFunction<R>(fn: () => R): () => R;\n\nexport function memoizeFunction<\n Arg0,\n const RestArgs extends readonly unknown[],\n R,\n K extends Primitive,\n>(\n fn: (arg0: Arg0, ...args: RestArgs) => R,\n argsToCacheKey: (arg0: Arg0, ...args: RestArgs) => K,\n): (arg0: Arg0, ...args: RestArgs) => R;\n\nexport function memoizeFunction<\n const Args extends readonly unknown[],\n R,\n K extends Primitive,\n>(\n fn: (...args: Args) => R,\n argsToCacheKey?: (...args: Args) => K,\n): (...args: Args) => R {\n type CacheEntry = Readonly<{ value: R }>;\n\n const mut_cache = new Map<K | symbol, CacheEntry>();\n\n const defaultKey = Symbol('memoize-default-key');\n\n return (...args: Args): R => {\n const key: K | symbol =\n argsToCacheKey === undefined ? defaultKey : argsToCacheKey(...args);\n\n const cached = mut_cache.get(key);\n\n if (cached !== undefined) {\n return cached.value;\n }\n\n const result = fn(...args);\n\n mut_cache.set(key, { value: result });\n\n return result;\n };\n}\n"],"names":[],"mappings":"AA0CO,SAAS,eAAA,CAKd,IACA,cAAA,EACsB;AAGtB,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAA4B;AAElD,EAAA,MAAM,UAAA,0BAAoB,qBAAqB,CAAA;AAE/C,EAAA,OAAO,IAAI,IAAA,KAAkB;AAC3B,IAAA,MAAM,MACJ,cAAA,KAAmB,MAAA,GAAY,UAAA,GAAa,cAAA,CAAe,GAAG,IAAI,CAAA;AAEpE,IAAA,MAAM,MAAA,GAAS,SAAA,CAAU,GAAA,CAAI,GAAG,CAAA;AAEhC,IAAA,IAAI,WAAW,MAAA,EAAW;AACxB,MAAA,OAAO,MAAA,CAAO,KAAA;AAAA,IAChB;AAEA,IAAA,MAAM,MAAA,GAAS,EAAA,CAAG,GAAG,IAAI,CAAA;AAEzB,IAAA,SAAA,CAAU,GAAA,CAAI,GAAA,EAAK,EAAE,KAAA,EAAO,QAAQ,CAAA;AAEpC,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"tuple.d.mts","sourceRoot":"","sources":["../../src/others/tuple.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,EAAE,GAAI,KAAK,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,EACnD,GAAG,MAAM,CAAC,KACT,QAAQ,CAAC,CAAC,CAAS,CAAC"}
1
+ {"version":3,"file":"tuple.d.mts","sourceRoot":"","sources":["../../src/others/tuple.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,EAAE,GAAI,KAAK,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,WAC1C,CAAC,KACT,QAAQ,CAAC,CAAC,CAAS,CAAC"}
@@ -1,53 +1,3 @@
1
- /**
2
- * Creates a readonly tuple from the given arguments with precise literal type
3
- * inference. It is a convenient shorthand for `[...args] as const`.
4
- *
5
- * @example
6
- *
7
- * ```ts
8
- * // Create a tuple with literal types preserved
9
- * const coordinates = tp(10, 20, 30);
10
- *
11
- * expectType<typeof coordinates, readonly [10, 20, 30]>('=');
12
- *
13
- * expectType<typeof coordinates, readonly number[]>('!=');
14
- *
15
- * assert.deepStrictEqual(coordinates, [10, 20, 30]);
16
- *
17
- * // The following two are equivalent
18
- * const a = tp(1, 2);
19
- *
20
- * const b = [1, 2] as const;
21
- *
22
- * expectType<typeof a, typeof b>('=');
23
- *
24
- * assert.deepStrictEqual(a, b);
25
- *
26
- * // Without tp, type would be number[]
27
- * const point = tp('x', 42, true);
28
- *
29
- * expectType<typeof point, readonly ['x', 42, true]>('=');
30
- *
31
- * assert.deepStrictEqual(point, ['x', 42, true]);
32
- *
33
- * // Useful for creating const tuples
34
- * const rgb = tp(255, 128, 0);
35
- *
36
- * expectType<typeof rgb, readonly [255, 128, 0]>('=');
37
- *
38
- * assert.isTrue(rgb[0] === 255);
39
- *
40
- * assert.isTrue(rgb[1] === 128);
41
- *
42
- * assert.isTrue(rgb[2] === 0);
43
- * ```
44
- *
45
- * @template T - A tuple type with literal types inferred from the arguments
46
- * @param args - The elements to include in the tuple (variadic)
47
- * @returns A readonly tuple containing the provided arguments with preserved
48
- * literal types
49
- * @see https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types
50
- */
51
1
  const tp = (...args) => args;
52
2
 
53
3
  export { tp };
@@ -1 +1 @@
1
- {"version":3,"file":"tuple.mjs","sources":["../../src/others/tuple.mts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDG;AACI,MAAM,EAAE,GAAG,CAChB,GAAG,IAAO,KACM;;;;"}
1
+ {"version":3,"file":"tuple.mjs","sources":["../../src/others/tuple.mts"],"sourcesContent":["/**\n * Creates a readonly tuple from the given arguments with precise literal type\n * inference. It is a convenient shorthand for `[...args] as const`.\n *\n * @example\n *\n * ```ts\n * // Create a tuple with literal types preserved\n * const coordinates = tp(10, 20, 30);\n *\n * expectType<typeof coordinates, readonly [10, 20, 30]>('=');\n *\n * expectType<typeof coordinates, readonly number[]>('!=');\n *\n * assert.deepStrictEqual(coordinates, [10, 20, 30]);\n *\n * // The following two are equivalent\n * const a = tp(1, 2);\n *\n * const b = [1, 2] as const;\n *\n * expectType<typeof a, typeof b>('=');\n *\n * assert.deepStrictEqual(a, b);\n *\n * // Without tp, type would be number[]\n * const point = tp('x', 42, true);\n *\n * expectType<typeof point, readonly ['x', 42, true]>('=');\n *\n * assert.deepStrictEqual(point, ['x', 42, true]);\n *\n * // Useful for creating const tuples\n * const rgb = tp(255, 128, 0);\n *\n * expectType<typeof rgb, readonly [255, 128, 0]>('=');\n *\n * assert.isTrue(rgb[0] === 255);\n *\n * assert.isTrue(rgb[1] === 128);\n *\n * assert.isTrue(rgb[2] === 0);\n * ```\n *\n * @template T - A tuple type with literal types inferred from the arguments\n * @param args - The elements to include in the tuple (variadic)\n * @returns A readonly tuple containing the provided arguments with preserved\n * literal types\n * @see https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types\n */\nexport const tp = <const T extends readonly unknown[]>(\n ...args: T\n): Readonly<T> => args;\n"],"names":[],"mappings":"AAkDO,MAAM,EAAA,GAAK,IACb,IAAA,KACa;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"unknown-to-string.d.mts","sourceRoot":"","sources":["../../src/others/unknown-to-string.mts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,OAAO,EACd,UAAU,OAAO,CAAC,QAAQ,CAAC;IAAE,iBAAiB,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,KAC1D,MAuEF,CAAC"}
1
+ {"version":3,"file":"unknown-to-string.d.mts","sourceRoot":"","sources":["../../src/others/unknown-to-string.mts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,eAAe,UACnB,OAAO,YACJ,OAAO,CAAC,QAAQ,CAAC;IAAE,iBAAiB,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,KAC1D,MAuEF,CAAC"}
@@ -1,96 +1,49 @@
1
1
  import { isDate, isRegExp, isError, isMap, isSet } from '@sindresorhus/is';
2
2
 
3
- /**
4
- * Converts an unknown value to its string representation in a type-safe manner.
5
- *
6
- * This function handles all JavaScript types and provides consistent string
7
- * conversion with proper error handling for edge cases like circular
8
- * references. Unlike naive toString() calls, this function never throws and
9
- * handles all value types gracefully.
10
- *
11
- * **Type conversion rules:**
12
- *
13
- * - Strings: returned as-is
14
- * - Numbers, booleans, bigints: converted via toString()
15
- * - Symbols: converted to their description string
16
- * - Functions: converted to their string representation
17
- * - null: returns "null" (not "null" from JSON)
18
- * - undefined: returns "undefined"
19
- * - Date: converted to ISO string
20
- * - RegExp: converted to regex literal string
21
- * - Map: converted to Map representation with entries
22
- * - Set: converted to Set representation with values
23
- * - Error: returns error message
24
- * - Objects: JSON stringified (with optional pretty printing)
25
- *
26
- * @param value - The unknown value to convert to string
27
- * @param options - Optional configuration for the conversion
28
- * @param options.prettyPrintObject - If true, objects are formatted with
29
- * 2-space indentation
30
- * @returns The string representation of the value. For circular references or
31
- * non-serializable objects, returns an error message string
32
- *
33
- * **Error Handling:** Circular references and non-serializable objects return
34
- * descriptive error messages instead of throwing
35
- * @see JSON.stringify - Underlying serialization for objects
36
- */
37
3
  const unknownToString = (value, options) => {
38
- switch (typeof value) {
39
- case 'string':
40
- return value;
41
- case 'bigint':
42
- return `${value.toString()}n`;
43
- case 'number':
44
- case 'boolean':
45
- case 'symbol':
46
- case 'function':
47
- return value.toString();
48
- case 'undefined':
49
- return 'undefined';
50
- case 'object': {
51
- if (value === null) {
52
- return 'null';
53
- }
54
- try {
55
- // Special handling for Date
56
- if (isDate(value)) {
57
- return value.toISOString();
58
- }
59
- // Special handling for RegExp
60
- if (isRegExp(value)) {
61
- return value.toString();
62
- }
63
- if (isError(value)) {
64
- return value.message;
65
- }
66
- const prettyPrintObject = options?.prettyPrintObject === true;
67
- // Special handling for Map
68
- if (isMap(value)) {
69
- const entries = Array.from(value);
70
- const entriesStr = prettyPrintObject
71
- ? JSON.stringify(entries, undefined, 2)
72
- : JSON.stringify(entries);
73
- return `Map(${entriesStr})`;
74
- }
75
- // Special handling for Set
76
- if (isSet(value)) {
77
- const values = Array.from(value);
78
- const valuesStr = prettyPrintObject
79
- ? JSON.stringify(values, undefined, 2)
80
- : JSON.stringify(values);
81
- return `Set(${valuesStr})`;
82
- }
83
- return prettyPrintObject
84
- ? JSON.stringify(value, undefined, 2)
85
- : JSON.stringify(value);
86
- }
87
- catch (error) {
88
- return isError(error)
89
- ? error.message
90
- : '[Circular or Non-serializable]';
91
- }
4
+ switch (typeof value) {
5
+ case "string":
6
+ return value;
7
+ case "bigint":
8
+ return `${value.toString()}n`;
9
+ case "number":
10
+ case "boolean":
11
+ case "symbol":
12
+ case "function":
13
+ return value.toString();
14
+ case "undefined":
15
+ return "undefined";
16
+ case "object": {
17
+ if (value === null) {
18
+ return "null";
19
+ }
20
+ try {
21
+ if (isDate(value)) {
22
+ return value.toISOString();
92
23
  }
24
+ if (isRegExp(value)) {
25
+ return value.toString();
26
+ }
27
+ if (isError(value)) {
28
+ return value.message;
29
+ }
30
+ const prettyPrintObject = options?.prettyPrintObject === true;
31
+ if (isMap(value)) {
32
+ const entries = Array.from(value);
33
+ const entriesStr = prettyPrintObject ? JSON.stringify(entries, void 0, 2) : JSON.stringify(entries);
34
+ return `Map(${entriesStr})`;
35
+ }
36
+ if (isSet(value)) {
37
+ const values = Array.from(value);
38
+ const valuesStr = prettyPrintObject ? JSON.stringify(values, void 0, 2) : JSON.stringify(values);
39
+ return `Set(${valuesStr})`;
40
+ }
41
+ return prettyPrintObject ? JSON.stringify(value, void 0, 2) : JSON.stringify(value);
42
+ } catch (error) {
43
+ return isError(error) ? error.message : "[Circular or Non-serializable]";
44
+ }
93
45
  }
46
+ }
94
47
  };
95
48
 
96
49
  export { unknownToString };
@@ -1 +1 @@
1
- {"version":3,"file":"unknown-to-string.mjs","sources":["../../src/others/unknown-to-string.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCG;MACU,eAAe,GAAG,CAC7B,KAAc,EACd,OAA2D,KACjD;IACV,QAAQ,OAAO,KAAK;AAClB,QAAA,KAAK,QAAQ;AACX,YAAA,OAAO,KAAK;AAEd,QAAA,KAAK,QAAQ;AACX,YAAA,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,GAAG;AAE/B,QAAA,KAAK,QAAQ;AACb,QAAA,KAAK,SAAS;AACd,QAAA,KAAK,QAAQ;AACb,QAAA,KAAK,UAAU;AACb,YAAA,OAAO,KAAK,CAAC,QAAQ,EAAE;AAEzB,QAAA,KAAK,WAA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SAAS,CAAC,KAAK,CAAC;YAC3B;YAAE,OAAO,KAAK,EAAE;gBACd,OAAO,OAAO,CAAC,KAAK;sBAChB,KAAK,CAAC;sBACN,gCAAgC;YACtC;QACF;;AAEJ;;;;"}
1
+ {"version":3,"file":"unknown-to-string.mjs","sources":["../../src/others/unknown-to-string.mts"],"sourcesContent":["import { isDate, isError, isMap, isRegExp, isSet } from '@sindresorhus/is';\n\n/**\n * Converts an unknown value to its string representation in a type-safe manner.\n *\n * This function handles all JavaScript types and provides consistent string\n * conversion with proper error handling for edge cases like circular\n * references. Unlike naive toString() calls, this function never throws and\n * handles all value types gracefully.\n *\n * **Type conversion rules:**\n *\n * - Strings: returned as-is\n * - Numbers, booleans, bigints: converted via toString()\n * - Symbols: converted to their description string\n * - Functions: converted to their string representation\n * - null: returns \"null\" (not \"null\" from JSON)\n * - undefined: returns \"undefined\"\n * - Date: converted to ISO string\n * - RegExp: converted to regex literal string\n * - Map: converted to Map representation with entries\n * - Set: converted to Set representation with values\n * - Error: returns error message\n * - Objects: JSON stringified (with optional pretty printing)\n *\n * @param value - The unknown value to convert to string\n * @param options - Optional configuration for the conversion\n * @param options.prettyPrintObject - If true, objects are formatted with\n * 2-space indentation\n * @returns The string representation of the value. For circular references or\n * non-serializable objects, returns an error message string\n *\n * **Error Handling:** Circular references and non-serializable objects return\n * descriptive error messages instead of throwing\n * @see JSON.stringify - Underlying serialization for objects\n */\nexport const unknownToString = (\n value: unknown,\n options?: Partial<Readonly<{ prettyPrintObject: boolean }>>,\n): string => {\n switch (typeof value) {\n case 'string':\n return value;\n\n case 'bigint':\n return `${value.toString()}n`;\n\n case 'number':\n case 'boolean':\n case 'symbol':\n case 'function':\n return value.toString();\n\n case 'undefined':\n return 'undefined';\n\n case 'object': {\n if (value === null) {\n return 'null';\n }\n\n try {\n // Special handling for Date\n if (isDate(value)) {\n return value.toISOString();\n }\n\n // Special handling for RegExp\n if (isRegExp(value)) {\n return value.toString();\n }\n\n if (isError(value)) {\n return value.message;\n }\n\n const prettyPrintObject = options?.prettyPrintObject === true;\n\n // Special handling for Map\n if (isMap(value)) {\n const entries = Array.from(value);\n\n const entriesStr = prettyPrintObject\n ? JSON.stringify(entries, undefined, 2)\n : JSON.stringify(entries);\n\n return `Map(${entriesStr})`;\n }\n\n // Special handling for Set\n if (isSet(value)) {\n const values = Array.from(value);\n\n const valuesStr = prettyPrintObject\n ? JSON.stringify(values, undefined, 2)\n : JSON.stringify(values);\n\n return `Set(${valuesStr})`;\n }\n\n return prettyPrintObject\n ? JSON.stringify(value, undefined, 2)\n : JSON.stringify(value);\n } catch (error) {\n return isError(error)\n ? error.message\n : '[Circular or Non-serializable]';\n }\n }\n }\n};\n"],"names":[],"mappings":";;AAoCO,MAAM,eAAA,GAAkB,CAC7B,KAAA,EACA,OAAA,KACW;AACX,EAAA,QAAQ,OAAO,KAAA;AAAO,IACpB,KAAK,QAAA;AACH,MAAA,OAAO,KAAA;AAAA,IAET,KAAK,QAAA;AACH,MAAA,OAAO,CAAA,EAAG,KAAA,CAAM,QAAA,EAAU,CAAA,CAAA,CAAA;AAAA,IAE5B,KAAK,QAAA;AAAA,IACL,KAAK,SAAA;AAAA,IACL,KAAK,QAAA;AAAA,IACL,KAAK,UAAA;AACH,MAAA,OAAO,MAAM,QAAA,EAAS;AAAA,IAExB,KAAK,WAAA;AACH,MAAA,OAAO,WAAA;AAAA,IAET,KAAK,QAAA,EAAU;AACb,MAAA,IAAI,UAAU,IAAA,EAAM;AAClB,QAAA,OAAO,MAAA;AAAA,MACT;AAEA,MAAA,IAAI;AAEF,QAAA,IAAI,MAAA,CAAO,KAAK,CAAA,EAAG;AACjB,UAAA,OAAO,MAAM,WAAA,EAAY;AAAA,QAC3B;AAGA,QAAA,IAAI,QAAA,CAAS,KAAK,CAAA,EAAG;AACnB,UAAA,OAAO,MAAM,QAAA,EAAS;AAAA,QACxB;AAEA,QAAA,IAAI,OAAA,CAAQ,KAAK,CAAA,EAAG;AAClB,UAAA,OAAO,KAAA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,CAAC,EAChC,UAAU,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,KAAK,IAAI,KAC5E,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAIK,CAAC"}
1
+ {"version":3,"file":"promise.d.mts","sourceRoot":"","sources":["../../src/promise/promise.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,CAAC,YACtB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,KAAK,IAAI,KAC5E,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAIK,CAAC"}
@@ -1,55 +1,10 @@
1
1
  import { fromPromise } from '../functional/result/impl/result-from-promise.mjs';
2
2
  import '@sindresorhus/is';
3
3
 
4
- /**
5
- * Creates a Promise that wraps the result in a Result type for type-safe error
6
- * handling. This function is an alternative to `new Promise(executor)` that
7
- * provides enhanced type safety by returning a Result type instead of throwing
8
- * exceptions.
9
- *
10
- * @example
11
- *
12
- * ```ts
13
- * // Create a promise that resolves successfully
14
- * const successPromise = createPromise<number, string>((resolve) => {
15
- * setTimeout(() => {
16
- * resolve(42);
17
- * }, 0);
18
- * });
19
- *
20
- * const successResult = await successPromise;
21
- *
22
- * assert.isTrue(Result.isOk(successResult));
23
- *
24
- * if (Result.isOk(successResult)) {
25
- * assert.isTrue(successResult.value === 42);
26
- * }
27
- *
28
- * // Create a promise that rejects with an error
29
- * const errorPromise = createPromise<number, string>((_, reject) => {
30
- * setTimeout(() => {
31
- * reject('Something went wrong');
32
- * }, 0);
33
- * });
34
- *
35
- * const errorResult = await errorPromise;
36
- *
37
- * assert.isTrue(Result.isErr(errorResult));
38
- *
39
- * if (Result.isErr(errorResult)) {
40
- * assert.isTrue(errorResult.value === 'Something went wrong');
41
- * }
42
- * ```
43
- *
44
- * @template S - The type of successful value
45
- * @template E - The type of error value
46
- * @param executor - Function that takes resolve and reject callbacks
47
- * @returns A Promise that resolves to a Result containing either success or
48
- * error
49
- */
50
- const createPromise = (executor) =>
51
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion
52
- fromPromise(new Promise(executor));
4
+ const createPromise = (executor) => (
5
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
6
+ fromPromise(new Promise(executor))
7
+ );
53
8
 
54
9
  export { createPromise };
55
10
  //# sourceMappingURL=promise.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"promise.mjs","sources":["../../src/promise/promise.mts"],"sourcesContent":[null],"names":["Result.fromPromise"],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CG;AACI,MAAM,aAAa,GAAG,CAC3B,QAA6E;AAE7E;AACAA,WAAkB,CAAC,IAAI,OAAO,CAAI,QAAQ,CAAC;;;;"}
1
+ {"version":3,"file":"promise.mjs","sources":["../../src/promise/promise.mts"],"sourcesContent":["import { Result } from '../functional/index.mjs';\n\n/**\n * Creates a Promise that wraps the result in a Result type for type-safe error\n * handling. This function is an alternative to `new Promise(executor)` that\n * provides enhanced type safety by returning a Result type instead of throwing\n * exceptions.\n *\n * @example\n *\n * ```ts\n * // Create a promise that resolves successfully\n * const successPromise = createPromise<number, string>((resolve) => {\n * setTimeout(() => {\n * resolve(42);\n * }, 0);\n * });\n *\n * const successResult = await successPromise;\n *\n * assert.isTrue(Result.isOk(successResult));\n *\n * if (Result.isOk(successResult)) {\n * assert.isTrue(successResult.value === 42);\n * }\n *\n * // Create a promise that rejects with an error\n * const errorPromise = createPromise<number, string>((_, reject) => {\n * setTimeout(() => {\n * reject('Something went wrong');\n * }, 0);\n * });\n *\n * const errorResult = await errorPromise;\n *\n * assert.isTrue(Result.isErr(errorResult));\n *\n * if (Result.isErr(errorResult)) {\n * assert.isTrue(errorResult.value === 'Something went wrong');\n * }\n * ```\n *\n * @template S - The type of successful value\n * @template E - The type of error value\n * @param executor - Function that takes resolve and reject callbacks\n * @returns A Promise that resolves to a Result containing either success or\n * error\n */\nexport const createPromise = <S, E>(\n executor: (resolve: (value: S) => void, reject: (reason?: E) => void) => void,\n): Promise<Result<S, E>> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Result.fromPromise(new Promise<S>(executor)) satisfies Promise<\n Result<S, unknown>\n > as Promise<Result<S, E>>;\n"],"names":["Result.fromPromise"],"mappings":";;;AAgDO,MAAM,gBAAgB,CAC3B,QAAA;AAAA;AAAA,EAGAA,WAAO,CAAY,IAAI,OAAA,CAAW,QAAQ,CAAC;AAAA;;;;"}