ts-data-forge 3.3.1 → 4.1.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 (562) hide show
  1. package/dist/array/impl/array-utils-element-access.d.mts +3 -4
  2. package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
  3. package/dist/array/impl/array-utils-element-access.mjs +8 -8
  4. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  5. package/dist/array/impl/array-utils-reducing-value.d.mts +8 -9
  6. package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
  7. package/dist/array/impl/array-utils-reducing-value.mjs +9 -7
  8. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  9. package/dist/array/impl/array-utils-search.d.mts +0 -1
  10. package/dist/array/impl/array-utils-search.d.mts.map +1 -1
  11. package/dist/array/impl/array-utils-search.mjs +6 -6
  12. package/dist/array/impl/array-utils-search.mjs.map +1 -1
  13. package/dist/array/impl/array-utils-transformation.mjs +2 -4
  14. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  15. package/dist/collections/imap-mapped.d.mts +0 -1
  16. package/dist/collections/imap-mapped.d.mts.map +1 -1
  17. package/dist/collections/imap-mapped.mjs +7 -6
  18. package/dist/collections/imap-mapped.mjs.map +1 -1
  19. package/dist/collections/imap.d.mts +0 -1
  20. package/dist/collections/imap.d.mts.map +1 -1
  21. package/dist/collections/imap.mjs +11 -9
  22. package/dist/collections/imap.mjs.map +1 -1
  23. package/dist/collections/queue.d.mts +0 -1
  24. package/dist/collections/queue.d.mts.map +1 -1
  25. package/dist/collections/queue.mjs +4 -4
  26. package/dist/collections/queue.mjs.map +1 -1
  27. package/dist/collections/stack.d.mts +0 -1
  28. package/dist/collections/stack.d.mts.map +1 -1
  29. package/dist/collections/stack.mjs +4 -4
  30. package/dist/collections/stack.mjs.map +1 -1
  31. package/dist/entry-point.d.mts +1 -0
  32. package/dist/entry-point.d.mts.map +1 -1
  33. package/dist/entry-point.mjs +8 -4
  34. package/dist/entry-point.mjs.map +1 -1
  35. package/dist/functional/index.d.mts +3 -2
  36. package/dist/functional/index.d.mts.map +1 -1
  37. package/dist/functional/index.mjs +6 -2
  38. package/dist/functional/index.mjs.map +1 -1
  39. package/dist/functional/optional/impl/index.d.mts +18 -0
  40. package/dist/functional/optional/impl/index.d.mts.map +1 -0
  41. package/dist/functional/optional/impl/index.mjs +17 -0
  42. package/dist/functional/optional/impl/index.mjs.map +1 -0
  43. package/dist/functional/optional/impl/optional-expect-to-be.d.mts +29 -0
  44. package/dist/functional/optional/impl/optional-expect-to-be.d.mts.map +1 -0
  45. package/dist/functional/optional/impl/optional-expect-to-be.mjs +25 -0
  46. package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -0
  47. package/dist/functional/optional/impl/optional-filter.d.mts +29 -0
  48. package/dist/functional/optional/impl/optional-filter.d.mts.map +1 -0
  49. package/dist/functional/optional/impl/optional-filter.mjs +28 -0
  50. package/dist/functional/optional/impl/optional-filter.mjs.map +1 -0
  51. package/dist/functional/optional/impl/optional-flat-map.d.mts +33 -0
  52. package/dist/functional/optional/impl/optional-flat-map.d.mts.map +1 -0
  53. package/dist/functional/optional/impl/optional-flat-map.mjs +21 -0
  54. package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -0
  55. package/dist/functional/optional/impl/optional-from-nullable.d.mts +24 -0
  56. package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +1 -0
  57. package/dist/functional/optional/impl/optional-from-nullable.mjs +29 -0
  58. package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -0
  59. package/dist/functional/optional/impl/optional-is-none.d.mts +22 -0
  60. package/dist/functional/optional/impl/optional-is-none.d.mts.map +1 -0
  61. package/dist/functional/optional/impl/optional-is-none.mjs +25 -0
  62. package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -0
  63. package/dist/functional/optional/impl/optional-is-optional.d.mts +18 -0
  64. package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -0
  65. package/dist/functional/optional/impl/optional-is-optional.mjs +27 -0
  66. package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -0
  67. package/dist/functional/optional/impl/optional-is-some.d.mts +22 -0
  68. package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -0
  69. package/dist/functional/optional/impl/optional-is-some.mjs +25 -0
  70. package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -0
  71. package/dist/functional/optional/impl/optional-map.d.mts +31 -0
  72. package/dist/functional/optional/impl/optional-map.d.mts.map +1 -0
  73. package/dist/functional/optional/impl/optional-map.mjs +25 -0
  74. package/dist/functional/optional/impl/optional-map.mjs.map +1 -0
  75. package/dist/functional/optional/impl/optional-none.d.mts +16 -0
  76. package/dist/functional/optional/impl/optional-none.d.mts.map +1 -0
  77. package/dist/functional/optional/impl/optional-none.mjs +20 -0
  78. package/dist/functional/optional/impl/optional-none.mjs.map +1 -0
  79. package/dist/functional/optional/impl/optional-or-else.d.mts +35 -0
  80. package/dist/functional/optional/impl/optional-or-else.d.mts.map +1 -0
  81. package/dist/functional/optional/impl/optional-or-else.mjs +19 -0
  82. package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -0
  83. package/dist/functional/optional/impl/optional-some.d.mts +19 -0
  84. package/dist/functional/optional/impl/optional-some.d.mts.map +1 -0
  85. package/dist/functional/optional/impl/optional-some.mjs +26 -0
  86. package/dist/functional/optional/impl/optional-some.mjs.map +1 -0
  87. package/dist/functional/optional/impl/optional-to-nullable.d.mts +27 -0
  88. package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -0
  89. package/dist/functional/optional/impl/optional-to-nullable.mjs +31 -0
  90. package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -0
  91. package/dist/functional/optional/impl/optional-unwrap-or.d.mts +33 -0
  92. package/dist/functional/optional/impl/optional-unwrap-or.d.mts.map +1 -0
  93. package/dist/functional/optional/impl/optional-unwrap-or.mjs +19 -0
  94. package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -0
  95. package/dist/functional/optional/impl/optional-unwrap-throw.d.mts +29 -0
  96. package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -0
  97. package/dist/functional/optional/impl/optional-unwrap-throw.mjs +38 -0
  98. package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -0
  99. package/dist/functional/optional/impl/optional-unwrap.d.mts +28 -0
  100. package/dist/functional/optional/impl/optional-unwrap.d.mts.map +1 -0
  101. package/dist/functional/optional/impl/optional-unwrap.mjs +11 -0
  102. package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -0
  103. package/dist/functional/optional/impl/optional-zip.d.mts +31 -0
  104. package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -0
  105. package/dist/functional/optional/impl/optional-zip.mjs +39 -0
  106. package/dist/functional/optional/impl/optional-zip.mjs.map +1 -0
  107. package/dist/functional/optional/impl/tag.d.mts +5 -0
  108. package/dist/functional/optional/impl/tag.d.mts.map +1 -0
  109. package/dist/functional/optional/impl/tag.mjs +7 -0
  110. package/dist/functional/optional/impl/tag.mjs.map +1 -0
  111. package/dist/functional/optional/impl/types.d.mts +22 -0
  112. package/dist/functional/optional/impl/types.d.mts.map +1 -0
  113. package/dist/functional/optional/impl/types.mjs +2 -0
  114. package/dist/functional/optional/impl/types.mjs.map +1 -0
  115. package/dist/functional/optional/index.d.mts +2 -0
  116. package/dist/functional/optional/index.d.mts.map +1 -0
  117. package/dist/functional/optional/index.mjs +3 -0
  118. package/dist/functional/optional/index.mjs.map +1 -0
  119. package/dist/functional/pipe.d.mts +4 -4
  120. package/dist/functional/pipe.d.mts.map +1 -1
  121. package/dist/functional/pipe.mjs +4 -3
  122. package/dist/functional/pipe.mjs.map +1 -1
  123. package/dist/functional/result/impl/index.d.mts +24 -0
  124. package/dist/functional/result/impl/index.d.mts.map +1 -0
  125. package/dist/functional/result/impl/index.mjs +23 -0
  126. package/dist/functional/result/impl/index.mjs.map +1 -0
  127. package/dist/functional/result/impl/result-err.d.mts +25 -0
  128. package/dist/functional/result/impl/result-err.d.mts.map +1 -0
  129. package/dist/functional/result/impl/result-err.mjs +32 -0
  130. package/dist/functional/result/impl/result-err.mjs.map +1 -0
  131. package/dist/functional/result/impl/result-expect-to-be.d.mts +27 -0
  132. package/dist/functional/result/impl/result-expect-to-be.d.mts.map +1 -0
  133. package/dist/functional/result/impl/result-expect-to-be.mjs +26 -0
  134. package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -0
  135. package/dist/functional/result/impl/result-flat-map.d.mts +39 -0
  136. package/dist/functional/result/impl/result-flat-map.d.mts.map +1 -0
  137. package/dist/functional/result/impl/result-flat-map.mjs +24 -0
  138. package/dist/functional/result/impl/result-flat-map.mjs.map +1 -0
  139. package/dist/functional/result/impl/result-fold.d.mts +45 -0
  140. package/dist/functional/result/impl/result-fold.d.mts.map +1 -0
  141. package/dist/functional/result/impl/result-fold.mjs +26 -0
  142. package/dist/functional/result/impl/result-fold.mjs.map +1 -0
  143. package/dist/functional/result/impl/result-from-promise.d.mts +32 -0
  144. package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -0
  145. package/dist/functional/result/impl/result-from-promise.mjs +32 -0
  146. package/dist/functional/result/impl/result-from-promise.mjs.map +1 -0
  147. package/dist/functional/result/impl/result-from-throwable.d.mts +29 -0
  148. package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -0
  149. package/dist/functional/result/impl/result-from-throwable.mjs +46 -0
  150. package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -0
  151. package/dist/functional/result/impl/result-is-err.d.mts +20 -0
  152. package/dist/functional/result/impl/result-is-err.d.mts.map +1 -0
  153. package/dist/functional/result/impl/result-is-err.mjs +23 -0
  154. package/dist/functional/result/impl/result-is-err.mjs.map +1 -0
  155. package/dist/functional/result/impl/result-is-ok.d.mts +20 -0
  156. package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -0
  157. package/dist/functional/result/impl/result-is-ok.mjs +23 -0
  158. package/dist/functional/result/impl/result-is-ok.mjs.map +1 -0
  159. package/dist/functional/result/impl/result-is-result.d.mts +17 -0
  160. package/dist/functional/result/impl/result-is-result.d.mts.map +1 -0
  161. package/dist/functional/result/impl/result-is-result.mjs +26 -0
  162. package/dist/functional/result/impl/result-is-result.mjs.map +1 -0
  163. package/dist/functional/result/impl/result-map-err.d.mts +33 -0
  164. package/dist/functional/result/impl/result-map-err.d.mts.map +1 -0
  165. package/dist/functional/result/impl/result-map-err.mjs +25 -0
  166. package/dist/functional/result/impl/result-map-err.mjs.map +1 -0
  167. package/dist/functional/result/impl/result-map.d.mts +34 -0
  168. package/dist/functional/result/impl/result-map.d.mts.map +1 -0
  169. package/dist/functional/result/impl/result-map.mjs +25 -0
  170. package/dist/functional/result/impl/result-map.mjs.map +1 -0
  171. package/dist/functional/result/impl/result-ok.d.mts +25 -0
  172. package/dist/functional/result/impl/result-ok.d.mts.map +1 -0
  173. package/dist/functional/result/impl/result-ok.mjs +32 -0
  174. package/dist/functional/result/impl/result-ok.mjs.map +1 -0
  175. package/dist/functional/result/impl/result-or-else.d.mts +32 -0
  176. package/dist/functional/result/impl/result-or-else.d.mts.map +1 -0
  177. package/dist/functional/result/impl/result-or-else.mjs +20 -0
  178. package/dist/functional/result/impl/result-or-else.mjs.map +1 -0
  179. package/dist/functional/result/impl/result-swap.d.mts +20 -0
  180. package/dist/functional/result/impl/result-swap.d.mts.map +1 -0
  181. package/dist/functional/result/impl/result-swap.mjs +28 -0
  182. package/dist/functional/result/impl/result-swap.mjs.map +1 -0
  183. package/dist/functional/result/impl/result-to-optional.d.mts +28 -0
  184. package/dist/functional/result/impl/result-to-optional.d.mts.map +1 -0
  185. package/dist/functional/result/impl/result-to-optional.mjs +34 -0
  186. package/dist/functional/result/impl/result-to-optional.mjs.map +1 -0
  187. package/dist/functional/result/impl/result-unwrap-err-or.d.mts +29 -0
  188. package/dist/functional/result/impl/result-unwrap-err-or.d.mts.map +1 -0
  189. package/dist/functional/result/impl/result-unwrap-err-or.mjs +20 -0
  190. package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -0
  191. package/dist/functional/result/impl/result-unwrap-err-throw.d.mts +30 -0
  192. package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +1 -0
  193. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +47 -0
  194. package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -0
  195. package/dist/functional/result/impl/result-unwrap-err.d.mts +31 -0
  196. package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -0
  197. package/dist/functional/result/impl/result-unwrap-err.mjs +36 -0
  198. package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -0
  199. package/dist/functional/result/impl/result-unwrap-ok-or.d.mts +29 -0
  200. package/dist/functional/result/impl/result-unwrap-ok-or.d.mts.map +1 -0
  201. package/dist/functional/result/impl/result-unwrap-ok-or.mjs +20 -0
  202. package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -0
  203. package/dist/functional/result/impl/result-unwrap-ok.d.mts +23 -0
  204. package/dist/functional/result/impl/result-unwrap-ok.d.mts.map +1 -0
  205. package/dist/functional/result/impl/result-unwrap-ok.mjs +11 -0
  206. package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -0
  207. package/dist/functional/result/impl/result-unwrap-throw.d.mts +30 -0
  208. package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -0
  209. package/dist/functional/result/impl/result-unwrap-throw.mjs +41 -0
  210. package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -0
  211. package/dist/functional/result/impl/result-zip.d.mts +29 -0
  212. package/dist/functional/result/impl/result-zip.d.mts.map +1 -0
  213. package/dist/functional/result/impl/result-zip.mjs +38 -0
  214. package/dist/functional/result/impl/result-zip.mjs.map +1 -0
  215. package/dist/functional/result/impl/tag.d.mts +5 -0
  216. package/dist/functional/result/impl/tag.d.mts.map +1 -0
  217. package/dist/functional/result/impl/tag.mjs +7 -0
  218. package/dist/functional/result/impl/tag.mjs.map +1 -0
  219. package/dist/functional/result/impl/types.d.mts +29 -0
  220. package/dist/functional/result/impl/types.d.mts.map +1 -0
  221. package/dist/functional/result/impl/types.mjs +2 -0
  222. package/dist/functional/result/impl/types.mjs.map +1 -0
  223. package/dist/functional/result/index.d.mts +2 -0
  224. package/dist/functional/result/index.d.mts.map +1 -0
  225. package/dist/functional/result/index.mjs +3 -0
  226. package/dist/functional/result/index.mjs.map +1 -0
  227. package/dist/functional/ternary-result/impl/index.d.mts +29 -0
  228. package/dist/functional/ternary-result/impl/index.d.mts.map +1 -0
  229. package/dist/functional/ternary-result/impl/index.mjs +28 -0
  230. package/dist/functional/ternary-result/impl/index.mjs.map +1 -0
  231. package/dist/functional/ternary-result/impl/tag.d.mts +7 -0
  232. package/dist/functional/ternary-result/impl/tag.d.mts.map +1 -0
  233. package/dist/functional/ternary-result/impl/tag.mjs +9 -0
  234. package/dist/functional/ternary-result/impl/tag.mjs.map +1 -0
  235. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts +14 -0
  236. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -0
  237. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +21 -0
  238. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -0
  239. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts +18 -0
  240. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts.map +1 -0
  241. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +24 -0
  242. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -0
  243. package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts +29 -0
  244. package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts.map +1 -0
  245. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +41 -0
  246. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -0
  247. package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts +27 -0
  248. package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts.map +1 -0
  249. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +36 -0
  250. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -0
  251. package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts +20 -0
  252. package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +1 -0
  253. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +24 -0
  254. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -0
  255. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts +17 -0
  256. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -0
  257. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +33 -0
  258. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -0
  259. package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts +20 -0
  260. package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts.map +1 -0
  261. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +23 -0
  262. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -0
  263. package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts +21 -0
  264. package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +1 -0
  265. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +24 -0
  266. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -0
  267. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts +17 -0
  268. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +1 -0
  269. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +28 -0
  270. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -0
  271. package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts +21 -0
  272. package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +1 -0
  273. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +24 -0
  274. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -0
  275. package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts +23 -0
  276. package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts.map +1 -0
  277. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +26 -0
  278. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -0
  279. package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts +21 -0
  280. package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts.map +1 -0
  281. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +29 -0
  282. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -0
  283. package/dist/functional/ternary-result/impl/ternary-result-map.d.mts +29 -0
  284. package/dist/functional/ternary-result/impl/ternary-result-map.d.mts.map +1 -0
  285. package/dist/functional/ternary-result/impl/ternary-result-map.mjs +35 -0
  286. package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -0
  287. package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts +16 -0
  288. package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -0
  289. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +23 -0
  290. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -0
  291. package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts +26 -0
  292. package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts.map +1 -0
  293. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +19 -0
  294. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -0
  295. package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts +16 -0
  296. package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +1 -0
  297. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +25 -0
  298. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -0
  299. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts +22 -0
  300. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts.map +1 -0
  301. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +17 -0
  302. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -0
  303. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts +18 -0
  304. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +1 -0
  305. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +36 -0
  306. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -0
  307. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts +17 -0
  308. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +1 -0
  309. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +22 -0
  310. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -0
  311. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts +22 -0
  312. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts.map +1 -0
  313. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +17 -0
  314. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -0
  315. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts +17 -0
  316. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts.map +1 -0
  317. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +13 -0
  318. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -0
  319. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts +18 -0
  320. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -0
  321. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +36 -0
  322. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -0
  323. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts +19 -0
  324. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts.map +1 -0
  325. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +17 -0
  326. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -0
  327. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts +18 -0
  328. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +1 -0
  329. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +32 -0
  330. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -0
  331. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts +17 -0
  332. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +1 -0
  333. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +22 -0
  334. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -0
  335. package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts +18 -0
  336. package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -0
  337. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +26 -0
  338. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -0
  339. package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts +26 -0
  340. package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -0
  341. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +48 -0
  342. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -0
  343. package/dist/functional/ternary-result/impl/types.d.mts +25 -0
  344. package/dist/functional/ternary-result/impl/types.d.mts.map +1 -0
  345. package/dist/functional/ternary-result/impl/types.mjs +2 -0
  346. package/dist/functional/ternary-result/impl/types.mjs.map +1 -0
  347. package/dist/functional/ternary-result/impl/variant-name.d.mts +3 -0
  348. package/dist/functional/ternary-result/impl/variant-name.d.mts.map +1 -0
  349. package/dist/functional/ternary-result/impl/variant-name.mjs +16 -0
  350. package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -0
  351. package/dist/functional/ternary-result/index.d.mts +2 -0
  352. package/dist/functional/ternary-result/index.d.mts.map +1 -0
  353. package/dist/functional/ternary-result/index.mjs +3 -0
  354. package/dist/functional/ternary-result/index.mjs.map +1 -0
  355. package/dist/globals.d.mts +136 -0
  356. package/dist/index.d.mts +0 -1
  357. package/dist/index.d.mts.map +1 -1
  358. package/dist/index.mjs +0 -4
  359. package/dist/index.mjs.map +1 -1
  360. package/dist/json/json.d.mts +0 -1
  361. package/dist/json/json.d.mts.map +1 -1
  362. package/dist/json/json.mjs +8 -8
  363. package/dist/json/json.mjs.map +1 -1
  364. package/dist/number/branded-types/finite-number.mjs +1 -1
  365. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  366. package/dist/number/branded-types/int.mjs +1 -1
  367. package/dist/number/branded-types/int.mjs.map +1 -1
  368. package/dist/number/branded-types/int16.mjs +1 -1
  369. package/dist/number/branded-types/int16.mjs.map +1 -1
  370. package/dist/number/branded-types/int32.mjs +1 -1
  371. package/dist/number/branded-types/int32.mjs.map +1 -1
  372. package/dist/number/branded-types/non-negative-finite-number.mjs +1 -1
  373. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  374. package/dist/number/branded-types/non-negative-int16.mjs +1 -1
  375. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  376. package/dist/number/branded-types/non-negative-int32.mjs +1 -1
  377. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  378. package/dist/number/branded-types/non-zero-finite-number.mjs +1 -1
  379. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  380. package/dist/number/branded-types/non-zero-int.mjs +1 -1
  381. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  382. package/dist/number/branded-types/non-zero-int16.mjs +1 -1
  383. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  384. package/dist/number/branded-types/non-zero-int32.mjs +1 -1
  385. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  386. package/dist/number/branded-types/non-zero-safe-int.mjs +1 -1
  387. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  388. package/dist/number/branded-types/non-zero-uint16.mjs +1 -1
  389. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  390. package/dist/number/branded-types/non-zero-uint32.mjs +1 -1
  391. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  392. package/dist/number/branded-types/positive-finite-number.mjs +1 -1
  393. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  394. package/dist/number/branded-types/positive-int.mjs +1 -1
  395. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  396. package/dist/number/branded-types/positive-int16.mjs +1 -1
  397. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  398. package/dist/number/branded-types/positive-int32.mjs +1 -1
  399. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  400. package/dist/number/branded-types/positive-safe-int.mjs +1 -1
  401. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  402. package/dist/number/branded-types/positive-uint16.mjs +1 -1
  403. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  404. package/dist/number/branded-types/positive-uint32.mjs +1 -1
  405. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  406. package/dist/number/branded-types/safe-int.mjs +1 -1
  407. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  408. package/dist/number/branded-types/safe-uint.mjs +1 -1
  409. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  410. package/dist/number/branded-types/uint.mjs +1 -1
  411. package/dist/number/branded-types/uint.mjs.map +1 -1
  412. package/dist/number/branded-types/uint16.mjs +1 -1
  413. package/dist/number/branded-types/uint16.mjs.map +1 -1
  414. package/dist/number/branded-types/uint32.mjs +1 -1
  415. package/dist/number/branded-types/uint32.mjs.map +1 -1
  416. package/dist/number/enum/int8.mjs +1 -1
  417. package/dist/number/enum/int8.mjs.map +1 -1
  418. package/dist/number/enum/uint8.mjs +1 -1
  419. package/dist/number/enum/uint8.mjs.map +1 -1
  420. package/dist/number/refined-number-utils.mjs +0 -2
  421. package/dist/number/refined-number-utils.mjs.map +1 -1
  422. package/dist/promise/promise.d.mts +0 -1
  423. package/dist/promise/promise.d.mts.map +1 -1
  424. package/dist/promise/promise.mjs +2 -3
  425. package/dist/promise/promise.mjs.map +1 -1
  426. package/package.json +27 -21
  427. package/src/array/impl/array-utils-element-access.mts +6 -6
  428. package/src/array/impl/array-utils-element-access.test.mts +6 -6
  429. package/src/array/impl/array-utils-reducing-value.mts +8 -24
  430. package/src/array/impl/array-utils-reducing-value.test.mts +8 -8
  431. package/src/array/impl/array-utils-slice-clamped.test.mts +1 -1
  432. package/src/entry-point.mts +1 -0
  433. package/src/functional/index.mts +3 -2
  434. package/src/functional/optional/impl/index.mts +17 -0
  435. package/src/functional/optional/impl/optional-expect-to-be.mts +65 -0
  436. package/src/functional/optional/impl/optional-filter.mts +71 -0
  437. package/src/functional/optional/impl/optional-flat-map.mts +67 -0
  438. package/src/functional/optional/impl/optional-from-nullable.mts +28 -0
  439. package/src/functional/optional/impl/optional-is-none.mts +25 -0
  440. package/src/functional/optional/impl/optional-is-optional.mts +27 -0
  441. package/src/functional/optional/impl/optional-is-some.mts +25 -0
  442. package/src/functional/optional/impl/optional-map.mts +69 -0
  443. package/src/functional/optional/impl/optional-none.mts +17 -0
  444. package/src/functional/optional/impl/optional-or-else.mts +73 -0
  445. package/src/functional/optional/impl/optional-some.mts +23 -0
  446. package/src/functional/optional/impl/optional-to-nullable.mts +31 -0
  447. package/src/functional/optional/impl/optional-unwrap-or.mts +64 -0
  448. package/src/functional/optional/impl/optional-unwrap-throw.mts +39 -0
  449. package/src/functional/optional/impl/optional-unwrap.mts +41 -0
  450. package/src/functional/optional/impl/optional-zip.mts +40 -0
  451. package/src/functional/optional/impl/tag.mts +6 -0
  452. package/src/functional/optional/impl/types.mts +28 -0
  453. package/src/functional/optional/index.mts +1 -0
  454. package/src/functional/optional.test.mts +7 -8
  455. package/src/functional/pipe.mts +5 -5
  456. package/src/functional/pipe.test.mts +1 -1
  457. package/src/functional/result/impl/index.mts +23 -0
  458. package/src/functional/result/impl/result-err.mts +29 -0
  459. package/src/functional/result/impl/result-expect-to-be.mts +63 -0
  460. package/src/functional/result/impl/result-flat-map.mts +79 -0
  461. package/src/functional/result/impl/result-fold.mts +95 -0
  462. package/src/functional/result/impl/result-from-promise.mts +39 -0
  463. package/src/functional/result/impl/result-from-throwable.mts +42 -0
  464. package/src/functional/result/impl/result-is-err.mts +23 -0
  465. package/src/functional/result/impl/result-is-ok.mts +23 -0
  466. package/src/functional/result/impl/result-is-result.mts +23 -0
  467. package/src/functional/result/impl/result-map-err.mts +72 -0
  468. package/src/functional/result/impl/result-map.mts +73 -0
  469. package/src/functional/result/impl/result-ok.mts +29 -0
  470. package/src/functional/result/impl/result-or-else.mts +63 -0
  471. package/src/functional/result/impl/result-swap.mts +28 -0
  472. package/src/functional/result/impl/result-to-optional.mts +34 -0
  473. package/src/functional/result/impl/result-unwrap-err-or.mts +60 -0
  474. package/src/functional/result/impl/result-unwrap-err-throw.mts +53 -0
  475. package/src/functional/result/impl/result-unwrap-err.mts +36 -0
  476. package/src/functional/result/impl/result-unwrap-ok-or.mts +60 -0
  477. package/src/functional/result/impl/result-unwrap-ok.mts +35 -0
  478. package/src/functional/result/impl/result-unwrap-throw.mts +43 -0
  479. package/src/functional/result/impl/result-zip.mts +39 -0
  480. package/src/functional/result/impl/tag.mts +6 -0
  481. package/src/functional/result/impl/types.mts +35 -0
  482. package/src/functional/result/index.mts +1 -0
  483. package/src/functional/result.test.mts +5 -4
  484. package/src/functional/ternary-result/impl/index.mts +28 -0
  485. package/src/functional/ternary-result/impl/tag.mts +11 -0
  486. package/src/functional/ternary-result/impl/ternary-result-err.mts +18 -0
  487. package/src/functional/ternary-result/impl/ternary-result-expect-to-be.mts +53 -0
  488. package/src/functional/ternary-result/impl/ternary-result-flat-map.mts +95 -0
  489. package/src/functional/ternary-result/impl/ternary-result-fold.mts +93 -0
  490. package/src/functional/ternary-result/impl/ternary-result-from-promise.mts +27 -0
  491. package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +31 -0
  492. package/src/functional/ternary-result/impl/ternary-result-is-err.mts +23 -0
  493. package/src/functional/ternary-result/impl/ternary-result-is-ok.mts +24 -0
  494. package/src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts +27 -0
  495. package/src/functional/ternary-result/impl/ternary-result-is-warn.mts +24 -0
  496. package/src/functional/ternary-result/impl/ternary-result-map-err.mts +64 -0
  497. package/src/functional/ternary-result/impl/ternary-result-map-warn.mts +66 -0
  498. package/src/functional/ternary-result/impl/ternary-result-map.mts +81 -0
  499. package/src/functional/ternary-result/impl/ternary-result-ok.mts +20 -0
  500. package/src/functional/ternary-result/impl/ternary-result-or-else.mts +66 -0
  501. package/src/functional/ternary-result/impl/ternary-result-to-optional.mts +25 -0
  502. package/src/functional/ternary-result/impl/ternary-result-unwrap-err-or.mts +45 -0
  503. package/src/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mts +40 -0
  504. package/src/functional/ternary-result/impl/ternary-result-unwrap-err.mts +22 -0
  505. package/src/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mts +45 -0
  506. package/src/functional/ternary-result/impl/ternary-result-unwrap-ok.mts +32 -0
  507. package/src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts +45 -0
  508. package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mts +42 -0
  509. package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mts +38 -0
  510. package/src/functional/ternary-result/impl/ternary-result-unwrap-warn.mts +22 -0
  511. package/src/functional/ternary-result/impl/ternary-result-warn.mts +23 -0
  512. package/src/functional/ternary-result/impl/ternary-result-zip.mts +53 -0
  513. package/src/functional/ternary-result/impl/types.mts +39 -0
  514. package/src/functional/ternary-result/impl/variant-name.mts +17 -0
  515. package/src/functional/ternary-result/index.mts +1 -0
  516. package/src/functional/ternary-result.test.mts +198 -0
  517. package/src/globals.d.mts +136 -0
  518. package/src/guard/is-non-empty-string.test.mts +1 -1
  519. package/src/guard/is-non-null-object.test.mts +3 -3
  520. package/src/guard/is-primitive.test.mts +3 -3
  521. package/src/guard/is-type.test.mts +3 -3
  522. package/src/index.mts +0 -1
  523. package/src/number/branded-types/finite-number.mts +7 -7
  524. package/src/number/branded-types/int.mts +7 -7
  525. package/src/number/branded-types/int16.mts +9 -9
  526. package/src/number/branded-types/int32.mts +9 -9
  527. package/src/number/branded-types/non-negative-finite-number.mts +8 -8
  528. package/src/number/branded-types/non-negative-int16.mts +9 -9
  529. package/src/number/branded-types/non-negative-int32.mts +9 -9
  530. package/src/number/branded-types/non-zero-finite-number.mts +7 -7
  531. package/src/number/branded-types/non-zero-int.mts +7 -7
  532. package/src/number/branded-types/non-zero-int16.mts +9 -9
  533. package/src/number/branded-types/non-zero-int32.mts +9 -9
  534. package/src/number/branded-types/non-zero-safe-int.mts +9 -9
  535. package/src/number/branded-types/non-zero-uint16.mts +9 -9
  536. package/src/number/branded-types/non-zero-uint32.mts +9 -9
  537. package/src/number/branded-types/positive-finite-number.mts +8 -8
  538. package/src/number/branded-types/positive-int.mts +8 -8
  539. package/src/number/branded-types/positive-int16.mts +9 -9
  540. package/src/number/branded-types/positive-int32.mts +9 -9
  541. package/src/number/branded-types/positive-safe-int.mts +9 -9
  542. package/src/number/branded-types/positive-uint16.mts +9 -9
  543. package/src/number/branded-types/positive-uint32.mts +9 -9
  544. package/src/number/branded-types/safe-int.mts +9 -9
  545. package/src/number/branded-types/safe-uint.mts +9 -9
  546. package/src/number/branded-types/uint.mts +8 -8
  547. package/src/number/branded-types/uint16.mts +9 -9
  548. package/src/number/branded-types/uint32.mts +9 -9
  549. package/src/number/enum/int8.mts +3 -3
  550. package/src/number/enum/int8.test.mts +9 -9
  551. package/src/number/enum/uint8.mts +3 -3
  552. package/src/number/enum/uint8.test.mts +8 -8
  553. package/dist/functional/optional.d.mts +0 -482
  554. package/dist/functional/optional.d.mts.map +0 -1
  555. package/dist/functional/optional.mjs +0 -328
  556. package/dist/functional/optional.mjs.map +0 -1
  557. package/dist/functional/result.d.mts +0 -712
  558. package/dist/functional/result.d.mts.map +0 -1
  559. package/dist/functional/result.mjs +0 -539
  560. package/dist/functional/result.mjs.map +0 -1
  561. package/src/functional/optional.mts +0 -713
  562. package/src/functional/result.mts +0 -1087
@@ -1,712 +0,0 @@
1
- import { Optional } from './optional.mjs';
2
- /** @internal String literal tag to identify the 'Ok' variant of Result. */
3
- declare const OkTypeTagName = "ts-data-forge::Result.ok";
4
- /** @internal String literal tag to identify the 'Err' variant of Result. */
5
- declare const ErrTypeTagName = "ts-data-forge::Result.err";
6
- /**
7
- * @template S The type of the success value.
8
- * @internal
9
- * Represents the 'Ok' variant of a Result, containing a success value.
10
- */
11
- type Ok_<S> = Readonly<{
12
- /**
13
- * @internal
14
- * Discriminant property for the 'Ok' type.
15
- */
16
- $$tag: typeof OkTypeTagName;
17
- /** The success value. */
18
- value: S;
19
- }>;
20
- /**
21
- * @template E The type of the error value.
22
- * @internal
23
- * Represents the 'Err' variant of a Result, containing an error value.
24
- */
25
- type Err_<E> = Readonly<{
26
- /**
27
- * @internal
28
- * Discriminant property for the 'Err' type.
29
- */
30
- $$tag: typeof ErrTypeTagName;
31
- /** The error value. */
32
- value: E;
33
- }>;
34
- /**
35
- * Represents a value that can either be a success (`Ok`) or an error (`Err`).
36
- *
37
- * @template S The type of the success value.
38
- * @template E The type of the error value.
39
- */
40
- export type Result<S, E> = Ok_<S> | Err_<E>;
41
- /**
42
- * Namespace for the `Result` type and related functions. Provides utilities to
43
- * handle operations that can succeed or fail.
44
- */
45
- export declare namespace Result {
46
- /**
47
- * Checks if the given value is a `Result`.
48
- *
49
- * @example
50
- *
51
- * ```ts
52
- * const okValue = Result.ok('success');
53
- * const errValue = Result.err(new Error('failure'));
54
- * const notResult = { $$tag: 'ts-data-forge::Result.ok' };
55
- *
56
- * assert.ok(Result.isResult(okValue));
57
- * assert.ok(Result.isResult(errValue));
58
- * assert.notOk(Result.isResult(notResult));
59
- * ```
60
- *
61
- * @param maybeOptional The value to check.
62
- * @returns `true` if the value is a `Result`, otherwise `false`.
63
- */
64
- export const isResult: (maybeOptional: unknown) => maybeOptional is Result<unknown, unknown>;
65
- /**
66
- * Represents a `Result` that is a success, containing a value.
67
- *
68
- * @template S The type of the success value.
69
- */
70
- export type Ok<S> = Ok_<S>;
71
- /**
72
- * Represents a `Result` that is an error, containing an error value.
73
- *
74
- * @template E The type of the error value.
75
- */
76
- export type Err<E> = Err_<E>;
77
- /**
78
- * Base type for any `Result`, used for generic constraints. Represents a
79
- * `Result` with unknown success and error types.
80
- */
81
- export type Base = Result<unknown, unknown>;
82
- /**
83
- * Extracts the success value type `S` from a `Result.Ok<S>`. If the `Result`
84
- * is `Result.Err<E>`, resolves to `never`.
85
- *
86
- * @template R The `Result.Base` type to unwrap.
87
- */
88
- export type UnwrapOk<R extends Base> = R extends Ok<infer S> ? S : never;
89
- /**
90
- * Extracts the error value type `E` from a `Result.Err<E>`. If the `Result`
91
- * is `Result.Ok<S>`, resolves to `never`.
92
- *
93
- * @template R The `Result.Base` type to unwrap.
94
- */
95
- export type UnwrapErr<R extends Base> = R extends Err<infer E> ? E : never;
96
- /**
97
- * Narrows a `Result.Base` type to `Result.Ok<S>` if it is an `Ok`. If the
98
- * `Result` is `Result.Err<E>`, resolves to `never`.
99
- *
100
- * @template R The `Result.Base` type to narrow.
101
- */
102
- export type NarrowToOk<R extends Base> = R extends Err<unknown> ? never : R;
103
- /**
104
- * Narrows a `Result.Base` type to `Result.Err<E>` if it is an `Err`. If the
105
- * `Result` is `Result.Ok<S>`, resolves to `never`.
106
- *
107
- * @template R The `Result.Base` type to narrow.
108
- */
109
- export type NarrowToErr<R extends Base> = R extends Ok<unknown> ? never : R;
110
- /**
111
- * Creates a `Result.Ok` containing the given success value.
112
- *
113
- * Use this constructor when an operation succeeds and you want to wrap the
114
- * successful result in a Result type for consistent error handling.
115
- *
116
- * @example
117
- *
118
- * ```ts
119
- * const success = Result.ok({ id: 1 });
120
- * const failure = Result.err(new Error('missing data'));
121
- *
122
- * assert.deepStrictEqual(success, {
123
- * $$tag: 'ts-data-forge::Result.ok',
124
- * value: { id: 1 },
125
- * });
126
- * assert.ok(Result.isErr(failure));
127
- * ```
128
- *
129
- * @template S The type of the success value.
130
- * @param value The success value.
131
- * @returns A `Result.Ok<S>` containing the value.
132
- */
133
- export const ok: <S>(value: S) => Ok<S>;
134
- /**
135
- * Creates a `Result.Err` containing the given error value.
136
- *
137
- * Use this constructor when an operation fails and you want to wrap the error
138
- * information in a Result type for consistent error handling.
139
- *
140
- * @example
141
- *
142
- * ```ts
143
- * const success = Result.ok({ id: 1 });
144
- * const failure = Result.err(new Error('missing data'));
145
- *
146
- * assert.deepStrictEqual(success, {
147
- * $$tag: 'ts-data-forge::Result.ok',
148
- * value: { id: 1 },
149
- * });
150
- * assert.ok(Result.isErr(failure));
151
- * ```
152
- *
153
- * @template E The type of the error value.
154
- * @param value The error value.
155
- * @returns A `Result.Err<E>` containing the value.
156
- */
157
- export const err: <E>(value: E) => Err<E>;
158
- /**
159
- * Checks if a `Result` is `Result.Ok`. Acts as a type guard, narrowing the
160
- * type to the success variant.
161
- *
162
- * This function is essential for type-safe Result handling, allowing
163
- * TypeScript to understand that subsequent operations will work with the
164
- * success value rather than the error value.
165
- *
166
- * @example
167
- *
168
- * ```ts
169
- * const operation = Result.ok(3);
170
- * const failure = Result.err('error');
171
- *
172
- * if (Result.isOk(operation)) {
173
- * const value: number = operation.value;
174
- * assert(value === 3);
175
- * }
176
- *
177
- * assert.ok(Result.isErr(failure));
178
- * ```
179
- *
180
- * @template R The `Result.Base` type to check.
181
- * @param result The `Result` to check.
182
- * @returns `true` if the `Result` is `Result.Ok`, otherwise `false`.
183
- */
184
- export const isOk: <R extends Base>(result: R) => result is NarrowToOk<R>;
185
- /**
186
- * Checks if a `Result` is `Result.Err`. Acts as a type guard, narrowing the
187
- * type to the error variant.
188
- *
189
- * This function is essential for type-safe Result handling, allowing
190
- * TypeScript to understand that subsequent operations will work with the
191
- * error value rather than the success value.
192
- *
193
- * @example
194
- *
195
- * ```ts
196
- * const operation = Result.ok(3);
197
- * const failure = Result.err('error');
198
- *
199
- * if (Result.isOk(operation)) {
200
- * const value: number = operation.value;
201
- * assert(value === 3);
202
- * }
203
- *
204
- * assert.ok(Result.isErr(failure));
205
- * ```
206
- *
207
- * @template R The `Result.Base` type to check.
208
- * @param result The `Result` to check.
209
- * @returns `true` if the `Result` is `Result.Err`, otherwise `false`.
210
- */
211
- export const isErr: <R extends Base>(result: R) => result is NarrowToErr<R>;
212
- /**
213
- * Unwraps a `Result`, returning the success value. Throws an error if the
214
- * `Result` is `Result.Err`.
215
- *
216
- * This is useful when you're confident that a Result should contain a success
217
- * value and want to treat errors as exceptional conditions. The error message
218
- * will be constructed from the error value using the provided string
219
- * conversion function.
220
- *
221
- * @example
222
- *
223
- * ```ts
224
- * const okResult = Result.ok('data');
225
- * const errResult = Result.err(new Error('fail'));
226
- *
227
- * assert(Result.unwrapThrow(okResult) === 'data');
228
- * assert.throws(() => Result.unwrapThrow(errResult), /fail/u);
229
- * ```
230
- *
231
- * @template R The `Result.Base` type to unwrap.
232
- * @param result The `Result` to unwrap.
233
- * @param toStr An optional function to convert the error value to a string
234
- * for the error message. Defaults to `String`.
235
- * @returns The success value if `Result.Ok`.
236
- * @throws {Error} Error with the stringified error value if the `Result` is
237
- * `Result.Err`.
238
- */
239
- export const unwrapThrow: <R extends Base>(result: R, toStr?: (e: UnwrapErr<R>) => string) => UnwrapOk<R>;
240
- /**
241
- * Unwraps a `Result`, returning the success value or `undefined` if it's an
242
- * error.
243
- *
244
- * This function provides a safe way to extract success values from Results
245
- * without throwing exceptions. It has overloaded behavior based on the type:
246
- *
247
- * - For `Result.Ok<T>`: Always returns `T` (guaranteed by type system)
248
- * - For general `Result<T, E>`: Returns `T | undefined`
249
- *
250
- * @example
251
- *
252
- * ```ts
253
- * const okResult = Result.ok(42);
254
- * const errResult = Result.err('oops');
255
- *
256
- * // Result.unwrapOk returns the value for Ok results
257
- *
258
- * assert(Result.unwrapOk(okResult) === 42);
259
- *
260
- * // Result.unwrapOk returns undefined for Err results
261
- * // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
262
- * assert(Result.unwrapOk(errResult) === undefined);
263
- * ```
264
- *
265
- * @template R The `Result.Base` type to unwrap.
266
- * @param result The `Result` to unwrap.
267
- * @returns The success value if `Result.Ok`, otherwise `undefined`.
268
- */
269
- export function unwrapOk<R extends Ok<unknown>>(result: R): UnwrapOk<R>;
270
- export function unwrapOk<R extends Base>(result: R): UnwrapOk<R> | undefined;
271
- /**
272
- * Unwraps a `Result`, returning the success value or a default value if it is
273
- * `Result.Err`.
274
- *
275
- * @example
276
- *
277
- * ```ts
278
- * const okValue = Result.ok(10);
279
- * const errValue = Result.err('fail');
280
- *
281
- * assert(Result.unwrapOkOr(okValue, 0) === 10);
282
- * assert(Result.unwrapOkOr(errValue, 0) === 0);
283
- *
284
- * const unwrapWithDefault = Result.unwrapOkOr(5);
285
- *
286
- * assert(unwrapWithDefault(Result.ok(3)) === 3);
287
- * assert(unwrapWithDefault(Result.err('no data')) === 5);
288
- * ```
289
- *
290
- * @template R The `Result.Base` type to unwrap.
291
- * @template D The type of the default value.
292
- * @param result The `Result` to unwrap.
293
- * @param defaultValue The value to return if `result` is `Result.Err`.
294
- * @returns The success value if `Result.Ok`, otherwise `defaultValue`.
295
- */
296
- export function unwrapOkOr<R extends Base, D>(result: R, defaultValue: D): D | UnwrapOk<R>;
297
- export function unwrapOkOr<S, D>(defaultValue: D): <E>(result: Result<S, E>) => D | S;
298
- /**
299
- * Unwraps a `Result`, returning the error value. Throws an error if the
300
- * `Result` is `Result.Ok`.
301
- *
302
- * This function is used when you expect a Result to be an error and want to
303
- * extract the error value. If the Result is unexpectedly Ok, it will throw an
304
- * error with information about the unexpected success value.
305
- *
306
- * @example
307
- *
308
- * ```ts
309
- * const errResult = Result.err(new Error('broken'));
310
- * const okResult = Result.ok('value');
311
- *
312
- * assert(Result.unwrapErrThrow(errResult).message === 'broken');
313
- * assert.throws(() => Result.unwrapErrThrow(okResult), /Expected Err/u);
314
- * ```
315
- *
316
- * @template R The `Result.Base` type to unwrap.
317
- * @param result The `Result` to unwrap.
318
- * @param toStr An optional function to convert the success value to a string
319
- * for the error message when the Result is unexpectedly Ok. Defaults to
320
- * `String`.
321
- * @returns The error value if `Result.Err`.
322
- * @throws {Error} Error with message "Expected Err but got Ok: {value}" if
323
- * the `Result` is `Result.Ok`.
324
- */
325
- export const unwrapErrThrow: <R extends Base>(result: R, toStr?: (v: UnwrapOk<R>) => string) => UnwrapErr<R>;
326
- /**
327
- * Unwraps a `Result`, returning the error value or `undefined` if it is
328
- * `Result.Ok`.
329
- *
330
- * This provides a safe way to extract error values from Results without
331
- * throwing exceptions. Useful for error handling patterns where you want to
332
- * check for specific error conditions.
333
- *
334
- * @example
335
- *
336
- * ```ts
337
- * const okResult = Result.ok('data');
338
- * const errResult = Result.err('problem');
339
- *
340
- * // Result.unwrapErr returns undefined for Ok results
341
- * // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
342
- * assert(Result.unwrapErr(okResult) === undefined);
343
- *
344
- * // Result.unwrapErr returns the error value for Err results
345
- *
346
- * assert(Result.unwrapErr(errResult) === 'problem');
347
- * ```
348
- *
349
- * @template R The `Result.Base` type to unwrap.
350
- * @param result The `Result` to unwrap.
351
- * @returns The error value if `Result.Err`, otherwise `undefined`.
352
- */
353
- export const unwrapErr: <R extends Base>(result: R) => UnwrapErr<R> | undefined;
354
- /**
355
- * Unwraps a `Result`, returning the error value or a default value if it is
356
- * `Result.Ok`.
357
- *
358
- * @example
359
- *
360
- * ```ts
361
- * const okResult = Result.ok('success');
362
- * const errResult = Result.err('failure');
363
- *
364
- * assert(Result.unwrapErrOr(okResult, 'default') === 'default');
365
- * assert(Result.unwrapErrOr(errResult, 'default') === 'failure');
366
- *
367
- * const unwrapError = Result.unwrapErrOr('fallback error');
368
- *
369
- * assert(unwrapError(Result.err('boom')) === 'boom');
370
- * assert(unwrapError(Result.ok('no error')) === 'fallback error');
371
- * ```
372
- *
373
- * @template R The `Result.Base` type to unwrap.
374
- * @template D The type of the default value.
375
- * @param result The `Result` to unwrap.
376
- * @param defaultValue The value to return if `result` is `Result.Ok`.
377
- * @returns The error value if `Result.Err`, otherwise `defaultValue`.
378
- */
379
- export function unwrapErrOr<R extends Base, D>(result: R, defaultValue: D): D | UnwrapErr<R>;
380
- export function unwrapErrOr<E, D>(defaultValue: D): <S>(result: Result<S, E>) => D | E;
381
- /**
382
- * Maps a `Result<S, E>` to `Result<S2, E>` by applying a function to the
383
- * success value. If the `Result` is `Result.Err`, returns the original
384
- * `Err`.
385
- *
386
- * @example
387
- *
388
- * ```ts
389
- * const okNumber = Result.ok(5);
390
- * const errMessage = Result.err('error');
391
- *
392
- * const doubled = Result.map(okNumber, (value) => value * 2);
393
- * const untouchedError = Result.map(errMessage, (value: number) => value * 2);
394
- *
395
- * assert.deepStrictEqual(doubled, Result.ok(10));
396
- * assert.deepStrictEqual(untouchedError, errMessage);
397
- *
398
- * const mapToLength = Result.map((text: string) => text.length);
399
- *
400
- * assert.deepStrictEqual(mapToLength(Result.ok('abc')), Result.ok(3));
401
- * assert.deepStrictEqual(mapToLength(Result.err('bad')), Result.err('bad'));
402
- * ```
403
- *
404
- * @template R The input `Result.Base` type.
405
- * @template S2 The type of the success value returned by the mapping
406
- * function.
407
- * @param result The `Result` to map.
408
- * @param mapFn The function to apply to the success value if present.
409
- * @returns A new `Result<S2, UnwrapErr<R>>`.
410
- */
411
- export function map<R extends Base, S2>(result: R, mapFn: (value: UnwrapOk<R>) => S2): Result<S2, UnwrapErr<R>>;
412
- export function map<S, S2>(mapFn: (value: S) => S2): <E>(result: Result<S, E>) => Result<S2, E>;
413
- /**
414
- * Maps a `Result<S, E>` to `Result<S, E2>` by applying a function to the
415
- * error value. If the `Result` is `Result.Ok`, returns the original `Ok`.
416
- *
417
- * @example
418
- *
419
- * ```ts
420
- * const okValue = Result.ok(3) as Result<number, string>;
421
- * const errValue = Result.err('missing');
422
- *
423
- * const untouchedOk = Result.mapErr(okValue, (error) => error.toUpperCase());
424
- * const uppercasedErr = Result.mapErr(errValue, (error) => error.toUpperCase());
425
- *
426
- * assert.deepStrictEqual(untouchedOk, Result.ok(3));
427
- * assert.deepStrictEqual(uppercasedErr, Result.err('MISSING'));
428
- *
429
- * const mapError = Result.mapErr((error: Readonly<Error>) => error.message);
430
- *
431
- * const wrapped = mapError(Result.err(new Error('boom')));
432
- *
433
- * assert.deepStrictEqual(wrapped, Result.err('boom'));
434
- * ```
435
- *
436
- * @template R The input `Result.Base` type.
437
- * @template E2 The type of the error value returned by the mapping function.
438
- * @param result The `Result` to map.
439
- * @param mapFn The function to apply to the error value if present.
440
- * @returns A new `Result<UnwrapOk<R>, E2>`.
441
- */
442
- export function mapErr<R extends Base, E2>(result: R, mapFn: (error: UnwrapErr<R>) => E2): Result<UnwrapOk<R>, E2>;
443
- export function mapErr<E, E2>(mapFn: (error: E) => E2): <S>(result: Result<S, E>) => Result<S, E2>;
444
- /**
445
- * Applies one of two functions depending on whether the `Result` is `Ok` or
446
- * `Err`.
447
- *
448
- * @example
449
- *
450
- * ```ts
451
- * const okValue = Result.ok(2);
452
- * const errValue = Result.err('bad');
453
- *
454
- * const foldedOk = Result.fold(
455
- * okValue,
456
- * (value) => value * 2,
457
- * (error) => error,
458
- * );
459
- * const foldedErr = Result.fold(
460
- * errValue,
461
- * (value: number) => value * 2,
462
- * (error) => error.toUpperCase(),
463
- * );
464
- *
465
- * assert.deepStrictEqual(foldedOk, Result.ok(4));
466
- * assert.deepStrictEqual(foldedErr, Result.err('BAD'));
467
- *
468
- * const foldNumbers = Result.fold(
469
- * (value: number) => value * 3,
470
- * (error: string) => error.length,
471
- * );
472
- *
473
- * assert.deepStrictEqual(foldNumbers(Result.ok(3)), Result.ok(9));
474
- * assert.deepStrictEqual(foldNumbers(Result.err('oops')), Result.err(4));
475
- * ```
476
- *
477
- * @template R The input `Result.Base` type.
478
- * @template S2 The type of the success value returned by `mapFn`.
479
- * @template E2 The type of the error value returned by `mapErrFn`.
480
- * @param result The `Result` to fold.
481
- * @param mapFn The function to apply if `result` is `Ok`.
482
- * @param mapErrFn The function to apply if `result` is `Err`.
483
- * @returns A new `Result<S2, E2>` based on the applied function.
484
- */
485
- export function fold<R extends Base, S2, E2>(result: R, mapFn: (value: UnwrapOk<R>) => S2, mapErrFn: (error: UnwrapErr<R>) => E2): Result<S2, E2>;
486
- export function fold<S, E, S2, E2>(mapFn: (value: S) => S2, mapErrFn: (error: E) => E2): (result: Result<S, E>) => Result<S2, E2>;
487
- /**
488
- * Applies a function that returns a `Result` to the success value of a
489
- * `Result`. If the input is `Err`, returns the original `Err`. This is the
490
- * monadic bind operation for `Result`.
491
- *
492
- * @example
493
- *
494
- * ```ts
495
- * const parseNumber = (input: string): Result<number, string> => {
496
- * const num = Number.parseInt(input, 10);
497
- * return Number.isNaN(num) ? Result.err('not a number') : Result.ok(num);
498
- * };
499
- *
500
- * const parsed = Result.flatMap(Result.ok('42'), parseNumber);
501
- * const failure = Result.flatMap(Result.ok('abc'), parseNumber);
502
- * const passthrough = Result.flatMap(Result.err('fail'), parseNumber);
503
- *
504
- * assert.deepStrictEqual(parsed, Result.ok(42));
505
- * assert.deepStrictEqual(failure, Result.err('not a number'));
506
- * assert.deepStrictEqual(passthrough, Result.err('fail'));
507
- *
508
- * const parseThenDouble = Result.flatMap((input: string) =>
509
- * Result.map(parseNumber(input), (value) => value * 2),
510
- * );
511
- *
512
- * assert.deepStrictEqual(parseThenDouble(Result.ok('10')), Result.ok(20));
513
- * ```
514
- *
515
- * @template R The input `Result.Base` type.
516
- * @template S2 The success type of the `Result` returned by the function.
517
- * @template E2 The error type of the `Result` returned by the function.
518
- * @param result The `Result` to flat map.
519
- * @param flatMapFn The function to apply that returns a `Result`.
520
- * @returns The result of applying the function, or the original `Err`.
521
- */
522
- export function flatMap<R extends Base, S2, E2>(result: R, flatMapFn: (value: UnwrapOk<R>) => Result<S2, E2>): Result<S2, E2 | UnwrapErr<R>>;
523
- export function flatMap<S, S2, E2>(flatMapFn: (value: S) => Result<S2, E2>): <E>(result: Result<S, E>) => Result<S2, E | E2>;
524
- /**
525
- * Unwraps a `Result`, returning the success value or throwing an error with
526
- * the provided message.
527
- *
528
- * @example
529
- *
530
- * ```ts
531
- * const okValue = Result.ok('data');
532
- *
533
- * assert(Result.expectToBe(okValue, 'should have value') === 'data');
534
- *
535
- * const expectResult = Result.expectToBe<string>('missing result');
536
- *
537
- * assert.throws(() => expectResult(Result.err('boom')), /missing result/u);
538
- * assert(expectResult(Result.ok('value')) === 'value');
539
- * ```
540
- *
541
- * @template R The `Result.Base` type to unwrap.
542
- * @param result The `Result` to unwrap.
543
- * @param message The error message to throw if the `Result` is `Result.Err`.
544
- * @returns The success value if `Result.Ok`.
545
- * @throws Error with the provided message if the `Result` is `Result.Err`.
546
- */
547
- export function expectToBe<R extends Base>(result: R, message: string): UnwrapOk<R>;
548
- export function expectToBe<S>(message: string): <E>(result: Result<S, E>) => S;
549
- /**
550
- * @template P The Promise type.
551
- * @internal
552
- * Utility type to extract the resolved value type from a Promise.
553
- */
554
- type UnwrapPromise<P extends Promise<unknown>> = P extends Promise<infer V> ? V : never;
555
- /**
556
- * Converts a Promise into a Promise that resolves to a `Result`. If the input
557
- * Promise resolves, the `Result` will be `Ok` with the resolved value. If the
558
- * input Promise rejects, the `Result` will be `Err` with the rejection
559
- * reason.
560
- *
561
- * @example
562
- *
563
- * ```ts
564
- * const successPromise = Result.fromPromise(Promise.resolve('ok'));
565
- * const failurePromise = Result.fromPromise(Promise.reject(new Error('fail')));
566
- *
567
- * const resolved = await successPromise;
568
- * const rejected = await failurePromise;
569
- *
570
- * assert.deepStrictEqual(resolved, Result.ok('ok'));
571
- * assert.ok(Result.isErr(rejected));
572
- * ```
573
- *
574
- * @template P The type of the input Promise.
575
- * @param promise The Promise to convert.
576
- * @returns A Promise that resolves to `Result<UnwrapPromise<P>, unknown>`.
577
- */
578
- export const fromPromise: <P extends Promise<unknown>>(promise: P) => Promise<Result<UnwrapPromise<P>, unknown>>;
579
- /**
580
- * Wraps a function that may throw an exception in a `Result`.
581
- *
582
- * This is a fundamental utility for converting traditional exception-based
583
- * error handling into Result-based error handling. Any thrown value is
584
- * converted to an Error object for consistent error handling.
585
- *
586
- * If the function executes successfully, returns `Result.Ok` with the result.
587
- * If the function throws, returns `Result.Err` with the caught error.
588
- *
589
- * @example
590
- *
591
- * ```ts
592
- * const success = Result.fromThrowable(() => 1 + 1);
593
- * const failure = Result.fromThrowable(() => {
594
- * throw new Error('boom');
595
- * });
596
- *
597
- * assert.deepStrictEqual(success, Result.ok(2));
598
- * assert.ok(Result.isErr(failure));
599
- * ```
600
- *
601
- * @template T The return type of the function.
602
- * @param fn The function to execute that may throw.
603
- * @returns A `Result<T, Error>` containing either the successful result or
604
- * the caught error.
605
- */
606
- export const fromThrowable: <T>(fn: () => T) => Result<T, Error>;
607
- /**
608
- * Swaps the success and error values of a `Result`.
609
- *
610
- * @example
611
- *
612
- * ```ts
613
- * const okValue = Result.ok('value');
614
- * const errValue = Result.err('error');
615
- *
616
- * assert.deepStrictEqual(Result.swap(okValue), Result.err('value'));
617
- * assert.deepStrictEqual(Result.swap(errValue), Result.ok('error'));
618
- * ```
619
- *
620
- * @template R The input `Result.Base` type.
621
- * @param result The `Result` to swap.
622
- * @returns A new `Result` with success and error swapped.
623
- */
624
- export const swap: <R extends Base>(result: R) => Result<UnwrapErr<R>, UnwrapOk<R>>;
625
- /**
626
- * Converts a `Result` to an `Optional`.
627
- *
628
- * This conversion is useful when you want to discard error information and
629
- * only care about whether an operation succeeded. The error information is
630
- * lost in this conversion, so use it when error details are not needed.
631
- *
632
- * If the `Result` is `Ok`, returns `Some` with the value. If the `Result` is
633
- * `Err`, returns `None`.
634
- *
635
- * @example
636
- *
637
- * ```ts
638
- * const okValue = Result.ok(7);
639
- * const errValue = Result.err('fail');
640
- *
641
- * assert.deepStrictEqual(Result.toOptional(okValue), Optional.some(7));
642
- * assert.deepStrictEqual(Result.toOptional(errValue), Optional.none);
643
- * ```
644
- *
645
- * @template R The input `Result.Base` type.
646
- * @param result The `Result` to convert.
647
- * @returns An `Optional<UnwrapOk<R>>` containing the success value or
648
- * representing `None`.
649
- */
650
- export const toOptional: <R extends Base>(result: R) => Optional<UnwrapOk<R>>;
651
- /**
652
- * Returns the `Result` if it is `Ok`, otherwise returns the alternative.
653
- *
654
- * @example
655
- *
656
- * ```ts
657
- * const primary = Result.ok('primary');
658
- * const fallback = Result.ok('fallback');
659
- * const failure = Result.err('failure');
660
- *
661
- * assert.deepStrictEqual(Result.orElse(primary, fallback), primary);
662
- * assert.deepStrictEqual(Result.orElse(failure, fallback), fallback);
663
- *
664
- * const orElseFallback = Result.orElse(Result.ok('default'));
665
- *
666
- * assert.deepStrictEqual(
667
- * orElseFallback(Result.err('missing')),
668
- * Result.ok('default'),
669
- * );
670
- * assert.deepStrictEqual(orElseFallback(Result.ok('value')), Result.ok('value'));
671
- * ```
672
- *
673
- * @template R The input `Result.Base` type.
674
- * @param result The `Result` to check.
675
- * @param alternative The alternative `Result` to return if the first is
676
- * `Err`.
677
- * @returns The first `Result` if `Ok`, otherwise the alternative.
678
- */
679
- export function orElse<R extends Base, R2 extends Base>(result: R, alternative: R2): NarrowToOk<R> | R2;
680
- export function orElse<S, E, S2, E2>(alternative: Result<S2, E2>): (result: Result<S, E>) => Result<S, E> | Result<S2, E2>;
681
- /**
682
- * Combines two `Result` values into a single `Result` containing a tuple. If
683
- * either `Result` is `Err`, returns the first `Err` encountered.
684
- *
685
- * @example
686
- *
687
- * ```ts
688
- * const first = Result.ok('left');
689
- * const second = Result.ok(1);
690
- *
691
- * const expected: readonly [string, number] = ['left', 1];
692
- *
693
- * assert.deepStrictEqual(Result.zip(first, second), Result.ok(expected));
694
- * assert.deepStrictEqual(
695
- * Result.zip(first, Result.err('error')),
696
- * Result.err('error'),
697
- * );
698
- * ```
699
- *
700
- * @template S1 The success type of the first `Result`.
701
- * @template E1 The error type of the first `Result`.
702
- * @template S2 The success type of the second `Result`.
703
- * @template E2 The error type of the second `Result`.
704
- * @param resultA The first `Result`.
705
- * @param resultB The second `Result`.
706
- * @returns A `Result` containing a tuple of both values, or the first `Err`.
707
- */
708
- export const zip: <S1, E1, S2, E2>(resultA: Result<S1, E1>, resultB: Result<S2, E2>) => Result<readonly [S1, S2], E1 | E2>;
709
- export {};
710
- }
711
- export {};
712
- //# sourceMappingURL=result.d.mts.map