ts-data-forge 14.6.4 → 14.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (558) hide show
  1. package/README.md +2 -1
  2. package/dist/expect-type.d.mts +2 -70
  3. package/dist/expect-type.d.mts.map +1 -1
  4. package/dist/expect-type.mjs +1 -68
  5. package/dist/expect-type.mjs.map +1 -1
  6. package/dist/functional/index.d.mts +11 -6
  7. package/dist/functional/index.d.mts.map +1 -1
  8. package/dist/functional/index.mjs +10 -6
  9. package/dist/functional/index.mjs.map +1 -1
  10. package/dist/guard/has-key.d.mts +2 -51
  11. package/dist/guard/has-key.d.mts.map +1 -1
  12. package/dist/guard/has-key.mjs +1 -41
  13. package/dist/guard/has-key.mjs.map +1 -1
  14. package/dist/guard/is-non-null-object.d.mts +2 -34
  15. package/dist/guard/is-non-null-object.d.mts.map +1 -1
  16. package/dist/guard/is-non-null-object.mjs +1 -34
  17. package/dist/guard/is-non-null-object.mjs.map +1 -1
  18. package/dist/guard/is-record.d.mts +2 -89
  19. package/dist/guard/is-record.d.mts.map +1 -1
  20. package/dist/guard/is-record.mjs +1 -88
  21. package/dist/guard/is-record.mjs.map +1 -1
  22. package/dist/guard/key-is-in.d.mts +2 -42
  23. package/dist/guard/key-is-in.d.mts.map +1 -1
  24. package/dist/guard/key-is-in.mjs +1 -40
  25. package/dist/guard/key-is-in.mjs.map +1 -1
  26. package/dist/number/num.d.mts +9 -1
  27. package/dist/number/num.d.mts.map +1 -1
  28. package/dist/number/num.mjs +24 -16
  29. package/dist/number/num.mjs.map +1 -1
  30. package/dist/others/index.d.mts +1 -0
  31. package/dist/others/index.d.mts.map +1 -1
  32. package/dist/others/index.mjs +1 -0
  33. package/dist/others/index.mjs.map +1 -1
  34. package/dist/others/panic-error.d.mts +9 -0
  35. package/dist/others/panic-error.d.mts.map +1 -0
  36. package/dist/others/panic-error.mjs +9 -0
  37. package/dist/others/panic-error.mjs.map +1 -0
  38. package/dist/others/unknown-to-string.d.mts +2 -37
  39. package/dist/others/unknown-to-string.d.mts.map +1 -1
  40. package/dist/others/unknown-to-string.mjs +1 -92
  41. package/dist/others/unknown-to-string.mjs.map +1 -1
  42. package/dist/types.d.mts +1 -41
  43. package/dist/types.d.mts.map +1 -1
  44. package/dist/types.mjs +0 -1
  45. package/dist/types.mjs.map +1 -1
  46. package/package.json +5 -5
  47. package/src/expect-type.mts +2 -78
  48. package/src/functional/index.mts +31 -6
  49. package/src/guard/has-key.mts +2 -72
  50. package/src/guard/is-non-null-object.mts +2 -36
  51. package/src/guard/is-record.mts +2 -95
  52. package/src/guard/key-is-in.mts +2 -49
  53. package/src/number/num.mts +36 -28
  54. package/src/others/index.mts +1 -0
  55. package/src/others/panic-error.mts +8 -0
  56. package/src/others/unknown-to-string.mts +2 -111
  57. package/src/types.mts +4 -54
  58. package/dist/functional/async-result/async-result.d.mts +0 -16
  59. package/dist/functional/async-result/async-result.d.mts.map +0 -1
  60. package/dist/functional/async-result/async-result.mjs +0 -2
  61. package/dist/functional/async-result/async-result.mjs.map +0 -1
  62. package/dist/functional/async-result/impl/async-result-flat-map.d.mts +0 -39
  63. package/dist/functional/async-result/impl/async-result-flat-map.d.mts.map +0 -1
  64. package/dist/functional/async-result/impl/async-result-flat-map.mjs +0 -23
  65. package/dist/functional/async-result/impl/async-result-flat-map.mjs.map +0 -1
  66. package/dist/functional/async-result/impl/async-result-from-promise.d.mts +0 -47
  67. package/dist/functional/async-result/impl/async-result-from-promise.d.mts.map +0 -1
  68. package/dist/functional/async-result/impl/async-result-from-promise.mjs +0 -10
  69. package/dist/functional/async-result/impl/async-result-from-promise.mjs.map +0 -1
  70. package/dist/functional/async-result/impl/async-result-from-throwable.d.mts +0 -53
  71. package/dist/functional/async-result/impl/async-result-from-throwable.d.mts.map +0 -1
  72. package/dist/functional/async-result/impl/async-result-from-throwable.mjs +0 -15
  73. package/dist/functional/async-result/impl/async-result-from-throwable.mjs.map +0 -1
  74. package/dist/functional/async-result/impl/async-result-map-err.d.mts +0 -35
  75. package/dist/functional/async-result/impl/async-result-map-err.d.mts.map +0 -1
  76. package/dist/functional/async-result/impl/async-result-map-err.mjs +0 -20
  77. package/dist/functional/async-result/impl/async-result-map-err.mjs.map +0 -1
  78. package/dist/functional/async-result/impl/async-result-map.d.mts +0 -45
  79. package/dist/functional/async-result/impl/async-result-map.d.mts.map +0 -1
  80. package/dist/functional/async-result/impl/async-result-map.mjs +0 -20
  81. package/dist/functional/async-result/impl/async-result-map.mjs.map +0 -1
  82. package/dist/functional/async-result/impl/async-result-unwrap-or.d.mts +0 -34
  83. package/dist/functional/async-result/impl/async-result-unwrap-or.d.mts.map +0 -1
  84. package/dist/functional/async-result/impl/async-result-unwrap-or.mjs +0 -37
  85. package/dist/functional/async-result/impl/async-result-unwrap-or.mjs.map +0 -1
  86. package/dist/functional/async-result/impl/index.d.mts +0 -8
  87. package/dist/functional/async-result/impl/index.d.mts.map +0 -1
  88. package/dist/functional/async-result/impl/index.mjs +0 -8
  89. package/dist/functional/async-result/impl/index.mjs.map +0 -1
  90. package/dist/functional/async-result/impl/types.d.mts +0 -45
  91. package/dist/functional/async-result/impl/types.d.mts.map +0 -1
  92. package/dist/functional/async-result/impl/types.mjs +0 -2
  93. package/dist/functional/async-result/impl/types.mjs.map +0 -1
  94. package/dist/functional/async-result/index.d.mts +0 -2
  95. package/dist/functional/async-result/index.d.mts.map +0 -1
  96. package/dist/functional/async-result/index.mjs +0 -2
  97. package/dist/functional/async-result/index.mjs.map +0 -1
  98. package/dist/functional/match.d.mts +0 -80
  99. package/dist/functional/match.d.mts.map +0 -1
  100. package/dist/functional/match.mjs +0 -31
  101. package/dist/functional/match.mjs.map +0 -1
  102. package/dist/functional/optional/impl/index.d.mts +0 -19
  103. package/dist/functional/optional/impl/index.d.mts.map +0 -1
  104. package/dist/functional/optional/impl/index.mjs +0 -19
  105. package/dist/functional/optional/impl/index.mjs.map +0 -1
  106. package/dist/functional/optional/impl/optional-expect-to-be.d.mts +0 -37
  107. package/dist/functional/optional/impl/optional-expect-to-be.d.mts.map +0 -1
  108. package/dist/functional/optional/impl/optional-expect-to-be.mjs +0 -22
  109. package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +0 -1
  110. package/dist/functional/optional/impl/optional-filter.d.mts +0 -33
  111. package/dist/functional/optional/impl/optional-filter.d.mts.map +0 -1
  112. package/dist/functional/optional/impl/optional-filter.mjs +0 -25
  113. package/dist/functional/optional/impl/optional-filter.mjs.map +0 -1
  114. package/dist/functional/optional/impl/optional-flat-map.d.mts +0 -39
  115. package/dist/functional/optional/impl/optional-flat-map.d.mts.map +0 -1
  116. package/dist/functional/optional/impl/optional-flat-map.mjs +0 -18
  117. package/dist/functional/optional/impl/optional-flat-map.mjs.map +0 -1
  118. package/dist/functional/optional/impl/optional-from-nullable.d.mts +0 -27
  119. package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +0 -1
  120. package/dist/functional/optional/impl/optional-from-nullable.mjs +0 -28
  121. package/dist/functional/optional/impl/optional-from-nullable.mjs.map +0 -1
  122. package/dist/functional/optional/impl/optional-is-none.d.mts +0 -23
  123. package/dist/functional/optional/impl/optional-is-none.d.mts.map +0 -1
  124. package/dist/functional/optional/impl/optional-is-none.mjs +0 -22
  125. package/dist/functional/optional/impl/optional-is-none.mjs.map +0 -1
  126. package/dist/functional/optional/impl/optional-is-optional.d.mts +0 -21
  127. package/dist/functional/optional/impl/optional-is-optional.d.mts.map +0 -1
  128. package/dist/functional/optional/impl/optional-is-optional.mjs +0 -26
  129. package/dist/functional/optional/impl/optional-is-optional.mjs.map +0 -1
  130. package/dist/functional/optional/impl/optional-is-some.d.mts +0 -24
  131. package/dist/functional/optional/impl/optional-is-some.d.mts.map +0 -1
  132. package/dist/functional/optional/impl/optional-is-some.mjs +0 -23
  133. package/dist/functional/optional/impl/optional-is-some.mjs.map +0 -1
  134. package/dist/functional/optional/impl/optional-map.d.mts +0 -34
  135. package/dist/functional/optional/impl/optional-map.d.mts.map +0 -1
  136. package/dist/functional/optional/impl/optional-map.mjs +0 -22
  137. package/dist/functional/optional/impl/optional-map.mjs.map +0 -1
  138. package/dist/functional/optional/impl/optional-match.d.mts +0 -48
  139. package/dist/functional/optional/impl/optional-match.d.mts.map +0 -1
  140. package/dist/functional/optional/impl/optional-match.mjs +0 -20
  141. package/dist/functional/optional/impl/optional-match.mjs.map +0 -1
  142. package/dist/functional/optional/impl/optional-none.d.mts +0 -19
  143. package/dist/functional/optional/impl/optional-none.d.mts.map +0 -1
  144. package/dist/functional/optional/impl/optional-none.mjs +0 -19
  145. package/dist/functional/optional/impl/optional-none.mjs.map +0 -1
  146. package/dist/functional/optional/impl/optional-or-else.d.mts +0 -43
  147. package/dist/functional/optional/impl/optional-or-else.d.mts.map +0 -1
  148. package/dist/functional/optional/impl/optional-or-else.mjs +0 -16
  149. package/dist/functional/optional/impl/optional-or-else.mjs.map +0 -1
  150. package/dist/functional/optional/impl/optional-some.d.mts +0 -22
  151. package/dist/functional/optional/impl/optional-some.d.mts.map +0 -1
  152. package/dist/functional/optional/impl/optional-some.mjs +0 -25
  153. package/dist/functional/optional/impl/optional-some.mjs.map +0 -1
  154. package/dist/functional/optional/impl/optional-to-nullable.d.mts +0 -30
  155. package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +0 -1
  156. package/dist/functional/optional/impl/optional-to-nullable.mjs +0 -30
  157. package/dist/functional/optional/impl/optional-to-nullable.mjs.map +0 -1
  158. package/dist/functional/optional/impl/optional-unwrap-or.d.mts +0 -37
  159. package/dist/functional/optional/impl/optional-unwrap-or.d.mts.map +0 -1
  160. package/dist/functional/optional/impl/optional-unwrap-or.mjs +0 -16
  161. package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +0 -1
  162. package/dist/functional/optional/impl/optional-unwrap-throw.d.mts +0 -31
  163. package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +0 -1
  164. package/dist/functional/optional/impl/optional-unwrap-throw.mjs +0 -36
  165. package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +0 -1
  166. package/dist/functional/optional/impl/optional-unwrap.d.mts +0 -32
  167. package/dist/functional/optional/impl/optional-unwrap.d.mts.map +0 -1
  168. package/dist/functional/optional/impl/optional-unwrap.mjs +0 -8
  169. package/dist/functional/optional/impl/optional-unwrap.mjs.map +0 -1
  170. package/dist/functional/optional/impl/optional-zip.d.mts +0 -35
  171. package/dist/functional/optional/impl/optional-zip.d.mts.map +0 -1
  172. package/dist/functional/optional/impl/optional-zip.mjs +0 -39
  173. package/dist/functional/optional/impl/optional-zip.mjs.map +0 -1
  174. package/dist/functional/optional/impl/tag.d.mts +0 -6
  175. package/dist/functional/optional/impl/tag.d.mts.map +0 -1
  176. package/dist/functional/optional/impl/tag.mjs +0 -4
  177. package/dist/functional/optional/impl/tag.mjs.map +0 -1
  178. package/dist/functional/optional/impl/types.d.mts +0 -24
  179. package/dist/functional/optional/impl/types.d.mts.map +0 -1
  180. package/dist/functional/optional/impl/types.mjs +0 -2
  181. package/dist/functional/optional/impl/types.mjs.map +0 -1
  182. package/dist/functional/optional/index.d.mts +0 -2
  183. package/dist/functional/optional/index.d.mts.map +0 -1
  184. package/dist/functional/optional/index.mjs +0 -2
  185. package/dist/functional/optional/index.mjs.map +0 -1
  186. package/dist/functional/optional/optional.d.mts +0 -16
  187. package/dist/functional/optional/optional.d.mts.map +0 -1
  188. package/dist/functional/optional/optional.mjs +0 -2
  189. package/dist/functional/optional/optional.mjs.map +0 -1
  190. package/dist/functional/pipe.d.mts +0 -102
  191. package/dist/functional/pipe.d.mts.map +0 -1
  192. package/dist/functional/pipe.mjs +0 -45
  193. package/dist/functional/pipe.mjs.map +0 -1
  194. package/dist/functional/result/impl/index.d.mts +0 -28
  195. package/dist/functional/result/impl/index.d.mts.map +0 -1
  196. package/dist/functional/result/impl/index.mjs +0 -28
  197. package/dist/functional/result/impl/index.mjs.map +0 -1
  198. package/dist/functional/result/impl/result-err.d.mts +0 -28
  199. package/dist/functional/result/impl/result-err.d.mts.map +0 -1
  200. package/dist/functional/result/impl/result-err.mjs +0 -31
  201. package/dist/functional/result/impl/result-err.mjs.map +0 -1
  202. package/dist/functional/result/impl/result-expect-to-be.d.mts +0 -33
  203. package/dist/functional/result/impl/result-expect-to-be.d.mts.map +0 -1
  204. package/dist/functional/result/impl/result-expect-to-be.mjs +0 -23
  205. package/dist/functional/result/impl/result-expect-to-be.mjs.map +0 -1
  206. package/dist/functional/result/impl/result-flat-map.d.mts +0 -45
  207. package/dist/functional/result/impl/result-flat-map.d.mts.map +0 -1
  208. package/dist/functional/result/impl/result-flat-map.mjs +0 -21
  209. package/dist/functional/result/impl/result-flat-map.mjs.map +0 -1
  210. package/dist/functional/result/impl/result-fold.d.mts +0 -50
  211. package/dist/functional/result/impl/result-fold.d.mts.map +0 -1
  212. package/dist/functional/result/impl/result-fold.mjs +0 -23
  213. package/dist/functional/result/impl/result-fold.mjs.map +0 -1
  214. package/dist/functional/result/impl/result-from-optional.d.mts +0 -41
  215. package/dist/functional/result/impl/result-from-optional.d.mts.map +0 -1
  216. package/dist/functional/result/impl/result-from-optional.mjs +0 -21
  217. package/dist/functional/result/impl/result-from-optional.mjs.map +0 -1
  218. package/dist/functional/result/impl/result-from-promise.d.mts +0 -43
  219. package/dist/functional/result/impl/result-from-promise.d.mts.map +0 -1
  220. package/dist/functional/result/impl/result-from-promise.mjs +0 -39
  221. package/dist/functional/result/impl/result-from-promise.mjs.map +0 -1
  222. package/dist/functional/result/impl/result-from-throwable.d.mts +0 -32
  223. package/dist/functional/result/impl/result-from-throwable.d.mts.map +0 -1
  224. package/dist/functional/result/impl/result-from-throwable.mjs +0 -46
  225. package/dist/functional/result/impl/result-from-throwable.mjs.map +0 -1
  226. package/dist/functional/result/impl/result-is-err.d.mts +0 -23
  227. package/dist/functional/result/impl/result-is-err.d.mts.map +0 -1
  228. package/dist/functional/result/impl/result-is-err.mjs +0 -22
  229. package/dist/functional/result/impl/result-is-err.mjs.map +0 -1
  230. package/dist/functional/result/impl/result-is-ok.d.mts +0 -23
  231. package/dist/functional/result/impl/result-is-ok.d.mts.map +0 -1
  232. package/dist/functional/result/impl/result-is-ok.mjs +0 -22
  233. package/dist/functional/result/impl/result-is-ok.mjs.map +0 -1
  234. package/dist/functional/result/impl/result-is-result.d.mts +0 -22
  235. package/dist/functional/result/impl/result-is-result.d.mts.map +0 -1
  236. package/dist/functional/result/impl/result-is-result.mjs +0 -26
  237. package/dist/functional/result/impl/result-is-result.mjs.map +0 -1
  238. package/dist/functional/result/impl/result-map-err.d.mts +0 -39
  239. package/dist/functional/result/impl/result-map-err.d.mts.map +0 -1
  240. package/dist/functional/result/impl/result-map-err.mjs +0 -22
  241. package/dist/functional/result/impl/result-map-err.mjs.map +0 -1
  242. package/dist/functional/result/impl/result-map.d.mts +0 -39
  243. package/dist/functional/result/impl/result-map.d.mts.map +0 -1
  244. package/dist/functional/result/impl/result-map.mjs +0 -22
  245. package/dist/functional/result/impl/result-map.mjs.map +0 -1
  246. package/dist/functional/result/impl/result-match.d.mts +0 -47
  247. package/dist/functional/result/impl/result-match.d.mts.map +0 -1
  248. package/dist/functional/result/impl/result-match.mjs +0 -20
  249. package/dist/functional/result/impl/result-match.mjs.map +0 -1
  250. package/dist/functional/result/impl/result-ok.d.mts +0 -28
  251. package/dist/functional/result/impl/result-ok.d.mts.map +0 -1
  252. package/dist/functional/result/impl/result-ok.mjs +0 -31
  253. package/dist/functional/result/impl/result-ok.mjs.map +0 -1
  254. package/dist/functional/result/impl/result-or-else.d.mts +0 -40
  255. package/dist/functional/result/impl/result-or-else.d.mts.map +0 -1
  256. package/dist/functional/result/impl/result-or-else.mjs +0 -17
  257. package/dist/functional/result/impl/result-or-else.mjs.map +0 -1
  258. package/dist/functional/result/impl/result-safe-try.d.mts +0 -51
  259. package/dist/functional/result/impl/result-safe-try.d.mts.map +0 -1
  260. package/dist/functional/result/impl/result-safe-try.mjs +0 -35
  261. package/dist/functional/result/impl/result-safe-try.mjs.map +0 -1
  262. package/dist/functional/result/impl/result-safe-unwrap.d.mts +0 -36
  263. package/dist/functional/result/impl/result-safe-unwrap.d.mts.map +0 -1
  264. package/dist/functional/result/impl/result-safe-unwrap.mjs +0 -42
  265. package/dist/functional/result/impl/result-safe-unwrap.mjs.map +0 -1
  266. package/dist/functional/result/impl/result-swap.d.mts +0 -23
  267. package/dist/functional/result/impl/result-swap.d.mts.map +0 -1
  268. package/dist/functional/result/impl/result-swap.mjs +0 -27
  269. package/dist/functional/result/impl/result-swap.mjs.map +0 -1
  270. package/dist/functional/result/impl/result-to-optional.d.mts +0 -32
  271. package/dist/functional/result/impl/result-to-optional.d.mts.map +0 -1
  272. package/dist/functional/result/impl/result-to-optional.mjs +0 -32
  273. package/dist/functional/result/impl/result-to-optional.mjs.map +0 -1
  274. package/dist/functional/result/impl/result-unwrap-err-or.d.mts +0 -33
  275. package/dist/functional/result/impl/result-unwrap-err-or.d.mts.map +0 -1
  276. package/dist/functional/result/impl/result-unwrap-err-or.mjs +0 -17
  277. package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +0 -1
  278. package/dist/functional/result/impl/result-unwrap-err-throw.d.mts +0 -33
  279. package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +0 -1
  280. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +0 -46
  281. package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +0 -1
  282. package/dist/functional/result/impl/result-unwrap-err.d.mts +0 -33
  283. package/dist/functional/result/impl/result-unwrap-err.d.mts.map +0 -1
  284. package/dist/functional/result/impl/result-unwrap-err.mjs +0 -34
  285. package/dist/functional/result/impl/result-unwrap-err.mjs.map +0 -1
  286. package/dist/functional/result/impl/result-unwrap-ok-or.d.mts +0 -33
  287. package/dist/functional/result/impl/result-unwrap-ok-or.d.mts.map +0 -1
  288. package/dist/functional/result/impl/result-unwrap-ok-or.mjs +0 -17
  289. package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +0 -1
  290. package/dist/functional/result/impl/result-unwrap-ok.d.mts +0 -26
  291. package/dist/functional/result/impl/result-unwrap-ok.d.mts.map +0 -1
  292. package/dist/functional/result/impl/result-unwrap-ok.mjs +0 -8
  293. package/dist/functional/result/impl/result-unwrap-ok.mjs.map +0 -1
  294. package/dist/functional/result/impl/result-unwrap-throw.d.mts +0 -33
  295. package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +0 -1
  296. package/dist/functional/result/impl/result-unwrap-throw.mjs +0 -40
  297. package/dist/functional/result/impl/result-unwrap-throw.mjs.map +0 -1
  298. package/dist/functional/result/impl/result-zip.d.mts +0 -32
  299. package/dist/functional/result/impl/result-zip.d.mts.map +0 -1
  300. package/dist/functional/result/impl/result-zip.mjs +0 -37
  301. package/dist/functional/result/impl/result-zip.mjs.map +0 -1
  302. package/dist/functional/result/impl/tag.d.mts +0 -6
  303. package/dist/functional/result/impl/tag.d.mts.map +0 -1
  304. package/dist/functional/result/impl/tag.mjs +0 -4
  305. package/dist/functional/result/impl/tag.mjs.map +0 -1
  306. package/dist/functional/result/impl/types.d.mts +0 -31
  307. package/dist/functional/result/impl/types.d.mts.map +0 -1
  308. package/dist/functional/result/impl/types.mjs +0 -2
  309. package/dist/functional/result/impl/types.mjs.map +0 -1
  310. package/dist/functional/result/index.d.mts +0 -2
  311. package/dist/functional/result/index.d.mts.map +0 -1
  312. package/dist/functional/result/index.mjs +0 -2
  313. package/dist/functional/result/index.mjs.map +0 -1
  314. package/dist/functional/result/result.d.mts +0 -16
  315. package/dist/functional/result/result.d.mts.map +0 -1
  316. package/dist/functional/result/result.mjs +0 -2
  317. package/dist/functional/result/result.mjs.map +0 -1
  318. package/dist/functional/ternary-result/impl/index.d.mts +0 -29
  319. package/dist/functional/ternary-result/impl/index.d.mts.map +0 -1
  320. package/dist/functional/ternary-result/impl/index.mjs +0 -29
  321. package/dist/functional/ternary-result/impl/index.mjs.map +0 -1
  322. package/dist/functional/ternary-result/impl/tag.d.mts +0 -8
  323. package/dist/functional/ternary-result/impl/tag.d.mts.map +0 -1
  324. package/dist/functional/ternary-result/impl/tag.mjs +0 -6
  325. package/dist/functional/ternary-result/impl/tag.mjs.map +0 -1
  326. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts +0 -16
  327. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +0 -1
  328. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +0 -19
  329. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +0 -1
  330. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts +0 -24
  331. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts.map +0 -1
  332. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +0 -21
  333. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +0 -1
  334. package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts +0 -39
  335. package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts.map +0 -1
  336. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +0 -38
  337. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +0 -1
  338. package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts +0 -30
  339. package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts.map +0 -1
  340. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +0 -33
  341. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +0 -1
  342. package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts +0 -23
  343. package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +0 -1
  344. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +0 -23
  345. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +0 -1
  346. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts +0 -20
  347. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +0 -1
  348. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +0 -33
  349. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +0 -1
  350. package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts +0 -21
  351. package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts.map +0 -1
  352. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +0 -20
  353. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +0 -1
  354. package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts +0 -23
  355. package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +0 -1
  356. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +0 -22
  357. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +0 -1
  358. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts +0 -22
  359. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +0 -1
  360. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +0 -28
  361. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +0 -1
  362. package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts +0 -22
  363. package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +0 -1
  364. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +0 -21
  365. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +0 -1
  366. package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts +0 -27
  367. package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts.map +0 -1
  368. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +0 -23
  369. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +0 -1
  370. package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts +0 -28
  371. package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts.map +0 -1
  372. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +0 -26
  373. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +0 -1
  374. package/dist/functional/ternary-result/impl/ternary-result-map.d.mts +0 -36
  375. package/dist/functional/ternary-result/impl/ternary-result-map.d.mts.map +0 -1
  376. package/dist/functional/ternary-result/impl/ternary-result-map.mjs +0 -32
  377. package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +0 -1
  378. package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts +0 -17
  379. package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +0 -1
  380. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +0 -20
  381. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +0 -1
  382. package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts +0 -29
  383. package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts.map +0 -1
  384. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +0 -16
  385. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +0 -1
  386. package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts +0 -23
  387. package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +0 -1
  388. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +0 -26
  389. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +0 -1
  390. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts +0 -28
  391. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts.map +0 -1
  392. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +0 -14
  393. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +0 -1
  394. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts +0 -20
  395. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +0 -1
  396. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +0 -34
  397. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +0 -1
  398. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts +0 -20
  399. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +0 -1
  400. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +0 -21
  401. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +0 -1
  402. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts +0 -25
  403. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts.map +0 -1
  404. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +0 -14
  405. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +0 -1
  406. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts +0 -20
  407. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts.map +0 -1
  408. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +0 -10
  409. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +0 -1
  410. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts +0 -21
  411. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +0 -1
  412. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +0 -35
  413. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +0 -1
  414. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts +0 -22
  415. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts.map +0 -1
  416. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +0 -14
  417. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +0 -1
  418. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts +0 -20
  419. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +0 -1
  420. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +0 -30
  421. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +0 -1
  422. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts +0 -20
  423. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +0 -1
  424. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +0 -21
  425. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +0 -1
  426. package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts +0 -19
  427. package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +0 -1
  428. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +0 -23
  429. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +0 -1
  430. package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts +0 -34
  431. package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +0 -1
  432. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +0 -52
  433. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +0 -1
  434. package/dist/functional/ternary-result/impl/types.d.mts +0 -26
  435. package/dist/functional/ternary-result/impl/types.d.mts.map +0 -1
  436. package/dist/functional/ternary-result/impl/types.mjs +0 -2
  437. package/dist/functional/ternary-result/impl/types.mjs.map +0 -1
  438. package/dist/functional/ternary-result/impl/variant-name.d.mts +0 -4
  439. package/dist/functional/ternary-result/impl/variant-name.d.mts.map +0 -1
  440. package/dist/functional/ternary-result/impl/variant-name.mjs +0 -13
  441. package/dist/functional/ternary-result/impl/variant-name.mjs.map +0 -1
  442. package/dist/functional/ternary-result/index.d.mts +0 -2
  443. package/dist/functional/ternary-result/index.d.mts.map +0 -1
  444. package/dist/functional/ternary-result/index.mjs +0 -2
  445. package/dist/functional/ternary-result/index.mjs.map +0 -1
  446. package/dist/functional/ternary-result/ternary-result.d.mts +0 -40
  447. package/dist/functional/ternary-result/ternary-result.d.mts.map +0 -1
  448. package/dist/functional/ternary-result/ternary-result.mjs +0 -2
  449. package/dist/functional/ternary-result/ternary-result.mjs.map +0 -1
  450. package/src/functional/async-result/async-result.mts +0 -17
  451. package/src/functional/async-result/impl/async-result-flat-map.mts +0 -99
  452. package/src/functional/async-result/impl/async-result-from-promise.mts +0 -69
  453. package/src/functional/async-result/impl/async-result-from-throwable.mts +0 -78
  454. package/src/functional/async-result/impl/async-result-map-err.mts +0 -84
  455. package/src/functional/async-result/impl/async-result-map.mts +0 -94
  456. package/src/functional/async-result/impl/async-result-unwrap-or.mts +0 -42
  457. package/src/functional/async-result/impl/index.mts +0 -7
  458. package/src/functional/async-result/impl/types.mts +0 -51
  459. package/src/functional/async-result/index.mts +0 -1
  460. package/src/functional/async-result.test.mts +0 -291
  461. package/src/functional/match.mts +0 -193
  462. package/src/functional/match.test.mts +0 -180
  463. package/src/functional/optional/impl/index.mts +0 -18
  464. package/src/functional/optional/impl/optional-expect-to-be.mts +0 -75
  465. package/src/functional/optional/impl/optional-filter.mts +0 -78
  466. package/src/functional/optional/impl/optional-flat-map.mts +0 -75
  467. package/src/functional/optional/impl/optional-from-nullable.mts +0 -31
  468. package/src/functional/optional/impl/optional-is-none.mts +0 -26
  469. package/src/functional/optional/impl/optional-is-optional.mts +0 -30
  470. package/src/functional/optional/impl/optional-is-some.mts +0 -27
  471. package/src/functional/optional/impl/optional-map.mts +0 -90
  472. package/src/functional/optional/impl/optional-match.mts +0 -108
  473. package/src/functional/optional/impl/optional-none.mts +0 -20
  474. package/src/functional/optional/impl/optional-or-else.mts +0 -83
  475. package/src/functional/optional/impl/optional-some.mts +0 -27
  476. package/src/functional/optional/impl/optional-to-nullable.mts +0 -34
  477. package/src/functional/optional/impl/optional-unwrap-or.mts +0 -70
  478. package/src/functional/optional/impl/optional-unwrap-throw.mts +0 -41
  479. package/src/functional/optional/impl/optional-unwrap.mts +0 -45
  480. package/src/functional/optional/impl/optional-zip.mts +0 -44
  481. package/src/functional/optional/impl/tag.mts +0 -8
  482. package/src/functional/optional/impl/types.mts +0 -31
  483. package/src/functional/optional/index.mts +0 -1
  484. package/src/functional/optional/optional.mts +0 -19
  485. package/src/functional/optional.test.mts +0 -883
  486. package/src/functional/pipe.mts +0 -180
  487. package/src/functional/pipe.test.mts +0 -155
  488. package/src/functional/result/impl/index.mts +0 -27
  489. package/src/functional/result/impl/result-err.mts +0 -33
  490. package/src/functional/result/impl/result-expect-to-be.mts +0 -73
  491. package/src/functional/result/impl/result-flat-map.mts +0 -88
  492. package/src/functional/result/impl/result-fold.mts +0 -102
  493. package/src/functional/result/impl/result-from-optional.mts +0 -80
  494. package/src/functional/result/impl/result-from-promise.mts +0 -51
  495. package/src/functional/result/impl/result-from-throwable.mts +0 -48
  496. package/src/functional/result/impl/result-is-err.mts +0 -26
  497. package/src/functional/result/impl/result-is-ok.mts +0 -26
  498. package/src/functional/result/impl/result-is-result.mts +0 -28
  499. package/src/functional/result/impl/result-map-err.mts +0 -96
  500. package/src/functional/result/impl/result-map.mts +0 -96
  501. package/src/functional/result/impl/result-match.mts +0 -108
  502. package/src/functional/result/impl/result-ok.mts +0 -33
  503. package/src/functional/result/impl/result-or-else.mts +0 -73
  504. package/src/functional/result/impl/result-safe-try.mts +0 -110
  505. package/src/functional/result/impl/result-safe-unwrap.mts +0 -50
  506. package/src/functional/result/impl/result-swap.mts +0 -31
  507. package/src/functional/result/impl/result-to-optional.mts +0 -37
  508. package/src/functional/result/impl/result-unwrap-err-or.mts +0 -66
  509. package/src/functional/result/impl/result-unwrap-err-throw.mts +0 -56
  510. package/src/functional/result/impl/result-unwrap-err.mts +0 -38
  511. package/src/functional/result/impl/result-unwrap-ok-or.mts +0 -66
  512. package/src/functional/result/impl/result-unwrap-ok.mts +0 -39
  513. package/src/functional/result/impl/result-unwrap-throw.mts +0 -46
  514. package/src/functional/result/impl/result-zip.mts +0 -42
  515. package/src/functional/result/impl/tag.mts +0 -8
  516. package/src/functional/result/impl/types.mts +0 -38
  517. package/src/functional/result/index.mts +0 -1
  518. package/src/functional/result/result.mts +0 -19
  519. package/src/functional/result.test.mts +0 -1349
  520. package/src/functional/ternary-result/impl/index.mts +0 -28
  521. package/src/functional/ternary-result/impl/tag.mts +0 -17
  522. package/src/functional/ternary-result/impl/ternary-result-err.mts +0 -21
  523. package/src/functional/ternary-result/impl/ternary-result-expect-to-be.mts +0 -65
  524. package/src/functional/ternary-result/impl/ternary-result-flat-map.mts +0 -112
  525. package/src/functional/ternary-result/impl/ternary-result-fold.mts +0 -102
  526. package/src/functional/ternary-result/impl/ternary-result-from-promise.mts +0 -30
  527. package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +0 -36
  528. package/src/functional/ternary-result/impl/ternary-result-is-err.mts +0 -24
  529. package/src/functional/ternary-result/impl/ternary-result-is-ok.mts +0 -26
  530. package/src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts +0 -32
  531. package/src/functional/ternary-result/impl/ternary-result-is-warn.mts +0 -25
  532. package/src/functional/ternary-result/impl/ternary-result-map-err.mts +0 -74
  533. package/src/functional/ternary-result/impl/ternary-result-map-warn.mts +0 -79
  534. package/src/functional/ternary-result/impl/ternary-result-map.mts +0 -95
  535. package/src/functional/ternary-result/impl/ternary-result-ok.mts +0 -22
  536. package/src/functional/ternary-result/impl/ternary-result-or-else.mts +0 -72
  537. package/src/functional/ternary-result/impl/ternary-result-to-optional.mts +0 -31
  538. package/src/functional/ternary-result/impl/ternary-result-unwrap-err-or.mts +0 -54
  539. package/src/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mts +0 -42
  540. package/src/functional/ternary-result/impl/ternary-result-unwrap-err.mts +0 -25
  541. package/src/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mts +0 -51
  542. package/src/functional/ternary-result/impl/ternary-result-unwrap-ok.mts +0 -39
  543. package/src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts +0 -48
  544. package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mts +0 -48
  545. package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mts +0 -40
  546. package/src/functional/ternary-result/impl/ternary-result-unwrap-warn.mts +0 -25
  547. package/src/functional/ternary-result/impl/ternary-result-warn.mts +0 -28
  548. package/src/functional/ternary-result/impl/ternary-result-zip.mts +0 -61
  549. package/src/functional/ternary-result/impl/types.mts +0 -46
  550. package/src/functional/ternary-result/impl/variant-name.mts +0 -18
  551. package/src/functional/ternary-result/index.mts +0 -1
  552. package/src/functional/ternary-result/ternary-result.mts +0 -50
  553. package/src/functional/ternary-result.test.mts +0 -310
  554. package/src/guard/has-key.test.mts +0 -111
  555. package/src/guard/is-non-null-object.test.mts +0 -109
  556. package/src/guard/is-record.test.mts +0 -195
  557. package/src/guard/key-is-in.test.mts +0 -21
  558. package/src/others/unknown-to-string.test.mts +0 -295
@@ -1,180 +0,0 @@
1
- import { expectType } from '../expect-type.mjs';
2
- import { match } from './match.mjs';
3
-
4
- describe(match, () => {
5
- type Direction = 'E' | 'N' | 'S' | 'W';
6
-
7
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
8
- const direction: Direction = 'N' as Direction;
9
-
10
- test('literal union', () => {
11
- const res = match(direction, {
12
- E: 2,
13
- N: 3,
14
- S: 4,
15
- W: 5,
16
- });
17
-
18
- expectType<typeof res, 2 | 3 | 4 | 5>('=');
19
-
20
- expect(res).toBe(3);
21
- });
22
-
23
- test('Literal union with missing key - requires default', () => {
24
- const res = match(
25
- direction,
26
- {
27
- E: 2,
28
- S: 4,
29
- W: 5,
30
- },
31
- 999,
32
- );
33
-
34
- expectType<typeof res, 2 | 4 | 5 | 999>('=');
35
-
36
- expect(res).toBe(999);
37
- });
38
-
39
- test('Literal union with missing key - 2-arg form should cause type error', () => {
40
- // @ts-expect-error Cannot use 2-argument form when not all cases are covered
41
- const res = match(direction, {
42
- E: 2,
43
- S: 4,
44
- W: 5,
45
- });
46
-
47
- expectType<typeof res, unknown>('=');
48
-
49
- expect(res).toBeUndefined();
50
- });
51
-
52
- test('Missing key cases with string - requires default', () => {
53
- const res = match(
54
- direction as string,
55
- {
56
- E: 2,
57
- S: 4,
58
- W: 5,
59
- },
60
- 'default',
61
- );
62
-
63
- expectType<typeof res, 2 | 4 | 5 | 'default'>('=');
64
-
65
- expect(res).toBe('default');
66
- });
67
-
68
- test('String type always requires default even with all keys', () => {
69
- const res = match(
70
- direction as string,
71
- {
72
- E: 2,
73
- N: 3,
74
- S: 4,
75
- W: 5,
76
- },
77
- 'default',
78
- );
79
-
80
- expectType<typeof res, 2 | 3 | 4 | 5 | 'default'>('=');
81
-
82
- expect(res).toBe(3);
83
- });
84
-
85
- test('A case with excess properties', () => {
86
- // @ts-expect-error excess properties
87
- const res = match(direction, {
88
- E: 2,
89
- N: 3,
90
- S: 4,
91
- W: 5,
92
- X: 0,
93
- });
94
-
95
- expectType<typeof res, 2 | 3 | 4 | 5>('=');
96
-
97
- expect(res).toBe(3);
98
- });
99
-
100
- test('with default case - all keys present should cause type error', () => {
101
- const res = match(
102
- direction,
103
- {
104
- E: 2,
105
- N: 3,
106
- S: 4,
107
- W: 5,
108
- },
109
- // @ts-expect-error When all cases are covered, default value should not be allowed
110
- 999,
111
- );
112
-
113
- expect(res).toBe(3);
114
- });
115
-
116
- test('all keys present without default - should work correctly', () => {
117
- const res = match(direction, {
118
- E: 2,
119
- N: 3,
120
- S: 4,
121
- W: 5,
122
- });
123
-
124
- expectType<typeof res, 2 | 3 | 4 | 5>('=');
125
-
126
- expect(res).toBe(3);
127
- });
128
-
129
- test('with default case - missing key', () => {
130
- const res = match(
131
- direction,
132
- {
133
- E: 2,
134
- S: 4,
135
- W: 5,
136
- },
137
- 999,
138
- );
139
-
140
- expectType<typeof res, 2 | 4 | 5 | 999>('=');
141
-
142
- expect(res).toBe(999);
143
- });
144
-
145
- test('with default case - string key', () => {
146
- const res = match(
147
- direction as string,
148
- {
149
- E: 2,
150
- N: 3,
151
- S: 4,
152
- W: 5,
153
- },
154
- 'default',
155
- );
156
-
157
- expectType<typeof res, 2 | 3 | 4 | 5 | 'default'>('=');
158
-
159
- expect(res).toBe(3);
160
- });
161
-
162
- test('with default case - string key missing', () => {
163
- const unknownDirection = 'X' as string;
164
-
165
- const res = match(
166
- unknownDirection,
167
- {
168
- E: 2,
169
- N: 3,
170
- S: 4,
171
- W: 5,
172
- },
173
- 'default',
174
- );
175
-
176
- expectType<typeof res, 2 | 3 | 4 | 5 | 'default'>('=');
177
-
178
- expect(res).toBe('default');
179
- });
180
- });
@@ -1,18 +0,0 @@
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';
@@ -1,75 +0,0 @@
1
- import { type Optional, type UnknownOptional } from '../optional.mjs';
2
- import { isSome } from './optional-is-some.mjs';
3
- import { unwrap } from './optional-unwrap.mjs';
4
- import { type Unwrap } from './types.mjs';
5
-
6
- /**
7
- * Unwraps an `Optional`, returning the contained value or throwing an error
8
- * with the provided message.
9
- *
10
- * @example
11
- *
12
- * ```ts
13
- * const optionalValue = Optional.some('data');
14
- *
15
- * assert.isTrue(
16
- * Optional.expectToBe(optionalValue, 'value expected') === 'data',
17
- * );
18
- *
19
- * const expectValue = Optional.expectToBe('missing optional');
20
- *
21
- * const throwTest = (): void => {
22
- * expectValue(Optional.none);
23
- * };
24
- *
25
- * assert.throws(throwTest, /missing optional/u);
26
- *
27
- * assert.isTrue(expectValue(Optional.some('present')) === 'present');
28
- * ```
29
- *
30
- * @template O The `UnknownOptional` type to unwrap.
31
- * @param optional The `Optional` to unwrap.
32
- * @param message The error message to throw if the `Optional` is
33
- * `None`.
34
- * @returns The contained value if `Some`.
35
- * @throws Error with the provided message if the `Optional` is
36
- * `None`.
37
- */
38
- export function expectToBe<O extends UnknownOptional>(
39
- optional: O,
40
- message: string,
41
- ): Unwrap<O>;
42
-
43
- // Curried version
44
- export function expectToBe(message: string): <O>(optional: Optional<O>) => O;
45
-
46
- export function expectToBe<O extends UnknownOptional>(
47
- ...args: readonly [optional: O, message: string] | readonly [message: string]
48
- ): Unwrap<O> | ((optional: Optional<Unwrap<O>>) => Unwrap<O>) {
49
- switch (args.length) {
50
- case 2: {
51
- const [optional, message] = args;
52
-
53
- return expectToBeImpl(optional, message);
54
- }
55
-
56
- case 1: {
57
- // Curried version: first argument is message
58
- const [message] = args;
59
-
60
- return (optional: Optional<Unwrap<O>>): Unwrap<O> =>
61
- expectToBeImpl(optional, message);
62
- }
63
- }
64
- }
65
-
66
- const expectToBeImpl = <O extends UnknownOptional>(
67
- optional: O,
68
- message: string,
69
- ): Unwrap<O> => {
70
- if (isSome(optional)) {
71
- return unwrap(optional);
72
- }
73
-
74
- throw new Error(message);
75
- };
@@ -1,78 +0,0 @@
1
- import { type Optional, type UnknownOptional } from '../optional.mjs';
2
- import { isSome } from './optional-is-some.mjs';
3
- import { none } from './optional-none.mjs';
4
- import { some } from './optional-some.mjs';
5
- import { unwrap } from './optional-unwrap.mjs';
6
- import { type Unwrap } from './types.mjs';
7
-
8
- /**
9
- * Filters an `Optional` based on a predicate. If the `Optional` is `Some` and
10
- * the predicate returns true, returns the original `Optional`. Otherwise
11
- * returns `None`.
12
- *
13
- * @example
14
- *
15
- * ```ts
16
- * const even = Optional.filter(Optional.some(4), (value) => value % 2 === 0);
17
- *
18
- * const odd = Optional.filter(Optional.some(3), (value) => value % 2 === 0);
19
- *
20
- * assert.deepStrictEqual(even, Optional.some(4));
21
- *
22
- * assert.deepStrictEqual(odd, Optional.none);
23
- *
24
- * const filterEven = Optional.filter((value: number) => value % 2 === 0);
25
- *
26
- * assert.deepStrictEqual(filterEven(Optional.some(6)), Optional.some(6));
27
- *
28
- * assert.deepStrictEqual(filterEven(Optional.some(5)), Optional.none);
29
- * ```
30
- *
31
- * @template O The input `UnknownOptional` type.
32
- * @param optional The `Optional` to filter.
33
- * @param predicate The predicate function.
34
- * @returns The filtered `Optional`.
35
- */
36
- export function filter<O extends UnknownOptional>(
37
- optional: O,
38
- predicate: (value: Unwrap<O>) => boolean,
39
- ): Optional<Unwrap<O>>;
40
-
41
- // Curried version
42
- export function filter<S>(
43
- predicate: (value: S) => boolean,
44
- ): (optional: Optional<S>) => Optional<S>;
45
-
46
- export function filter<O extends UnknownOptional>(
47
- ...args:
48
- | readonly [optional: O, predicate: (value: Unwrap<O>) => boolean]
49
- | readonly [predicate: (value: Unwrap<O>) => boolean]
50
- ): Optional<Unwrap<O>> | ((optional: O) => Optional<Unwrap<O>>) {
51
- switch (args.length) {
52
- case 2: {
53
- const [optional, predicate] = args;
54
-
55
- return filterImpl(optional, predicate);
56
- }
57
-
58
- case 1: {
59
- // Curried version: first argument is predicate function
60
- const [predicate] = args;
61
-
62
- return (optional: O) => filterImpl(optional, predicate);
63
- }
64
- }
65
- }
66
-
67
- const filterImpl = <O extends UnknownOptional>(
68
- optional: O,
69
- predicate: (value: Unwrap<O>) => boolean,
70
- ): Optional<Unwrap<O>> => {
71
- if (isSome(optional)) {
72
- const value = unwrap(optional);
73
-
74
- return predicate(value) ? some(value) : none;
75
- }
76
-
77
- return none;
78
- };
@@ -1,75 +0,0 @@
1
- import { type Optional, type UnknownOptional } from '../optional.mjs';
2
- import { isSome } from './optional-is-some.mjs';
3
- import { none } from './optional-none.mjs';
4
- import { unwrap } from './optional-unwrap.mjs';
5
- import { type Unwrap } from './types.mjs';
6
-
7
- /**
8
- * Applies a function that returns an `Optional` to the value in an
9
- * `Some`. If the input is `None`, returns `None`.
10
- * This is the monadic bind operation for `Optional`.
11
- *
12
- * @example
13
- *
14
- * ```ts
15
- * const parseNumber = (input: string): Optional<number> => {
16
- * const num = Num.safeParseInt(input);
17
- *
18
- * return Result.isErr(num) ? Optional.none : Optional.some(num.value);
19
- * };
20
- *
21
- * const parsed = Optional.flatMap(Optional.some('10'), parseNumber);
22
- *
23
- * assert.deepStrictEqual(parsed, Optional.some(10));
24
- *
25
- * const flatMapParse = Optional.flatMap(parseNumber);
26
- *
27
- * assert.deepStrictEqual(flatMapParse(Optional.some('5')), Optional.some(5));
28
- *
29
- * assert.deepStrictEqual(
30
- * flatMapParse(Optional.some('invalid')),
31
- * Optional.none,
32
- * );
33
- * ```
34
- *
35
- * @template O The input `UnknownOptional` type.
36
- * @template S2 The value type of the `Optional` returned by the function.
37
- * @param optional The `Optional` to flat map.
38
- * @param flatMapFn The function to apply that returns an `Optional`.
39
- * @returns The result of applying the function, or `None`.
40
- */
41
- export function flatMap<O extends UnknownOptional, S2>(
42
- optional: O,
43
- flatMapFn: (value: Unwrap<O>) => Optional<S2>,
44
- ): Optional<S2>;
45
-
46
- // Curried version
47
- export function flatMap<S, S2>(
48
- flatMapFn: (value: S) => Optional<S2>,
49
- ): (optional: Optional<S>) => Optional<S2>;
50
-
51
- export function flatMap<O extends UnknownOptional, S2>(
52
- ...args:
53
- | readonly [optional: O, flatMapFn: (value: Unwrap<O>) => Optional<S2>]
54
- | readonly [flatMapFn: (value: Unwrap<O>) => Optional<S2>]
55
- ): Optional<S2> | ((optional: O) => Optional<S2>) {
56
- switch (args.length) {
57
- case 2: {
58
- const [optional, flatMapFn] = args;
59
-
60
- return flatMapImpl(optional, flatMapFn);
61
- }
62
-
63
- case 1: {
64
- // Curried version
65
- const [flatMapFn] = args;
66
-
67
- return (optional: O) => flatMapImpl(optional, flatMapFn);
68
- }
69
- }
70
- }
71
-
72
- const flatMapImpl = <O extends UnknownOptional, S2>(
73
- optional: O,
74
- flatMapFn: (value: Unwrap<O>) => Optional<S2>,
75
- ): Optional<S2> => (isSome(optional) ? flatMapFn(unwrap(optional)) : none);
@@ -1,31 +0,0 @@
1
- import { type Optional } from '../optional.mjs';
2
- import { none } from './optional-none.mjs';
3
- import { some } from './optional-some.mjs';
4
-
5
- /**
6
- * Converts a nullable value to an `Optional`.
7
- *
8
- * This is the primary way to lift nullable values (null or undefined) into
9
- * the Optional type system. The function treats both `null` and `undefined`
10
- * as empty values, converting them to `None`.
11
- *
12
- * @example
13
- *
14
- * ```ts
15
- * const present = Optional.fromNullable('hello');
16
- *
17
- * const absent = Optional.fromNullable<string | null>(null);
18
- *
19
- * assert.deepStrictEqual(present, Optional.some('hello'));
20
- *
21
- * assert.deepStrictEqual(absent, Optional.none);
22
- * ```
23
- *
24
- * @template T The type of the nullable value.
25
- * @param value The nullable value to convert.
26
- * @returns `Some<NonNullable<T>>` if the value is not null or
27
- * undefined, otherwise `None`.
28
- */
29
- export const fromNullable = <T,>(
30
- value: T | null | undefined,
31
- ): Optional<NonNullable<T>> => (value == null ? none : some(value));
@@ -1,26 +0,0 @@
1
- import { type UnknownOptional } from '../optional.mjs';
2
- import { NoneTypeTagName } from './tag.mjs';
3
- import { type NarrowToNone } from './types.mjs';
4
-
5
- /**
6
- * Checks if an {@link Optional} is {@link None}. Acts as a type guard.
7
- *
8
- * @example
9
- *
10
- * ```ts
11
- * const optionalValue = Optional.none as Optional<number>;
12
- *
13
- * if (Optional.isNone(optionalValue)) {
14
- * // Type narrowed to None
15
- * expectType<typeof optionalValue, None>('=');
16
- * }
17
- * ```
18
- *
19
- * @template O The {@link UnknownOptional} type to check.
20
- * @param optional The {@link Optional} to check.
21
- * @returns `true` if the {@link Optional} is {@link None}, `false`
22
- * otherwise.
23
- */
24
- export const isNone = <O extends UnknownOptional>(
25
- optional: O,
26
- ): optional is NarrowToNone<O> => optional.$$tag === NoneTypeTagName;
@@ -1,30 +0,0 @@
1
- import { hasKey, isRecord } from '../../../guard/index.mjs';
2
- import { type Optional } from '../optional.mjs';
3
- import { NoneTypeTagName, SomeTypeTagName } from './tag.mjs';
4
-
5
- /**
6
- * Checks if the given value is an {@link Optional}.
7
- *
8
- * @example
9
- *
10
- * ```ts
11
- * const maybeOptional = Optional.some('value');
12
- *
13
- * const notOptional = { $$tag: 'ts-data-forge::Optional.some' } as const;
14
- *
15
- * assert.isTrue(Optional.isOptional(maybeOptional));
16
- *
17
- * assert.isFalse(Optional.isOptional(notOptional));
18
- * ```
19
- *
20
- * @param maybeOptional The value to check.
21
- * @returns `true` if the value is an {@link Optional}, otherwise `false`.
22
- */
23
- export const isOptional = (
24
- maybeOptional: unknown,
25
- ): maybeOptional is Optional<unknown> =>
26
- isRecord(maybeOptional) &&
27
- hasKey(maybeOptional, '$$tag') &&
28
- ((maybeOptional.$$tag === SomeTypeTagName &&
29
- hasKey(maybeOptional, 'value')) ||
30
- maybeOptional.$$tag === NoneTypeTagName);
@@ -1,27 +0,0 @@
1
- import { type UnknownOptional } from '../optional.mjs';
2
- import { SomeTypeTagName } from './tag.mjs';
3
- import { type NarrowToSome } from './types.mjs';
4
-
5
- /**
6
- * Checks if an {@link Optional} is {@link Some}. Acts as a type guard.
7
- *
8
- * @example
9
- *
10
- * ```ts
11
- * const optionalNumber = Optional.some(42);
12
- *
13
- * if (Optional.isSome(optionalNumber)) {
14
- * const value: number = optionalNumber.value;
15
- *
16
- * assert.isTrue(value === 42);
17
- * }
18
- * ```
19
- *
20
- * @template O The {@link UnknownOptional} type to check.
21
- * @param optional The {@link Optional} to check.
22
- * @returns `true` if the {@link Optional} is {@link Some}, `false`
23
- * otherwise.
24
- */
25
- export const isSome = <O extends UnknownOptional>(
26
- optional: O,
27
- ): optional is NarrowToSome<O> => optional.$$tag === SomeTypeTagName;
@@ -1,90 +0,0 @@
1
- import { type Optional, type UnknownOptional } from '../optional.mjs';
2
- import { isSome } from './optional-is-some.mjs';
3
- import { none } from './optional-none.mjs';
4
- import { some } from './optional-some.mjs';
5
- import { unwrap } from './optional-unwrap.mjs';
6
- import { type Unwrap } from './types.mjs';
7
-
8
- /**
9
- * Maps an {@link Optional}<S> to {@link Optional}<S2> by applying a function to
10
- * a contained value. If the {@link Optional} is {@link None}, it
11
- * returns {@link Optional.none}. Otherwise, it applies the `mapFn` to the
12
- * value in `Some` and returns a new `Some` with the result.
13
- *
14
- * @example
15
- *
16
- * ```ts
17
- * const numberOptional = Optional.some(21);
18
- *
19
- * const mapped = Optional.map(numberOptional, (value) => value * 2);
20
- *
21
- * assert.deepStrictEqual(mapped, Optional.some(42));
22
- *
23
- * const mapToLength = Optional.map((text: string) => text.length);
24
- *
25
- * assert.deepStrictEqual(mapToLength(Optional.some('abc')), Optional.some(3));
26
- *
27
- * assert.deepStrictEqual(mapToLength(Optional.none), Optional.none);
28
- * ```
29
- *
30
- * @template O The input `UnknownOptional` type.
31
- * @template S2 The type of the value returned by the mapping function.
32
- * @param optional The `Optional` to map.
33
- * @param mapFn The function to apply to the value if it exists.
34
- * @returns A new `Optional<S2>` resulting from the mapping, or
35
- * `None` if the input was `None`.
36
- */
37
- export function map<O extends UnknownOptional, S2>(
38
- optional: O,
39
- mapFn: (value: Unwrap<O>) => S2,
40
- ): Optional<S2>;
41
-
42
- // Curried version
43
- //
44
- // The returned function is generic over the *whole* optional, mirroring the
45
- // direct overload above, rather than fixing its parameter to `Optional<S>`.
46
- // Fixing it makes the curried form unusable from a caller that is itself
47
- // generic over the optional: with `S` bound to `Unwrap<O>` at currying time
48
- // the parameter becomes `Optional<Unwrap<O>>`, and TypeScript cannot show a
49
- // bare `O extends UnknownOptional` is assignable to that — although every
50
- // concrete instantiation of `O` is.
51
- //
52
- // The conditional is what keeps the check: `O` is inferred from the argument
53
- // and its value type still has to satisfy `S`, so mapping a `(s: string) =>
54
- // …` over an `Optional<number>` stays an error. The cost is the message it
55
- // produces — "not assignable to `never`" rather than naming the two optionals.
56
- export function map<S, S2>(
57
- mapFn: (value: S) => S2,
58
- ): <O extends UnknownOptional>(
59
- optional: Unwrap<O> extends S ? O : never,
60
- ) => Optional<S2>;
61
-
62
- export function map<O extends UnknownOptional, S2>(
63
- ...args:
64
- | readonly [optional: O, mapFn: (value: Unwrap<O>) => S2]
65
- | readonly [mapFn: (value: Unwrap<O>) => S2]
66
- ): Optional<S2> | ((optional: O) => Optional<S2>) {
67
- switch (args.length) {
68
- case 2: {
69
- const [optional, mapFn] = args;
70
-
71
- return mapImpl(optional, mapFn);
72
- }
73
-
74
- case 1: {
75
- // Curried version: first argument is mapping function
76
- const [mapFn] = args;
77
-
78
- return (optional: O) => mapImpl(optional, mapFn);
79
- }
80
- }
81
- }
82
-
83
- const mapImpl = <O extends UnknownOptional, S2>(
84
- optional: O,
85
- mapFn: (value: Unwrap<O>) => S2,
86
- ): Optional<S2> =>
87
- isSome(optional)
88
- ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
89
- some(mapFn(unwrap(optional)!))
90
- : none;