ts-data-forge 14.6.1 → 14.6.3

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 (420) hide show
  1. package/dist/array/impl/array-utils-creation.mjs +126 -26
  2. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  3. package/dist/array/impl/array-utils-element-access.mjs +63 -30
  4. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  5. package/dist/array/impl/array-utils-iterators.mjs +68 -52
  6. package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
  7. package/dist/array/impl/array-utils-length-bounded-array-cast.mjs +109 -73
  8. package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -1
  9. package/dist/array/impl/array-utils-length-bounded-array-guard.mjs +70 -32
  10. package/dist/array/impl/array-utils-length-bounded-array-guard.mjs.map +1 -1
  11. package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs +102 -73
  12. package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs.map +1 -1
  13. package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs +77 -33
  14. package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs.map +1 -1
  15. package/dist/array/impl/array-utils-modification.mjs +75 -122
  16. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  17. package/dist/array/impl/array-utils-reducing-value.mjs +99 -149
  18. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  19. package/dist/array/impl/array-utils-search.mjs +112 -136
  20. package/dist/array/impl/array-utils-search.mjs.map +1 -1
  21. package/dist/array/impl/array-utils-set-op.mjs +146 -38
  22. package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
  23. package/dist/array/impl/array-utils-size.mjs +10 -8
  24. package/dist/array/impl/array-utils-size.mjs.map +1 -1
  25. package/dist/array/impl/array-utils-slice-clamped.mjs +13 -50
  26. package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
  27. package/dist/array/impl/array-utils-slicing.mjs +92 -76
  28. package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
  29. package/dist/array/impl/array-utils-transformation.mjs +291 -199
  30. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  31. package/dist/array/impl/array-utils-validation.mjs +53 -55
  32. package/dist/array/impl/array-utils-validation.mjs.map +1 -1
  33. package/dist/array/impl/index.mjs +17 -17
  34. package/dist/array/impl/index.mjs.map +1 -1
  35. package/dist/array/index.mjs +2 -3
  36. package/dist/array/index.mjs.map +1 -1
  37. package/dist/collections/imap-mapped.mjs +335 -292
  38. package/dist/collections/imap-mapped.mjs.map +1 -1
  39. package/dist/collections/imap.mjs +280 -239
  40. package/dist/collections/imap.mjs.map +1 -1
  41. package/dist/collections/index.mjs +7 -7
  42. package/dist/collections/index.mjs.map +1 -1
  43. package/dist/collections/iset-mapped.mjs +448 -265
  44. package/dist/collections/iset-mapped.mjs.map +1 -1
  45. package/dist/collections/iset.mjs +328 -201
  46. package/dist/collections/iset.mjs.map +1 -1
  47. package/dist/collections/queue.mjs +181 -149
  48. package/dist/collections/queue.mjs.map +1 -1
  49. package/dist/collections/stack.mjs +167 -138
  50. package/dist/collections/stack.mjs.map +1 -1
  51. package/dist/entry-point.mjs +4 -77
  52. package/dist/entry-point.mjs.map +1 -1
  53. package/dist/expect-type.mjs +69 -3
  54. package/dist/expect-type.mjs.map +1 -1
  55. package/dist/functional/async-result/async-result.mjs +2 -3
  56. package/dist/functional/async-result/async-result.mjs.map +1 -1
  57. package/dist/functional/async-result/impl/async-result-flat-map.mjs +18 -20
  58. package/dist/functional/async-result/impl/async-result-flat-map.mjs.map +1 -1
  59. package/dist/functional/async-result/impl/async-result-from-promise.mjs +9 -10
  60. package/dist/functional/async-result/impl/async-result-from-promise.mjs.map +1 -1
  61. package/dist/functional/async-result/impl/async-result-from-throwable.mjs +12 -14
  62. package/dist/functional/async-result/impl/async-result-from-throwable.mjs.map +1 -1
  63. package/dist/functional/async-result/impl/async-result-map-err.mjs +15 -18
  64. package/dist/functional/async-result/impl/async-result-map-err.mjs.map +1 -1
  65. package/dist/functional/async-result/impl/async-result-map.mjs +15 -18
  66. package/dist/functional/async-result/impl/async-result-map.mjs.map +1 -1
  67. package/dist/functional/async-result/impl/async-result-unwrap-or.mjs +35 -8
  68. package/dist/functional/async-result/impl/async-result-unwrap-or.mjs.map +1 -1
  69. package/dist/functional/async-result/impl/index.mjs +8 -7
  70. package/dist/functional/async-result/impl/index.mjs.map +1 -1
  71. package/dist/functional/async-result/impl/types.mjs +2 -2
  72. package/dist/functional/async-result/impl/types.mjs.map +1 -1
  73. package/dist/functional/async-result/index.mjs +2 -3
  74. package/dist/functional/async-result/index.mjs.map +1 -1
  75. package/dist/functional/index.mjs +7 -11
  76. package/dist/functional/index.mjs.map +1 -1
  77. package/dist/functional/match.mjs +27 -13
  78. package/dist/functional/match.mjs.map +1 -1
  79. package/dist/functional/optional/impl/index.mjs +19 -18
  80. package/dist/functional/optional/impl/index.mjs.map +1 -1
  81. package/dist/functional/optional/impl/optional-expect-to-be.mjs +15 -17
  82. package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
  83. package/dist/functional/optional/impl/optional-filter.mjs +16 -18
  84. package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
  85. package/dist/functional/optional/impl/optional-flat-map.mjs +12 -14
  86. package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
  87. package/dist/functional/optional/impl/optional-from-nullable.mjs +24 -3
  88. package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
  89. package/dist/functional/optional/impl/optional-is-none.mjs +19 -3
  90. package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -1
  91. package/dist/functional/optional/impl/optional-is-optional.mjs +24 -6
  92. package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
  93. package/dist/functional/optional/impl/optional-is-some.mjs +20 -3
  94. package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
  95. package/dist/functional/optional/impl/optional-map.mjs +15 -17
  96. package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
  97. package/dist/functional/optional/impl/optional-match.mjs +15 -17
  98. package/dist/functional/optional/impl/optional-match.mjs.map +1 -1
  99. package/dist/functional/optional/impl/optional-none.mjs +16 -3
  100. package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
  101. package/dist/functional/optional/impl/optional-or-else.mjs +12 -14
  102. package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
  103. package/dist/functional/optional/impl/optional-some.mjs +22 -6
  104. package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
  105. package/dist/functional/optional/impl/optional-to-nullable.mjs +26 -3
  106. package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
  107. package/dist/functional/optional/impl/optional-unwrap-or.mjs +11 -13
  108. package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
  109. package/dist/functional/optional/impl/optional-unwrap-throw.mjs +33 -8
  110. package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
  111. package/dist/functional/optional/impl/optional-unwrap.mjs +6 -9
  112. package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
  113. package/dist/functional/optional/impl/optional-zip.mjs +34 -3
  114. package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
  115. package/dist/functional/optional/impl/tag.mjs +3 -4
  116. package/dist/functional/optional/impl/tag.mjs.map +1 -1
  117. package/dist/functional/optional/impl/types.mjs +2 -2
  118. package/dist/functional/optional/impl/types.mjs.map +1 -1
  119. package/dist/functional/optional/index.mjs +2 -3
  120. package/dist/functional/optional/index.mjs.map +1 -1
  121. package/dist/functional/optional/optional.mjs +2 -3
  122. package/dist/functional/optional/optional.mjs.map +1 -1
  123. package/dist/functional/pipe.mjs +42 -14
  124. package/dist/functional/pipe.mjs.map +1 -1
  125. package/dist/functional/result/impl/index.mjs +28 -27
  126. package/dist/functional/result/impl/index.mjs.map +1 -1
  127. package/dist/functional/result/impl/result-err.mjs +28 -6
  128. package/dist/functional/result/impl/result-err.mjs.map +1 -1
  129. package/dist/functional/result/impl/result-expect-to-be.mjs +16 -17
  130. package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
  131. package/dist/functional/result/impl/result-flat-map.mjs +17 -20
  132. package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
  133. package/dist/functional/result/impl/result-fold.mjs +17 -20
  134. package/dist/functional/result/impl/result-fold.mjs.map +1 -1
  135. package/dist/functional/result/impl/result-from-optional.mjs +16 -19
  136. package/dist/functional/result/impl/result-from-optional.mjs.map +1 -1
  137. package/dist/functional/result/impl/result-from-promise.mjs +35 -6
  138. package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
  139. package/dist/functional/result/impl/result-from-throwable.mjs +40 -13
  140. package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
  141. package/dist/functional/result/impl/result-is-err.mjs +19 -3
  142. package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
  143. package/dist/functional/result/impl/result-is-ok.mjs +19 -3
  144. package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
  145. package/dist/functional/result/impl/result-is-result.mjs +23 -5
  146. package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
  147. package/dist/functional/result/impl/result-map-err.mjs +17 -20
  148. package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
  149. package/dist/functional/result/impl/result-map.mjs +17 -20
  150. package/dist/functional/result/impl/result-map.mjs.map +1 -1
  151. package/dist/functional/result/impl/result-match.mjs +16 -20
  152. package/dist/functional/result/impl/result-match.mjs.map +1 -1
  153. package/dist/functional/result/impl/result-ok.mjs +28 -6
  154. package/dist/functional/result/impl/result-ok.mjs.map +1 -1
  155. package/dist/functional/result/impl/result-or-else.mjs +13 -14
  156. package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
  157. package/dist/functional/result/impl/result-safe-try.mjs +32 -21
  158. package/dist/functional/result/impl/result-safe-try.mjs.map +1 -1
  159. package/dist/functional/result/impl/result-safe-unwrap.mjs +39 -11
  160. package/dist/functional/result/impl/result-safe-unwrap.mjs.map +1 -1
  161. package/dist/functional/result/impl/result-swap.mjs +21 -6
  162. package/dist/functional/result/impl/result-swap.mjs.map +1 -1
  163. package/dist/functional/result/impl/result-to-optional.mjs +28 -5
  164. package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
  165. package/dist/functional/result/impl/result-unwrap-err-or.mjs +12 -13
  166. package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
  167. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +42 -19
  168. package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
  169. package/dist/functional/result/impl/result-unwrap-err.mjs +31 -6
  170. package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
  171. package/dist/functional/result/impl/result-unwrap-ok-or.mjs +12 -13
  172. package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
  173. package/dist/functional/result/impl/result-unwrap-ok.mjs +6 -9
  174. package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
  175. package/dist/functional/result/impl/result-unwrap-throw.mjs +37 -10
  176. package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
  177. package/dist/functional/result/impl/result-zip.mjs +33 -3
  178. package/dist/functional/result/impl/result-zip.mjs.map +1 -1
  179. package/dist/functional/result/impl/tag.mjs +3 -4
  180. package/dist/functional/result/impl/tag.mjs.map +1 -1
  181. package/dist/functional/result/impl/types.mjs +2 -2
  182. package/dist/functional/result/impl/types.mjs.map +1 -1
  183. package/dist/functional/result/index.mjs +2 -3
  184. package/dist/functional/result/index.mjs.map +1 -1
  185. package/dist/functional/result/result.mjs +2 -3
  186. package/dist/functional/result/result.mjs.map +1 -1
  187. package/dist/functional/ternary-result/impl/index.mjs +29 -28
  188. package/dist/functional/ternary-result/impl/index.mjs.map +1 -1
  189. package/dist/functional/ternary-result/impl/tag.mjs +5 -5
  190. package/dist/functional/ternary-result/impl/tag.mjs.map +1 -1
  191. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +16 -6
  192. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
  193. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +15 -18
  194. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
  195. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +29 -33
  196. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
  197. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +24 -26
  198. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
  199. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +19 -6
  200. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
  201. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +27 -12
  202. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
  203. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +17 -3
  204. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -1
  205. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +19 -3
  206. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -1
  207. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +26 -6
  208. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -1
  209. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +18 -3
  210. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
  211. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +17 -18
  212. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
  213. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +20 -23
  214. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
  215. package/dist/functional/ternary-result/impl/ternary-result-map.mjs +24 -26
  216. package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
  217. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +17 -6
  218. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
  219. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +11 -14
  220. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
  221. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +22 -8
  222. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -1
  223. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +11 -14
  224. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -1
  225. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +29 -18
  226. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
  227. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +18 -6
  228. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -1
  229. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +11 -14
  230. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -1
  231. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +6 -8
  232. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
  233. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +31 -23
  234. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
  235. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +11 -14
  236. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -1
  237. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +26 -16
  238. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
  239. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +18 -6
  240. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
  241. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +20 -7
  242. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
  243. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +46 -18
  244. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
  245. package/dist/functional/ternary-result/impl/types.mjs +2 -2
  246. package/dist/functional/ternary-result/impl/types.mjs.map +1 -1
  247. package/dist/functional/ternary-result/impl/variant-name.mjs +11 -13
  248. package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -1
  249. package/dist/functional/ternary-result/index.mjs +2 -3
  250. package/dist/functional/ternary-result/index.mjs.map +1 -1
  251. package/dist/functional/ternary-result/ternary-result.mjs +2 -3
  252. package/dist/functional/ternary-result/ternary-result.mjs.map +1 -1
  253. package/dist/guard/has-key.mjs +42 -3
  254. package/dist/guard/has-key.mjs.map +1 -1
  255. package/dist/guard/index.mjs +8 -8
  256. package/dist/guard/index.mjs.map +1 -1
  257. package/dist/guard/is-non-empty-string.mjs +38 -3
  258. package/dist/guard/is-non-empty-string.mjs.map +1 -1
  259. package/dist/guard/is-non-null-object.mjs +35 -3
  260. package/dist/guard/is-non-null-object.mjs.map +1 -1
  261. package/dist/guard/is-primitive.mjs +46 -15
  262. package/dist/guard/is-primitive.mjs.map +1 -1
  263. package/dist/guard/is-record.mjs +87 -4
  264. package/dist/guard/is-record.mjs.map +1 -1
  265. package/dist/guard/is-type.mjs +404 -19
  266. package/dist/guard/is-type.mjs.map +1 -1
  267. package/dist/guard/key-is-in.mjs +41 -3
  268. package/dist/guard/key-is-in.mjs.map +1 -1
  269. package/dist/index.mjs +12 -65
  270. package/dist/index.mjs.map +1 -1
  271. package/dist/iterator/index.mjs +2 -2
  272. package/dist/iterator/index.mjs.map +1 -1
  273. package/dist/iterator/range.mjs +18 -56
  274. package/dist/iterator/range.mjs.map +1 -1
  275. package/dist/json/index.mjs +2 -2
  276. package/dist/json/index.mjs.map +1 -1
  277. package/dist/json/json.mjs +346 -105
  278. package/dist/json/json.mjs.map +1 -1
  279. package/dist/number/branded-types/finite-number.mjs +148 -137
  280. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  281. package/dist/number/branded-types/index.mjs +33 -33
  282. package/dist/number/branded-types/index.mjs.map +1 -1
  283. package/dist/number/branded-types/int.mjs +245 -209
  284. package/dist/number/branded-types/int.mjs.map +1 -1
  285. package/dist/number/branded-types/int16.mjs +141 -131
  286. package/dist/number/branded-types/int16.mjs.map +1 -1
  287. package/dist/number/branded-types/int32.mjs +141 -131
  288. package/dist/number/branded-types/int32.mjs.map +1 -1
  289. package/dist/number/branded-types/negative-finite-number.mjs +155 -149
  290. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  291. package/dist/number/branded-types/negative-int.mjs +125 -110
  292. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  293. package/dist/number/branded-types/negative-safe-int.mjs +126 -115
  294. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  295. package/dist/number/branded-types/non-negative-finite-number.mjs +164 -154
  296. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  297. package/dist/number/branded-types/non-negative-int16.mjs +137 -125
  298. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  299. package/dist/number/branded-types/non-negative-int32.mjs +137 -125
  300. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  301. package/dist/number/branded-types/non-positive-finite-number.mjs +143 -139
  302. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  303. package/dist/number/branded-types/non-positive-int.mjs +116 -99
  304. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  305. package/dist/number/branded-types/non-positive-safe-int.mjs +118 -107
  306. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  307. package/dist/number/branded-types/non-zero-finite-number.mjs +144 -129
  308. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  309. package/dist/number/branded-types/non-zero-int.mjs +102 -82
  310. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  311. package/dist/number/branded-types/non-zero-int16.mjs +118 -105
  312. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  313. package/dist/number/branded-types/non-zero-int32.mjs +118 -105
  314. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  315. package/dist/number/branded-types/non-zero-safe-int.mjs +121 -107
  316. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  317. package/dist/number/branded-types/non-zero-uint16.mjs +118 -104
  318. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  319. package/dist/number/branded-types/non-zero-uint32.mjs +118 -104
  320. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  321. package/dist/number/branded-types/positive-finite-number.mjs +167 -160
  322. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  323. package/dist/number/branded-types/positive-int.mjs +260 -224
  324. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  325. package/dist/number/branded-types/positive-int16.mjs +134 -122
  326. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  327. package/dist/number/branded-types/positive-int32.mjs +134 -122
  328. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  329. package/dist/number/branded-types/positive-safe-int.mjs +291 -257
  330. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  331. package/dist/number/branded-types/positive-uint16.mjs +134 -122
  332. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  333. package/dist/number/branded-types/positive-uint32.mjs +134 -122
  334. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  335. package/dist/number/branded-types/safe-int.mjs +283 -254
  336. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  337. package/dist/number/branded-types/safe-uint.mjs +134 -123
  338. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  339. package/dist/number/branded-types/uint.mjs +248 -211
  340. package/dist/number/branded-types/uint.mjs.map +1 -1
  341. package/dist/number/branded-types/uint16.mjs +132 -121
  342. package/dist/number/branded-types/uint16.mjs.map +1 -1
  343. package/dist/number/branded-types/uint32.mjs +132 -121
  344. package/dist/number/branded-types/uint32.mjs.map +1 -1
  345. package/dist/number/enum/index.mjs +3 -3
  346. package/dist/number/enum/index.mjs.map +1 -1
  347. package/dist/number/enum/int8.mjs +146 -131
  348. package/dist/number/enum/int8.mjs.map +1 -1
  349. package/dist/number/enum/uint8.mjs +133 -119
  350. package/dist/number/enum/uint8.mjs.map +1 -1
  351. package/dist/number/index.mjs +6 -37
  352. package/dist/number/index.mjs.map +1 -1
  353. package/dist/number/num-arithmetic-types.mjs +42 -1
  354. package/dist/number/num-arithmetic-types.mjs.map +1 -1
  355. package/dist/number/num.mjs +549 -91
  356. package/dist/number/num.mjs.map +1 -1
  357. package/dist/number/refined-number-utils.mjs +294 -133
  358. package/dist/number/refined-number-utils.mjs.map +1 -1
  359. package/dist/object/index.mjs +2 -2
  360. package/dist/object/index.mjs.map +1 -1
  361. package/dist/object/object.mjs +356 -203
  362. package/dist/object/object.mjs.map +1 -1
  363. package/dist/others/cast-mutable.mjs +38 -11
  364. package/dist/others/cast-mutable.mjs.map +1 -1
  365. package/dist/others/cast-readonly.mjs +37 -11
  366. package/dist/others/cast-readonly.mjs.map +1 -1
  367. package/dist/others/debounce-function.mjs +22 -11
  368. package/dist/others/debounce-function.mjs.map +1 -1
  369. package/dist/others/fast-deep-equal.mjs +70 -51
  370. package/dist/others/fast-deep-equal.mjs.map +1 -1
  371. package/dist/others/if-then.mjs +31 -4
  372. package/dist/others/if-then.mjs.map +1 -1
  373. package/dist/others/index.mjs +10 -10
  374. package/dist/others/index.mjs.map +1 -1
  375. package/dist/others/map-nullable.mjs +11 -13
  376. package/dist/others/map-nullable.mjs.map +1 -1
  377. package/dist/others/memoize-function.mjs +14 -16
  378. package/dist/others/memoize-function.mjs.map +1 -1
  379. package/dist/others/tuple.mjs +51 -3
  380. package/dist/others/tuple.mjs.map +1 -1
  381. package/dist/others/unknown-to-string.mjs +91 -47
  382. package/dist/others/unknown-to-string.mjs.map +1 -1
  383. package/dist/promise/index.mjs +2 -2
  384. package/dist/promise/index.mjs.map +1 -1
  385. package/dist/promise/promise.mjs +49 -8
  386. package/dist/promise/promise.mjs.map +1 -1
  387. package/dist/string/index.mjs +2 -2
  388. package/dist/string/index.mjs.map +1 -1
  389. package/dist/string/str.mjs +250 -83
  390. package/dist/string/str.mjs.map +1 -1
  391. package/dist/types.mjs +2 -1
  392. package/dist/types.mjs.map +1 -1
  393. package/package.json +6 -7
  394. package/src/guard/is-type.test.mts +2 -2
  395. package/src/number/branded-types/finite-number.test.mts +1 -1
  396. package/src/number/branded-types/int.test.mts +1 -1
  397. package/src/number/branded-types/int16.test.mts +1 -1
  398. package/src/number/branded-types/int32.test.mts +1 -1
  399. package/src/number/branded-types/non-negative-finite-number.test.mts +1 -1
  400. package/src/number/branded-types/non-negative-int16.test.mts +1 -1
  401. package/src/number/branded-types/non-negative-int32.test.mts +1 -1
  402. package/src/number/branded-types/non-zero-finite-number.test.mts +1 -1
  403. package/src/number/branded-types/non-zero-int.test.mts +1 -1
  404. package/src/number/branded-types/non-zero-int16.test.mts +1 -1
  405. package/src/number/branded-types/non-zero-int32.test.mts +1 -1
  406. package/src/number/branded-types/non-zero-safe-int.test.mts +1 -1
  407. package/src/number/branded-types/non-zero-uint16.test.mts +1 -1
  408. package/src/number/branded-types/non-zero-uint32.test.mts +1 -1
  409. package/src/number/branded-types/positive-finite-number.test.mts +1 -1
  410. package/src/number/branded-types/positive-int.test.mts +1 -1
  411. package/src/number/branded-types/positive-int16.test.mts +1 -1
  412. package/src/number/branded-types/positive-int32.test.mts +1 -1
  413. package/src/number/branded-types/positive-safe-int.test.mts +1 -1
  414. package/src/number/branded-types/positive-uint16.test.mts +1 -1
  415. package/src/number/branded-types/positive-uint32.test.mts +1 -1
  416. package/src/number/branded-types/safe-int.test.mts +1 -1
  417. package/src/number/branded-types/safe-uint.test.mts +1 -1
  418. package/src/number/branded-types/uint.test.mts +1 -1
  419. package/src/number/branded-types/uint16.test.mts +1 -1
  420. package/src/number/branded-types/uint32.test.mts +1 -1
@@ -1,17 +1,15 @@
1
- import { err } from '../../result/impl/result-err.mjs';
2
- import { ok } from '../../result/impl/result-ok.mjs';
3
- import '@sindresorhus/is';
4
-
5
- function fromThrowable(fn, mapError) {
6
- return mapError === void 0 ? fromThrowableImpl(fn, (error) => error) : fromThrowableImpl(fn, mapError);
1
+ import { Result } from '../../result/index.mjs';
2
+ export function fromThrowable(fn, mapError) {
3
+ return mapError === undefined
4
+ ? fromThrowableImpl(fn, (error) => error)
5
+ : fromThrowableImpl(fn, mapError);
7
6
  }
8
7
  const fromThrowableImpl = async (fn, mapError) => {
9
- try {
10
- return ok(await fn());
11
- } catch (error) {
12
- return err(mapError(error));
13
- }
8
+ try {
9
+ return Result.ok(await fn());
10
+ }
11
+ catch (error) {
12
+ return Result.err(mapError(error));
13
+ }
14
14
  };
15
-
16
- export { fromThrowable };
17
- //# sourceMappingURL=async-result-from-throwable.mjs.map
15
+ //# sourceMappingURL=async-result-from-throwable.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"async-result-from-throwable.mjs","sources":["../../../../src/functional/async-result/impl/async-result-from-throwable.mts"],"sourcesContent":["import { Result } from '../../result/index.mjs';\nimport { type AsyncResult } from '../async-result.mjs';\n\n/**\n * Wraps a function returning a `Promise` in an `AsyncResult`. Both a\n * synchronous `throw` while calling `fn` and an asynchronous rejection of the\n * returned Promise are caught, passed through `mapError`, and carried as\n * `Err`.\n *\n * Passing `mapError` is what gives the error channel a concrete type `E`.\n * Omitting it carries the thrown value through untouched, leaving the error\n * channel as `unknown`.\n *\n * @example\n *\n * ```ts\n * const success = await AsyncResult.fromThrowable(\n * () => Promise.resolve(2),\n * (error) => `failed: ${String(error)}`,\n * );\n *\n * const failure = await AsyncResult.fromThrowable(\n * (): Promise<number> => {\n * throw new Error('boom');\n * },\n * (error) => (isError(error) ? error.message : 'unknown'),\n * );\n *\n * assert.deepStrictEqual(success, Result.ok(2));\n *\n * assert.deepStrictEqual(failure, Result.err('boom'));\n *\n * // Without `mapError`, the thrown value is carried as-is.\n * const untyped = await AsyncResult.fromThrowable(\n * (): Promise<number> => {\n * throw new Error('boom');\n * },\n * );\n *\n * assert.isTrue(Result.isErr(untyped));\n * ```\n *\n * @template S The type of the success value.\n * @template E The type of the error value.\n * @param fn The function to execute; it may throw synchronously or return a\n * rejecting Promise.\n * @param mapError The function applied to the thrown value or rejection\n * reason to produce the error value. Omit it to carry the thrown value as\n * `unknown`.\n * @returns An `AsyncResult<S, E>` containing either the resolved value or the\n * mapped error.\n */\nexport function fromThrowable<S>(fn: () => Promise<S>): AsyncResult<S, unknown>;\n\nexport function fromThrowable<S, E>(\n fn: () => Promise<S>,\n mapError: (error: unknown) => E,\n): AsyncResult<S, E>;\n\nexport function fromThrowable<S, E>(\n fn: () => Promise<S>,\n mapError?: (error: unknown) => E,\n): AsyncResult<S, E> | AsyncResult<S, unknown> {\n return mapError === undefined\n ? fromThrowableImpl(fn, (error: unknown) => error)\n : fromThrowableImpl(fn, mapError);\n}\n\nconst fromThrowableImpl = async <S, E>(\n fn: () => Promise<S>,\n mapError: (error: unknown) => E,\n): AsyncResult<S, E> => {\n try {\n return Result.ok(await fn());\n } catch (error) {\n return Result.err(mapError(error));\n }\n};\n"],"names":["Result.ok","Result.err"],"mappings":";;;;AA2DO,SAAS,aAAA,CACd,IACA,QAAA,EAC6C;AAC7C,EAAA,OAAO,QAAA,KAAa,MAAA,GAChB,iBAAA,CAAkB,EAAA,EAAI,CAAC,UAAmB,KAAK,CAAA,GAC/C,iBAAA,CAAkB,EAAA,EAAI,QAAQ,CAAA;AACpC;AAEA,MAAM,iBAAA,GAAoB,OACxB,EAAA,EACA,QAAA,KACsB;AACtB,EAAA,IAAI;AACF,IAAA,OAAOA,EAAO,CAAG,MAAM,EAAA,EAAI,CAAA;AAAA,EAC7B,SAAS,KAAA,EAAO;AACd,IAAA,OAAOC,GAAO,CAAI,QAAA,CAAS,KAAK,CAAC,CAAA;AAAA,EACnC;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"async-result-from-throwable.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-from-throwable.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AA2DhD,MAAM,UAAU,aAAa,CAC3B,EAAoB,EACpB,QAAgC;IAEhC,OAAO,QAAQ,KAAK,SAAS;QAC3B,CAAC,CAAC,iBAAiB,CAAC,EAAE,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,KAAK,CAAC;QAClD,CAAC,CAAC,iBAAiB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,iBAAiB,GAAG,KAAK,EAC7B,EAAoB,EACpB,QAA+B,EACZ,EAAE;IACrB,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,CAAC;AACH,CAAC,CAAC"}
@@ -1,23 +1,20 @@
1
- import { err } from '../../result/impl/result-err.mjs';
2
- import { isOk } from '../../result/impl/result-is-ok.mjs';
3
- import '@sindresorhus/is';
1
+ import { Result } from '../../result/index.mjs';
2
+ export function mapErr(...args) {
3
+ switch (args.length) {
4
+ case 2: {
4
5
 
5
- function mapErr(...args) {
6
- switch (args.length) {
7
- case 2: {
8
- const [asyncResult, mapFn] = args;
9
- return mapErrImpl(asyncResult, mapFn);
10
- }
11
- case 1: {
12
- const [mapFn] = args;
13
- return (asyncResult) => mapErrImpl(asyncResult, mapFn);
6
+ const [asyncResult, mapFn] = args;
7
+ return mapErrImpl(asyncResult, mapFn);
8
+ }
9
+ case 1: {
10
+
11
+ const [mapFn] = args;
12
+ return (asyncResult) => mapErrImpl(asyncResult, mapFn);
13
+ }
14
14
  }
15
- }
16
15
  }
17
16
  const mapErrImpl = async (asyncResult, mapFn) => {
18
- const result = await asyncResult;
19
- return isOk(result) ? result : err(await mapFn(result.value));
17
+ const result = await asyncResult;
18
+ return Result.isOk(result) ? result : Result.err(await mapFn(result.value));
20
19
  };
21
-
22
- export { mapErr };
23
- //# sourceMappingURL=async-result-map-err.mjs.map
20
+ //# sourceMappingURL=async-result-map-err.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"async-result-map-err.mjs","sources":["../../../../src/functional/async-result/impl/async-result-map-err.mts"],"sourcesContent":["import { Result } from '../../result/index.mjs';\nimport { type AsyncResult } from '../async-result.mjs';\n\n/**\n * Maps an `AsyncResult<S, E>` to `AsyncResult<S, E2>` by applying a function\n * to the error value. The mapping function may be synchronous or return a\n * `Promise`; both are handled transparently. If the `AsyncResult` resolves to\n * `Ok`, the original `Ok` is passed through and the function is not called.\n *\n * If `mapFn` throws or returns a rejecting Promise, the rejection propagates\n * as-is — it is **not** caught and converted into an `Err`.\n *\n * @example\n *\n * ```ts\n * const errValue = AsyncResult.fromPromise(\n * Promise.reject(new Error('boom')),\n * () => 'failure',\n * );\n *\n * const uppercased = await AsyncResult.mapErr(errValue, (error) =>\n * error.toUpperCase(),\n * );\n *\n * assert.deepStrictEqual(uppercased, Result.err('FAILURE'));\n * ```\n *\n * @template S The type of the success value.\n * @template E The type of the error value of the input.\n * @template E2 The type of the error value returned by the mapping function.\n * @param asyncResult The `AsyncResult` to map.\n * @param mapFn The function to apply to the error value if present.\n * @returns A new `AsyncResult<S, E2>`.\n */\nexport function mapErr<S, E, E2>(\n asyncResult: AsyncResult<S, E>,\n mapFn: (error: E) => E2 | Promise<E2>,\n): AsyncResult<S, E2>;\n\n// Curried version\n//\n// Unlike `Result.mapErr`, the returned function can simply be generic over\n// `S`: an `AsyncResult` is a `Promise`, not a discriminated union, so there\n// is no literal-narrowing problem that would require the whole-result\n// generic trick used by the synchronous combinators.\nexport function mapErr<E, E2>(\n mapFn: (error: E) => E2 | Promise<E2>,\n): <S>(asyncResult: AsyncResult<S, E>) => AsyncResult<S, E2>;\n\nexport function mapErr<S, E, E2>(\n ...args:\n | readonly [\n asyncResult: AsyncResult<S, E>,\n mapFn: (error: E) => E2 | Promise<E2>,\n ]\n | readonly [mapFn: (error: E) => E2 | Promise<E2>]\n):\n | AsyncResult<S, E2>\n | ((asyncResult: AsyncResult<S, E>) => AsyncResult<S, E2>) {\n switch (args.length) {\n case 2: {\n // Direct version: first argument is asyncResult\n const [asyncResult, mapFn] = args;\n\n return mapErrImpl(asyncResult, mapFn);\n }\n\n case 1: {\n // Curried version: first argument is mapping function\n const [mapFn] = args;\n\n return (asyncResult: AsyncResult<S, E>) => mapErrImpl(asyncResult, mapFn);\n }\n }\n}\n\nconst mapErrImpl = async <S, E, E2>(\n asyncResult: AsyncResult<S, E>,\n mapFn: (error: E) => E2 | Promise<E2>,\n): AsyncResult<S, E2> => {\n const result = await asyncResult;\n\n return Result.isOk(result) ? result : Result.err(await mapFn(result.value));\n};\n"],"names":["Result.isOk","Result.err"],"mappings":";;;;AAiDO,SAAS,UACX,IAAA,EAQwD;AAC3D,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,WAAA,EAAa,KAAK,CAAA,GAAI,IAAA;AAE7B,MAAA,OAAO,UAAA,CAAW,aAAa,KAAK,CAAA;AAAA,IACtC;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,KAAK,CAAA,GAAI,IAAA;AAEhB,MAAA,OAAO,CAAC,WAAA,KAAmC,UAAA,CAAW,WAAA,EAAa,KAAK,CAAA;AAAA,IAC1E;AAAA;AAEJ;AAEA,MAAM,UAAA,GAAa,OACjB,WAAA,EACA,KAAA,KACuB;AACvB,EAAA,MAAM,SAAS,MAAM,WAAA;AAErB,EAAA,OAAOA,IAAO,CAAK,MAAM,CAAA,GAAI,MAAA,GAASC,GAAO,CAAI,MAAM,KAAA,CAAM,MAAA,CAAO,KAAK,CAAC,CAAA;AAC5E,CAAA;;;;"}
1
+ {"version":3,"file":"async-result-map-err.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-map-err.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAiDhD,MAAM,UAAU,MAAM,CACpB,GAAG,IAKiD;IAIpD,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,gDAAgD;YAChD,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;YAElC,OAAO,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,sDAAsD;YACtD,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;YAErB,OAAO,CAAC,WAA8B,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,GAAG,KAAK,EACtB,WAA8B,EAC9B,KAAqC,EACjB,EAAE;IACtB,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC;IAEjC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9E,CAAC,CAAC"}
@@ -1,23 +1,20 @@
1
- import { isErr } from '../../result/impl/result-is-err.mjs';
2
- import { ok } from '../../result/impl/result-ok.mjs';
3
- import '@sindresorhus/is';
1
+ import { Result } from '../../result/index.mjs';
2
+ export function map(...args) {
3
+ switch (args.length) {
4
+ case 2: {
4
5
 
5
- function map(...args) {
6
- switch (args.length) {
7
- case 2: {
8
- const [asyncResult, mapFn] = args;
9
- return mapImpl(asyncResult, mapFn);
10
- }
11
- case 1: {
12
- const [mapFn] = args;
13
- return (asyncResult) => mapImpl(asyncResult, mapFn);
6
+ const [asyncResult, mapFn] = args;
7
+ return mapImpl(asyncResult, mapFn);
8
+ }
9
+ case 1: {
10
+
11
+ const [mapFn] = args;
12
+ return (asyncResult) => mapImpl(asyncResult, mapFn);
13
+ }
14
14
  }
15
- }
16
15
  }
17
16
  const mapImpl = async (asyncResult, mapFn) => {
18
- const result = await asyncResult;
19
- return isErr(result) ? result : ok(await mapFn(result.value));
17
+ const result = await asyncResult;
18
+ return Result.isErr(result) ? result : Result.ok(await mapFn(result.value));
20
19
  };
21
-
22
- export { map };
23
- //# sourceMappingURL=async-result-map.mjs.map
20
+ //# sourceMappingURL=async-result-map.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"async-result-map.mjs","sources":["../../../../src/functional/async-result/impl/async-result-map.mts"],"sourcesContent":["import { Result } from '../../result/index.mjs';\nimport { type AsyncResult } from '../async-result.mjs';\n\n/**\n * Maps an `AsyncResult<S, E>` to `AsyncResult<S2, E>` by applying a function\n * to the success value. The mapping function may be synchronous or return a\n * `Promise`; both are handled transparently. If the `AsyncResult` resolves to\n * `Err`, the original `Err` is passed through and the function is not called.\n *\n * If `mapFn` throws or returns a rejecting Promise, the rejection propagates\n * as-is — it is **not** caught and converted into an `Err`. `map` performs no\n * implicit error conversion; write a fallible step as\n * `AsyncResult.flatMap` combined with `AsyncResult.fromThrowable` instead, so\n * that the error type stays explicit.\n *\n * @example\n *\n * ```ts\n * const okValue = AsyncResult.fromPromise(\n * Promise.resolve(5),\n * () => 'failed',\n * );\n *\n * const doubled = await AsyncResult.map(okValue, (value) => value * 2);\n *\n * assert.deepStrictEqual(doubled, Result.ok(10));\n *\n * const double = AsyncResult.map((value: number) => value * 2);\n *\n * const curried = await double(\n * AsyncResult.fromPromise(Promise.resolve(21), () => 'failed'),\n * );\n *\n * assert.deepStrictEqual(curried, Result.ok(42));\n * ```\n *\n * @template S The type of the success value of the input.\n * @template S2 The type of the success value returned by the mapping\n * function.\n * @template E The type of the error value.\n * @param asyncResult The `AsyncResult` to map.\n * @param mapFn The function to apply to the success value if present.\n * @returns A new `AsyncResult<S2, E>`.\n */\nexport function map<S, S2, E>(\n asyncResult: AsyncResult<S, E>,\n mapFn: (value: S) => Promise<S2> | S2,\n): AsyncResult<S2, E>;\n\n// Curried version\n//\n// Unlike `Result.map`, the returned function can simply be generic over `E`:\n// an `AsyncResult` is a `Promise`, not a discriminated union, so there is no\n// literal-narrowing problem that would require the whole-result generic\n// trick used by the synchronous combinators.\nexport function map<S, S2>(\n mapFn: (value: S) => Promise<S2> | S2,\n): <E>(asyncResult: AsyncResult<S, E>) => AsyncResult<S2, E>;\n\nexport function map<S, S2, E>(\n ...args:\n | readonly [\n asyncResult: AsyncResult<S, E>,\n mapFn: (value: S) => Promise<S2> | S2,\n ]\n | readonly [mapFn: (value: S) => Promise<S2> | S2]\n):\n | AsyncResult<S2, E>\n | ((asyncResult: AsyncResult<S, E>) => AsyncResult<S2, E>) {\n switch (args.length) {\n case 2: {\n // Direct version: first argument is asyncResult\n const [asyncResult, mapFn] = args;\n\n return mapImpl(asyncResult, mapFn);\n }\n\n case 1: {\n // Curried version\n const [mapFn] = args;\n\n return (asyncResult: AsyncResult<S, E>) => mapImpl(asyncResult, mapFn);\n }\n }\n}\n\nconst mapImpl = async <S, S2, E>(\n asyncResult: AsyncResult<S, E>,\n mapFn: (value: S) => Promise<S2> | S2,\n): AsyncResult<S2, E> => {\n const result = await asyncResult;\n\n return Result.isErr(result) ? result : Result.ok(await mapFn(result.value));\n};\n"],"names":["Result.isErr","Result.ok"],"mappings":";;;;AA2DO,SAAS,OACX,IAAA,EAQwD;AAC3D,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,WAAA,EAAa,KAAK,CAAA,GAAI,IAAA;AAE7B,MAAA,OAAO,OAAA,CAAQ,aAAa,KAAK,CAAA;AAAA,IACnC;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,KAAK,CAAA,GAAI,IAAA;AAEhB,MAAA,OAAO,CAAC,WAAA,KAAmC,OAAA,CAAQ,WAAA,EAAa,KAAK,CAAA;AAAA,IACvE;AAAA;AAEJ;AAEA,MAAM,OAAA,GAAU,OACd,WAAA,EACA,KAAA,KACuB;AACvB,EAAA,MAAM,SAAS,MAAM,WAAA;AAErB,EAAA,OAAOA,KAAO,CAAM,MAAM,CAAA,GAAI,MAAA,GAASC,EAAO,CAAG,MAAM,KAAA,CAAM,MAAA,CAAO,KAAK,CAAC,CAAA;AAC5E,CAAA;;;;"}
1
+ {"version":3,"file":"async-result-map.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-map.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AA2DhD,MAAM,UAAU,GAAG,CACjB,GAAG,IAKiD;IAIpD,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,gDAAgD;YAChD,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;YAElC,OAAO,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,kBAAkB;YAClB,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;YAErB,OAAO,CAAC,WAA8B,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,OAAO,GAAG,KAAK,EACnB,WAA8B,EAC9B,KAAqC,EACjB,EAAE;IACtB,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC;IAEjC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9E,CAAC,CAAC"}
@@ -1,10 +1,37 @@
1
- import { isOk } from '../../result/impl/result-is-ok.mjs';
2
- import '@sindresorhus/is';
1
+ import { Result } from '../../result/index.mjs';
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
3
17
 
4
- const unwrapOr = async (asyncResult, defaultValue) => {
5
- const result = await asyncResult;
6
- return isOk(result) ? result.value : defaultValue;
7
- };
8
18
 
9
- export { unwrapOr };
10
- //# sourceMappingURL=async-result-unwrap-or.mjs.map
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+ export const unwrapOr = async (asyncResult, defaultValue) => {
34
+ const result = await asyncResult;
35
+ return Result.isOk(result) ? result.value : defaultValue;
36
+ };
37
+ //# sourceMappingURL=async-result-unwrap-or.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"async-result-unwrap-or.mjs","sources":["../../../../src/functional/async-result/impl/async-result-unwrap-or.mts"],"sourcesContent":["import { Result } from '../../result/index.mjs';\nimport { type AsyncResult } from '../async-result.mjs';\n\n/**\n * Unwraps an `AsyncResult`, resolving to the success value or a default value\n * if it resolves to `Err`.\n *\n * @example\n *\n * ```ts\n * const okValue = AsyncResult.fromPromise(\n * Promise.resolve(10),\n * () => 'failed',\n * );\n *\n * const errValue = AsyncResult.fromPromise(\n * Promise.reject(new Error('boom')),\n * () => 'failed',\n * );\n *\n * assert.isTrue((await AsyncResult.unwrapOr(okValue, 0)) === 10);\n *\n * assert.isTrue((await AsyncResult.unwrapOr(errValue, 0)) === 0);\n * ```\n *\n * @template S The type of the success value.\n * @template E The type of the error value.\n * @template D The type of the default value.\n * @param asyncResult The `AsyncResult` to unwrap.\n * @param defaultValue The value to resolve to if `asyncResult` resolves to\n * `Err`.\n * @returns A Promise of the success value if `Ok`, otherwise of\n * `defaultValue`.\n */\nexport const unwrapOr = async <S, E, D>(\n asyncResult: AsyncResult<S, E>,\n defaultValue: D,\n): Promise<D | S> => {\n const result = await asyncResult;\n\n return Result.isOk(result) ? result.value : defaultValue;\n};\n"],"names":["Result.isOk"],"mappings":";;;AAkCO,MAAM,QAAA,GAAW,OACtB,WAAA,EACA,YAAA,KACmB;AACnB,EAAA,MAAM,SAAS,MAAM,WAAA;AAErB,EAAA,OAAOA,IAAO,CAAK,MAAM,CAAA,GAAI,OAAO,KAAA,GAAQ,YAAA;AAC9C;;;;"}
1
+ {"version":3,"file":"async-result-unwrap-or.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-unwrap-or.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAC3B,WAA8B,EAC9B,YAAe,EACC,EAAE;IAClB,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC;IAEjC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC;AAC3D,CAAC,CAAC"}
@@ -1,7 +1,8 @@
1
- export { flatMap } from './async-result-flat-map.mjs';
2
- export { fromPromise } from './async-result-from-promise.mjs';
3
- export { fromThrowable } from './async-result-from-throwable.mjs';
4
- export { mapErr } from './async-result-map-err.mjs';
5
- export { map } from './async-result-map.mjs';
6
- export { unwrapOr } from './async-result-unwrap-or.mjs';
7
- //# sourceMappingURL=index.mjs.map
1
+ export * from './async-result-flat-map.mjs';
2
+ export * from './async-result-from-promise.mjs';
3
+ export * from './async-result-from-throwable.mjs';
4
+ export * from './async-result-map-err.mjs';
5
+ export * from './async-result-map.mjs';
6
+ export * from './async-result-unwrap-or.mjs';
7
+ export * from './types.mjs';
8
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/index.mts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,aAAa,CAAC"}
@@ -1,2 +1,2 @@
1
-
2
- //# sourceMappingURL=types.mjs.map
1
+ export {};
2
+ //# sourceMappingURL=types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/types.mts"],"names":[],"mappings":""}
@@ -1,3 +1,2 @@
1
- import * as index from './impl/index.mjs';
2
- export { index as AsyncResult };
3
- //# sourceMappingURL=index.mjs.map
1
+ export * from './async-result.mjs';
2
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/functional/async-result/index.mts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -1,11 +1,7 @@
1
- import * as index from './async-result/impl/index.mjs';
2
- export { index as AsyncResult };
3
- export { match } from './match.mjs';
4
- import * as index$1 from './optional/impl/index.mjs';
5
- export { index$1 as Optional };
6
- export { pipe } from './pipe.mjs';
7
- import * as index$2 from './result/impl/index.mjs';
8
- export { index$2 as Result };
9
- import * as index$3 from './ternary-result/impl/index.mjs';
10
- export { index$3 as TernaryResult };
11
- //# sourceMappingURL=index.mjs.map
1
+ export * from './async-result/index.mjs';
2
+ export * from './match.mjs';
3
+ export * from './optional/index.mjs';
4
+ export * from './pipe.mjs';
5
+ export * from './result/index.mjs';
6
+ export * from './ternary-result/index.mjs';
7
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/functional/index.mts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC"}
@@ -1,17 +1,31 @@
1
- import { keyIsIn } from '../guard/key-is-in.mjs';
2
1
 
3
- function match(...args) {
4
- switch (args.length) {
5
- case 2: {
6
- const [target, cases] = args;
7
- return cases[target];
2
+ import { keyIsIn } from '../guard/index.mjs';
3
+ export function match(...args) {
4
+ switch (args.length) {
5
+ case 2: {
6
+ const [target, cases] = args;
7
+ return cases[target];
8
+ }
9
+ case 3: {
10
+ const [target, cases, defaultValue] = args;
11
+ return keyIsIn(target, cases) ? cases[target] : defaultValue;
12
+ }
8
13
  }
9
- case 3: {
10
- const [target, cases, defaultValue] = args;
11
- return keyIsIn(target, cases) ? cases[target] : defaultValue;
12
- }
13
- }
14
14
  }
15
15
 
16
- export { match };
17
- //# sourceMappingURL=match.mjs.map
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+ //# sourceMappingURL=match.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"match.mjs","sources":["../../src/functional/match.mts"],"sourcesContent":["import {\n type ReadonlyRecord,\n type RelaxedExclude,\n type TypeEq,\n type UnknownRecord,\n type ValueOf,\n} from 'ts-type-forge';\nimport { expectType } from '../expect-type.mjs';\nimport { keyIsIn } from '../guard/index.mjs';\n\n/**\n * Type-safe pattern matching function for string-based discriminated unions.\n *\n * Provides compile-time guarantees for exhaustive case handling when working\n * with literal string unions. Automatically enforces completeness checking when\n * all cases are covered, and requires a default value when cases are\n * incomplete.\n *\n * ## Key Features:\n *\n * - **Exhaustive Matching**: When all cases of a literal union are handled, no\n * default value is needed\n * - **Partial Matching**: When cases are incomplete or working with general\n * string types, a default value is required\n * - **Type Safety**: Prevents extra cases and ensures only valid keys are used\n * - **Strict Property Checking**: Rejects objects with unexpected properties\n *\n * @example\n *\n * ```ts\n * type Status = 'draft' | 'review' | 'published';\n *\n * const status: Status = 'draft';\n *\n * const message = match<\n * Status,\n * Readonly<{ draft: string; review: string; published: string }>\n * >(status, {\n * draft: 'Work in progress',\n * review: 'Awaiting feedback',\n * published: 'Complete',\n * });\n *\n * assert.isTrue(message === 'Work in progress');\n * ```\n *\n * @param target - The value to match against\n * @param cases - Object mapping possible values to their corresponding results\n * @param defaultValue - Fallback value (required when not all cases are\n * covered)\n * @returns The matched result or default value\n */\nexport function match<\n const Case extends string,\n const R extends ReadonlyRecord<Case, unknown>,\n>(target: Case, cases: StrictPropertyCheck<R, Case>): R[Case];\n\nexport function match<\n const Case extends string,\n const R extends UnknownRecord,\n const D,\n>(\n target: Case,\n cases: StrictPropertyCheck<R, Case>,\n defaultValue: IsLiteralUnionFullyCovered<Case, R> extends true ? never : D,\n): ValueOf<R> | D;\n\nexport function match<\n const Case extends string,\n const R extends UnknownRecord,\n const D,\n>(\n ...args:\n | readonly [target: Case, cases: R]\n | readonly [target: Case, cases: R, defaultValue: D]\n): ValueOf<R> | D {\n switch (args.length) {\n case 2: {\n const [target, cases] = args;\n\n return cases[target];\n }\n\n case 3: {\n const [target, cases, defaultValue] = args;\n\n return keyIsIn(target, cases) ? cases[target] : defaultValue;\n }\n }\n}\n\n/**\n * @template T The object type to check.\n * @template ExpectedKeys The union of string literal types representing the\n * allowed keys.\n * @internal\n * Helper type to ensure that an object `T` only contains keys specified in `ExpectedKeys`.\n * If `T` has any keys not in `ExpectedKeys`, this type resolves to `never`.\n */\ntype StrictPropertyCheck<T, ExpectedKeys extends PropertyKey> =\n RelaxedExclude<keyof T, ExpectedKeys> extends never ? T : never;\n\n/**\n * @template Case A union of string literal types representing the possible\n * cases.\n * @template R A record type.\n * @internal\n * Helper type to check if all cases in `Case` union are fully covered by keys in `R`.\n * This checks bidirectional coverage: all Case members are in R, and no extra keys.\n */\ntype AllCasesCovered<Case extends PropertyKey, R> =\n TypeEq<Case, keyof R> extends true ? true : false;\n\nexpectType<AllCasesCovered<'a' | 'b', Readonly<{ a: 1; b: 2 }>>, true>('=');\n\nexpectType<AllCasesCovered<'a' | 'b' | 'c', Readonly<{ a: 1; b: 2 }>>, false>(\n '=',\n);\n\nexpectType<AllCasesCovered<'a' | 'b', Readonly<{ a: 1; b: 2; c: 3 }>>, false>(\n '=',\n);\n\nexpectType<AllCasesCovered<string, ReadonlyRecord<string, string>>, true>('=');\n\n/**\n * @template Case A union of string literal types.\n * @template R A record type.\n * @internal\n * Helper type to check if Case is a literal union type and all cases are covered.\n */\ntype IsLiteralUnionFullyCovered<\n Case extends PropertyKey,\n R extends UnknownRecord,\n> =\n TypeEq<IsLiteralType<Case>, true> extends true\n ? AllCasesCovered<Case, R>\n : false;\n\nexpectType<\n IsLiteralUnionFullyCovered<'a' | 'b', Readonly<{ a: 1; b: 2 }>>,\n true\n>('=');\n\nexpectType<\n IsLiteralUnionFullyCovered<'a' | 'b' | 'c', Readonly<{ a: 1; b: 2 }>>,\n false\n>('=');\n\nexpectType<\n IsLiteralUnionFullyCovered<'a' | 'b', Readonly<{ a: 1; b: 2; c: 3 }>>,\n false\n>('=');\n\nexpectType<\n IsLiteralUnionFullyCovered<string, ReadonlyRecord<string, string>>,\n false\n>('=');\n\nexpectType<\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n IsLiteralUnionFullyCovered<'a' | 'b' | string, Readonly<{ a: 1; b: 2 }>>,\n false\n>('=');\n\n/**\n * @template T The PropertyKey type to check.\n * @returns `true` if `T` is a literal type, `false` otherwise.\n * @internal\n * Helper type to determine if a given PropertyKey `T` is a literal type (e.g., 'a', 1)\n * or a general type (e.g., string, number).\n */\ntype IsLiteralType<T extends PropertyKey> = string extends T\n ? false\n : number extends T\n ? false\n : symbol extends T\n ? false\n : true;\n\nexpectType<IsLiteralType<'a' | 'b'>, true>('=');\n\nexpectType<IsLiteralType<'a'>, true>('=');\n\nexpectType<IsLiteralType<string>, false>('=');\n\nexpectType<IsLiteralType<number>, false>('=');\n\nexpectType<IsLiteralType<1>, true>('=');\n\nexpectType<IsLiteralType<number | 'aa'>, false>('=');\n\nexpectType<IsLiteralType<'aa' | 32>, true>('=');\n"],"names":[],"mappings":";;AAmEO,SAAS,SAKX,IAAA,EAGa;AAChB,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,MAAA,EAAQ,KAAK,CAAA,GAAI,IAAA;AAExB,MAAA,OAAO,MAAM,MAAM,CAAA;AAAA,IAAA;AACrB,IAEA,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,MAAA,EAAQ,KAAA,EAAO,YAAY,CAAA,GAAI,IAAA;AAEtC,MAAA,OAAO,QAAQ,MAAA,EAAQ,KAAK,CAAA,GAAI,KAAA,CAAM,MAAM,CAAA,GAAI,YAAA;AAAA,IAAA;AAClD;AAEJ;;;;"}
1
+ {"version":3,"file":"match.mjs","sourceRoot":"","sources":["../../src/functional/match.mts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AA2D7C,MAAM,UAAU,KAAK,CAKnB,GAAG,IAEmD;IAEtD,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;YAE7B,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,GAAG,IAAI,CAAC;YAE3C,OAAO,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;QAC/D,CAAC;IACH,CAAC;AACH,CAAC;AAwBD,UAAU,CAA6D,GAAG,CAAC,CAAC;AAE5E,UAAU,CACR,GAAG,CACJ,CAAC;AAEF,UAAU,CACR,GAAG,CACJ,CAAC;AAEF,UAAU,CAAgE,GAAG,CAAC,CAAC;AAgB/E,UAAU,CAGR,GAAG,CAAC,CAAC;AAEP,UAAU,CAGR,GAAG,CAAC,CAAC;AAEP,UAAU,CAGR,GAAG,CAAC,CAAC;AAEP,UAAU,CAGR,GAAG,CAAC,CAAC;AAEP,UAAU,CAIR,GAAG,CAAC,CAAC;AAiBP,UAAU,CAAiC,GAAG,CAAC,CAAC;AAEhD,UAAU,CAA2B,GAAG,CAAC,CAAC;AAE1C,UAAU,CAA+B,GAAG,CAAC,CAAC;AAE9C,UAAU,CAA+B,GAAG,CAAC,CAAC;AAE9C,UAAU,CAAyB,GAAG,CAAC,CAAC;AAExC,UAAU,CAAsC,GAAG,CAAC,CAAC;AAErD,UAAU,CAAiC,GAAG,CAAC,CAAC"}
@@ -1,18 +1,19 @@
1
- export { expectToBe } from './optional-expect-to-be.mjs';
2
- export { filter } from './optional-filter.mjs';
3
- export { flatMap } from './optional-flat-map.mjs';
4
- export { fromNullable } from './optional-from-nullable.mjs';
5
- export { isNone } from './optional-is-none.mjs';
6
- export { isOptional } from './optional-is-optional.mjs';
7
- export { isSome } from './optional-is-some.mjs';
8
- export { map } from './optional-map.mjs';
9
- export { match } from './optional-match.mjs';
10
- export { none } from './optional-none.mjs';
11
- export { orElse } from './optional-or-else.mjs';
12
- export { some } from './optional-some.mjs';
13
- export { toNullable } from './optional-to-nullable.mjs';
14
- export { unwrapOr } from './optional-unwrap-or.mjs';
15
- export { unwrapThrow } from './optional-unwrap-throw.mjs';
16
- export { unwrap } from './optional-unwrap.mjs';
17
- export { zip } from './optional-zip.mjs';
18
- //# sourceMappingURL=index.mjs.map
1
+ export * from './optional-expect-to-be.mjs';
2
+ export * from './optional-filter.mjs';
3
+ export * from './optional-flat-map.mjs';
4
+ export * from './optional-from-nullable.mjs';
5
+ export * from './optional-is-none.mjs';
6
+ export * from './optional-is-optional.mjs';
7
+ export * from './optional-is-some.mjs';
8
+ export * from './optional-map.mjs';
9
+ export * from './optional-match.mjs';
10
+ export * from './optional-none.mjs';
11
+ export * from './optional-or-else.mjs';
12
+ export * from './optional-some.mjs';
13
+ export * from './optional-to-nullable.mjs';
14
+ export * from './optional-unwrap-or.mjs';
15
+ export * from './optional-unwrap-throw.mjs';
16
+ export * from './optional-unwrap.mjs';
17
+ export * from './optional-zip.mjs';
18
+ export * from './types.mjs';
19
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/functional/optional/impl/index.mts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
@@ -1,24 +1,22 @@
1
1
  import { isSome } from './optional-is-some.mjs';
2
2
  import { unwrap } from './optional-unwrap.mjs';
3
+ export function expectToBe(...args) {
4
+ switch (args.length) {
5
+ case 2: {
6
+ const [optional, message] = args;
7
+ return expectToBeImpl(optional, message);
8
+ }
9
+ case 1: {
3
10
 
4
- function expectToBe(...args) {
5
- switch (args.length) {
6
- case 2: {
7
- const [optional, message] = args;
8
- return expectToBeImpl(optional, message);
11
+ const [message] = args;
12
+ return (optional) => expectToBeImpl(optional, message);
13
+ }
9
14
  }
10
- case 1: {
11
- const [message] = args;
12
- return (optional) => expectToBeImpl(optional, message);
13
- }
14
- }
15
15
  }
16
16
  const expectToBeImpl = (optional, message) => {
17
- if (isSome(optional)) {
18
- return unwrap(optional);
19
- }
20
- throw new Error(message);
17
+ if (isSome(optional)) {
18
+ return unwrap(optional);
19
+ }
20
+ throw new Error(message);
21
21
  };
22
-
23
- export { expectToBe };
24
- //# sourceMappingURL=optional-expect-to-be.mjs.map
22
+ //# sourceMappingURL=optional-expect-to-be.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"optional-expect-to-be.mjs","sources":["../../../../src/functional/optional/impl/optional-expect-to-be.mts"],"sourcesContent":["import { type Optional, 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 * Unwraps an `Optional`, returning the contained value or throwing an error\n * with the provided message.\n *\n * @example\n *\n * ```ts\n * const optionalValue = Optional.some('data');\n *\n * assert.isTrue(\n * Optional.expectToBe(optionalValue, 'value expected') === 'data',\n * );\n *\n * const expectValue = Optional.expectToBe('missing optional');\n *\n * const throwTest = (): void => {\n * expectValue(Optional.none);\n * };\n *\n * assert.throws(throwTest, /missing optional/u);\n *\n * assert.isTrue(expectValue(Optional.some('present')) === 'present');\n * ```\n *\n * @template O The `UnknownOptional` type to unwrap.\n * @param optional The `Optional` to unwrap.\n * @param message The error message to throw if the `Optional` is\n * `None`.\n * @returns The contained value if `Some`.\n * @throws Error with the provided message if the `Optional` is\n * `None`.\n */\nexport function expectToBe<O extends UnknownOptional>(\n optional: O,\n message: string,\n): Unwrap<O>;\n\n// Curried version\nexport function expectToBe(message: string): <O>(optional: Optional<O>) => O;\n\nexport function expectToBe<O extends UnknownOptional>(\n ...args: readonly [optional: O, message: string] | readonly [message: string]\n): Unwrap<O> | ((optional: Optional<Unwrap<O>>) => Unwrap<O>) {\n switch (args.length) {\n case 2: {\n const [optional, message] = args;\n\n return expectToBeImpl(optional, message);\n }\n\n case 1: {\n // Curried version: first argument is message\n const [message] = args;\n\n return (optional: Optional<Unwrap<O>>): Unwrap<O> =>\n expectToBeImpl(optional, message);\n }\n }\n}\n\nconst expectToBeImpl = <O extends UnknownOptional>(\n optional: O,\n message: string,\n): Unwrap<O> => {\n if (isSome(optional)) {\n return unwrap(optional);\n }\n\n throw new Error(message);\n};\n"],"names":[],"mappings":";;;AA6CO,SAAS,cACX,IAAA,EACyD;AAC5D,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,QAAA,EAAU,OAAO,CAAA,GAAI,IAAA;AAE5B,MAAA,OAAO,cAAA,CAAe,UAAU,OAAO,CAAA;AAAA,IACzC;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,OAAO,CAAA,GAAI,IAAA;AAElB,MAAA,OAAO,CAAC,QAAA,KACN,cAAA,CAAe,QAAA,EAAU,OAAO,CAAA;AAAA,IACpC;AAAA;AAEJ;AAEA,MAAM,cAAA,GAAiB,CACrB,QAAA,EACA,OAAA,KACc;AACd,EAAA,IAAI,MAAA,CAAO,QAAQ,CAAA,EAAG;AACpB,IAAA,OAAO,OAAO,QAAQ,CAAA;AAAA,EACxB;AAEA,EAAA,MAAM,IAAI,MAAM,OAAO,CAAA;AACzB,CAAA;;;;"}
1
+ {"version":3,"file":"optional-expect-to-be.mjs","sourceRoot":"","sources":["../../../../src/functional/optional/impl/optional-expect-to-be.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AA2C/C,MAAM,UAAU,UAAU,CACxB,GAAG,IAA0E;IAE7E,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;YAEjC,OAAO,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC3C,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,6CAA6C;YAC7C,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;YAEvB,OAAO,CAAC,QAA6B,EAAa,EAAE,CAClD,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,cAAc,GAAG,CACrB,QAAW,EACX,OAAe,EACJ,EAAE;IACb,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrB,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC,CAAC"}
@@ -2,26 +2,24 @@ 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
  import { unwrap } from './optional-unwrap.mjs';
5
+ export function filter(...args) {
6
+ switch (args.length) {
7
+ case 2: {
8
+ const [optional, predicate] = args;
9
+ return filterImpl(optional, predicate);
10
+ }
11
+ case 1: {
5
12
 
6
- function filter(...args) {
7
- switch (args.length) {
8
- case 2: {
9
- const [optional, predicate] = args;
10
- return filterImpl(optional, predicate);
13
+ const [predicate] = args;
14
+ return (optional) => filterImpl(optional, predicate);
15
+ }
11
16
  }
12
- case 1: {
13
- const [predicate] = args;
14
- return (optional) => filterImpl(optional, predicate);
15
- }
16
- }
17
17
  }
18
18
  const filterImpl = (optional, predicate) => {
19
- if (isSome(optional)) {
20
- const value = unwrap(optional);
21
- return predicate(value) ? some(value) : none;
22
- }
23
- return none;
19
+ if (isSome(optional)) {
20
+ const value = unwrap(optional);
21
+ return predicate(value) ? some(value) : none;
22
+ }
23
+ return none;
24
24
  };
25
-
26
- export { filter };
27
- //# sourceMappingURL=optional-filter.mjs.map
25
+ //# sourceMappingURL=optional-filter.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"optional-filter.mjs","sources":["../../../../src/functional/optional/impl/optional-filter.mts"],"sourcesContent":["import { type Optional, type UnknownOptional } from '../optional.mjs';\nimport { isSome } from './optional-is-some.mjs';\nimport { none } from './optional-none.mjs';\nimport { some } from './optional-some.mjs';\nimport { unwrap } from './optional-unwrap.mjs';\nimport { type Unwrap } from './types.mjs';\n\n/**\n * Filters an `Optional` based on a predicate. If the `Optional` is `Some` and\n * the predicate returns true, returns the original `Optional`. Otherwise\n * returns `None`.\n *\n * @example\n *\n * ```ts\n * const even = Optional.filter(Optional.some(4), (value) => value % 2 === 0);\n *\n * const odd = Optional.filter(Optional.some(3), (value) => value % 2 === 0);\n *\n * assert.deepStrictEqual(even, Optional.some(4));\n *\n * assert.deepStrictEqual(odd, Optional.none);\n *\n * const filterEven = Optional.filter((value: number) => value % 2 === 0);\n *\n * assert.deepStrictEqual(filterEven(Optional.some(6)), Optional.some(6));\n *\n * assert.deepStrictEqual(filterEven(Optional.some(5)), Optional.none);\n * ```\n *\n * @template O The input `UnknownOptional` type.\n * @param optional The `Optional` to filter.\n * @param predicate The predicate function.\n * @returns The filtered `Optional`.\n */\nexport function filter<O extends UnknownOptional>(\n optional: O,\n predicate: (value: Unwrap<O>) => boolean,\n): Optional<Unwrap<O>>;\n\n// Curried version\nexport function filter<S>(\n predicate: (value: S) => boolean,\n): (optional: Optional<S>) => Optional<S>;\n\nexport function filter<O extends UnknownOptional>(\n ...args:\n | readonly [optional: O, predicate: (value: Unwrap<O>) => boolean]\n | readonly [predicate: (value: Unwrap<O>) => boolean]\n): Optional<Unwrap<O>> | ((optional: O) => Optional<Unwrap<O>>) {\n switch (args.length) {\n case 2: {\n const [optional, predicate] = args;\n\n return filterImpl(optional, predicate);\n }\n\n case 1: {\n // Curried version: first argument is predicate function\n const [predicate] = args;\n\n return (optional: O) => filterImpl(optional, predicate);\n }\n }\n}\n\nconst filterImpl = <O extends UnknownOptional>(\n optional: O,\n predicate: (value: Unwrap<O>) => boolean,\n): Optional<Unwrap<O>> => {\n if (isSome(optional)) {\n const value = unwrap(optional);\n\n return predicate(value) ? some(value) : none;\n }\n\n return none;\n};\n"],"names":[],"mappings":";;;;;AA6CO,SAAS,UACX,IAAA,EAG2D;AAC9D,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,QAAA,EAAU,SAAS,CAAA,GAAI,IAAA;AAE9B,MAAA,OAAO,UAAA,CAAW,UAAU,SAAS,CAAA;AAAA,IACvC;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,SAAS,CAAA,GAAI,IAAA;AAEpB,MAAA,OAAO,CAAC,QAAA,KAAgB,UAAA,CAAW,QAAA,EAAU,SAAS,CAAA;AAAA,IACxD;AAAA;AAEJ;AAEA,MAAM,UAAA,GAAa,CACjB,QAAA,EACA,SAAA,KACwB;AACxB,EAAA,IAAI,MAAA,CAAO,QAAQ,CAAA,EAAG;AACpB,IAAA,MAAM,KAAA,GAAQ,OAAO,QAAQ,CAAA;AAE7B,IAAA,OAAO,SAAA,CAAU,KAAK,CAAA,GAAI,IAAA,CAAK,KAAK,CAAA,GAAI,IAAA;AAAA,EAC1C;AAEA,EAAA,OAAO,IAAA;AACT,CAAA;;;;"}
1
+ {"version":3,"file":"optional-filter.mjs","sourceRoot":"","sources":["../../../../src/functional/optional/impl/optional-filter.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAyC/C,MAAM,UAAU,MAAM,CACpB,GAAG,IAEoD;IAEvD,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC;YAEnC,OAAO,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QACzC,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,wDAAwD;YACxD,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;YAEzB,OAAO,CAAC,QAAW,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,GAAG,CACjB,QAAW,EACX,SAAwC,EACnB,EAAE;IACvB,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrB,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QAE/B,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC/C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -1,20 +1,18 @@
1
1
  import { isSome } from './optional-is-some.mjs';
2
2
  import { none } from './optional-none.mjs';
3
3
  import { unwrap } from './optional-unwrap.mjs';
4
+ export function flatMap(...args) {
5
+ switch (args.length) {
6
+ case 2: {
7
+ const [optional, flatMapFn] = args;
8
+ return flatMapImpl(optional, flatMapFn);
9
+ }
10
+ case 1: {
4
11
 
5
- function flatMap(...args) {
6
- switch (args.length) {
7
- case 2: {
8
- const [optional, flatMapFn] = args;
9
- return flatMapImpl(optional, flatMapFn);
12
+ const [flatMapFn] = args;
13
+ return (optional) => flatMapImpl(optional, flatMapFn);
14
+ }
10
15
  }
11
- case 1: {
12
- const [flatMapFn] = args;
13
- return (optional) => flatMapImpl(optional, flatMapFn);
14
- }
15
- }
16
16
  }
17
- const flatMapImpl = (optional, flatMapFn) => isSome(optional) ? flatMapFn(unwrap(optional)) : none;
18
-
19
- export { flatMap };
20
- //# sourceMappingURL=optional-flat-map.mjs.map
17
+ const flatMapImpl = (optional, flatMapFn) => (isSome(optional) ? flatMapFn(unwrap(optional)) : none);
18
+ //# sourceMappingURL=optional-flat-map.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"optional-flat-map.mjs","sources":["../../../../src/functional/optional/impl/optional-flat-map.mts"],"sourcesContent":["import { type Optional, type UnknownOptional } from '../optional.mjs';\nimport { isSome } from './optional-is-some.mjs';\nimport { none } from './optional-none.mjs';\nimport { unwrap } from './optional-unwrap.mjs';\nimport { type Unwrap } from './types.mjs';\n\n/**\n * Applies a function that returns an `Optional` to the value in an\n * `Some`. If the input is `None`, returns `None`.\n * This is the monadic bind operation for `Optional`.\n *\n * @example\n *\n * ```ts\n * const parseNumber = (input: string): Optional<number> => {\n * const num = Num.safeParseInt(input);\n *\n * return Result.isErr(num) ? Optional.none : Optional.some(num.value);\n * };\n *\n * const parsed = Optional.flatMap(Optional.some('10'), parseNumber);\n *\n * assert.deepStrictEqual(parsed, Optional.some(10));\n *\n * const flatMapParse = Optional.flatMap(parseNumber);\n *\n * assert.deepStrictEqual(flatMapParse(Optional.some('5')), Optional.some(5));\n *\n * assert.deepStrictEqual(\n * flatMapParse(Optional.some('invalid')),\n * Optional.none,\n * );\n * ```\n *\n * @template O The input `UnknownOptional` type.\n * @template S2 The value type of the `Optional` returned by the function.\n * @param optional The `Optional` to flat map.\n * @param flatMapFn The function to apply that returns an `Optional`.\n * @returns The result of applying the function, or `None`.\n */\nexport function flatMap<O extends UnknownOptional, S2>(\n optional: O,\n flatMapFn: (value: Unwrap<O>) => Optional<S2>,\n): Optional<S2>;\n\n// Curried version\nexport function flatMap<S, S2>(\n flatMapFn: (value: S) => Optional<S2>,\n): (optional: Optional<S>) => Optional<S2>;\n\nexport function flatMap<O extends UnknownOptional, S2>(\n ...args:\n | readonly [optional: O, flatMapFn: (value: Unwrap<O>) => Optional<S2>]\n | readonly [flatMapFn: (value: Unwrap<O>) => Optional<S2>]\n): Optional<S2> | ((optional: O) => Optional<S2>) {\n switch (args.length) {\n case 2: {\n const [optional, flatMapFn] = args;\n\n return flatMapImpl(optional, flatMapFn);\n }\n\n case 1: {\n // Curried version\n const [flatMapFn] = args;\n\n return (optional: O) => flatMapImpl(optional, flatMapFn);\n }\n }\n}\n\nconst flatMapImpl = <O extends UnknownOptional, S2>(\n optional: O,\n flatMapFn: (value: Unwrap<O>) => Optional<S2>,\n): Optional<S2> => (isSome(optional) ? flatMapFn(unwrap(optional)) : none);\n"],"names":[],"mappings":";;;;AAkDO,SAAS,WACX,IAAA,EAG6C;AAChD,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,QAAA,EAAU,SAAS,CAAA,GAAI,IAAA;AAE9B,MAAA,OAAO,WAAA,CAAY,UAAU,SAAS,CAAA;AAAA,IACxC;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,SAAS,CAAA,GAAI,IAAA;AAEpB,MAAA,OAAO,CAAC,QAAA,KAAgB,WAAA,CAAY,QAAA,EAAU,SAAS,CAAA;AAAA,IACzD;AAAA;AAEJ;AAEA,MAAM,WAAA,GAAc,CAClB,QAAA,EACA,SAAA,KACkB,MAAA,CAAO,QAAQ,CAAA,GAAI,SAAA,CAAU,MAAA,CAAO,QAAQ,CAAC,CAAA,GAAI,IAAA;;;;"}
1
+ {"version":3,"file":"optional-flat-map.mjs","sourceRoot":"","sources":["../../../../src/functional/optional/impl/optional-flat-map.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AA+C/C,MAAM,UAAU,OAAO,CACrB,GAAG,IAEyD;IAE5D,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC;YAEnC,OAAO,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAC1C,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,kBAAkB;YAClB,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;YAEzB,OAAO,CAAC,QAAW,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,WAAW,GAAG,CAClB,QAAW,EACX,SAA6C,EAC/B,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC"}
@@ -1,7 +1,28 @@
1
1
  import { none } from './optional-none.mjs';
2
2
  import { some } from './optional-some.mjs';
3
3
 
4
- const fromNullable = (value) => value == null ? none : some(value);
5
4
 
6
- export { fromNullable };
7
- //# sourceMappingURL=optional-from-nullable.mjs.map
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+ export const fromNullable = (value) => (value == null ? none : some(value));
28
+ //# sourceMappingURL=optional-from-nullable.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"optional-from-nullable.mjs","sources":["../../../../src/functional/optional/impl/optional-from-nullable.mts"],"sourcesContent":["import { type Optional } from '../optional.mjs';\nimport { none } from './optional-none.mjs';\nimport { some } from './optional-some.mjs';\n\n/**\n * Converts a nullable value to an `Optional`.\n *\n * This is the primary way to lift nullable values (null or undefined) into\n * the Optional type system. The function treats both `null` and `undefined`\n * as empty values, converting them to `None`.\n *\n * @example\n *\n * ```ts\n * const present = Optional.fromNullable('hello');\n *\n * const absent = Optional.fromNullable<string | null>(null);\n *\n * assert.deepStrictEqual(present, Optional.some('hello'));\n *\n * assert.deepStrictEqual(absent, Optional.none);\n * ```\n *\n * @template T The type of the nullable value.\n * @param value The nullable value to convert.\n * @returns `Some<NonNullable<T>>` if the value is not null or\n * undefined, otherwise `None`.\n */\nexport const fromNullable = <T,>(\n value: T | null | undefined,\n): Optional<NonNullable<T>> => (value == null ? none : some(value));\n"],"names":[],"mappings":";;;AA4BO,MAAM,eAAe,CAC1B,KAAA,KAC8B,SAAS,IAAA,GAAO,IAAA,GAAO,KAAK,KAAK;;;;"}
1
+ {"version":3,"file":"optional-from-nullable.mjs","sourceRoot":"","sources":["../../../../src/functional/optional/impl/optional-from-nullable.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAA2B,EACD,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC"}