ts-data-forge 8.0.0 → 9.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (429) hide show
  1. package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
  2. package/dist/array/impl/array-utils-creation.mjs +17 -112
  3. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  4. package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
  5. package/dist/array/impl/array-utils-element-access.mjs +22 -61
  6. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  7. package/dist/array/impl/array-utils-iterators.d.mts.map +1 -1
  8. package/dist/array/impl/array-utils-iterators.mjs +9 -63
  9. package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
  10. package/dist/array/impl/array-utils-modification.mjs +78 -78
  11. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  12. package/dist/array/impl/array-utils-reducing-value.mjs +95 -89
  13. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  14. package/dist/array/impl/array-utils-search.mjs +100 -92
  15. package/dist/array/impl/array-utils-search.mjs.map +1 -1
  16. package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
  17. package/dist/array/impl/array-utils-set-op.mjs +31 -141
  18. package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
  19. package/dist/array/impl/array-utils-size.d.mts.map +1 -1
  20. package/dist/array/impl/array-utils-size.mjs +4 -8
  21. package/dist/array/impl/array-utils-size.mjs.map +1 -1
  22. package/dist/array/impl/array-utils-slice-clamped.mjs +11 -12
  23. package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
  24. package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
  25. package/dist/array/impl/array-utils-slicing.mjs +44 -96
  26. package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
  27. package/dist/array/impl/array-utils-transformation.d.mts +1 -1
  28. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
  29. package/dist/array/impl/array-utils-transformation.mjs +150 -292
  30. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  31. package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
  32. package/dist/array/impl/array-utils-validation.mjs +18 -169
  33. package/dist/array/impl/array-utils-validation.mjs.map +1 -1
  34. package/dist/collections/imap-mapped.d.mts.map +1 -1
  35. package/dist/collections/imap-mapped.mjs +243 -330
  36. package/dist/collections/imap-mapped.mjs.map +1 -1
  37. package/dist/collections/imap.d.mts.map +1 -1
  38. package/dist/collections/imap.mjs +190 -275
  39. package/dist/collections/imap.mjs.map +1 -1
  40. package/dist/collections/iset-mapped.d.mts +1 -1
  41. package/dist/collections/iset-mapped.d.mts.map +1 -1
  42. package/dist/collections/iset-mapped.mjs +222 -444
  43. package/dist/collections/iset-mapped.mjs.map +1 -1
  44. package/dist/collections/iset.d.mts +1 -1
  45. package/dist/collections/iset.d.mts.map +1 -1
  46. package/dist/collections/iset.mjs +158 -324
  47. package/dist/collections/iset.mjs.map +1 -1
  48. package/dist/collections/queue.d.mts.map +1 -1
  49. package/dist/collections/queue.mjs +106 -178
  50. package/dist/collections/queue.mjs.map +1 -1
  51. package/dist/collections/stack.d.mts.map +1 -1
  52. package/dist/collections/stack.mjs +95 -165
  53. package/dist/collections/stack.mjs.map +1 -1
  54. package/dist/entry-point.mjs +1 -0
  55. package/dist/entry-point.mjs.map +1 -1
  56. package/dist/expect-type.d.mts +1 -1
  57. package/dist/expect-type.d.mts.map +1 -1
  58. package/dist/expect-type.mjs +1 -69
  59. package/dist/expect-type.mjs.map +1 -1
  60. package/dist/functional/match.mjs +9 -9
  61. package/dist/functional/match.mjs.map +1 -1
  62. package/dist/functional/optional/impl/optional-expect-to-be.mjs +13 -14
  63. package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
  64. package/dist/functional/optional/impl/optional-filter.mjs +14 -15
  65. package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
  66. package/dist/functional/optional/impl/optional-flat-map.mjs +10 -11
  67. package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
  68. package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +1 -1
  69. package/dist/functional/optional/impl/optional-from-nullable.mjs +1 -25
  70. package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
  71. package/dist/functional/optional/impl/optional-is-none.d.mts.map +1 -1
  72. package/dist/functional/optional/impl/optional-is-none.mjs +0 -19
  73. package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -1
  74. package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -1
  75. package/dist/functional/optional/impl/optional-is-optional.mjs +1 -23
  76. package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
  77. package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -1
  78. package/dist/functional/optional/impl/optional-is-some.mjs +0 -20
  79. package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
  80. package/dist/functional/optional/impl/optional-map.mjs +13 -14
  81. package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
  82. package/dist/functional/optional/impl/optional-none.mjs +0 -16
  83. package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
  84. package/dist/functional/optional/impl/optional-or-else.mjs +10 -11
  85. package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
  86. package/dist/functional/optional/impl/optional-some.d.mts.map +1 -1
  87. package/dist/functional/optional/impl/optional-some.mjs +2 -21
  88. package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
  89. package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -1
  90. package/dist/functional/optional/impl/optional-to-nullable.mjs +1 -27
  91. package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
  92. package/dist/functional/optional/impl/optional-unwrap-or.mjs +9 -10
  93. package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
  94. package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -1
  95. package/dist/functional/optional/impl/optional-unwrap-throw.mjs +4 -32
  96. package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
  97. package/dist/functional/optional/impl/optional-unwrap.mjs +4 -4
  98. package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
  99. package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -1
  100. package/dist/functional/optional/impl/optional-zip.mjs +1 -35
  101. package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
  102. package/dist/functional/optional/impl/tag.mjs +2 -3
  103. package/dist/functional/optional/impl/tag.mjs.map +1 -1
  104. package/dist/functional/pipe.d.mts.map +1 -1
  105. package/dist/functional/pipe.mjs +9 -34
  106. package/dist/functional/pipe.mjs.map +1 -1
  107. package/dist/functional/result/impl/result-err.d.mts.map +1 -1
  108. package/dist/functional/result/impl/result-err.mjs +2 -27
  109. package/dist/functional/result/impl/result-err.mjs.map +1 -1
  110. package/dist/functional/result/impl/result-expect-to-be.mjs +13 -15
  111. package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
  112. package/dist/functional/result/impl/result-flat-map.mjs +16 -16
  113. package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
  114. package/dist/functional/result/impl/result-fold.mjs +16 -16
  115. package/dist/functional/result/impl/result-fold.mjs.map +1 -1
  116. package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -1
  117. package/dist/functional/result/impl/result-from-promise.mjs +4 -31
  118. package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
  119. package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -1
  120. package/dist/functional/result/impl/result-from-throwable.mjs +8 -38
  121. package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
  122. package/dist/functional/result/impl/result-is-err.d.mts.map +1 -1
  123. package/dist/functional/result/impl/result-is-err.mjs +0 -19
  124. package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
  125. package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -1
  126. package/dist/functional/result/impl/result-is-ok.mjs +0 -19
  127. package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
  128. package/dist/functional/result/impl/result-is-result.d.mts.map +1 -1
  129. package/dist/functional/result/impl/result-is-result.mjs +1 -23
  130. package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
  131. package/dist/functional/result/impl/result-map-err.mjs +16 -16
  132. package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
  133. package/dist/functional/result/impl/result-map.mjs +16 -16
  134. package/dist/functional/result/impl/result-map.mjs.map +1 -1
  135. package/dist/functional/result/impl/result-ok.d.mts.map +1 -1
  136. package/dist/functional/result/impl/result-ok.mjs +2 -27
  137. package/dist/functional/result/impl/result-ok.mjs.map +1 -1
  138. package/dist/functional/result/impl/result-or-else.mjs +10 -12
  139. package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
  140. package/dist/functional/result/impl/result-swap.d.mts.map +1 -1
  141. package/dist/functional/result/impl/result-swap.mjs +4 -22
  142. package/dist/functional/result/impl/result-swap.mjs.map +1 -1
  143. package/dist/functional/result/impl/result-to-optional.d.mts.map +1 -1
  144. package/dist/functional/result/impl/result-to-optional.mjs +0 -27
  145. package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
  146. package/dist/functional/result/impl/result-unwrap-err-or.mjs +9 -11
  147. package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
  148. package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +1 -1
  149. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +13 -40
  150. package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
  151. package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -1
  152. package/dist/functional/result/impl/result-unwrap-err.mjs +4 -32
  153. package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
  154. package/dist/functional/result/impl/result-unwrap-ok-or.mjs +9 -11
  155. package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
  156. package/dist/functional/result/impl/result-unwrap-ok.mjs +4 -4
  157. package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
  158. package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -1
  159. package/dist/functional/result/impl/result-unwrap-throw.mjs +4 -35
  160. package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
  161. package/dist/functional/result/impl/result-zip.d.mts.map +1 -1
  162. package/dist/functional/result/impl/result-zip.mjs +1 -34
  163. package/dist/functional/result/impl/result-zip.mjs.map +1 -1
  164. package/dist/functional/result/impl/tag.mjs +2 -3
  165. package/dist/functional/result/impl/tag.mjs.map +1 -1
  166. package/dist/functional/ternary-result/impl/tag.mjs +3 -5
  167. package/dist/functional/ternary-result/impl/tag.mjs.map +1 -1
  168. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -1
  169. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +2 -15
  170. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
  171. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +13 -13
  172. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
  173. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +27 -26
  174. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
  175. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +21 -22
  176. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
  177. package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +1 -1
  178. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +4 -20
  179. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
  180. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -1
  181. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +7 -25
  182. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
  183. package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts.map +1 -1
  184. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +0 -17
  185. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -1
  186. package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +1 -1
  187. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +0 -19
  188. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -1
  189. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +1 -1
  190. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +1 -25
  191. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -1
  192. package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +1 -1
  193. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +0 -18
  194. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
  195. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +13 -15
  196. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
  197. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +18 -18
  198. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
  199. package/dist/functional/ternary-result/impl/ternary-result-map.mjs +21 -22
  200. package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
  201. package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -1
  202. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +2 -16
  203. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
  204. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +9 -9
  205. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
  206. package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +1 -1
  207. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +4 -22
  208. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -1
  209. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +9 -9
  210. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -1
  211. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +1 -1
  212. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +12 -27
  213. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
  214. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +1 -1
  215. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +4 -19
  216. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -1
  217. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +9 -9
  218. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -1
  219. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +4 -5
  220. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
  221. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -1
  222. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +15 -27
  223. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
  224. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +9 -9
  225. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -1
  226. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +1 -1
  227. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +10 -24
  228. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
  229. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +1 -1
  230. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +4 -19
  231. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
  232. package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -1
  233. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +3 -19
  234. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
  235. package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -1
  236. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +14 -45
  237. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
  238. package/dist/functional/ternary-result/impl/variant-name.d.mts +1 -1
  239. package/dist/functional/ternary-result/impl/variant-name.d.mts.map +1 -1
  240. package/dist/functional/ternary-result/impl/variant-name.mjs +8 -9
  241. package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -1
  242. package/dist/functional/ternary-result/ternary-result.d.mts.map +1 -1
  243. package/dist/guard/has-key.d.mts.map +1 -1
  244. package/dist/guard/has-key.mjs +0 -41
  245. package/dist/guard/has-key.mjs.map +1 -1
  246. package/dist/guard/index.d.mts +1 -0
  247. package/dist/guard/index.d.mts.map +1 -1
  248. package/dist/guard/index.mjs +1 -0
  249. package/dist/guard/index.mjs.map +1 -1
  250. package/dist/guard/is-length-bounded-string.d.mts +164 -0
  251. package/dist/guard/is-length-bounded-string.d.mts.map +1 -0
  252. package/dist/guard/is-length-bounded-string.mjs +7 -0
  253. package/dist/guard/is-length-bounded-string.mjs.map +1 -0
  254. package/dist/guard/is-non-empty-string.d.mts +1 -1
  255. package/dist/guard/is-non-empty-string.d.mts.map +1 -1
  256. package/dist/guard/is-non-empty-string.mjs +1 -38
  257. package/dist/guard/is-non-empty-string.mjs.map +1 -1
  258. package/dist/guard/is-non-null-object.d.mts.map +1 -1
  259. package/dist/guard/is-non-null-object.mjs +1 -35
  260. package/dist/guard/is-non-null-object.mjs.map +1 -1
  261. package/dist/guard/is-primitive.d.mts.map +1 -1
  262. package/dist/guard/is-primitive.mjs +12 -43
  263. package/dist/guard/is-primitive.mjs.map +1 -1
  264. package/dist/guard/is-record.d.mts.map +1 -1
  265. package/dist/guard/is-record.mjs +0 -86
  266. package/dist/guard/is-record.mjs.map +1 -1
  267. package/dist/guard/is-type.d.mts.map +1 -1
  268. package/dist/guard/is-type.mjs +12 -399
  269. package/dist/guard/is-type.mjs.map +1 -1
  270. package/dist/guard/key-is-in.d.mts.map +1 -1
  271. package/dist/guard/key-is-in.mjs +0 -40
  272. package/dist/guard/key-is-in.mjs.map +1 -1
  273. package/dist/index.mjs +1 -0
  274. package/dist/index.mjs.map +1 -1
  275. package/dist/iterator/range.mjs +16 -16
  276. package/dist/iterator/range.mjs.map +1 -1
  277. package/dist/json/json.d.mts.map +1 -1
  278. package/dist/json/json.mjs +52 -340
  279. package/dist/json/json.mjs.map +1 -1
  280. package/dist/number/branded-types/finite-number.d.mts +3 -3
  281. package/dist/number/branded-types/finite-number.mjs +135 -154
  282. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  283. package/dist/number/branded-types/int.d.mts +4 -4
  284. package/dist/number/branded-types/int.mjs +205 -245
  285. package/dist/number/branded-types/int.mjs.map +1 -1
  286. package/dist/number/branded-types/int16.d.mts +15 -15
  287. package/dist/number/branded-types/int16.mjs +116 -123
  288. package/dist/number/branded-types/int16.mjs.map +1 -1
  289. package/dist/number/branded-types/int32.d.mts +11 -11
  290. package/dist/number/branded-types/int32.mjs +116 -123
  291. package/dist/number/branded-types/int32.mjs.map +1 -1
  292. package/dist/number/branded-types/negative-finite-number.d.mts +4 -4
  293. package/dist/number/branded-types/negative-finite-number.mjs +129 -144
  294. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  295. package/dist/number/branded-types/negative-int.d.mts +5 -5
  296. package/dist/number/branded-types/negative-int.mjs +94 -113
  297. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  298. package/dist/number/branded-types/negative-safe-int.d.mts +5 -5
  299. package/dist/number/branded-types/negative-safe-int.mjs +103 -124
  300. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  301. package/dist/number/branded-types/non-negative-finite-number.d.mts +5 -5
  302. package/dist/number/branded-types/non-negative-finite-number.mjs +136 -142
  303. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  304. package/dist/number/branded-types/non-negative-int16.d.mts +16 -16
  305. package/dist/number/branded-types/non-negative-int16.mjs +109 -118
  306. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  307. package/dist/number/branded-types/non-negative-int32.d.mts +12 -12
  308. package/dist/number/branded-types/non-negative-int32.mjs +110 -119
  309. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  310. package/dist/number/branded-types/non-positive-finite-number.d.mts +3 -3
  311. package/dist/number/branded-types/non-positive-finite-number.mjs +120 -124
  312. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  313. package/dist/number/branded-types/non-positive-int.d.mts +4 -4
  314. package/dist/number/branded-types/non-positive-int.mjs +167 -212
  315. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  316. package/dist/number/branded-types/non-positive-safe-int.d.mts +4 -4
  317. package/dist/number/branded-types/non-positive-safe-int.mjs +95 -106
  318. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  319. package/dist/number/branded-types/non-zero-finite-number.d.mts +4 -4
  320. package/dist/number/branded-types/non-zero-finite-number.mjs +114 -123
  321. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  322. package/dist/number/branded-types/non-zero-int.d.mts +2 -2
  323. package/dist/number/branded-types/non-zero-int.mjs +72 -83
  324. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  325. package/dist/number/branded-types/non-zero-int16.d.mts +7 -7
  326. package/dist/number/branded-types/non-zero-int16.mjs +96 -107
  327. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  328. package/dist/number/branded-types/non-zero-int32.d.mts +5 -5
  329. package/dist/number/branded-types/non-zero-int32.mjs +97 -108
  330. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  331. package/dist/number/branded-types/non-zero-safe-int.d.mts +2 -2
  332. package/dist/number/branded-types/non-zero-safe-int.mjs +100 -111
  333. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  334. package/dist/number/branded-types/non-zero-uint16.d.mts +8 -8
  335. package/dist/number/branded-types/non-zero-uint16.mjs +96 -107
  336. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  337. package/dist/number/branded-types/non-zero-uint32.d.mts +6 -6
  338. package/dist/number/branded-types/non-zero-uint32.mjs +96 -107
  339. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  340. package/dist/number/branded-types/positive-finite-number.d.mts +8 -8
  341. package/dist/number/branded-types/positive-finite-number.mjs +139 -141
  342. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  343. package/dist/number/branded-types/positive-int.d.mts +11 -11
  344. package/dist/number/branded-types/positive-int.mjs +228 -271
  345. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  346. package/dist/number/branded-types/positive-int16.d.mts +19 -19
  347. package/dist/number/branded-types/positive-int16.mjs +109 -118
  348. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  349. package/dist/number/branded-types/positive-int32.d.mts +15 -15
  350. package/dist/number/branded-types/positive-int32.mjs +109 -118
  351. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  352. package/dist/number/branded-types/positive-safe-int.d.mts +11 -11
  353. package/dist/number/branded-types/positive-safe-int.mjs +244 -275
  354. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  355. package/dist/number/branded-types/positive-uint16.d.mts +17 -17
  356. package/dist/number/branded-types/positive-uint16.mjs +109 -118
  357. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  358. package/dist/number/branded-types/positive-uint32.d.mts +13 -13
  359. package/dist/number/branded-types/positive-uint32.mjs +110 -119
  360. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  361. package/dist/number/branded-types/safe-int.d.mts +4 -4
  362. package/dist/number/branded-types/safe-int.mjs +251 -292
  363. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  364. package/dist/number/branded-types/safe-uint.d.mts +8 -8
  365. package/dist/number/branded-types/safe-uint.mjs +111 -119
  366. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  367. package/dist/number/branded-types/uint.d.mts +8 -8
  368. package/dist/number/branded-types/uint.mjs +198 -225
  369. package/dist/number/branded-types/uint.mjs.map +1 -1
  370. package/dist/number/branded-types/uint16.d.mts +14 -14
  371. package/dist/number/branded-types/uint16.mjs +109 -119
  372. package/dist/number/branded-types/uint16.mjs.map +1 -1
  373. package/dist/number/branded-types/uint32.d.mts +10 -10
  374. package/dist/number/branded-types/uint32.mjs +110 -117
  375. package/dist/number/branded-types/uint32.mjs.map +1 -1
  376. package/dist/number/enum/int8.mjs +119 -145
  377. package/dist/number/enum/int8.mjs.map +1 -1
  378. package/dist/number/enum/uint8.mjs +107 -121
  379. package/dist/number/enum/uint8.mjs.map +1 -1
  380. package/dist/number/num.d.mts +2 -2
  381. package/dist/number/num.d.mts.map +1 -1
  382. package/dist/number/num.mjs +76 -537
  383. package/dist/number/num.mjs.map +1 -1
  384. package/dist/number/refined-number-utils.d.mts +1 -1
  385. package/dist/number/refined-number-utils.d.mts.map +1 -1
  386. package/dist/number/refined-number-utils.mjs +127 -263
  387. package/dist/number/refined-number-utils.mjs.map +1 -1
  388. package/dist/object/object.d.mts.map +1 -1
  389. package/dist/object/object.mjs +107 -222
  390. package/dist/object/object.mjs.map +1 -1
  391. package/dist/others/cast-mutable.d.mts.map +1 -1
  392. package/dist/others/cast-mutable.mjs +8 -37
  393. package/dist/others/cast-mutable.mjs.map +1 -1
  394. package/dist/others/cast-readonly.d.mts.map +1 -1
  395. package/dist/others/cast-readonly.mjs +8 -36
  396. package/dist/others/cast-readonly.mjs.map +1 -1
  397. package/dist/others/debounce-function.d.mts.map +1 -1
  398. package/dist/others/debounce-function.mjs +7 -16
  399. package/dist/others/debounce-function.mjs.map +1 -1
  400. package/dist/others/fast-deep-equal.d.mts.map +1 -1
  401. package/dist/others/fast-deep-equal.mjs +43 -59
  402. package/dist/others/fast-deep-equal.mjs.map +1 -1
  403. package/dist/others/if-then.d.mts.map +1 -1
  404. package/dist/others/if-then.mjs +0 -29
  405. package/dist/others/if-then.mjs.map +1 -1
  406. package/dist/others/map-nullable.mjs +9 -9
  407. package/dist/others/map-nullable.mjs.map +1 -1
  408. package/dist/others/memoize-function.mjs +12 -12
  409. package/dist/others/memoize-function.mjs.map +1 -1
  410. package/dist/others/tuple.d.mts.map +1 -1
  411. package/dist/others/tuple.mjs +0 -50
  412. package/dist/others/tuple.mjs.map +1 -1
  413. package/dist/others/unknown-to-string.d.mts.map +1 -1
  414. package/dist/others/unknown-to-string.mjs +41 -88
  415. package/dist/others/unknown-to-string.mjs.map +1 -1
  416. package/dist/promise/promise.d.mts.map +1 -1
  417. package/dist/promise/promise.mjs +4 -49
  418. package/dist/promise/promise.mjs.map +1 -1
  419. package/package.json +17 -16
  420. package/src/array/impl/array-utils-transformation.mts +1 -2
  421. package/src/array/impl/array-utils-transformation.test.mts +3 -36
  422. package/src/array/impl/array-utils-validation.test.mts +1 -3
  423. package/src/expect-type.mts +4 -5
  424. package/src/functional/ternary-result/ternary-result.mts +2 -6
  425. package/src/guard/index.mts +1 -0
  426. package/src/guard/is-length-bounded-string.mts +199 -0
  427. package/src/guard/is-length-bounded-string.test.mts +170 -0
  428. package/src/number/refined-number-utils.mts +1 -9
  429. package/src/object/object.mts +25 -23
@@ -1,19 +1,18 @@
1
1
  import { isNone } from './optional-is-none.mjs';
2
2
 
3
3
  function orElse(...args) {
4
- switch (args.length) {
5
- case 2: {
6
- const [optional, alternative] = args;
7
- return orElseImpl(optional, alternative);
8
- }
9
- case 1: {
10
- // Curried version
11
- const [alternative] = args;
12
- return (optional) => orElseImpl(optional, alternative);
13
- }
4
+ switch (args.length) {
5
+ case 2: {
6
+ const [optional, alternative] = args;
7
+ return orElseImpl(optional, alternative);
14
8
  }
9
+ case 1: {
10
+ const [alternative] = args;
11
+ return (optional) => orElseImpl(optional, alternative);
12
+ }
13
+ }
15
14
  }
16
- const orElseImpl = (optional, alternative) => (isNone(optional) ? alternative : optional);
15
+ const orElseImpl = (optional, alternative) => isNone(optional) ? alternative : optional;
17
16
 
18
17
  export { orElse };
19
18
  //# sourceMappingURL=optional-or-else.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"optional-or-else.mjs","sources":["../../../../src/functional/optional/impl/optional-or-else.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAqDM,SAAU,MAAM,CAIpB,GAAG,IAA0E,EAAA;AAE7E,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAI;AAEpC,YAAA,OAAO,UAAU,CAAC,QAAQ,EAAE,WAAW,CAAC;QAC1C;QAEA,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI;YAE1B,OAAO,CAAC,QAA6B,KACnC,UAAU,CAAC,QAAQ,EAAE,WAAW,CAAC;QACrC;;AAEJ;AAEA,MAAM,UAAU,GAAG,CAIjB,QAAW,EACX,WAAe,MACH,MAAM,CAAC,QAAQ,CAAC,GAAG,WAAW,GAAG,QAAQ,CAAC;;;;"}
1
+ {"version":3,"file":"optional-or-else.mjs","sources":["../../../../src/functional/optional/impl/optional-or-else.mts"],"sourcesContent":["import { type Optional, type UnknownOptional } from '../optional.mjs';\nimport { isNone } from './optional-is-none.mjs';\nimport { type Unwrap } from './types.mjs';\n\n/**\n * Returns the `Optional` if it is `Some`, otherwise returns the alternative.\n *\n * Provides a way to chain Optional operations with fallback values. This is\n * particularly useful for implementing default behavior or cascading lookups.\n * Supports both direct usage and curried form for functional composition.\n *\n * @example\n *\n * ```ts\n * const preferred = Optional.some('primary');\n *\n * const fallback = Optional.some('secondary');\n *\n * const noneValue = Optional.none as Optional<string>;\n *\n * assert.deepStrictEqual(Optional.orElse(preferred, fallback), preferred);\n *\n * assert.deepStrictEqual(Optional.orElse(noneValue, fallback), fallback);\n *\n * const orElseFallback = Optional.orElse(Optional.some('default'));\n *\n * assert.deepStrictEqual(\n * orElseFallback(Optional.none),\n * Optional.some('default'),\n * );\n *\n * assert.deepStrictEqual(\n * orElseFallback(Optional.some('value')),\n * Optional.some('value'),\n * );\n * ```\n *\n * @template O The input `UnknownOptional` type.\n * @param optional The `Optional` to check.\n * @param alternative The alternative `Optional` to return if the first is\n * `None`.\n * @returns The first `Optional` if `Some`, otherwise the alternative.\n */\nexport function orElse<\n O extends UnknownOptional,\n const O2 extends UnknownOptional,\n>(optional: O, alternative: O2): O | O2;\n\n// Curried version\nexport function orElse<O2>(\n alternative: Optional<O2>,\n): <O>(optional: Optional<O>) => Optional<O> | Optional<O2>;\n\nexport function orElse<\n O extends UnknownOptional,\n const O2 extends UnknownOptional,\n>(\n ...args: readonly [optional: O, alternative: O2] | readonly [alternative: O2]\n): (O | O2) | ((optional: Optional<Unwrap<O>>) => Optional<Unwrap<O>> | O2) {\n switch (args.length) {\n case 2: {\n const [optional, alternative] = args;\n\n return orElseImpl(optional, alternative);\n }\n\n case 1: {\n // Curried version\n const [alternative] = args;\n\n return (optional: Optional<Unwrap<O>>) =>\n orElseImpl(optional, alternative);\n }\n }\n}\n\nconst orElseImpl = <\n O extends UnknownOptional,\n const O2 extends UnknownOptional,\n>(\n optional: O,\n alternative: O2,\n): O | O2 => (isNone(optional) ? alternative : optional);\n"],"names":[],"mappings":";;AAqDO,SAAS,UAIX,IAAA,EACuE;AAC1E,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,IAAA;AAEhC,MAAA,OAAO,UAAA,CAAW,UAAU,WAAW,CAAA;AAAA,IACzC;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,WAAW,CAAA,GAAI,IAAA;AAEtB,MAAA,OAAO,CAAC,QAAA,KACN,UAAA,CAAW,QAAA,EAAU,WAAW,CAAA;AAAA,IACpC;AAAA;AAEJ;AAEA,MAAM,aAAa,CAIjB,QAAA,EACA,gBACY,MAAA,CAAO,QAAQ,IAAI,WAAA,GAAc,QAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"optional-some.d.mts","sourceRoot":"","sources":["../../../../src/functional/optional/impl/optional-some.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,CAAC,CAAC,EAAG,OAAO,CAAC,KAAG,IAAI,CAAC,CAAC,CAInC,CAAC"}
1
+ {"version":3,"file":"optional-some.d.mts","sourceRoot":"","sources":["../../../../src/functional/optional/impl/optional-some.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,CAAC,CAAC,SAAU,CAAC,KAAG,IAAI,CAAC,CAAC,CAInC,CAAC"}
@@ -1,27 +1,8 @@
1
1
  import { SomeTypeTagName } from './tag.mjs';
2
2
 
3
- /**
4
- * Creates an {@link Some} containing the given value.
5
- *
6
- * @example
7
- *
8
- * ```ts
9
- * const someValue = Optional.some({ id: 1 });
10
- *
11
- * const noneValue = Optional.none;
12
- *
13
- * assert.isTrue(Optional.isSome(someValue));
14
- *
15
- * assert.isTrue(Optional.isNone(noneValue));
16
- * ```
17
- *
18
- * @template S The type of the value.
19
- * @param value The value to wrap in an {@link Some}.
20
- * @returns An {@link Some}<S> containing the value.
21
- */
22
3
  const some = (value) => ({
23
- $$tag: SomeTypeTagName,
24
- value,
4
+ $$tag: SomeTypeTagName,
5
+ value
25
6
  });
26
7
 
27
8
  export { some };
@@ -1 +1 @@
1
- {"version":3,"file":"optional-some.mjs","sources":["../../../../src/functional/optional/impl/optional-some.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;;;;;;;;;;;;;;;;;;AAkBG;MACU,IAAI,GAAG,CAAW,KAAQ,MACpC;AACC,IAAA,KAAK,EAAE,eAAe;IACtB,KAAK;AACN,CAAA;;;;"}
1
+ {"version":3,"file":"optional-some.mjs","sources":["../../../../src/functional/optional/impl/optional-some.mts"],"sourcesContent":["import { type Some } from '../../../types.mjs';\nimport { SomeTypeTagName } from './tag.mjs';\n\n/**\n * Creates an {@link Some} containing the given value.\n *\n * @example\n *\n * ```ts\n * const someValue = Optional.some({ id: 1 });\n *\n * const noneValue = Optional.none;\n *\n * assert.isTrue(Optional.isSome(someValue));\n *\n * assert.isTrue(Optional.isNone(noneValue));\n * ```\n *\n * @template S The type of the value.\n * @param value The value to wrap in an {@link Some}.\n * @returns An {@link Some}<S> containing the value.\n */\nexport const some = <const S,>(value: S): Some<S> =>\n ({\n $$tag: SomeTypeTagName,\n value,\n }) as const;\n"],"names":[],"mappings":";;AAsBO,MAAM,IAAA,GAAO,CAAW,KAAA,MAC5B;AAAA,EACC,KAAA,EAAO,eAAA;AAAA,EACP;AACF,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"optional-to-nullable.d.mts","sourceRoot":"","sources":["../../../../src/functional/optional/impl/optional-to-nullable.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGvD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,eAAe,EAClD,UAAU,CAAC,KACV,MAAM,CAAC,CAAC,CAAC,GAAG,SAA8D,CAAC"}
1
+ {"version":3,"file":"optional-to-nullable.d.mts","sourceRoot":"","sources":["../../../../src/functional/optional/impl/optional-to-nullable.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGvD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,eAAe,YACxC,CAAC,KACV,MAAM,CAAC,CAAC,CAAC,GAAG,SAA8D,CAAC"}
@@ -1,33 +1,7 @@
1
1
  import { isSome } from './optional-is-some.mjs';
2
2
  import { unwrap } from './optional-unwrap.mjs';
3
3
 
4
- /**
5
- * Converts an `Optional` to a nullable value.
6
- *
7
- * This function extracts the value from an Optional, returning `undefined`
8
- * for empty Optionals. This is useful when interfacing with APIs or systems
9
- * that expect nullable values rather than Optional types.
10
- *
11
- * Note: This returns `undefined` (not `null`) for consistency with
12
- * JavaScript's undefined semantics and TypeScript's optional properties.
13
- *
14
- * @example
15
- *
16
- * ```ts
17
- * const someNumber = Optional.some(42);
18
- *
19
- * const noneNumber = Optional.none as Optional<number>;
20
- *
21
- * assert.isTrue(Optional.toNullable(someNumber) === 42);
22
- *
23
- * assert.isTrue(Optional.toNullable(noneNumber) === undefined);
24
- * ```
25
- *
26
- * @template O The `UnknownOptional` type to convert.
27
- * @param optional The `Optional` to convert.
28
- * @returns The contained value if `Some`, otherwise `undefined`.
29
- */
30
- const toNullable = (optional) => (isSome(optional) ? unwrap(optional) : undefined);
4
+ const toNullable = (optional) => isSome(optional) ? unwrap(optional) : void 0;
31
5
 
32
6
  export { toNullable };
33
7
  //# sourceMappingURL=optional-to-nullable.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"optional-to-nullable.mjs","sources":["../../../../src/functional/optional/impl/optional-to-nullable.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAKA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;AACI,MAAM,UAAU,GAAG,CACxB,QAAW,MACgB,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS;;;;"}
1
+ {"version":3,"file":"optional-to-nullable.mjs","sources":["../../../../src/functional/optional/impl/optional-to-nullable.mts"],"sourcesContent":["import { type UnknownOptional } from '../optional.mjs';\nimport { isSome } from './optional-is-some.mjs';\nimport { unwrap } from './optional-unwrap.mjs';\nimport { type Unwrap } from './types.mjs';\n\n/**\n * Converts an `Optional` to a nullable value.\n *\n * This function extracts the value from an Optional, returning `undefined`\n * for empty Optionals. This is useful when interfacing with APIs or systems\n * that expect nullable values rather than Optional types.\n *\n * Note: This returns `undefined` (not `null`) for consistency with\n * JavaScript's undefined semantics and TypeScript's optional properties.\n *\n * @example\n *\n * ```ts\n * const someNumber = Optional.some(42);\n *\n * const noneNumber = Optional.none as Optional<number>;\n *\n * assert.isTrue(Optional.toNullable(someNumber) === 42);\n *\n * assert.isTrue(Optional.toNullable(noneNumber) === undefined);\n * ```\n *\n * @template O The `UnknownOptional` type to convert.\n * @param optional The `Optional` to convert.\n * @returns The contained value if `Some`, otherwise `undefined`.\n */\nexport const toNullable = <O extends UnknownOptional>(\n optional: O,\n): Unwrap<O> | undefined => (isSome(optional) ? unwrap(optional) : undefined);\n"],"names":[],"mappings":";;;AA+BO,MAAM,UAAA,GAAa,CACxB,QAAA,KAC2B,MAAA,CAAO,QAAQ,CAAA,GAAI,MAAA,CAAO,QAAQ,CAAA,GAAI;;;;"}
@@ -1,17 +1,16 @@
1
1
  import { unwrap } from './optional-unwrap.mjs';
2
2
 
3
3
  function unwrapOr(...args) {
4
- switch (args.length) {
5
- case 2: {
6
- const [optional, defaultValue] = args;
7
- return unwrapOrImpl(optional, defaultValue);
8
- }
9
- case 1: {
10
- // Curried version: first argument is default value
11
- const [defaultValue] = args;
12
- return (optional) => unwrapOrImpl(optional, defaultValue);
13
- }
4
+ switch (args.length) {
5
+ case 2: {
6
+ const [optional, defaultValue] = args;
7
+ return unwrapOrImpl(optional, defaultValue);
14
8
  }
9
+ case 1: {
10
+ const [defaultValue] = args;
11
+ return (optional) => unwrapOrImpl(optional, defaultValue);
12
+ }
13
+ }
15
14
  }
16
15
  const unwrapOrImpl = (optional, defaultValue) => unwrap(optional) ?? defaultValue;
17
16
 
@@ -1 +1 @@
1
- {"version":3,"file":"optional-unwrap-or.mjs","sources":["../../../../src/functional/optional/impl/optional-unwrap-or.mts"],"sourcesContent":[null],"names":[],"mappings":";;AA8CM,SAAU,QAAQ,CACtB,GAAG,IAA0E,EAAA;AAE7E,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,GAAG,IAAI;AAErC,YAAA,OAAO,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC;QAC7C;QAEA,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI;YAE3B,OAAO,CAAC,QAA6B,KACnC,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC;QACxC;;AAEJ;AAEA,MAAM,YAAY,GAAG,CACnB,QAAW,EACX,YAAe,KACG,MAAM,CAAC,QAAQ,CAAC,IAAI,YAAY;;;;"}
1
+ {"version":3,"file":"optional-unwrap-or.mjs","sources":["../../../../src/functional/optional/impl/optional-unwrap-or.mts"],"sourcesContent":["import { type Optional, type UnknownOptional } from '../optional.mjs';\nimport { unwrap } from './optional-unwrap.mjs';\nimport { type Unwrap } from './types.mjs';\n\n/**\n * Unwraps an `Optional`, returning the contained value or a default value if\n * it's `None`.\n *\n * Supports both direct usage and curried form for functional composition.\n * This is often preferred over `unwrap()` when you have a sensible fallback\n * value.\n *\n * @example\n *\n * ```ts\n * const withValue = Optional.some(5);\n *\n * const withoutValue = Optional.none as Optional<number>;\n *\n * assert.isTrue(Optional.unwrapOr(withValue, 0) === 5);\n *\n * assert.isTrue(Optional.unwrapOr(withoutValue, 0) === 0);\n *\n * const unwrapWithDefault = Optional.unwrapOr(10);\n *\n * assert.isTrue(unwrapWithDefault(Optional.some(3)) === 3);\n *\n * assert.isTrue(unwrapWithDefault(Optional.none) === 10);\n * ```\n *\n * @template O The `UnknownOptional` type to unwrap.\n * @template D The type of the default value.\n * @param optional The `Optional` to unwrap.\n * @param defaultValue The value to return if `optional` is `None`.\n * @returns The contained value if `Some`, otherwise `defaultValue`.\n */\nexport function unwrapOr<O extends UnknownOptional, D>(\n optional: O,\n defaultValue: D,\n): D | Unwrap<O>;\n\n// Curried version\nexport function unwrapOr<D>(\n defaultValue: D,\n): <O>(optional: Optional<O>) => D | O;\n\nexport function unwrapOr<O extends UnknownOptional, D>(\n ...args: readonly [optional: O, defaultValue: D] | readonly [defaultValue: D]\n): (D | Unwrap<O>) | ((optional: Optional<Unwrap<O>>) => D | Unwrap<O>) {\n switch (args.length) {\n case 2: {\n const [optional, defaultValue] = args;\n\n return unwrapOrImpl(optional, defaultValue);\n }\n\n case 1: {\n // Curried version: first argument is default value\n const [defaultValue] = args;\n\n return (optional: Optional<Unwrap<O>>) =>\n unwrapOrImpl(optional, defaultValue);\n }\n }\n}\n\nconst unwrapOrImpl = <O extends UnknownOptional, D>(\n optional: O,\n defaultValue: D,\n): D | Unwrap<O> => unwrap(optional) ?? defaultValue;\n"],"names":[],"mappings":";;AA8CO,SAAS,YACX,IAAA,EACmE;AACtE,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,QAAA,EAAU,YAAY,CAAA,GAAI,IAAA;AAEjC,MAAA,OAAO,YAAA,CAAa,UAAU,YAAY,CAAA;AAAA,IAC5C;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,YAAY,CAAA,GAAI,IAAA;AAEvB,MAAA,OAAO,CAAC,QAAA,KACN,YAAA,CAAa,QAAA,EAAU,YAAY,CAAA;AAAA,IACvC;AAAA;AAEJ;AAEA,MAAM,eAAe,CACnB,QAAA,EACA,YAAA,KACkB,MAAA,CAAO,QAAQ,CAAA,IAAK,YAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"optional-unwrap-throw.d.mts","sourceRoot":"","sources":["../../../../src/functional/optional/impl/optional-unwrap-throw.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,eAAe,EACnD,UAAU,CAAC,KACV,MAAM,CAAC,CAAC,CAOV,CAAC"}
1
+ {"version":3,"file":"optional-unwrap-throw.d.mts","sourceRoot":"","sources":["../../../../src/functional/optional/impl/optional-unwrap-throw.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,eAAe,YACzC,CAAC,KACV,MAAM,CAAC,CAAC,CAOV,CAAC"}
@@ -1,38 +1,10 @@
1
1
  import { isSome } from './optional-is-some.mjs';
2
2
 
3
- /**
4
- * Unwraps an `Optional`, returning the contained value. Throws an error if
5
- * the `Optional` is `None`.
6
- *
7
- * This is a safer alternative to direct value access when you know the
8
- * Optional should contain a value. Use this method when an empty Optional
9
- * represents a programming error or unexpected condition.
10
- *
11
- * @example
12
- *
13
- * ```ts
14
- * const present = Optional.some('available');
15
- *
16
- * assert.isTrue(Optional.unwrapThrow(present) === 'available');
17
- *
18
- * assert.throws(
19
- * () => Optional.unwrapThrow(Optional.none),
20
- * /has failed because it is `None`/u,
21
- * );
22
- * ```
23
- *
24
- * @template O The `UnknownOptional` type to unwrap.
25
- * @param optional The `Optional` to unwrap.
26
- * @returns The contained value if `Some`.
27
- * @throws {Error} Error with message "`unwrapThrow()` has failed because it
28
- * is `None`" if the `Optional` is `None`.
29
- */
30
3
  const unwrapThrow = (optional) => {
31
- if (isSome(optional)) {
32
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion
33
- return optional.value;
34
- }
35
- throw new Error('`unwrapThrow()` has failed because it is `None`');
4
+ if (isSome(optional)) {
5
+ return optional.value;
6
+ }
7
+ throw new Error("`unwrapThrow()` has failed because it is `None`");
36
8
  };
37
9
 
38
10
  export { unwrapThrow };
@@ -1 +1 @@
1
- {"version":3,"file":"optional-unwrap-throw.mjs","sources":["../../../../src/functional/optional/impl/optional-unwrap-throw.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;AACI,MAAM,WAAW,GAAG,CACzB,QAAW,KACE;AACb,IAAA,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE;;QAEpB,OAAO,QAAQ,CAAC,KAAkB;IACpC;AAEA,IAAA,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC;AACpE;;;;"}
1
+ {"version":3,"file":"optional-unwrap-throw.mjs","sources":["../../../../src/functional/optional/impl/optional-unwrap-throw.mts"],"sourcesContent":["import { type UnknownOptional } from '../optional.mjs';\nimport { isSome } from './optional-is-some.mjs';\nimport { type Unwrap } from './types.mjs';\n\n/**\n * Unwraps an `Optional`, returning the contained value. Throws an error if\n * the `Optional` is `None`.\n *\n * This is a safer alternative to direct value access when you know the\n * Optional should contain a value. Use this method when an empty Optional\n * represents a programming error or unexpected condition.\n *\n * @example\n *\n * ```ts\n * const present = Optional.some('available');\n *\n * assert.isTrue(Optional.unwrapThrow(present) === 'available');\n *\n * assert.throws(\n * () => Optional.unwrapThrow(Optional.none),\n * /has failed because it is `None`/u,\n * );\n * ```\n *\n * @template O The `UnknownOptional` type to unwrap.\n * @param optional The `Optional` to unwrap.\n * @returns The contained value if `Some`.\n * @throws {Error} Error with message \"`unwrapThrow()` has failed because it\n * is `None`\" if the `Optional` is `None`.\n */\nexport const unwrapThrow = <O extends UnknownOptional>(\n optional: O,\n): Unwrap<O> => {\n if (isSome(optional)) {\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n return optional.value as Unwrap<O>;\n }\n\n throw new Error('`unwrapThrow()` has failed because it is `None`');\n};\n"],"names":[],"mappings":";;AA+BO,MAAM,WAAA,GAAc,CACzB,QAAA,KACc;AACd,EAAA,IAAI,MAAA,CAAO,QAAQ,CAAA,EAAG;AAEpB,IAAA,OAAO,QAAA,CAAS,KAAA;AAAA,EAClB;AAEA,EAAA,MAAM,IAAI,MAAM,iDAAiD,CAAA;AACnE;;;;"}
@@ -1,10 +1,10 @@
1
1
  import { isSome } from './optional-is-some.mjs';
2
2
 
3
3
  function unwrap(optional) {
4
- return isSome(optional)
5
- ? // eslint-disable-next-line total-functions/no-unsafe-type-assertion
6
- optional.value
7
- : undefined;
4
+ return isSome(optional) ? (
5
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
6
+ optional.value
7
+ ) : void 0;
8
8
  }
9
9
 
10
10
  export { unwrap };
@@ -1 +1 @@
1
- {"version":3,"file":"optional-unwrap.mjs","sources":["../../../../src/functional/optional/impl/optional-unwrap.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAqCM,SAAU,MAAM,CACpB,QAAW,EAAA;IAEX,OAAO,MAAM,CAAC,QAAQ;AACpB;AACG,YAAA,QAAQ,CAAC;UACV,SAAS;AACf;;;;"}
1
+ {"version":3,"file":"optional-unwrap.mjs","sources":["../../../../src/functional/optional/impl/optional-unwrap.mts"],"sourcesContent":["import { type Some } from '../../../types.mjs';\nimport { type UnknownOptional } from '../optional.mjs';\nimport { isSome } from './optional-is-some.mjs';\nimport { type Unwrap } from './types.mjs';\n\n/**\n * Unwraps an `Optional`, returning the contained value or `undefined` if\n * empty.\n *\n * This function provides a safe way to extract values from Optionals without\n * throwing exceptions. It has overloaded behavior based on the type:\n *\n * - For `Some<T>`: Always returns `T` (guaranteed by type system)\n * - For general `Optional<T>`: Returns `T | undefined`\n *\n * @example\n *\n * ```ts\n * const someString = Optional.some('text');\n *\n * const noneString = Optional.none as Optional<string>;\n *\n * assert.isTrue(Optional.unwrap(someString) === 'text');\n *\n * assert.isTrue(Optional.unwrap(noneString) === undefined);\n * ```\n *\n * @template O The `UnknownOptional` type to unwrap.\n * @param optional The `Optional` to unwrap.\n * @returns The contained value if `Some`, otherwise `undefined`.\n */\nexport function unwrap<O extends Some<unknown>>(optional: O): Unwrap<O>;\n\nexport function unwrap<O extends UnknownOptional>(\n optional: O,\n): Unwrap<O> | undefined;\n\nexport function unwrap<O extends UnknownOptional>(\n optional: O,\n): Unwrap<O> | undefined {\n return isSome(optional)\n ? // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n (optional.value as Unwrap<O>)\n : undefined;\n}\n"],"names":[],"mappings":";;AAqCO,SAAS,OACd,QAAA,EACuB;AACvB,EAAA,OAAO,OAAO,QAAQ,CAAA;AAAA;AAAA,IAEjB,QAAA,CAAS;AAAA,MACV,MAAA;AACN;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"optional-zip.d.mts","sourceRoot":"","sources":["../../../../src/functional/optional/impl/optional-zip.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAKhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,GAAG,GAAI,CAAC,EAAE,KAAK,CAAC,CAAC,EAC5B,WAAW,QAAQ,CAAC,CAAC,CAAC,EACtB,WAAW,QAAQ,CAAC,CAAC,CAAC,KACrB,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAGjB,CAAC"}
1
+ {"version":3,"file":"optional-zip.d.mts","sourceRoot":"","sources":["../../../../src/functional/optional/impl/optional-zip.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAKhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,GAAG,GAAI,CAAC,EAAE,KAAK,CAAC,CAAC,aACjB,QAAQ,CAAC,CAAC,CAAC,aACX,QAAQ,CAAC,CAAC,CAAC,KACrB,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAGjB,CAAC"}
@@ -2,41 +2,7 @@ import { isSome } from './optional-is-some.mjs';
2
2
  import { none } from './optional-none.mjs';
3
3
  import { some } from './optional-some.mjs';
4
4
 
5
- /**
6
- * Combines two `Optional` values into a single `Optional` containing a tuple.
7
- * If either `Optional` is `None`, returns `None`.
8
- *
9
- * @example
10
- *
11
- * ```ts
12
- * const zipped = Optional.zip(Optional.some('left'), Optional.some(1));
13
- *
14
- * assert.isTrue(Optional.isSome(zipped));
15
- *
16
- * if (Optional.isSome(zipped)) {
17
- * const expected: readonly [string, number] = ['left', 1] as const;
18
- *
19
- * assert.deepStrictEqual(zipped.value, expected);
20
- * }
21
- *
22
- * const missing = Optional.zip(
23
- * Optional.some('value'),
24
- * // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
25
- * Optional.none as Optional<number>,
26
- * );
27
- *
28
- * assert.deepStrictEqual(missing, Optional.none);
29
- * ```
30
- *
31
- * @template A The value type of the first `Optional`.
32
- * @template B The value type of the second `Optional`.
33
- * @param optionalA The first `Optional`.
34
- * @param optionalB The second `Optional`.
35
- * @returns An `Optional` containing a tuple of both values, or `None`.
36
- */
37
- const zip = (optionalA, optionalB) => isSome(optionalA) && isSome(optionalB)
38
- ? some([optionalA.value, optionalB.value])
39
- : none;
5
+ const zip = (optionalA, optionalB) => isSome(optionalA) && isSome(optionalB) ? some([optionalA.value, optionalB.value]) : none;
40
6
 
41
7
  export { zip };
42
8
  //# sourceMappingURL=optional-zip.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"optional-zip.mjs","sources":["../../../../src/functional/optional/impl/optional-zip.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AACI,MAAM,GAAG,GAAG,CACjB,SAAsB,EACtB,SAAsB,KAEtB,MAAM,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,SAAS;AACnC,MAAE,IAAI,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAU;MAChD;;;;"}
1
+ {"version":3,"file":"optional-zip.mjs","sources":["../../../../src/functional/optional/impl/optional-zip.mts"],"sourcesContent":["import { type Optional } from '../optional.mjs';\nimport { isSome } from './optional-is-some.mjs';\nimport { none } from './optional-none.mjs';\nimport { some } from './optional-some.mjs';\n\n/**\n * Combines two `Optional` values into a single `Optional` containing a tuple.\n * If either `Optional` is `None`, returns `None`.\n *\n * @example\n *\n * ```ts\n * const zipped = Optional.zip(Optional.some('left'), Optional.some(1));\n *\n * assert.isTrue(Optional.isSome(zipped));\n *\n * if (Optional.isSome(zipped)) {\n * const expected: readonly [string, number] = ['left', 1] as const;\n *\n * assert.deepStrictEqual(zipped.value, expected);\n * }\n *\n * const missing = Optional.zip(\n * Optional.some('value'),\n * // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n * Optional.none as Optional<number>,\n * );\n *\n * assert.deepStrictEqual(missing, Optional.none);\n * ```\n *\n * @template A The value type of the first `Optional`.\n * @template B The value type of the second `Optional`.\n * @param optionalA The first `Optional`.\n * @param optionalB The second `Optional`.\n * @returns An `Optional` containing a tuple of both values, or `None`.\n */\nexport const zip = <A, const B>(\n optionalA: Optional<A>,\n optionalB: Optional<B>,\n): Optional<readonly [A, B]> =>\n isSome(optionalA) && isSome(optionalB)\n ? some([optionalA.value, optionalB.value] as const)\n : none;\n"],"names":[],"mappings":";;;;AAqCO,MAAM,MAAM,CACjB,SAAA,EACA,SAAA,KAEA,MAAA,CAAO,SAAS,CAAA,IAAK,MAAA,CAAO,SAAS,CAAA,GACjC,KAAK,CAAC,SAAA,CAAU,OAAO,SAAA,CAAU,KAAK,CAAU,CAAA,GAChD;;;;"}
@@ -1,6 +1,5 @@
1
- const SomeTypeTagName = 'ts-data-forge::Optional.some';
2
- /** @internal String literal tag to identify the 'None' variant of Optional. */
3
- const NoneTypeTagName = 'ts-data-forge::Optional.none';
1
+ const SomeTypeTagName = "ts-data-forge::Optional.some";
2
+ const NoneTypeTagName = "ts-data-forge::Optional.none";
4
3
 
5
4
  export { NoneTypeTagName, SomeTypeTagName };
6
5
  //# sourceMappingURL=tag.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tag.mjs","sources":["../../../../src/functional/optional/impl/tag.mts"],"sourcesContent":[null],"names":[],"mappings":"AAGO,MAAM,eAAe,GAC1B;AAEF;AACO,MAAM,eAAe,GAAkB;;;;"}
1
+ {"version":3,"file":"tag.mjs","sources":["../../../../src/functional/optional/impl/tag.mts"],"sourcesContent":["/** @internal String literal tag to identify the 'Some' variant of Optional. */\nimport { type None, type Some } from '../../../types.mjs';\n\nexport const SomeTypeTagName: Some<unknown>['$$tag'] =\n 'ts-data-forge::Optional.some';\n\n/** @internal String literal tag to identify the 'None' variant of Optional. */\nexport const NoneTypeTagName: None['$$tag'] = 'ts-data-forge::Optional.none';\n"],"names":[],"mappings":"AAGO,MAAM,eAAA,GACX;AAGK,MAAM,eAAA,GAAiC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"pipe.d.mts","sourceRoot":"","sources":["../../src/functional/pipe.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEtE;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,CAAC,CAAC,EAAG,GAAG,CAAC,KAAG,IAAI,CAAC,CAAC,CAYI,CAAC;AAkBjD,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,GAC/B,eAAe,CAAC,CAAC,CAAC,GAClB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;AAgCjE,KAAK,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC;IAC1B,qCAAqC;IACrC,KAAK,EAAE,CAAC,CAAC;IAET;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC;CACtC,CAAC,CAAC;AAEH,KAAK,eAAe,CAAC,CAAC,IAAI,QAAQ,CAAC;IACjC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;CACvE,CAAC,CAAC;AAEH,KAAK,eAAe,CAAC,CAAC,SAAS,eAAe,IAAI,QAAQ,CAAC;IACzD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CACzE,CAAC,CAAC"}
1
+ {"version":3,"file":"pipe.d.mts","sourceRoot":"","sources":["../../src/functional/pipe.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEtE;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,CAAC,CAAC,KAAM,CAAC,KAAG,IAAI,CAAC,CAAC,CAYI,CAAC;AAkBjD,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,GAC/B,eAAe,CAAC,CAAC,CAAC,GAClB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;AAgCjE,KAAK,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC;IAC1B,qCAAqC;IACrC,KAAK,EAAE,CAAC,CAAC;IAET;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC;CACtC,CAAC,CAAC;AAEH,KAAK,eAAe,CAAC,CAAC,IAAI,QAAQ,CAAC;IACjC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;CACvE,CAAC,CAAC;AAEH,KAAK,eAAe,CAAC,CAAC,SAAS,eAAe,IAAI,QAAQ,CAAC;IACzD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CACzE,CAAC,CAAC"}
@@ -1,42 +1,17 @@
1
1
  import { isOptional } from './optional/impl/optional-is-optional.mjs';
2
2
  import { map } from './optional/impl/optional-map.mjs';
3
3
 
4
- /**
5
- * Creates a new pipe object that allows for chaining operations on a value.
6
- *
7
- * This function provides a fluent interface for applying transformations to
8
- * values, with intelligent method selection based on the input type:
9
- *
10
- * - For `Optional` values: Provides `mapOptional` for safe Optional
11
- * transformations
12
- * - For other values: Provides `mapNullable` for null-safe transformations
13
- * - All types get the basic `map` method for general transformations
14
- *
15
- * The pipe maintains type safety throughout the chain, automatically selecting
16
- * the appropriate overload based on the current value type.
17
- *
18
- * @template A The type of the initial value to wrap in a pipe.
19
- * @param a The initial value to wrap in a pipe.
20
- * @returns A pipe object with chaining methods appropriate for the value type.
21
- */
22
- const pipe = (a) =>
23
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion
24
- ({
4
+ const pipe = (a) => (
5
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
6
+ {
25
7
  value: a,
26
8
  map: (fn) => pipe(fn(a)),
27
- mapNullable: (fn) => pipe(a == null ? undefined : fn(a)),
28
- ...(isOptional(a)
29
- ? {
30
- mapOptional: (fn) => pipe(map(a, fn)),
31
- }
32
- : {}),
33
- });
34
- // NOTE: 以下では 'typing when used with generics' test で型エラーが出る。
35
- // 詳細は documents/reports/pipe-typing.md の 「mapNullable を条件付きで含めるのがうまくいかない理由」を参照。
36
- // export type Pipe<A> = PipeBase<A> &
37
- // ([A] extends [UnknownOptional] ? PipeMapOptional<A> : unknown) &
38
- // ([undefined] extends [A] ? PipeMapNullable<A> : unknown) &
39
- // ([null] extends [A] ? PipeMapNullable<A> : unknown);
9
+ mapNullable: (fn) => pipe(a == null ? void 0 : fn(a)),
10
+ ...isOptional(a) ? {
11
+ mapOptional: (fn) => pipe(map(a, fn))
12
+ } : {}
13
+ }
14
+ );
40
15
 
41
16
  export { pipe };
42
17
  //# sourceMappingURL=pipe.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pipe.mjs","sources":["../../src/functional/pipe.mts"],"sourcesContent":[null],"names":["Optional.isOptional","Optional.map"],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;AAiBG;AACI,MAAM,IAAI,GAAG,CAAW,CAAI;AACjC;AACA,CAAC;AACC,IAAA,KAAK,EAAE,CAAC;AACR,IAAA,GAAG,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxB,WAAW,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,IAAI,IAAI,GAAG,SAAS,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AAExD,IAAA,IAAIA,UAAmB,CAAC,CAAC;AACvB,UAAE;AACE,YAAA,WAAW,EAAE,CAAC,EAAE,KAAK,IAAI,CAACC,GAAY,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/C;UACD,EAAE,CAAC;AACR,CAAA;AAsBH;AACA;AACA;AACA;AACA;AACA;;;;"}
1
+ {"version":3,"file":"pipe.mjs","sources":["../../src/functional/pipe.mts"],"sourcesContent":["import { expectType } from '../expect-type.mjs';\nimport { Optional, type UnknownOptional } from './optional/index.mjs';\n\n/**\n * Creates a new pipe object that allows for chaining operations on a value.\n *\n * This function provides a fluent interface for applying transformations to\n * values, with intelligent method selection based on the input type:\n *\n * - For `Optional` values: Provides `mapOptional` for safe Optional\n * transformations\n * - For other values: Provides `mapNullable` for null-safe transformations\n * - All types get the basic `map` method for general transformations\n *\n * The pipe maintains type safety throughout the chain, automatically selecting\n * the appropriate overload based on the current value type.\n *\n * @template A The type of the initial value to wrap in a pipe.\n * @param a The initial value to wrap in a pipe.\n * @returns A pipe object with chaining methods appropriate for the value type.\n */\nexport const pipe = <const A,>(a: A): Pipe<A> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n ({\n value: a,\n map: (fn) => pipe(fn(a)),\n mapNullable: (fn) => pipe(a == null ? undefined : fn(a)),\n\n ...(Optional.isOptional(a)\n ? {\n mapOptional: (fn) => pipe(Optional.map(a, fn)),\n }\n : {}),\n }) satisfies PipeImpl<A> as unknown as Pipe<A>;\n\n// `PipeBase<A>` is always present; the conditional only *adds* `mapOptional`\n// for Optional values. Two subtleties motivate this shape:\n//\n// 1. The check is `[A] extends [UnknownOptional]` (a 1-tuple), not the bare\n// `A extends UnknownOptional`. A bare check distributes over unions, so a\n// piped union value such as `Result<D, E> | undefined` would expand into\n// `Pipe<Ok<D>> | Pipe<Err<E>> | Pipe<undefined>`. Calling a chained method\n// on that union of pipe objects forces TypeScript to synthesize a merged\n// call signature, during which a branded member like `Ok<D>` is widened to\n// its constraint (`Ok<number>`) — losing the brand `D`.\n//\n// 2. `value: A` lives on `PipeBase<A>`, *outside* the conditional. If `value`\n// flowed through the conditional, then for a not-yet-resolved generic `A`\n// the deferred true branch narrows `A` to `A & UnknownOptional`, so\n// `.value` would surface as the noisy `(A & UnknownOptional) | A`. Keeping\n// it on the unconditional base yields a clean `A`.\nexport type Pipe<A> = PipeBase<A> &\n PipeMapNullable<A> &\n ([A] extends [UnknownOptional] ? PipeMapOptional<A> : unknown);\n\n// NOTE: 以下では 'typing when used with generics' test で型エラーが出る。\n// 詳細は documents/reports/pipe-typing.md の 「mapNullable を条件付きで含めるのがうまくいかない理由」を参照。\n// export type Pipe<A> = PipeBase<A> &\n// ([A] extends [UnknownOptional] ? PipeMapOptional<A> : unknown) &\n// ([undefined] extends [A] ? PipeMapNullable<A> : unknown) &\n// ([null] extends [A] ? PipeMapNullable<A> : unknown);\n\nexpectType<Optional<number>, UnknownOptional>('<=');\n\nexpectType<number | undefined, undefined>('>=');\n\nexpectType<keyof Pipe<number | undefined>, 'value' | 'map' | 'mapNullable'>(\n '=',\n);\n\nexpectType<\n keyof Pipe<Optional<number>>,\n 'value' | 'map' | 'mapNullable' | 'mapOptional'\n>('=');\n\nexpectType<\n keyof Pipe<Optional<number | undefined>>,\n 'value' | 'map' | 'mapNullable' | 'mapOptional'\n>('=');\n\nexpectType<\n keyof Pipe<Optional<number> | undefined>,\n 'value' | 'map' | 'mapNullable'\n>('=');\n\ntype PipeBase<A> = Readonly<{\n /** The current value being piped. */\n value: A;\n\n /**\n * Maps the current value to a new value using the provided function.\n *\n * @example\n *\n * ```ts\n * const result = pipe(2)\n * .map((value) => value * 3)\n * .map((value) => `value: ${value}`);\n *\n * assert.deepStrictEqual(result.value, 'value: 6');\n * ```\n *\n * @template B The type of the new value.\n * @param fn Function to transform the current value.\n * @returns A new pipe containing the transformed value.\n */\n map: <B>(fn: (a: A) => B) => Pipe<B>;\n}>;\n\ntype PipeMapNullable<A> = Readonly<{\n /**\n * Maps the current value only if it's not null or undefined. If the current\n * value is null/undefined, the transformation is skipped and undefined is\n * propagated through the pipe.\n *\n * @example\n *\n * ```ts\n * const result = pipe<string | undefined>('hello')\n * .mapNullable((value) => value.toUpperCase())\n * .mapNullable((value) => value.slice(0, 2));\n *\n * assert.deepStrictEqual(result.value, 'HE');\n *\n * const empty = pipe<string | undefined>(undefined).mapNullable((value) =>\n * value.toUpperCase(),\n * );\n *\n * assert.isTrue(empty.value === undefined);\n * ```\n *\n * @template B The type of the transformed value.\n * @param fn Function to transform the non-null value.\n * @returns A new pipe containing the transformed value or undefined.\n */\n mapNullable: <B>(fn: (a: NonNullable<A>) => B) => Pipe<B | undefined>;\n}>;\n\ntype PipeMapOptional<A extends UnknownOptional> = Readonly<{\n /**\n * Maps the value inside an Optional using Optional.map semantics. If the\n * Optional is None, the transformation is skipped and None is propagated.\n * If the Optional is Some, the transformation is applied to the inner\n * value.\n *\n * @example\n *\n * ```ts\n * const result = pipe(Optional.some(10))\n * .mapOptional((value) => value * 2)\n * .mapOptional((value) => value + 5);\n *\n * assert.deepStrictEqual(result.value, Optional.some(25));\n *\n * const empty = pipe(Optional.none as Optional<number>).mapOptional(\n * (value) => value * 2,\n * );\n *\n * assert.isTrue(Optional.isNone(empty.value));\n * ```\n *\n * @template B The type of the transformed inner value.\n * @param fn Function to transform the inner value of the Optional.\n * @returns A new pipe containing an Optional with the transformed value.\n */\n mapOptional: <B>(fn: (a: Optional.Unwrap<A>) => B) => Pipe<Optional<B>>;\n}>;\n\n/** @internal */\ntype Cast<T, U> = T & U;\n\n/** @internal */\ntype PipeImpl<A> = Readonly<{\n value: A;\n map: <B>(fn: (a: A) => B) => PipeImpl<B>;\n mapNullable?: <B>(fn: (a: NonNullable<A>) => B) => PipeImpl<B | undefined>;\n mapOptional?: <B>(\n fn: (a: Optional.Unwrap<Cast<A, UnknownOptional>>) => B,\n ) => PipeImpl<Optional<B>>;\n}>;\n"],"names":["Optional.isOptional","Optional.map"],"mappings":";;;AAqBO,MAAM,OAAO,CAAW,CAAA;AAAA;AAAA,EAE5B;AAAA,IACC,KAAA,EAAO,CAAA;AAAA,IACP,KAAK,CAAC,EAAA,KAAO,IAAA,CAAK,EAAA,CAAG,CAAC,CAAC,CAAA;AAAA,IACvB,WAAA,EAAa,CAAC,EAAA,KAAO,IAAA,CAAK,KAAK,IAAA,GAAO,MAAA,GAAY,EAAA,CAAG,CAAC,CAAC,CAAA;AAAA,IAEvD,GAAIA,UAAS,CAAW,CAAC,CAAA,GACrB;AAAA,MACE,WAAA,EAAa,CAAC,EAAA,KAAO,IAAA,CAAKC,GAAS,CAAI,CAAA,EAAG,EAAE,CAAC;AAAA,QAE/C;AAAC;AACP;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"result-err.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-err.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAG9C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,GAAG,GAAI,KAAK,CAAC,CAAC,EAAG,OAAO,CAAC,KAAG,GAAG,CAAC,CAAC,CAIjC,CAAC"}
1
+ {"version":3,"file":"result-err.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-err.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAG9C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,GAAG,GAAI,KAAK,CAAC,CAAC,SAAU,CAAC,KAAG,GAAG,CAAC,CAAC,CAIjC,CAAC"}
@@ -1,33 +1,8 @@
1
1
  import { ErrTypeTagName } from './tag.mjs';
2
2
 
3
- /**
4
- * Creates a `Result.Err` containing the given error value.
5
- *
6
- * Use this constructor when an operation fails and you want to wrap the error
7
- * information 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 E The type of the error value.
25
- * @param value The error value.
26
- * @returns A `Result.Err<E>` containing the value.
27
- */
28
3
  const err = (value) => ({
29
- $$tag: ErrTypeTagName,
30
- value,
4
+ $$tag: ErrTypeTagName,
5
+ value
31
6
  });
32
7
 
33
8
  export { err };
@@ -1 +1 @@
1
- {"version":3,"file":"result-err.mjs","sources":["../../../../src/functional/result/impl/result-err.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;MACU,GAAG,GAAG,CAAW,KAAQ,MACnC;AACC,IAAA,KAAK,EAAE,cAAc;IACrB,KAAK;AACN,CAAA;;;;"}
1
+ {"version":3,"file":"result-err.mjs","sources":["../../../../src/functional/result/impl/result-err.mts"],"sourcesContent":["import { type Err } from '../../../types.mjs';\nimport { ErrTypeTagName } from './tag.mjs';\n\n/**\n * Creates a `Result.Err` containing the given error value.\n *\n * Use this constructor when an operation fails and you want to wrap the error\n * information 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 E The type of the error value.\n * @param value The error value.\n * @returns A `Result.Err<E>` containing the value.\n */\nexport const err = <const E,>(value: E): Err<E> =>\n ({\n $$tag: ErrTypeTagName,\n value,\n }) as const;\n"],"names":[],"mappings":";;AA4BO,MAAM,GAAA,GAAM,CAAW,KAAA,MAC3B;AAAA,EACC,KAAA,EAAO,cAAA;AAAA,EACP;AACF,CAAA;;;;"}
@@ -2,24 +2,22 @@ import { isOk } from './result-is-ok.mjs';
2
2
  import { unwrapOk } from './result-unwrap-ok.mjs';
3
3
 
4
4
  function expectToBe(...args) {
5
- switch (args.length) {
6
- case 2: {
7
- // Direct version: first argument is result
8
- const [result, message] = args;
9
- return expectToBeImpl(result, message);
10
- }
11
- case 1: {
12
- // Curried version: first argument is message
13
- const [message] = args;
14
- return (result) => expectToBeImpl(result, message);
15
- }
5
+ switch (args.length) {
6
+ case 2: {
7
+ const [result, message] = args;
8
+ return expectToBeImpl(result, message);
16
9
  }
10
+ case 1: {
11
+ const [message] = args;
12
+ return (result) => expectToBeImpl(result, message);
13
+ }
14
+ }
17
15
  }
18
16
  const expectToBeImpl = (result, message) => {
19
- if (isOk(result)) {
20
- return unwrapOk(result);
21
- }
22
- throw new Error(message);
17
+ if (isOk(result)) {
18
+ return unwrapOk(result);
19
+ }
20
+ throw new Error(message);
23
21
  };
24
22
 
25
23
  export { expectToBe };
@@ -1 +1 @@
1
- {"version":3,"file":"result-expect-to-be.mjs","sources":["../../../../src/functional/result/impl/result-expect-to-be.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AA2CM,SAAU,UAAU,CACxB,GAAG,IAAwE,EAAA;AAE3E,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;AAE9B,YAAA,OAAO,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC;QACxC;QAEA,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI;YAEtB,OAAO,CAAC,MAAS,KAAkB,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC;QACpE;;AAEJ;AAEA,MAAM,cAAc,GAAG,CACrB,MAAS,EACT,OAAe,KACA;AACf,IAAA,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE;AAChB,QAAA,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB;AAEA,IAAA,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC;AAC1B,CAAC;;;;"}
1
+ {"version":3,"file":"result-expect-to-be.mjs","sources":["../../../../src/functional/result/impl/result-expect-to-be.mts"],"sourcesContent":["import { 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 * Unwraps a `Result`, returning the success value or throwing an error with\n * the provided message.\n *\n * @example\n *\n * ```ts\n * const okValue = Result.ok('data');\n *\n * assert.isTrue(Result.expectToBe(okValue, 'should have value') === 'data');\n *\n * const expectResult = Result.expectToBe('missing result');\n *\n * const throwTest = (): void => {\n * expectResult(Result.err('boom'));\n * };\n *\n * assert.throws(throwTest, /missing result/u);\n *\n * assert.isTrue(expectResult(Result.ok('value')) === 'value');\n * ```\n *\n * @template R The `UnknownResult` type to unwrap.\n * @param result The `Result` to unwrap.\n * @param message The error message to throw if the `Result` is `Result.Err`.\n * @returns The success value if `Result.Ok`.\n * @throws Error with the provided message if the `Result` is `Result.Err`.\n */\nexport function expectToBe<R extends UnknownResult>(\n result: R,\n message: string,\n): UnwrapOk<R>;\n\n// Curried version\nexport function expectToBe(\n message: string,\n): <R extends UnknownResult>(result: R) => UnwrapOk<R>;\n\nexport function expectToBe<R extends UnknownResult>(\n ...args: readonly [result: R, message: string] | readonly [message: string]\n): UnwrapOk<R> | ((result: R) => UnwrapOk<R>) {\n switch (args.length) {\n case 2: {\n // Direct version: first argument is result\n const [result, message] = args;\n\n return expectToBeImpl(result, message);\n }\n\n case 1: {\n // Curried version: first argument is message\n const [message] = args;\n\n return (result: R): UnwrapOk<R> => expectToBeImpl(result, message);\n }\n }\n}\n\nconst expectToBeImpl = <R extends UnknownResult>(\n result: R,\n message: string,\n): UnwrapOk<R> => {\n if (isOk(result)) {\n return unwrapOk(result);\n }\n\n throw new Error(message);\n};\n"],"names":[],"mappings":";;;AA2CO,SAAS,cACX,IAAA,EACyC;AAC5C,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,MAAA,EAAQ,OAAO,CAAA,GAAI,IAAA;AAE1B,MAAA,OAAO,cAAA,CAAe,QAAQ,OAAO,CAAA;AAAA,IACvC;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,OAAO,CAAA,GAAI,IAAA;AAElB,MAAA,OAAO,CAAC,MAAA,KAA2B,cAAA,CAAe,MAAA,EAAQ,OAAO,CAAA;AAAA,IACnE;AAAA;AAEJ;AAEA,MAAM,cAAA,GAAiB,CACrB,MAAA,EACA,OAAA,KACgB;AAChB,EAAA,IAAI,IAAA,CAAK,MAAM,CAAA,EAAG;AAChB,IAAA,OAAO,SAAS,MAAM,CAAA;AAAA,EACxB;AAEA,EAAA,MAAM,IAAI,MAAM,OAAO,CAAA;AACzB,CAAA;;;;"}
@@ -1,24 +1,24 @@
1
1
  import { isErr } from './result-is-err.mjs';
2
2
 
3
3
  function flatMap(...args) {
4
- switch (args.length) {
5
- case 2: {
6
- // Direct version: first argument is result
7
- const [result, flatMapFn] = args;
8
- return flatMapImpl(result, flatMapFn);
9
- }
10
- case 1: {
11
- // Curried version
12
- const [flatMapFn] = args;
13
- return (result) => flatMapImpl(result, flatMapFn);
14
- }
4
+ switch (args.length) {
5
+ case 2: {
6
+ const [result, flatMapFn] = args;
7
+ return flatMapImpl(result, flatMapFn);
15
8
  }
9
+ case 1: {
10
+ const [flatMapFn] = args;
11
+ return (result) => flatMapImpl(result, flatMapFn);
12
+ }
13
+ }
16
14
  }
17
- const flatMapImpl = (result, flatMapFn) => isErr(result)
18
- ? // eslint-disable-next-line total-functions/no-unsafe-type-assertion
19
- result
20
- : // eslint-disable-next-line total-functions/no-unsafe-type-assertion
21
- flatMapFn(result.value);
15
+ const flatMapImpl = (result, flatMapFn) => isErr(result) ? (
16
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
17
+ result
18
+ ) : (
19
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
20
+ flatMapFn(result.value)
21
+ );
22
22
 
23
23
  export { flatMap };
24
24
  //# sourceMappingURL=result-flat-map.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"result-flat-map.mjs","sources":["../../../../src/functional/result/impl/result-flat-map.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAuDM,SAAU,OAAO,CACrB,GAAG,IAE6D,EAAA;AAIhE,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI;AAEhC,YAAA,OAAO,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC;QACvC;QAEA,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI;YAExB,OAAO,CAAC,MAAS,KAAK,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC;QACtD;;AAEJ;AAEA,MAAM,WAAW,GAAG,CAClB,MAAS,EACT,SAAiD,KAEjD,KAAK,CAAC,MAAM;AACV;QACG;AACH;AACE,QAAA,SAAS,CAAC,MAAM,CAAC,KAAoB,CAAC;;;;"}
1
+ {"version":3,"file":"result-flat-map.mjs","sources":["../../../../src/functional/result/impl/result-flat-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 { type UnwrapErr, type UnwrapOk } from './types.mjs';\n\n/**\n * Applies a function that returns a `Result` to the success value of a\n * `Result`. If the input is `Err`, returns the original `Err`. This is the\n * monadic bind operation for `Result`.\n *\n * @example\n *\n * ```ts\n * const parseNumber = (input: string): Result<number, string> => {\n * const num = Num.safeParseInt(input);\n *\n * return Result.mapErr(num, () => 'not a number');\n * };\n *\n * const parsed = Result.flatMap(Result.ok('42'), parseNumber);\n *\n * const failure = Result.flatMap(Result.ok('abc'), parseNumber);\n *\n * const passthrough = Result.flatMap(Result.err('fail'), parseNumber);\n *\n * assert.deepStrictEqual(parsed, Result.ok(42));\n *\n * assert.deepStrictEqual(failure, Result.err('not a number'));\n *\n * assert.deepStrictEqual(passthrough, Result.err('fail'));\n *\n * const parseThenDouble = Result.flatMap((input: string) =>\n * Result.map(parseNumber(input), (value) => value * 2),\n * );\n *\n * assert.deepStrictEqual(parseThenDouble(Result.ok('10')), Result.ok(20));\n * ```\n *\n * @template R The input `UnknownResult` type.\n * @template S2 The success type of the `Result` returned by the function.\n * @template E2 The error type of the `Result` returned by the function.\n * @param result The `Result` to flat map.\n * @param flatMapFn The function to apply that returns a `Result`.\n * @returns The result of applying the function, or the original `Err`.\n */\nexport function flatMap<R extends UnknownResult, S2, E2>(\n result: R,\n flatMapFn: (value: UnwrapOk<R>) => Result<S2, E2>,\n): Result<S2, E2 | UnwrapErr<R>>;\n\n// Curried version\nexport function flatMap<S, S2, E2>(\n flatMapFn: (value: S) => Result<S2, E2>,\n): <E>(result: Result<S, E>) => Result<S2, E | E2>;\n\nexport function flatMap<R extends UnknownResult, S2, E2>(\n ...args:\n | readonly [result: R, flatMapFn: (value: UnwrapOk<R>) => Result<S2, E2>]\n | readonly [flatMapFn: (value: UnwrapOk<R>) => Result<S2, E2>]\n):\n | Result<S2, E2 | UnwrapErr<R>>\n | ((result: R) => Result<S2, UnwrapErr<R> | E2>) {\n switch (args.length) {\n case 2: {\n // Direct version: first argument is result\n const [result, flatMapFn] = args;\n\n return flatMapImpl(result, flatMapFn);\n }\n\n case 1: {\n // Curried version\n const [flatMapFn] = args;\n\n return (result: R) => flatMapImpl(result, flatMapFn);\n }\n }\n}\n\nconst flatMapImpl = <R extends UnknownResult, S2, E2>(\n result: R,\n flatMapFn: (value: UnwrapOk<R>) => Result<S2, E2>,\n): Result<S2, E2 | 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 flatMapFn(result.value as UnwrapOk<R>);\n"],"names":[],"mappings":";;AAuDO,SAAS,WACX,IAAA,EAK8C;AACjD,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,IAAA;AAE5B,MAAA,OAAO,WAAA,CAAY,QAAQ,SAAS,CAAA;AAAA,IACtC;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,SAAS,CAAA,GAAI,IAAA;AAEpB,MAAA,OAAO,CAAC,MAAA,KAAc,WAAA,CAAY,MAAA,EAAQ,SAAS,CAAA;AAAA,IACrD;AAAA;AAEJ;AAEA,MAAM,WAAA,GAAc,CAClB,MAAA,EACA,SAAA,KAEA,MAAM,MAAM,CAAA;AAAA;AAAA,EAEP;AAAA;AAAA;AAAA,EAED,SAAA,CAAU,OAAO,KAAoB;AAAA,CAAA;;;;"}