ts-data-forge 9.0.0 → 10.0.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 (447) hide show
  1. package/README.md +1 -1
  2. package/dist/array/impl/array-utils-creation.d.mts +4 -4
  3. package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
  4. package/dist/array/impl/array-utils-creation.mjs +17 -112
  5. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  6. package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
  7. package/dist/array/impl/array-utils-element-access.mjs +22 -61
  8. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  9. package/dist/array/impl/array-utils-iterators.d.mts.map +1 -1
  10. package/dist/array/impl/array-utils-iterators.mjs +9 -63
  11. package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
  12. package/dist/array/impl/array-utils-modification.d.mts +7 -7
  13. package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
  14. package/dist/array/impl/array-utils-modification.mjs +78 -78
  15. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  16. package/dist/array/impl/array-utils-reducing-value.mjs +95 -89
  17. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  18. package/dist/array/impl/array-utils-search.mjs +100 -92
  19. package/dist/array/impl/array-utils-search.mjs.map +1 -1
  20. package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
  21. package/dist/array/impl/array-utils-set-op.mjs +31 -141
  22. package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
  23. package/dist/array/impl/array-utils-size.d.mts.map +1 -1
  24. package/dist/array/impl/array-utils-size.mjs +4 -8
  25. package/dist/array/impl/array-utils-size.mjs.map +1 -1
  26. package/dist/array/impl/array-utils-slice-clamped.mjs +11 -12
  27. package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
  28. package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
  29. package/dist/array/impl/array-utils-slicing.mjs +44 -96
  30. package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
  31. package/dist/array/impl/array-utils-transformation.d.mts +4 -4
  32. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
  33. package/dist/array/impl/array-utils-transformation.mjs +150 -292
  34. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  35. package/dist/array/impl/array-utils-validation.d.mts +17 -17
  36. package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
  37. package/dist/array/impl/array-utils-validation.mjs +23 -174
  38. package/dist/array/impl/array-utils-validation.mjs.map +1 -1
  39. package/dist/array/impl/index.mjs +1 -1
  40. package/dist/collections/imap-mapped.d.mts.map +1 -1
  41. package/dist/collections/imap-mapped.mjs +243 -330
  42. package/dist/collections/imap-mapped.mjs.map +1 -1
  43. package/dist/collections/imap.d.mts.map +1 -1
  44. package/dist/collections/imap.mjs +190 -275
  45. package/dist/collections/imap.mjs.map +1 -1
  46. package/dist/collections/iset-mapped.d.mts +1 -1
  47. package/dist/collections/iset-mapped.d.mts.map +1 -1
  48. package/dist/collections/iset-mapped.mjs +222 -444
  49. package/dist/collections/iset-mapped.mjs.map +1 -1
  50. package/dist/collections/iset.d.mts +1 -1
  51. package/dist/collections/iset.d.mts.map +1 -1
  52. package/dist/collections/iset.mjs +158 -324
  53. package/dist/collections/iset.mjs.map +1 -1
  54. package/dist/collections/queue.d.mts.map +1 -1
  55. package/dist/collections/queue.mjs +106 -178
  56. package/dist/collections/queue.mjs.map +1 -1
  57. package/dist/collections/stack.d.mts.map +1 -1
  58. package/dist/collections/stack.mjs +95 -165
  59. package/dist/collections/stack.mjs.map +1 -1
  60. package/dist/entry-point.mjs +2 -0
  61. package/dist/entry-point.mjs.map +1 -1
  62. package/dist/expect-type.d.mts +1 -1
  63. package/dist/expect-type.d.mts.map +1 -1
  64. package/dist/expect-type.mjs +1 -69
  65. package/dist/expect-type.mjs.map +1 -1
  66. package/dist/functional/match.mjs +9 -9
  67. package/dist/functional/match.mjs.map +1 -1
  68. package/dist/functional/optional/impl/optional-expect-to-be.mjs +13 -14
  69. package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
  70. package/dist/functional/optional/impl/optional-filter.mjs +14 -15
  71. package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
  72. package/dist/functional/optional/impl/optional-flat-map.mjs +10 -11
  73. package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
  74. package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +1 -1
  75. package/dist/functional/optional/impl/optional-from-nullable.mjs +1 -25
  76. package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
  77. package/dist/functional/optional/impl/optional-is-none.d.mts.map +1 -1
  78. package/dist/functional/optional/impl/optional-is-none.mjs +0 -19
  79. package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -1
  80. package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -1
  81. package/dist/functional/optional/impl/optional-is-optional.mjs +1 -23
  82. package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
  83. package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -1
  84. package/dist/functional/optional/impl/optional-is-some.mjs +0 -20
  85. package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
  86. package/dist/functional/optional/impl/optional-map.mjs +13 -14
  87. package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
  88. package/dist/functional/optional/impl/optional-none.mjs +0 -16
  89. package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
  90. package/dist/functional/optional/impl/optional-or-else.mjs +10 -11
  91. package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
  92. package/dist/functional/optional/impl/optional-some.d.mts.map +1 -1
  93. package/dist/functional/optional/impl/optional-some.mjs +2 -21
  94. package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
  95. package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -1
  96. package/dist/functional/optional/impl/optional-to-nullable.mjs +1 -27
  97. package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
  98. package/dist/functional/optional/impl/optional-unwrap-or.mjs +9 -10
  99. package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
  100. package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -1
  101. package/dist/functional/optional/impl/optional-unwrap-throw.mjs +4 -32
  102. package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
  103. package/dist/functional/optional/impl/optional-unwrap.mjs +4 -4
  104. package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
  105. package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -1
  106. package/dist/functional/optional/impl/optional-zip.mjs +1 -35
  107. package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
  108. package/dist/functional/optional/impl/tag.mjs +2 -3
  109. package/dist/functional/optional/impl/tag.mjs.map +1 -1
  110. package/dist/functional/pipe.d.mts.map +1 -1
  111. package/dist/functional/pipe.mjs +9 -34
  112. package/dist/functional/pipe.mjs.map +1 -1
  113. package/dist/functional/result/impl/result-err.d.mts.map +1 -1
  114. package/dist/functional/result/impl/result-err.mjs +2 -27
  115. package/dist/functional/result/impl/result-err.mjs.map +1 -1
  116. package/dist/functional/result/impl/result-expect-to-be.mjs +13 -15
  117. package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
  118. package/dist/functional/result/impl/result-flat-map.mjs +16 -16
  119. package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
  120. package/dist/functional/result/impl/result-fold.mjs +16 -16
  121. package/dist/functional/result/impl/result-fold.mjs.map +1 -1
  122. package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -1
  123. package/dist/functional/result/impl/result-from-promise.mjs +4 -31
  124. package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
  125. package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -1
  126. package/dist/functional/result/impl/result-from-throwable.mjs +8 -38
  127. package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
  128. package/dist/functional/result/impl/result-is-err.d.mts.map +1 -1
  129. package/dist/functional/result/impl/result-is-err.mjs +0 -19
  130. package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
  131. package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -1
  132. package/dist/functional/result/impl/result-is-ok.mjs +0 -19
  133. package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
  134. package/dist/functional/result/impl/result-is-result.d.mts.map +1 -1
  135. package/dist/functional/result/impl/result-is-result.mjs +1 -23
  136. package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
  137. package/dist/functional/result/impl/result-map-err.mjs +16 -16
  138. package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
  139. package/dist/functional/result/impl/result-map.mjs +16 -16
  140. package/dist/functional/result/impl/result-map.mjs.map +1 -1
  141. package/dist/functional/result/impl/result-ok.d.mts.map +1 -1
  142. package/dist/functional/result/impl/result-ok.mjs +2 -27
  143. package/dist/functional/result/impl/result-ok.mjs.map +1 -1
  144. package/dist/functional/result/impl/result-or-else.mjs +10 -12
  145. package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
  146. package/dist/functional/result/impl/result-swap.d.mts.map +1 -1
  147. package/dist/functional/result/impl/result-swap.mjs +4 -22
  148. package/dist/functional/result/impl/result-swap.mjs.map +1 -1
  149. package/dist/functional/result/impl/result-to-optional.d.mts.map +1 -1
  150. package/dist/functional/result/impl/result-to-optional.mjs +0 -27
  151. package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
  152. package/dist/functional/result/impl/result-unwrap-err-or.mjs +9 -11
  153. package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
  154. package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +1 -1
  155. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +13 -40
  156. package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
  157. package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -1
  158. package/dist/functional/result/impl/result-unwrap-err.mjs +4 -32
  159. package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
  160. package/dist/functional/result/impl/result-unwrap-ok-or.mjs +9 -11
  161. package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
  162. package/dist/functional/result/impl/result-unwrap-ok.mjs +4 -4
  163. package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
  164. package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -1
  165. package/dist/functional/result/impl/result-unwrap-throw.mjs +4 -35
  166. package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
  167. package/dist/functional/result/impl/result-zip.d.mts.map +1 -1
  168. package/dist/functional/result/impl/result-zip.mjs +1 -34
  169. package/dist/functional/result/impl/result-zip.mjs.map +1 -1
  170. package/dist/functional/result/impl/tag.mjs +2 -3
  171. package/dist/functional/result/impl/tag.mjs.map +1 -1
  172. package/dist/functional/ternary-result/impl/tag.mjs +3 -5
  173. package/dist/functional/ternary-result/impl/tag.mjs.map +1 -1
  174. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -1
  175. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +2 -15
  176. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
  177. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +13 -13
  178. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
  179. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +27 -26
  180. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
  181. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +21 -22
  182. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
  183. package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +1 -1
  184. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +4 -20
  185. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
  186. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -1
  187. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +7 -25
  188. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
  189. package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts.map +1 -1
  190. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +0 -17
  191. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -1
  192. package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +1 -1
  193. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +0 -19
  194. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -1
  195. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +1 -1
  196. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +1 -25
  197. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -1
  198. package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +1 -1
  199. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +0 -18
  200. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
  201. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +13 -15
  202. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
  203. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +18 -18
  204. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
  205. package/dist/functional/ternary-result/impl/ternary-result-map.mjs +21 -22
  206. package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
  207. package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -1
  208. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +2 -16
  209. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
  210. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +9 -9
  211. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
  212. package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +1 -1
  213. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +4 -22
  214. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -1
  215. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +9 -9
  216. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -1
  217. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +1 -1
  218. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +12 -27
  219. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
  220. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +1 -1
  221. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +4 -19
  222. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -1
  223. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +9 -9
  224. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -1
  225. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +4 -5
  226. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
  227. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -1
  228. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +15 -27
  229. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
  230. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +9 -9
  231. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -1
  232. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +1 -1
  233. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +10 -24
  234. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
  235. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +1 -1
  236. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +4 -19
  237. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
  238. package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -1
  239. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +3 -19
  240. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
  241. package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -1
  242. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +14 -45
  243. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
  244. package/dist/functional/ternary-result/impl/variant-name.d.mts +1 -1
  245. package/dist/functional/ternary-result/impl/variant-name.d.mts.map +1 -1
  246. package/dist/functional/ternary-result/impl/variant-name.mjs +8 -9
  247. package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -1
  248. package/dist/guard/as-length-bounded-array.d.mts +117 -0
  249. package/dist/guard/as-length-bounded-array.d.mts.map +1 -0
  250. package/dist/guard/as-length-bounded-array.mjs +37 -0
  251. package/dist/guard/as-length-bounded-array.mjs.map +1 -0
  252. package/dist/guard/has-key.d.mts.map +1 -1
  253. package/dist/guard/has-key.mjs +0 -41
  254. package/dist/guard/has-key.mjs.map +1 -1
  255. package/dist/guard/index.d.mts +2 -0
  256. package/dist/guard/index.d.mts.map +1 -1
  257. package/dist/guard/index.mjs +2 -0
  258. package/dist/guard/index.mjs.map +1 -1
  259. package/dist/guard/is-length-bounded-array.d.mts +159 -0
  260. package/dist/guard/is-length-bounded-array.d.mts.map +1 -0
  261. package/dist/guard/is-length-bounded-array.mjs +7 -0
  262. package/dist/guard/is-length-bounded-array.mjs.map +1 -0
  263. package/dist/guard/is-length-bounded-string.d.mts +5 -6
  264. package/dist/guard/is-length-bounded-string.d.mts.map +1 -1
  265. package/dist/guard/is-length-bounded-string.mjs +0 -157
  266. package/dist/guard/is-length-bounded-string.mjs.map +1 -1
  267. package/dist/guard/is-non-empty-string.d.mts +1 -1
  268. package/dist/guard/is-non-empty-string.d.mts.map +1 -1
  269. package/dist/guard/is-non-empty-string.mjs +1 -38
  270. package/dist/guard/is-non-empty-string.mjs.map +1 -1
  271. package/dist/guard/is-non-null-object.d.mts.map +1 -1
  272. package/dist/guard/is-non-null-object.mjs +1 -35
  273. package/dist/guard/is-non-null-object.mjs.map +1 -1
  274. package/dist/guard/is-primitive.d.mts.map +1 -1
  275. package/dist/guard/is-primitive.mjs +12 -43
  276. package/dist/guard/is-primitive.mjs.map +1 -1
  277. package/dist/guard/is-record.d.mts.map +1 -1
  278. package/dist/guard/is-record.mjs +0 -86
  279. package/dist/guard/is-record.mjs.map +1 -1
  280. package/dist/guard/is-type.d.mts.map +1 -1
  281. package/dist/guard/is-type.mjs +12 -399
  282. package/dist/guard/is-type.mjs.map +1 -1
  283. package/dist/guard/key-is-in.d.mts.map +1 -1
  284. package/dist/guard/key-is-in.mjs +0 -40
  285. package/dist/guard/key-is-in.mjs.map +1 -1
  286. package/dist/index.mjs +2 -0
  287. package/dist/index.mjs.map +1 -1
  288. package/dist/iterator/range.mjs +16 -16
  289. package/dist/iterator/range.mjs.map +1 -1
  290. package/dist/json/json.d.mts.map +1 -1
  291. package/dist/json/json.mjs +52 -340
  292. package/dist/json/json.mjs.map +1 -1
  293. package/dist/number/branded-types/finite-number.d.mts +3 -3
  294. package/dist/number/branded-types/finite-number.mjs +135 -154
  295. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  296. package/dist/number/branded-types/int.d.mts +4 -4
  297. package/dist/number/branded-types/int.mjs +205 -245
  298. package/dist/number/branded-types/int.mjs.map +1 -1
  299. package/dist/number/branded-types/int16.d.mts +15 -15
  300. package/dist/number/branded-types/int16.mjs +116 -123
  301. package/dist/number/branded-types/int16.mjs.map +1 -1
  302. package/dist/number/branded-types/int32.d.mts +11 -11
  303. package/dist/number/branded-types/int32.mjs +116 -123
  304. package/dist/number/branded-types/int32.mjs.map +1 -1
  305. package/dist/number/branded-types/negative-finite-number.d.mts +4 -4
  306. package/dist/number/branded-types/negative-finite-number.mjs +129 -144
  307. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  308. package/dist/number/branded-types/negative-int.d.mts +5 -5
  309. package/dist/number/branded-types/negative-int.mjs +94 -113
  310. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  311. package/dist/number/branded-types/negative-safe-int.d.mts +5 -5
  312. package/dist/number/branded-types/negative-safe-int.mjs +103 -124
  313. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  314. package/dist/number/branded-types/non-negative-finite-number.d.mts +5 -5
  315. package/dist/number/branded-types/non-negative-finite-number.mjs +136 -142
  316. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  317. package/dist/number/branded-types/non-negative-int16.d.mts +16 -16
  318. package/dist/number/branded-types/non-negative-int16.mjs +109 -118
  319. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  320. package/dist/number/branded-types/non-negative-int32.d.mts +12 -12
  321. package/dist/number/branded-types/non-negative-int32.mjs +110 -119
  322. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  323. package/dist/number/branded-types/non-positive-finite-number.d.mts +3 -3
  324. package/dist/number/branded-types/non-positive-finite-number.mjs +120 -124
  325. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  326. package/dist/number/branded-types/non-positive-int.d.mts +4 -4
  327. package/dist/number/branded-types/non-positive-int.mjs +167 -212
  328. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  329. package/dist/number/branded-types/non-positive-safe-int.d.mts +4 -4
  330. package/dist/number/branded-types/non-positive-safe-int.mjs +95 -106
  331. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  332. package/dist/number/branded-types/non-zero-finite-number.d.mts +4 -4
  333. package/dist/number/branded-types/non-zero-finite-number.mjs +114 -123
  334. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  335. package/dist/number/branded-types/non-zero-int.d.mts +2 -2
  336. package/dist/number/branded-types/non-zero-int.mjs +72 -83
  337. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  338. package/dist/number/branded-types/non-zero-int16.d.mts +7 -7
  339. package/dist/number/branded-types/non-zero-int16.mjs +96 -107
  340. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  341. package/dist/number/branded-types/non-zero-int32.d.mts +5 -5
  342. package/dist/number/branded-types/non-zero-int32.mjs +97 -108
  343. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  344. package/dist/number/branded-types/non-zero-safe-int.d.mts +2 -2
  345. package/dist/number/branded-types/non-zero-safe-int.mjs +100 -111
  346. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  347. package/dist/number/branded-types/non-zero-uint16.d.mts +8 -8
  348. package/dist/number/branded-types/non-zero-uint16.mjs +96 -107
  349. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  350. package/dist/number/branded-types/non-zero-uint32.d.mts +6 -6
  351. package/dist/number/branded-types/non-zero-uint32.mjs +96 -107
  352. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  353. package/dist/number/branded-types/positive-finite-number.d.mts +8 -8
  354. package/dist/number/branded-types/positive-finite-number.mjs +139 -141
  355. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  356. package/dist/number/branded-types/positive-int.d.mts +11 -11
  357. package/dist/number/branded-types/positive-int.mjs +228 -271
  358. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  359. package/dist/number/branded-types/positive-int16.d.mts +19 -19
  360. package/dist/number/branded-types/positive-int16.mjs +109 -118
  361. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  362. package/dist/number/branded-types/positive-int32.d.mts +15 -15
  363. package/dist/number/branded-types/positive-int32.mjs +109 -118
  364. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  365. package/dist/number/branded-types/positive-safe-int.d.mts +11 -11
  366. package/dist/number/branded-types/positive-safe-int.mjs +244 -275
  367. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  368. package/dist/number/branded-types/positive-uint16.d.mts +17 -17
  369. package/dist/number/branded-types/positive-uint16.mjs +109 -118
  370. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  371. package/dist/number/branded-types/positive-uint32.d.mts +13 -13
  372. package/dist/number/branded-types/positive-uint32.mjs +110 -119
  373. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  374. package/dist/number/branded-types/safe-int.d.mts +4 -4
  375. package/dist/number/branded-types/safe-int.mjs +251 -292
  376. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  377. package/dist/number/branded-types/safe-uint.d.mts +8 -8
  378. package/dist/number/branded-types/safe-uint.mjs +111 -119
  379. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  380. package/dist/number/branded-types/uint.d.mts +8 -8
  381. package/dist/number/branded-types/uint.mjs +198 -225
  382. package/dist/number/branded-types/uint.mjs.map +1 -1
  383. package/dist/number/branded-types/uint16.d.mts +14 -14
  384. package/dist/number/branded-types/uint16.mjs +109 -119
  385. package/dist/number/branded-types/uint16.mjs.map +1 -1
  386. package/dist/number/branded-types/uint32.d.mts +10 -10
  387. package/dist/number/branded-types/uint32.mjs +110 -117
  388. package/dist/number/branded-types/uint32.mjs.map +1 -1
  389. package/dist/number/enum/int8.mjs +119 -145
  390. package/dist/number/enum/int8.mjs.map +1 -1
  391. package/dist/number/enum/uint8.mjs +107 -121
  392. package/dist/number/enum/uint8.mjs.map +1 -1
  393. package/dist/number/num.d.mts +2 -2
  394. package/dist/number/num.d.mts.map +1 -1
  395. package/dist/number/num.mjs +76 -537
  396. package/dist/number/num.mjs.map +1 -1
  397. package/dist/number/refined-number-utils.d.mts +1 -1
  398. package/dist/number/refined-number-utils.d.mts.map +1 -1
  399. package/dist/number/refined-number-utils.mjs +127 -263
  400. package/dist/number/refined-number-utils.mjs.map +1 -1
  401. package/dist/object/object.d.mts.map +1 -1
  402. package/dist/object/object.mjs +107 -222
  403. package/dist/object/object.mjs.map +1 -1
  404. package/dist/others/cast-mutable.d.mts.map +1 -1
  405. package/dist/others/cast-mutable.mjs +8 -37
  406. package/dist/others/cast-mutable.mjs.map +1 -1
  407. package/dist/others/cast-readonly.d.mts.map +1 -1
  408. package/dist/others/cast-readonly.mjs +8 -36
  409. package/dist/others/cast-readonly.mjs.map +1 -1
  410. package/dist/others/debounce-function.d.mts.map +1 -1
  411. package/dist/others/debounce-function.mjs +7 -16
  412. package/dist/others/debounce-function.mjs.map +1 -1
  413. package/dist/others/fast-deep-equal.d.mts.map +1 -1
  414. package/dist/others/fast-deep-equal.mjs +43 -59
  415. package/dist/others/fast-deep-equal.mjs.map +1 -1
  416. package/dist/others/if-then.d.mts.map +1 -1
  417. package/dist/others/if-then.mjs +0 -29
  418. package/dist/others/if-then.mjs.map +1 -1
  419. package/dist/others/map-nullable.mjs +9 -9
  420. package/dist/others/map-nullable.mjs.map +1 -1
  421. package/dist/others/memoize-function.mjs +12 -12
  422. package/dist/others/memoize-function.mjs.map +1 -1
  423. package/dist/others/tuple.d.mts.map +1 -1
  424. package/dist/others/tuple.mjs +0 -50
  425. package/dist/others/tuple.mjs.map +1 -1
  426. package/dist/others/unknown-to-string.d.mts.map +1 -1
  427. package/dist/others/unknown-to-string.mjs +41 -88
  428. package/dist/others/unknown-to-string.mjs.map +1 -1
  429. package/dist/promise/promise.d.mts.map +1 -1
  430. package/dist/promise/promise.mjs +4 -49
  431. package/dist/promise/promise.mjs.map +1 -1
  432. package/package.json +14 -13
  433. package/src/array/impl/array-utils-creation.mts +3 -3
  434. package/src/array/impl/array-utils-modification.mts +7 -7
  435. package/src/array/impl/array-utils-modification.test.mts +4 -4
  436. package/src/array/impl/array-utils-transformation.mts +4 -4
  437. package/src/array/impl/array-utils-transformation.test.mts +7 -7
  438. package/src/array/impl/array-utils-validation.mts +24 -24
  439. package/src/array/impl/array-utils-validation.test.mts +94 -92
  440. package/src/collections/queue.test.mts +1 -1
  441. package/src/guard/as-length-bounded-array.mts +190 -0
  442. package/src/guard/as-length-bounded-array.test.mts +118 -0
  443. package/src/guard/index.mts +2 -0
  444. package/src/guard/is-length-bounded-array.mts +195 -0
  445. package/src/guard/is-length-bounded-array.test.mts +169 -0
  446. package/src/guard/is-length-bounded-string.mts +6 -6
  447. package/src/object/object.test.mts +3 -3
@@ -3,24 +3,24 @@ import { isOk } from './result-is-ok.mjs';
3
3
  import { ok } from './result-ok.mjs';
4
4
 
5
5
  function fold(...args) {
6
- switch (args.length) {
7
- case 3: {
8
- // Direct version: first argument is result
9
- const [result, mapFn, mapErrFn] = args;
10
- return foldImpl(result, mapFn, mapErrFn);
11
- }
12
- case 2: {
13
- // Curried version
14
- const [mapFn, mapErrFn] = args;
15
- return (result) => foldImpl(result, mapFn, mapErrFn);
16
- }
6
+ switch (args.length) {
7
+ case 3: {
8
+ const [result, mapFn, mapErrFn] = args;
9
+ return foldImpl(result, mapFn, mapErrFn);
17
10
  }
11
+ case 2: {
12
+ const [mapFn, mapErrFn] = args;
13
+ return (result) => foldImpl(result, mapFn, mapErrFn);
14
+ }
15
+ }
18
16
  }
19
- const foldImpl = (result, mapFn, mapErrFn) => isOk(result)
20
- ? // eslint-disable-next-line total-functions/no-unsafe-type-assertion
21
- ok(mapFn(result.value))
22
- : // eslint-disable-next-line total-functions/no-unsafe-type-assertion
23
- err(mapErrFn(result.value));
17
+ const foldImpl = (result, mapFn, mapErrFn) => isOk(result) ? (
18
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
19
+ ok(mapFn(result.value))
20
+ ) : (
21
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
22
+ err(mapErrFn(result.value))
23
+ );
24
24
 
25
25
  export { fold };
26
26
  //# sourceMappingURL=result-fold.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"result-fold.mjs","sources":["../../../../src/functional/result/impl/result-fold.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AA+DM,SAAU,IAAI,CAClB,GAAG,IASE,EAAA;AAEL,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;;YAEN,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAI;YAEtC,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC;QAC1C;QAEA,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAI;AAE9B,YAAA,OAAO,CAAC,MAAS,KAAK,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC;QACzD;;AAEJ;AAEA,MAAM,QAAQ,GAAG,CACf,MAAS,EACT,KAAiC,EACjC,QAAqC,KAErC,IAAI,CAAC,MAAM;AACT;AACE,QAAA,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAoB,CAAC;AACvC;QACE,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAqB,CAAC,CAAC;;;;"}
1
+ {"version":3,"file":"result-fold.mjs","sources":["../../../../src/functional/result/impl/result-fold.mts"],"sourcesContent":["import { type Result, type UnknownResult } from '../result.mjs';\nimport { err } from './result-err.mjs';\nimport { isOk } from './result-is-ok.mjs';\nimport { ok } from './result-ok.mjs';\nimport { type UnwrapErr, type UnwrapOk } from './types.mjs';\n\n/**\n * Applies one of two functions depending on whether the `Result` is `Ok` or\n * `Err`.\n *\n * @example\n *\n * ```ts\n * const okValue = Result.ok(2);\n *\n * const errValue = Result.err('bad');\n *\n * const foldedOk = Result.fold(\n * okValue,\n * (value) => value * 2,\n * (error) => error,\n * );\n *\n * const foldedErr = Result.fold(\n * errValue,\n * (value: number) => value * 2,\n * (error) => error.toUpperCase(),\n * );\n *\n * assert.deepStrictEqual(foldedOk, Result.ok(4));\n *\n * assert.deepStrictEqual(foldedErr, Result.err('BAD'));\n *\n * const foldNumbers = Result.fold(\n * (value: number) => value * 3,\n * (error: string) => error.length,\n * );\n *\n * assert.deepStrictEqual(foldNumbers(Result.ok(3)), Result.ok(9));\n *\n * assert.deepStrictEqual(foldNumbers(Result.err('oops')), Result.err(4));\n * ```\n *\n * @template R The input `UnknownResult` type.\n * @template S2 The type of the success value returned by `mapFn`.\n * @template E2 The type of the error value returned by `mapErrFn`.\n * @param result The `Result` to fold.\n * @param mapFn The function to apply if `result` is `Ok`.\n * @param mapErrFn The function to apply if `result` is `Err`.\n * @returns A new `Result<S2, E2>` based on the applied function.\n */\nexport function fold<R extends UnknownResult, S2, E2>(\n result: R,\n mapFn: (value: UnwrapOk<R>) => S2,\n mapErrFn: (error: UnwrapErr<R>) => E2,\n): Result<S2, E2>;\n\n// Curried version\nexport function fold<S, E, S2, E2>(\n mapFn: (value: S) => S2,\n mapErrFn: (error: E) => E2,\n): (result: Result<S, E>) => Result<S2, E2>;\n\nexport function fold<R extends UnknownResult, S2, E2>(\n ...args:\n | readonly [\n result: R,\n mapFn: (value: UnwrapOk<R>) => S2,\n mapErrFn: (error: UnwrapErr<R>) => E2,\n ]\n | readonly [\n mapFn: (value: UnwrapOk<R>) => S2,\n mapErrFn: (error: UnwrapErr<R>) => E2,\n ]\n): Result<S2, E2> | ((result: R) => Result<S2, E2>) {\n switch (args.length) {\n case 3: {\n // Direct version: first argument is result\n const [result, mapFn, mapErrFn] = args;\n\n return foldImpl(result, mapFn, mapErrFn);\n }\n\n case 2: {\n // Curried version\n const [mapFn, mapErrFn] = args;\n\n return (result: R) => foldImpl(result, mapFn, mapErrFn);\n }\n }\n}\n\nconst foldImpl = <R extends UnknownResult, S2, E2>(\n result: R,\n mapFn: (value: UnwrapOk<R>) => S2,\n mapErrFn: (error: UnwrapErr<R>) => E2,\n): Result<S2, E2> =>\n isOk(result)\n ? // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n ok(mapFn(result.value as UnwrapOk<R>))\n : // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n err(mapErrFn(result.value as UnwrapErr<R>));\n"],"names":[],"mappings":";;;;AA+DO,SAAS,QACX,IAAA,EAU+C;AAClD,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,MAAA,EAAQ,KAAA,EAAO,QAAQ,CAAA,GAAI,IAAA;AAElC,MAAA,OAAO,QAAA,CAAS,MAAA,EAAQ,KAAA,EAAO,QAAQ,CAAA;AAAA,IACzC;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,IAAA;AAE1B,MAAA,OAAO,CAAC,MAAA,KAAc,QAAA,CAAS,MAAA,EAAQ,OAAO,QAAQ,CAAA;AAAA,IACxD;AAAA;AAEJ;AAEA,MAAM,WAAW,CACf,MAAA,EACA,KAAA,EACA,QAAA,KAEA,KAAK,MAAM,CAAA;AAAA;AAAA,EAEP,EAAA,CAAG,KAAA,CAAM,MAAA,CAAO,KAAoB,CAAC;AAAA;AAAA;AAAA,EAErC,GAAA,CAAI,QAAA,CAAS,MAAA,CAAO,KAAqB,CAAC;AAAA,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"result-from-promise.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-from-promise.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C;;;;GAIG;AACH,KAAK,aAAa,CAAC,CAAC,SAAS,OAAO,CAAC,OAAO,CAAC,IAC3C,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,OAAO,CAAC,OAAO,CAAC,EACpD,SAAS,CAAC,KACT,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAEmB,CAAC"}
1
+ {"version":3,"file":"result-from-promise.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-from-promise.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C;;;;GAIG;AACH,KAAK,aAAa,CAAC,CAAC,SAAS,OAAO,CAAC,OAAO,CAAC,IAC3C,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,OAAO,CAAC,OAAO,CAAC,WAC3C,CAAC,KACT,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAEmB,CAAC"}
@@ -1,37 +1,10 @@
1
1
  import { err } from './result-err.mjs';
2
2
  import { ok } from './result-ok.mjs';
3
3
 
4
- /**
5
- * Converts a Promise into a Promise that resolves to a `Result`. If the input
6
- * Promise resolves, the `Result` will be `Ok` with the resolved value. If the
7
- * input Promise rejects, the `Result` will be `Err` with the rejection
8
- * reason.
9
- *
10
- * @example
11
- *
12
- * ```ts
13
- * const successPromise = Result.fromPromise(Promise.resolve('ok'));
14
- *
15
- * const failurePromise = Result.fromPromise(
16
- * Promise.reject(new Error('fail')),
17
- * );
18
- *
19
- * const resolved = await successPromise;
20
- *
21
- * const rejected = await failurePromise;
22
- *
23
- * assert.deepStrictEqual(resolved, Result.ok('ok'));
24
- *
25
- * assert.isTrue(Result.isErr(rejected));
26
- * ```
27
- *
28
- * @template P The type of the input Promise.
29
- * @param promise The Promise to convert.
30
- * @returns A Promise that resolves to `Result<UnwrapPromise<P>, unknown>`.
31
- */
32
- const fromPromise = (promise) =>
33
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion
34
- promise.then((v) => ok(v)).catch(err);
4
+ const fromPromise = (promise) => (
5
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
6
+ promise.then((v) => ok(v)).catch(err)
7
+ );
35
8
 
36
9
  export { fromPromise };
37
10
  //# sourceMappingURL=result-from-promise.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"result-from-promise.mjs","sources":["../../../../src/functional/result/impl/result-from-promise.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACI,MAAM,WAAW,GAAG,CACzB,OAAU;AAEV;AACA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAyB,CAAC,CAAC,KAAK,CAAC,GAAG;;;;"}
1
+ {"version":3,"file":"result-from-promise.mjs","sources":["../../../../src/functional/result/impl/result-from-promise.mts"],"sourcesContent":["import { type Ok } from '../../../types.mjs';\nimport { type Result } from '../result.mjs';\nimport { err } from './result-err.mjs';\nimport { ok } from './result-ok.mjs';\n\n/**\n * @template P The Promise type.\n * @internal\n * Utility type to extract the resolved value type from a Promise.\n */\ntype UnwrapPromise<P extends Promise<unknown>> =\n P extends Promise<infer V> ? V : never;\n\n/**\n * Converts a Promise into a Promise that resolves to a `Result`. If the input\n * Promise resolves, the `Result` will be `Ok` with the resolved value. If the\n * input Promise rejects, the `Result` will be `Err` with the rejection\n * reason.\n *\n * @example\n *\n * ```ts\n * const successPromise = Result.fromPromise(Promise.resolve('ok'));\n *\n * const failurePromise = Result.fromPromise(\n * Promise.reject(new Error('fail')),\n * );\n *\n * const resolved = await successPromise;\n *\n * const rejected = await failurePromise;\n *\n * assert.deepStrictEqual(resolved, Result.ok('ok'));\n *\n * assert.isTrue(Result.isErr(rejected));\n * ```\n *\n * @template P The type of the input Promise.\n * @param promise The Promise to convert.\n * @returns A Promise that resolves to `Result<UnwrapPromise<P>, unknown>`.\n */\nexport const fromPromise = <P extends Promise<unknown>>(\n promise: P,\n): Promise<Result<UnwrapPromise<P>, unknown>> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n promise.then((v) => ok(v) as Ok<UnwrapPromise<P>>).catch(err);\n"],"names":[],"mappings":";;;AAyCO,MAAM,cAAc,CACzB,OAAA;AAAA;AAAA,EAGA,OAAA,CAAQ,KAAK,CAAC,CAAA,KAAM,GAAG,CAAC,CAAyB,CAAA,CAAE,KAAA,CAAM,GAAG;AAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"result-from-throwable.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-from-throwable.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,EAAG,IAAI,MAAM,CAAC,KAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAY9D,CAAC"}
1
+ {"version":3,"file":"result-from-throwable.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-from-throwable.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,MAAO,MAAM,CAAC,KAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAY9D,CAAC"}
@@ -3,46 +3,16 @@ import { unknownToString } from '../../../others/unknown-to-string.mjs';
3
3
  import { err } from './result-err.mjs';
4
4
  import { ok } from './result-ok.mjs';
5
5
 
6
- /**
7
- * Wraps a function that may throw an exception in a `Result`.
8
- *
9
- * This is a fundamental utility for converting traditional exception-based
10
- * error handling into Result-based error handling. Any thrown value is
11
- * converted to an Error object for consistent error handling.
12
- *
13
- * If the function executes successfully, returns `Result.Ok` with the result.
14
- * If the function throws, returns `Result.Err` with the caught error.
15
- *
16
- * @example
17
- *
18
- * ```ts
19
- * const success = Result.fromThrowable(() => 1 + 1);
20
- *
21
- * const failure = Result.fromThrowable(() => {
22
- * throw new Error('boom');
23
- * });
24
- *
25
- * assert.deepStrictEqual(success, Result.ok(2));
26
- *
27
- * assert.isTrue(Result.isErr(failure));
28
- * ```
29
- *
30
- * @template T The return type of the function.
31
- * @param fn The function to execute that may throw.
32
- * @returns A `Result<T, Error>` containing either the successful result or
33
- * the caught error.
34
- */
35
6
  const fromThrowable = (fn) => {
36
- try {
37
- return ok(fn());
38
- }
39
- catch (error) {
40
- if (isError(error)) {
41
- return err(error);
42
- }
43
- const msg = unknownToString(error);
44
- return err(new Error(msg));
7
+ try {
8
+ return ok(fn());
9
+ } catch (error) {
10
+ if (isError(error)) {
11
+ return err(error);
45
12
  }
13
+ const msg = unknownToString(error);
14
+ return err(new Error(msg));
15
+ }
46
16
  };
47
17
 
48
18
  export { fromThrowable };
@@ -1 +1 @@
1
- {"version":3,"file":"result-from-throwable.mjs","sources":["../../../../src/functional/result/impl/result-from-throwable.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;AACI,MAAM,aAAa,GAAG,CAAK,EAAW,KAAsB;AACjE,IAAA,IAAI;AACF,QAAA,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;IACjB;IAAE,OAAO,KAAK,EAAE;AACd,QAAA,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;AAClB,YAAA,OAAO,GAAG,CAAC,KAAK,CAAC;QACnB;AAEA,QAAA,MAAM,GAAG,GAAG,eAAe,CAAC,KAAK,CAAC;QAElC,OAAO,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B;AACF;;;;"}
1
+ {"version":3,"file":"result-from-throwable.mjs","sources":["../../../../src/functional/result/impl/result-from-throwable.mts"],"sourcesContent":["import { isError } from '@sindresorhus/is';\nimport { unknownToString } from '../../../others/index.mjs';\nimport { type Result } from '../result.mjs';\nimport { err } from './result-err.mjs';\nimport { ok } from './result-ok.mjs';\n\n/**\n * Wraps a function that may throw an exception in a `Result`.\n *\n * This is a fundamental utility for converting traditional exception-based\n * error handling into Result-based error handling. Any thrown value is\n * converted to an Error object for consistent error handling.\n *\n * If the function executes successfully, returns `Result.Ok` with the result.\n * If the function throws, returns `Result.Err` with the caught error.\n *\n * @example\n *\n * ```ts\n * const success = Result.fromThrowable(() => 1 + 1);\n *\n * const failure = Result.fromThrowable(() => {\n * throw new Error('boom');\n * });\n *\n * assert.deepStrictEqual(success, Result.ok(2));\n *\n * assert.isTrue(Result.isErr(failure));\n * ```\n *\n * @template T The return type of the function.\n * @param fn The function to execute that may throw.\n * @returns A `Result<T, Error>` containing either the successful result or\n * the caught error.\n */\nexport const fromThrowable = <T,>(fn: () => T): Result<T, Error> => {\n try {\n return ok(fn());\n } catch (error) {\n if (isError(error)) {\n return err(error);\n }\n\n const msg = unknownToString(error);\n\n return err(new Error(msg));\n }\n};\n"],"names":[],"mappings":";;;;;AAmCO,MAAM,aAAA,GAAgB,CAAK,EAAA,KAAkC;AAClE,EAAA,IAAI;AACF,IAAA,OAAO,EAAA,CAAG,IAAI,CAAA;AAAA,EAChB,SAAS,KAAA,EAAO;AACd,IAAA,IAAI,OAAA,CAAQ,KAAK,CAAA,EAAG;AAClB,MAAA,OAAO,IAAI,KAAK,CAAA;AAAA,IAClB;AAEA,IAAA,MAAM,GAAA,GAAM,gBAAgB,KAAK,CAAA;AAEjC,IAAA,OAAO,GAAA,CAAI,IAAI,KAAA,CAAM,GAAG,CAAC,CAAA;AAAA,EAC3B;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"result-is-err.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-is-err.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,aAAa,EAC3C,QAAQ,CAAC,KACR,MAAM,IAAI,WAAW,CAAC,CAAC,CAAoC,CAAC"}
1
+ {"version":3,"file":"result-is-err.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-is-err.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,aAAa,UACnC,CAAC,KACR,MAAM,IAAI,WAAW,CAAC,CAAC,CAAoC,CAAC"}
@@ -1,24 +1,5 @@
1
1
  import { ErrTypeTagName } from './tag.mjs';
2
2
 
3
- /**
4
- * Type guard for the error variant.
5
- *
6
- * @example
7
- *
8
- * ```ts
9
- * const operation = Result.ok(3);
10
- *
11
- * const failure = Result.err('error');
12
- *
13
- * if (Result.isOk(operation)) {
14
- * const value: number = operation.value;
15
- *
16
- * assert.isTrue(value === 3);
17
- * }
18
- *
19
- * assert.isTrue(Result.isErr(failure));
20
- * ```
21
- */
22
3
  const isErr = (result) => result.$$tag === ErrTypeTagName;
23
4
 
24
5
  export { isErr };
@@ -1 +1 @@
1
- {"version":3,"file":"result-is-err.mjs","sources":["../../../../src/functional/result/impl/result-is-err.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,KAAK,GAAG,CACnB,MAAS,KACoB,MAAM,CAAC,KAAK,KAAK;;;;"}
1
+ {"version":3,"file":"result-is-err.mjs","sources":["../../../../src/functional/result/impl/result-is-err.mts"],"sourcesContent":["import { type UnknownResult } from '../result.mjs';\nimport { ErrTypeTagName } from './tag.mjs';\nimport { type NarrowToErr } from './types.mjs';\n\n/**\n * Type guard for the error variant.\n *\n * @example\n *\n * ```ts\n * const operation = Result.ok(3);\n *\n * const failure = Result.err('error');\n *\n * if (Result.isOk(operation)) {\n * const value: number = operation.value;\n *\n * assert.isTrue(value === 3);\n * }\n *\n * assert.isTrue(Result.isErr(failure));\n * ```\n */\nexport const isErr = <R extends UnknownResult>(\n result: R,\n): result is NarrowToErr<R> => result.$$tag === ErrTypeTagName;\n"],"names":[],"mappings":";;AAuBO,MAAM,KAAA,GAAQ,CACnB,MAAA,KAC6B,MAAA,CAAO,KAAA,KAAU;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"result-is-ok.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-is-ok.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,aAAa,EAC1C,QAAQ,CAAC,KACR,MAAM,IAAI,UAAU,CAAC,CAAC,CAAmC,CAAC"}
1
+ {"version":3,"file":"result-is-ok.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-is-ok.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,aAAa,UAClC,CAAC,KACR,MAAM,IAAI,UAAU,CAAC,CAAC,CAAmC,CAAC"}
@@ -1,24 +1,5 @@
1
1
  import { OkTypeTagName } from './tag.mjs';
2
2
 
3
- /**
4
- * Type guard for the ok variant.
5
- *
6
- * @example
7
- *
8
- * ```ts
9
- * const operation = Result.ok(3);
10
- *
11
- * const failure = Result.err('error');
12
- *
13
- * if (Result.isOk(operation)) {
14
- * const value: number = operation.value;
15
- *
16
- * assert.isTrue(value === 3);
17
- * }
18
- *
19
- * assert.isTrue(Result.isErr(failure));
20
- * ```
21
- */
22
3
  const isOk = (result) => result.$$tag === OkTypeTagName;
23
4
 
24
5
  export { isOk };
@@ -1 +1 @@
1
- {"version":3,"file":"result-is-ok.mjs","sources":["../../../../src/functional/result/impl/result-is-ok.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,IAAI,GAAG,CAClB,MAAS,KACmB,MAAM,CAAC,KAAK,KAAK;;;;"}
1
+ {"version":3,"file":"result-is-ok.mjs","sources":["../../../../src/functional/result/impl/result-is-ok.mts"],"sourcesContent":["import { type UnknownResult } from '../result.mjs';\nimport { OkTypeTagName } from './tag.mjs';\nimport { type NarrowToOk } from './types.mjs';\n\n/**\n * Type guard for the ok variant.\n *\n * @example\n *\n * ```ts\n * const operation = Result.ok(3);\n *\n * const failure = Result.err('error');\n *\n * if (Result.isOk(operation)) {\n * const value: number = operation.value;\n *\n * assert.isTrue(value === 3);\n * }\n *\n * assert.isTrue(Result.isErr(failure));\n * ```\n */\nexport const isOk = <R extends UnknownResult>(\n result: R,\n): result is NarrowToOk<R> => result.$$tag === OkTypeTagName;\n"],"names":[],"mappings":";;AAuBO,MAAM,IAAA,GAAO,CAClB,MAAA,KAC4B,MAAA,CAAO,KAAA,KAAU;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"result-is-result.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-is-result.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,QAAQ,GAAI,aAAa,OAAO,KAAG,WAAW,IAAI,aAIgB,CAAC"}
1
+ {"version":3,"file":"result-is-result.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-is-result.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,QAAQ,gBAAiB,OAAO,KAAG,WAAW,IAAI,aAIgB,CAAC"}
@@ -2,29 +2,7 @@ import { hasKey } from '../../../guard/has-key.mjs';
2
2
  import { isRecord } from '../../../guard/is-record.mjs';
3
3
  import { ErrTypeTagName, OkTypeTagName } from './tag.mjs';
4
4
 
5
- /**
6
- * Checks whether the provided value is a {@link Result<S, E>}.
7
- *
8
- * @example
9
- *
10
- * ```ts
11
- * const okValue = Result.ok('success');
12
- *
13
- * const errValue = Result.err(new Error('failure'));
14
- *
15
- * const notResult = { $$tag: 'ts-data-forge::Result.ok' } as const;
16
- *
17
- * assert.isTrue(Result.isResult(okValue));
18
- *
19
- * assert.isTrue(Result.isResult(errValue));
20
- *
21
- * assert.isFalse(Result.isResult(notResult));
22
- * ```
23
- */
24
- const isResult = (maybeResult) => isRecord(maybeResult) &&
25
- hasKey(maybeResult, '$$tag') &&
26
- hasKey(maybeResult, 'value') &&
27
- (maybeResult.$$tag === ErrTypeTagName || maybeResult.$$tag === OkTypeTagName);
5
+ const isResult = (maybeResult) => isRecord(maybeResult) && hasKey(maybeResult, "$$tag") && hasKey(maybeResult, "value") && (maybeResult.$$tag === ErrTypeTagName || maybeResult.$$tag === OkTypeTagName);
28
6
 
29
7
  export { isResult };
30
8
  //# sourceMappingURL=result-is-result.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"result-is-result.mjs","sources":["../../../../src/functional/result/impl/result-is-result.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAIA;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,QAAQ,GAAG,CAAC,WAAoB,KAC3C,QAAQ,CAAC,WAAW,CAAC;AACrB,IAAA,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC;AAC5B,IAAA,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC;AAC5B,KAAC,WAAW,CAAC,KAAK,KAAK,cAAc,IAAI,WAAW,CAAC,KAAK,KAAK,aAAa;;;;"}
1
+ {"version":3,"file":"result-is-result.mjs","sources":["../../../../src/functional/result/impl/result-is-result.mts"],"sourcesContent":["import { hasKey, isRecord } from '../../../guard/index.mjs';\nimport { type UnknownResult } from '../result.mjs';\nimport { ErrTypeTagName, OkTypeTagName } from './tag.mjs';\n\n/**\n * Checks whether the provided value is a {@link Result<S, E>}.\n *\n * @example\n *\n * ```ts\n * const okValue = Result.ok('success');\n *\n * const errValue = Result.err(new Error('failure'));\n *\n * const notResult = { $$tag: 'ts-data-forge::Result.ok' } as const;\n *\n * assert.isTrue(Result.isResult(okValue));\n *\n * assert.isTrue(Result.isResult(errValue));\n *\n * assert.isFalse(Result.isResult(notResult));\n * ```\n */\nexport const isResult = (maybeResult: unknown): maybeResult is UnknownResult =>\n isRecord(maybeResult) &&\n hasKey(maybeResult, '$$tag') &&\n hasKey(maybeResult, 'value') &&\n (maybeResult.$$tag === ErrTypeTagName || maybeResult.$$tag === OkTypeTagName);\n"],"names":[],"mappings":";;;;AAuBO,MAAM,WAAW,CAAC,WAAA,KACvB,SAAS,WAAW,CAAA,IACpB,OAAO,WAAA,EAAa,OAAO,CAAA,IAC3B,MAAA,CAAO,aAAa,OAAO,CAAA,KAC1B,YAAY,KAAA,KAAU,cAAA,IAAkB,YAAY,KAAA,KAAU,aAAA;;;;"}
@@ -2,24 +2,24 @@ import { err } from './result-err.mjs';
2
2
  import { isOk } from './result-is-ok.mjs';
3
3
 
4
4
  function mapErr(...args) {
5
- switch (args.length) {
6
- case 2: {
7
- // Direct version: first argument is result
8
- const [result, mapFn] = args;
9
- return mapErrImpl(result, mapFn);
10
- }
11
- case 1: {
12
- // Curried version: first argument is mapping function
13
- const [mapFn] = args;
14
- return (result) => mapErrImpl(result, mapFn);
15
- }
5
+ switch (args.length) {
6
+ case 2: {
7
+ const [result, mapFn] = args;
8
+ return mapErrImpl(result, mapFn);
16
9
  }
10
+ case 1: {
11
+ const [mapFn] = args;
12
+ return (result) => mapErrImpl(result, mapFn);
13
+ }
14
+ }
17
15
  }
18
- const mapErrImpl = (result, mapFn) => isOk(result)
19
- ? // eslint-disable-next-line total-functions/no-unsafe-type-assertion
20
- result
21
- : // eslint-disable-next-line total-functions/no-unsafe-type-assertion
22
- err(mapFn(result.value));
16
+ const mapErrImpl = (result, mapFn) => isOk(result) ? (
17
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
18
+ result
19
+ ) : (
20
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
21
+ err(mapFn(result.value))
22
+ );
23
23
 
24
24
  export { mapErr };
25
25
  //# sourceMappingURL=result-map-err.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"result-map-err.mjs","sources":["../../../../src/functional/result/impl/result-map-err.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAkDM,SAAU,MAAM,CACpB,GAAG,IAE8C,EAAA;AAEjD,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,IAAI;AAE5B,YAAA,OAAO,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC;QAClC;QAEA,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI;YAEpB,OAAO,CAAC,MAAS,KAAK,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC;QACjD;;AAEJ;AAEA,MAAM,UAAU,GAAG,CACjB,MAAS,EACT,KAAkC,KAElC,IAAI,CAAC,MAAM;AACT;QACG;AACH;QACE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,KAAqB,CAAC,CAAC;;;;"}
1
+ {"version":3,"file":"result-map-err.mjs","sources":["../../../../src/functional/result/impl/result-map-err.mts"],"sourcesContent":["import { type Ok } from '../../../types.mjs';\nimport { type Result, type UnknownResult } from '../result.mjs';\nimport { err } from './result-err.mjs';\nimport { isOk } from './result-is-ok.mjs';\nimport { type UnwrapErr, type UnwrapOk } from './types.mjs';\n\n/**\n * Maps a `Result<S, E>` to `Result<S, E2>` by applying a function to the\n * error value. If the `Result` is `Result.Ok`, returns the original `Ok`.\n *\n * @example\n *\n * ```ts\n * const okValue = Result.ok(3) as Result<number, string>;\n *\n * const errValue = Result.err('missing');\n *\n * const untouchedOk = Result.mapErr(okValue, (error) => error.toUpperCase());\n *\n * const uppercasedErr = Result.mapErr(errValue, (error) =>\n * error.toUpperCase(),\n * );\n *\n * assert.deepStrictEqual(untouchedOk, Result.ok(3));\n *\n * assert.deepStrictEqual(uppercasedErr, Result.err('MISSING'));\n *\n * const mapError = Result.mapErr((error: Readonly<Error>) => error.message);\n *\n * const wrapped = mapError(Result.err(new Error('boom')));\n *\n * assert.deepStrictEqual(wrapped, Result.err('boom'));\n * ```\n *\n * @template R The input `UnknownResult` type.\n * @template E2 The type of the error value returned by the mapping function.\n * @param result The `Result` to map.\n * @param mapFn The function to apply to the error value if present.\n * @returns A new `Result<UnwrapOk<R>, E2>`.\n */\nexport function mapErr<R extends UnknownResult, E2>(\n result: R,\n mapFn: (error: UnwrapErr<R>) => E2,\n): Result<UnwrapOk<R>, E2>;\n\n// Curried version\nexport function mapErr<E, E2>(\n mapFn: (error: E) => E2,\n): <S>(result: Result<S, E>) => Result<S, E2>;\n\nexport function mapErr<R extends UnknownResult, E2>(\n ...args:\n | readonly [result: R, mapFn: (error: UnwrapErr<R>) => E2]\n | readonly [mapFn: (error: UnwrapErr<R>) => E2]\n): Result<UnwrapOk<R>, E2> | ((result: R) => Result<UnwrapOk<R>, E2>) {\n switch (args.length) {\n case 2: {\n // Direct version: first argument is result\n const [result, mapFn] = args;\n\n return mapErrImpl(result, mapFn);\n }\n\n case 1: {\n // Curried version: first argument is mapping function\n const [mapFn] = args;\n\n return (result: R) => mapErrImpl(result, mapFn);\n }\n }\n}\n\nconst mapErrImpl = <R extends UnknownResult, E2>(\n result: R,\n mapFn: (error: UnwrapErr<R>) => E2,\n): Result<UnwrapOk<R>, E2> =>\n isOk(result)\n ? // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n (result as Ok<UnwrapOk<R>>)\n : // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n err(mapFn(result.value as UnwrapErr<R>));\n"],"names":[],"mappings":";;;AAkDO,SAAS,UACX,IAAA,EAGiE;AACpE,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,MAAA,EAAQ,KAAK,CAAA,GAAI,IAAA;AAExB,MAAA,OAAO,UAAA,CAAW,QAAQ,KAAK,CAAA;AAAA,IACjC;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,KAAK,CAAA,GAAI,IAAA;AAEhB,MAAA,OAAO,CAAC,MAAA,KAAc,UAAA,CAAW,MAAA,EAAQ,KAAK,CAAA;AAAA,IAChD;AAAA;AAEJ;AAEA,MAAM,UAAA,GAAa,CACjB,MAAA,EACA,KAAA,KAEA,KAAK,MAAM,CAAA;AAAA;AAAA,EAEN;AAAA;AAAA;AAAA,EAED,GAAA,CAAI,KAAA,CAAM,MAAA,CAAO,KAAqB,CAAC;AAAA,CAAA;;;;"}
@@ -2,24 +2,24 @@ import { isErr } from './result-is-err.mjs';
2
2
  import { ok } from './result-ok.mjs';
3
3
 
4
4
  function map(...args) {
5
- switch (args.length) {
6
- case 2: {
7
- // Direct version: first argument is result
8
- const [result, mapFn] = args;
9
- return mapImpl(result, mapFn);
10
- }
11
- case 1: {
12
- // Curried version
13
- const [mapFn] = args;
14
- return (result) => mapImpl(result, mapFn);
15
- }
5
+ switch (args.length) {
6
+ case 2: {
7
+ const [result, mapFn] = args;
8
+ return mapImpl(result, mapFn);
16
9
  }
10
+ case 1: {
11
+ const [mapFn] = args;
12
+ return (result) => mapImpl(result, mapFn);
13
+ }
14
+ }
17
15
  }
18
- const mapImpl = (result, mapFn) => isErr(result)
19
- ? // eslint-disable-next-line total-functions/no-unsafe-type-assertion
20
- result
21
- : // eslint-disable-next-line total-functions/no-unsafe-type-assertion
22
- ok(mapFn(result.value));
16
+ const mapImpl = (result, mapFn) => isErr(result) ? (
17
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
18
+ result
19
+ ) : (
20
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
21
+ ok(mapFn(result.value))
22
+ );
23
23
 
24
24
  export { map };
25
25
  //# sourceMappingURL=result-map.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"result-map.mjs","sources":["../../../../src/functional/result/impl/result-map.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAkDM,SAAU,GAAG,CACjB,GAAG,IAE6C,EAAA;AAEhD,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,IAAI;AAE5B,YAAA,OAAO,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC;QAC/B;QAEA,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI;YAEpB,OAAO,CAAC,MAAS,KAAK,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC;QAC9C;;AAEJ;AAEA,MAAM,OAAO,GAAG,CACd,MAAS,EACT,KAAiC,KAEjC,KAAK,CAAC,MAAM;AACV;QACG;AACH;QACE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAoB,CAAC,CAAC;;;;"}
1
+ {"version":3,"file":"result-map.mjs","sources":["../../../../src/functional/result/impl/result-map.mts"],"sourcesContent":["import { type Err } from '../../../types.mjs';\nimport { type Result, type UnknownResult } from '../result.mjs';\nimport { isErr } from './result-is-err.mjs';\nimport { ok } from './result-ok.mjs';\nimport { type UnwrapErr, type UnwrapOk } from './types.mjs';\n\n/**\n * Maps a `Result<S, E>` to `Result<S2, E>` by applying a function to the\n * success value. If the `Result` is `Result.Err`, returns the original\n * `Err`.\n *\n * @example\n *\n * ```ts\n * const okNumber = Result.ok(5);\n *\n * const errMessage = Result.err('error');\n *\n * const doubled = Result.map(okNumber, (value) => value * 2);\n *\n * const untouchedError = Result.map(errMessage, (value: number) => value * 2);\n *\n * assert.deepStrictEqual(doubled, Result.ok(10));\n *\n * assert.deepStrictEqual(untouchedError, errMessage);\n *\n * const mapToLength = Result.map((text: string) => text.length);\n *\n * assert.deepStrictEqual(mapToLength(Result.ok('abc')), Result.ok(3));\n *\n * assert.deepStrictEqual(mapToLength(Result.err('bad')), Result.err('bad'));\n * ```\n *\n * @template R The input `UnknownResult` type.\n * @template S2 The type of the success value returned by the mapping\n * function.\n * @param result The `Result` to map.\n * @param mapFn The function to apply to the success value if present.\n * @returns A new `Result<S2, UnwrapErr<R>>`.\n */\nexport function map<R extends UnknownResult, S2>(\n result: R,\n mapFn: (value: UnwrapOk<R>) => S2,\n): Result<S2, UnwrapErr<R>>;\n\n// Curried version\nexport function map<S, S2>(\n mapFn: (value: S) => S2,\n): <E>(result: Result<S, E>) => Result<S2, E>;\n\nexport function map<R extends UnknownResult, S2>(\n ...args:\n | readonly [result: R, mapFn: (value: UnwrapOk<R>) => S2]\n | readonly [mapFn: (value: UnwrapOk<R>) => S2]\n): Result<S2, UnwrapErr<R>> | ((result: R) => Result<S2, UnwrapErr<R>>) {\n switch (args.length) {\n case 2: {\n // Direct version: first argument is result\n const [result, mapFn] = args;\n\n return mapImpl(result, mapFn);\n }\n\n case 1: {\n // Curried version\n const [mapFn] = args;\n\n return (result: R) => mapImpl(result, mapFn);\n }\n }\n}\n\nconst mapImpl = <R extends UnknownResult, S2>(\n result: R,\n mapFn: (value: UnwrapOk<R>) => S2,\n): Result<S2, UnwrapErr<R>> =>\n isErr(result)\n ? // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n (result as Err<UnwrapErr<R>>)\n : // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n ok(mapFn(result.value as UnwrapOk<R>));\n"],"names":[],"mappings":";;;AAkDO,SAAS,OACX,IAAA,EAGmE;AACtE,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,MAAA,EAAQ,KAAK,CAAA,GAAI,IAAA;AAExB,MAAA,OAAO,OAAA,CAAQ,QAAQ,KAAK,CAAA;AAAA,IAC9B;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,KAAK,CAAA,GAAI,IAAA;AAEhB,MAAA,OAAO,CAAC,MAAA,KAAc,OAAA,CAAQ,MAAA,EAAQ,KAAK,CAAA;AAAA,IAC7C;AAAA;AAEJ;AAEA,MAAM,OAAA,GAAU,CACd,MAAA,EACA,KAAA,KAEA,MAAM,MAAM,CAAA;AAAA;AAAA,EAEP;AAAA;AAAA;AAAA,EAED,EAAA,CAAG,KAAA,CAAM,MAAA,CAAO,KAAoB,CAAC;AAAA,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"result-ok.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-ok.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAG7C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,EAAE,GAAI,KAAK,CAAC,CAAC,EAAG,OAAO,CAAC,KAAG,EAAE,CAAC,CAAC,CAI/B,CAAC"}
1
+ {"version":3,"file":"result-ok.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-ok.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAG7C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,EAAE,GAAI,KAAK,CAAC,CAAC,SAAU,CAAC,KAAG,EAAE,CAAC,CAAC,CAI/B,CAAC"}
@@ -1,33 +1,8 @@
1
1
  import { OkTypeTagName } from './tag.mjs';
2
2
 
3
- /**
4
- * Creates a `Result.Ok` containing the given success value.
5
- *
6
- * Use this constructor when an operation succeeds and you want to wrap the
7
- * successful result in a Result type for consistent error handling.
8
- *
9
- * @example
10
- *
11
- * ```ts
12
- * const success = Result.ok({ id: 1 });
13
- *
14
- * const failure = Result.err(new Error('missing data'));
15
- *
16
- * assert.deepStrictEqual(success, {
17
- * $$tag: 'ts-data-forge::Result.ok',
18
- * value: { id: 1 },
19
- * });
20
- *
21
- * assert.isTrue(Result.isErr(failure));
22
- * ```
23
- *
24
- * @template S The type of the success value.
25
- * @param value The success value.
26
- * @returns A `Result.Ok<S>` containing the value.
27
- */
28
3
  const ok = (value) => ({
29
- $$tag: OkTypeTagName,
30
- value,
4
+ $$tag: OkTypeTagName,
5
+ value
31
6
  });
32
7
 
33
8
  export { ok };
@@ -1 +1 @@
1
- {"version":3,"file":"result-ok.mjs","sources":["../../../../src/functional/result/impl/result-ok.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;MACU,EAAE,GAAG,CAAW,KAAQ,MAClC;AACC,IAAA,KAAK,EAAE,aAAa;IACpB,KAAK;AACN,CAAA;;;;"}
1
+ {"version":3,"file":"result-ok.mjs","sources":["../../../../src/functional/result/impl/result-ok.mts"],"sourcesContent":["import { type Ok } from '../../../types.mjs';\nimport { OkTypeTagName } from './tag.mjs';\n\n/**\n * Creates a `Result.Ok` containing the given success value.\n *\n * Use this constructor when an operation succeeds and you want to wrap the\n * successful result in a Result type for consistent error handling.\n *\n * @example\n *\n * ```ts\n * const success = Result.ok({ id: 1 });\n *\n * const failure = Result.err(new Error('missing data'));\n *\n * assert.deepStrictEqual(success, {\n * $$tag: 'ts-data-forge::Result.ok',\n * value: { id: 1 },\n * });\n *\n * assert.isTrue(Result.isErr(failure));\n * ```\n *\n * @template S The type of the success value.\n * @param value The success value.\n * @returns A `Result.Ok<S>` containing the value.\n */\nexport const ok = <const S,>(value: S): Ok<S> =>\n ({\n $$tag: OkTypeTagName,\n value,\n }) as const;\n"],"names":[],"mappings":";;AA4BO,MAAM,EAAA,GAAK,CAAW,KAAA,MAC1B;AAAA,EACC,KAAA,EAAO,aAAA;AAAA,EACP;AACF,CAAA;;;;"}
@@ -1,20 +1,18 @@
1
1
  import { isOk } from './result-is-ok.mjs';
2
2
 
3
3
  function orElse(...args) {
4
- switch (args.length) {
5
- case 2: {
6
- // Direct version: first argument is result
7
- const [result, alternative] = args;
8
- return orElseImpl(result, alternative);
9
- }
10
- case 1: {
11
- // Curried version
12
- const [alternative] = args;
13
- return (result) => orElseImpl(result, alternative);
14
- }
4
+ switch (args.length) {
5
+ case 2: {
6
+ const [result, alternative] = args;
7
+ return orElseImpl(result, alternative);
15
8
  }
9
+ case 1: {
10
+ const [alternative] = args;
11
+ return (result) => orElseImpl(result, alternative);
12
+ }
13
+ }
16
14
  }
17
- const orElseImpl = (result, alternative) => (isOk(result) ? result : alternative);
15
+ const orElseImpl = (result, alternative) => isOk(result) ? result : alternative;
18
16
 
19
17
  export { orElse };
20
18
  //# sourceMappingURL=result-or-else.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"result-or-else.mjs","sources":["../../../../src/functional/result/impl/result-or-else.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAiDM,SAAU,MAAM,CACpB,GAAG,IAAwE,EAAA;AAE3E,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI;AAElC,YAAA,OAAO,UAAU,CAAC,MAAM,EAAE,WAAW,CAAC;QACxC;QAEA,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI;YAE1B,OAAO,CAAC,MAAS,KAAK,UAAU,CAAC,MAAM,EAAE,WAAW,CAAC;QACvD;;AAEJ;AAEA,MAAM,UAAU,GAAG,CACjB,MAAS,EACT,WAAe,MACS,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,WAAW,CAAC;;;;"}
1
+ {"version":3,"file":"result-or-else.mjs","sources":["../../../../src/functional/result/impl/result-or-else.mts"],"sourcesContent":["import { type UnknownResult } from '../result.mjs';\nimport { isOk } from './result-is-ok.mjs';\nimport { type NarrowToOk } from './types.mjs';\n\n/**\n * Returns the `Result` if it is `Ok`, otherwise returns the alternative.\n *\n * @example\n *\n * ```ts\n * const primary = Result.ok('primary');\n *\n * const fallback = Result.ok('fallback');\n *\n * const failure = Result.err('failure');\n *\n * assert.deepStrictEqual(Result.orElse(primary, fallback), primary);\n *\n * assert.deepStrictEqual(Result.orElse(failure, fallback), fallback);\n *\n * const orElseFallback = Result.orElse(Result.ok('default'));\n *\n * assert.deepStrictEqual(\n * orElseFallback(Result.err('missing')),\n * Result.ok('default'),\n * );\n *\n * assert.deepStrictEqual(\n * orElseFallback(Result.ok('value')),\n * Result.ok('value'),\n * );\n * ```\n *\n * @template R The input `UnknownResult` type.\n * @param result The `Result` to check.\n * @param alternative The alternative `Result` to return if the first is\n * `Err`.\n * @returns The first `Result` if `Ok`, otherwise the alternative.\n */\nexport function orElse<R extends UnknownResult, R2 extends UnknownResult>(\n result: R,\n alternative: R2,\n): NarrowToOk<R> | R2;\n\n// Curried version\nexport function orElse<R2 extends UnknownResult>(\n alternative: R2,\n): <R extends UnknownResult>(result: R) => NarrowToOk<R> | R2;\n\nexport function orElse<R extends UnknownResult, R2 extends UnknownResult>(\n ...args: readonly [result: R, alternative: R2] | readonly [alternative: R2]\n): (NarrowToOk<R> | R2) | ((result: R) => R | R2) {\n switch (args.length) {\n case 2: {\n // Direct version: first argument is result\n const [result, alternative] = args;\n\n return orElseImpl(result, alternative);\n }\n\n case 1: {\n // Curried version\n const [alternative] = args;\n\n return (result: R) => orElseImpl(result, alternative);\n }\n }\n}\n\nconst orElseImpl = <R extends UnknownResult, R2 extends UnknownResult>(\n result: R,\n alternative: R2,\n): NarrowToOk<R> | R2 => (isOk(result) ? result : alternative);\n"],"names":[],"mappings":";;AAiDO,SAAS,UACX,IAAA,EAC6C;AAChD,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,MAAA,EAAQ,WAAW,CAAA,GAAI,IAAA;AAE9B,MAAA,OAAO,UAAA,CAAW,QAAQ,WAAW,CAAA;AAAA,IACvC;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,WAAW,CAAA,GAAI,IAAA;AAEtB,MAAA,OAAO,CAAC,MAAA,KAAc,UAAA,CAAW,MAAA,EAAQ,WAAW,CAAA;AAAA,IACtD;AAAA;AAEJ;AAEA,MAAM,aAAa,CACjB,MAAA,EACA,gBACwB,IAAA,CAAK,MAAM,IAAI,MAAA,GAAS,WAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"result-swap.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-swap.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAKhE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,aAAa,EAC1C,QAAQ,CAAC,KACR,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAEsC,CAAC"}
1
+ {"version":3,"file":"result-swap.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-swap.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAKhE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,aAAa,UAClC,CAAC,KACR,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAEsC,CAAC"}
@@ -3,28 +3,10 @@ import { isOk } from './result-is-ok.mjs';
3
3
  import { ok } from './result-ok.mjs';
4
4
  import { unwrapOk } from './result-unwrap-ok.mjs';
5
5
 
6
- /**
7
- * Swaps the success and error values of a `Result`.
8
- *
9
- * @example
10
- *
11
- * ```ts
12
- * const okValue = Result.ok('value');
13
- *
14
- * const errValue = Result.err('error');
15
- *
16
- * assert.deepStrictEqual(Result.swap(okValue), Result.err('value'));
17
- *
18
- * assert.deepStrictEqual(Result.swap(errValue), Result.ok('error'));
19
- * ```
20
- *
21
- * @template R The input `UnknownResult` type.
22
- * @param result The `Result` to swap.
23
- * @returns A new `Result` with success and error swapped.
24
- */
25
- const swap = (result) =>
26
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion
27
- isOk(result) ? err(unwrapOk(result)) : ok(result.value);
6
+ const swap = (result) => (
7
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
8
+ isOk(result) ? err(unwrapOk(result)) : ok(result.value)
9
+ );
28
10
 
29
11
  export { swap };
30
12
  //# sourceMappingURL=result-swap.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"result-swap.mjs","sources":["../../../../src/functional/result/impl/result-swap.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAOA;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,IAAI,GAAG,CAClB,MAAS;AAET;AACA,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAqB;;;;"}
1
+ {"version":3,"file":"result-swap.mjs","sources":["../../../../src/functional/result/impl/result-swap.mts"],"sourcesContent":["import { type Result, type UnknownResult } from '../result.mjs';\nimport { err } from './result-err.mjs';\nimport { isOk } from './result-is-ok.mjs';\nimport { ok } from './result-ok.mjs';\nimport { unwrapOk } from './result-unwrap-ok.mjs';\nimport { type UnwrapErr, type UnwrapOk } from './types.mjs';\n\n/**\n * Swaps the success and error values of a `Result`.\n *\n * @example\n *\n * ```ts\n * const okValue = Result.ok('value');\n *\n * const errValue = Result.err('error');\n *\n * assert.deepStrictEqual(Result.swap(okValue), Result.err('value'));\n *\n * assert.deepStrictEqual(Result.swap(errValue), Result.ok('error'));\n * ```\n *\n * @template R The input `UnknownResult` type.\n * @param result The `Result` to swap.\n * @returns A new `Result` with success and error swapped.\n */\nexport const swap = <R extends UnknownResult>(\n result: R,\n): Result<UnwrapErr<R>, UnwrapOk<R>> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n isOk(result) ? err(unwrapOk(result)) : ok(result.value as UnwrapErr<R>);\n"],"names":[],"mappings":";;;;;AA0BO,MAAM,OAAO,CAClB,MAAA;AAAA;AAAA,EAGA,IAAA,CAAK,MAAM,CAAA,GAAI,GAAA,CAAI,QAAA,CAAS,MAAM,CAAC,CAAA,GAAI,EAAA,CAAG,MAAA,CAAO,KAAqB;AAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"result-to-optional.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-to-optional.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,aAAa,EAChD,QAAQ,CAAC,KACR,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CACyC,CAAC"}
1
+ {"version":3,"file":"result-to-optional.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-to-optional.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,aAAa,UACxC,CAAC,KACR,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CACyC,CAAC"}
@@ -3,33 +3,6 @@ import { some } from '../../optional/impl/optional-some.mjs';
3
3
  import { isOk } from './result-is-ok.mjs';
4
4
  import { unwrapOk } from './result-unwrap-ok.mjs';
5
5
 
6
- /**
7
- * Converts a `Result` to an `Optional`.
8
- *
9
- * This conversion is useful when you want to discard error information and
10
- * only care about whether an operation succeeded. The error information is
11
- * lost in this conversion, so use it when error details are not needed.
12
- *
13
- * If the `Result` is `Ok`, returns `Some` with the value. If the `Result` is
14
- * `Err`, returns `None`.
15
- *
16
- * @example
17
- *
18
- * ```ts
19
- * const okValue = Result.ok(7);
20
- *
21
- * const errValue = Result.err('fail');
22
- *
23
- * assert.deepStrictEqual(Result.toOptional(okValue), Optional.some(7));
24
- *
25
- * assert.deepStrictEqual(Result.toOptional(errValue), Optional.none);
26
- * ```
27
- *
28
- * @template R The input `UnknownResult` type.
29
- * @param result The `Result` to convert.
30
- * @returns An `Optional<UnwrapOk<R>>` containing the success value or
31
- * representing `None`.
32
- */
33
6
  const toOptional = (result) => isOk(result) ? some(unwrapOk(result)) : none;
34
7
 
35
8
  export { toOptional };
@@ -1 +1 @@
1
- {"version":3,"file":"result-to-optional.mjs","sources":["../../../../src/functional/result/impl/result-to-optional.mts"],"sourcesContent":[null],"names":["Optional.some","Optional.none"],"mappings":";;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;AACI,MAAM,UAAU,GAAG,CACxB,MAAS,KAET,IAAI,CAAC,MAAM,CAAC,GAAGA,IAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAGC;;;;"}
1
+ {"version":3,"file":"result-to-optional.mjs","sources":["../../../../src/functional/result/impl/result-to-optional.mts"],"sourcesContent":["import { Optional } from '../../optional/index.mjs';\nimport { type UnknownResult } from '../result.mjs';\nimport { isOk } from './result-is-ok.mjs';\nimport { unwrapOk } from './result-unwrap-ok.mjs';\nimport { type UnwrapOk } from './types.mjs';\n\n/**\n * Converts a `Result` to an `Optional`.\n *\n * This conversion is useful when you want to discard error information and\n * only care about whether an operation succeeded. The error information is\n * lost in this conversion, so use it when error details are not needed.\n *\n * If the `Result` is `Ok`, returns `Some` with the value. If the `Result` is\n * `Err`, returns `None`.\n *\n * @example\n *\n * ```ts\n * const okValue = Result.ok(7);\n *\n * const errValue = Result.err('fail');\n *\n * assert.deepStrictEqual(Result.toOptional(okValue), Optional.some(7));\n *\n * assert.deepStrictEqual(Result.toOptional(errValue), Optional.none);\n * ```\n *\n * @template R The input `UnknownResult` type.\n * @param result The `Result` to convert.\n * @returns An `Optional<UnwrapOk<R>>` containing the success value or\n * representing `None`.\n */\nexport const toOptional = <R extends UnknownResult>(\n result: R,\n): Optional<UnwrapOk<R>> =>\n isOk(result) ? Optional.some(unwrapOk(result)) : Optional.none;\n"],"names":["Optional.some","Optional.none"],"mappings":";;;;;AAiCO,MAAM,UAAA,GAAa,CACxB,MAAA,KAEA,IAAA,CAAK,MAAM,CAAA,GAAIA,IAAS,CAAK,QAAA,CAAS,MAAM,CAAC,CAAA,GAAIC;;;;"}