ts-data-forge 14.6.0 → 14.6.2

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 (409) 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 +69 -53
  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 +71 -33
  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 +100 -150
  18. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  19. package/dist/array/impl/array-utils-search.mjs +110 -134
  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 +94 -78
  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 +54 -56
  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 -291
  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.d.mts.map +1 -1
  44. package/dist/collections/iset-mapped.mjs +448 -263
  45. package/dist/collections/iset-mapped.mjs.map +1 -1
  46. package/dist/collections/iset.mjs +328 -201
  47. package/dist/collections/iset.mjs.map +1 -1
  48. package/dist/collections/queue.mjs +183 -151
  49. package/dist/collections/queue.mjs.map +1 -1
  50. package/dist/collections/stack.mjs +169 -140
  51. package/dist/collections/stack.mjs.map +1 -1
  52. package/dist/entry-point.mjs +4 -77
  53. package/dist/entry-point.mjs.map +1 -1
  54. package/dist/expect-type.mjs +70 -4
  55. package/dist/expect-type.mjs.map +1 -1
  56. package/dist/functional/async-result/async-result.mjs +2 -3
  57. package/dist/functional/async-result/async-result.mjs.map +1 -1
  58. package/dist/functional/async-result/impl/async-result-flat-map.mjs +19 -21
  59. package/dist/functional/async-result/impl/async-result-flat-map.mjs.map +1 -1
  60. package/dist/functional/async-result/impl/async-result-from-promise.mjs +9 -10
  61. package/dist/functional/async-result/impl/async-result-from-promise.mjs.map +1 -1
  62. package/dist/functional/async-result/impl/async-result-from-throwable.mjs +12 -14
  63. package/dist/functional/async-result/impl/async-result-from-throwable.mjs.map +1 -1
  64. package/dist/functional/async-result/impl/async-result-map-err.mjs +16 -19
  65. package/dist/functional/async-result/impl/async-result-map-err.mjs.map +1 -1
  66. package/dist/functional/async-result/impl/async-result-map.mjs +16 -19
  67. package/dist/functional/async-result/impl/async-result-map.mjs.map +1 -1
  68. package/dist/functional/async-result/impl/async-result-unwrap-or.mjs +36 -9
  69. package/dist/functional/async-result/impl/async-result-unwrap-or.mjs.map +1 -1
  70. package/dist/functional/async-result/impl/index.mjs +8 -7
  71. package/dist/functional/async-result/impl/index.mjs.map +1 -1
  72. package/dist/functional/async-result/impl/types.mjs +2 -2
  73. package/dist/functional/async-result/impl/types.mjs.map +1 -1
  74. package/dist/functional/async-result/index.mjs +2 -3
  75. package/dist/functional/async-result/index.mjs.map +1 -1
  76. package/dist/functional/index.mjs +7 -11
  77. package/dist/functional/index.mjs.map +1 -1
  78. package/dist/functional/match.mjs +27 -13
  79. package/dist/functional/match.mjs.map +1 -1
  80. package/dist/functional/optional/impl/index.mjs +19 -18
  81. package/dist/functional/optional/impl/index.mjs.map +1 -1
  82. package/dist/functional/optional/impl/optional-expect-to-be.mjs +16 -18
  83. package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
  84. package/dist/functional/optional/impl/optional-filter.mjs +17 -19
  85. package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
  86. package/dist/functional/optional/impl/optional-flat-map.mjs +13 -15
  87. package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
  88. package/dist/functional/optional/impl/optional-from-nullable.mjs +26 -5
  89. package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
  90. package/dist/functional/optional/impl/optional-is-none.mjs +21 -5
  91. package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -1
  92. package/dist/functional/optional/impl/optional-is-optional.mjs +26 -8
  93. package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
  94. package/dist/functional/optional/impl/optional-is-some.mjs +22 -5
  95. package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
  96. package/dist/functional/optional/impl/optional-map.mjs +16 -18
  97. package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
  98. package/dist/functional/optional/impl/optional-match.mjs +16 -18
  99. package/dist/functional/optional/impl/optional-match.mjs.map +1 -1
  100. package/dist/functional/optional/impl/optional-none.mjs +18 -5
  101. package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
  102. package/dist/functional/optional/impl/optional-or-else.mjs +13 -15
  103. package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
  104. package/dist/functional/optional/impl/optional-some.mjs +23 -7
  105. package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
  106. package/dist/functional/optional/impl/optional-to-nullable.mjs +28 -5
  107. package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
  108. package/dist/functional/optional/impl/optional-unwrap-or.mjs +12 -14
  109. package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
  110. package/dist/functional/optional/impl/optional-unwrap-throw.mjs +34 -9
  111. package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
  112. package/dist/functional/optional/impl/optional-unwrap.mjs +6 -9
  113. package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
  114. package/dist/functional/optional/impl/optional-zip.mjs +36 -5
  115. package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
  116. package/dist/functional/optional/impl/tag.mjs +4 -5
  117. package/dist/functional/optional/impl/tag.mjs.map +1 -1
  118. package/dist/functional/optional/impl/types.mjs +2 -2
  119. package/dist/functional/optional/impl/types.mjs.map +1 -1
  120. package/dist/functional/optional/index.mjs +2 -3
  121. package/dist/functional/optional/index.mjs.map +1 -1
  122. package/dist/functional/optional/optional.mjs +2 -3
  123. package/dist/functional/optional/optional.mjs.map +1 -1
  124. package/dist/functional/pipe.mjs +42 -14
  125. package/dist/functional/pipe.mjs.map +1 -1
  126. package/dist/functional/result/impl/index.mjs +28 -27
  127. package/dist/functional/result/impl/index.mjs.map +1 -1
  128. package/dist/functional/result/impl/result-err.mjs +29 -7
  129. package/dist/functional/result/impl/result-err.mjs.map +1 -1
  130. package/dist/functional/result/impl/result-expect-to-be.mjs +17 -18
  131. package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
  132. package/dist/functional/result/impl/result-flat-map.mjs +18 -21
  133. package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
  134. package/dist/functional/result/impl/result-fold.mjs +18 -21
  135. package/dist/functional/result/impl/result-fold.mjs.map +1 -1
  136. package/dist/functional/result/impl/result-from-optional.mjs +17 -20
  137. package/dist/functional/result/impl/result-from-optional.mjs.map +1 -1
  138. package/dist/functional/result/impl/result-from-promise.mjs +37 -8
  139. package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
  140. package/dist/functional/result/impl/result-from-throwable.mjs +41 -14
  141. package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
  142. package/dist/functional/result/impl/result-is-err.mjs +21 -5
  143. package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
  144. package/dist/functional/result/impl/result-is-ok.mjs +21 -5
  145. package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
  146. package/dist/functional/result/impl/result-is-result.mjs +25 -7
  147. package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
  148. package/dist/functional/result/impl/result-map-err.mjs +18 -21
  149. package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
  150. package/dist/functional/result/impl/result-map.mjs +18 -21
  151. package/dist/functional/result/impl/result-map.mjs.map +1 -1
  152. package/dist/functional/result/impl/result-match.mjs +17 -21
  153. package/dist/functional/result/impl/result-match.mjs.map +1 -1
  154. package/dist/functional/result/impl/result-ok.mjs +29 -7
  155. package/dist/functional/result/impl/result-ok.mjs.map +1 -1
  156. package/dist/functional/result/impl/result-or-else.mjs +14 -15
  157. package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
  158. package/dist/functional/result/impl/result-safe-try.mjs +32 -21
  159. package/dist/functional/result/impl/result-safe-try.mjs.map +1 -1
  160. package/dist/functional/result/impl/result-safe-unwrap.mjs +40 -12
  161. package/dist/functional/result/impl/result-safe-unwrap.mjs.map +1 -1
  162. package/dist/functional/result/impl/result-swap.mjs +23 -8
  163. package/dist/functional/result/impl/result-swap.mjs.map +1 -1
  164. package/dist/functional/result/impl/result-to-optional.mjs +30 -7
  165. package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
  166. package/dist/functional/result/impl/result-unwrap-err-or.mjs +13 -14
  167. package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
  168. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +43 -20
  169. package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
  170. package/dist/functional/result/impl/result-unwrap-err.mjs +33 -8
  171. package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
  172. package/dist/functional/result/impl/result-unwrap-ok-or.mjs +13 -14
  173. package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
  174. package/dist/functional/result/impl/result-unwrap-ok.mjs +6 -9
  175. package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
  176. package/dist/functional/result/impl/result-unwrap-throw.mjs +38 -11
  177. package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
  178. package/dist/functional/result/impl/result-zip.mjs +35 -5
  179. package/dist/functional/result/impl/result-zip.mjs.map +1 -1
  180. package/dist/functional/result/impl/tag.mjs +4 -5
  181. package/dist/functional/result/impl/tag.mjs.map +1 -1
  182. package/dist/functional/result/impl/types.mjs +2 -2
  183. package/dist/functional/result/impl/types.mjs.map +1 -1
  184. package/dist/functional/result/index.mjs +2 -3
  185. package/dist/functional/result/index.mjs.map +1 -1
  186. package/dist/functional/result/result.mjs +2 -3
  187. package/dist/functional/result/result.mjs.map +1 -1
  188. package/dist/functional/ternary-result/impl/index.mjs +29 -28
  189. package/dist/functional/ternary-result/impl/index.mjs.map +1 -1
  190. package/dist/functional/ternary-result/impl/tag.mjs +6 -6
  191. package/dist/functional/ternary-result/impl/tag.mjs.map +1 -1
  192. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +17 -7
  193. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
  194. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +15 -18
  195. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
  196. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +28 -32
  197. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
  198. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +24 -26
  199. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
  200. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +21 -8
  201. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
  202. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +28 -13
  203. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
  204. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +19 -5
  205. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -1
  206. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +21 -5
  207. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -1
  208. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +28 -8
  209. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -1
  210. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +20 -5
  211. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
  212. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +17 -18
  213. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
  214. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +20 -23
  215. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
  216. package/dist/functional/ternary-result/impl/ternary-result-map.mjs +24 -26
  217. package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
  218. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +18 -7
  219. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
  220. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +11 -14
  221. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
  222. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +24 -10
  223. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -1
  224. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +11 -14
  225. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -1
  226. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +30 -19
  227. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
  228. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +20 -8
  229. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -1
  230. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +11 -14
  231. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -1
  232. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +7 -9
  233. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
  234. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +30 -22
  235. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
  236. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +11 -14
  237. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -1
  238. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +27 -17
  239. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
  240. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +20 -8
  241. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
  242. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +21 -8
  243. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
  244. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +47 -19
  245. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
  246. package/dist/functional/ternary-result/impl/types.mjs +2 -2
  247. package/dist/functional/ternary-result/impl/types.mjs.map +1 -1
  248. package/dist/functional/ternary-result/impl/variant-name.mjs +12 -14
  249. package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -1
  250. package/dist/functional/ternary-result/index.mjs +2 -3
  251. package/dist/functional/ternary-result/index.mjs.map +1 -1
  252. package/dist/functional/ternary-result/ternary-result.mjs +2 -3
  253. package/dist/functional/ternary-result/ternary-result.mjs.map +1 -1
  254. package/dist/guard/has-key.mjs +43 -4
  255. package/dist/guard/has-key.mjs.map +1 -1
  256. package/dist/guard/index.mjs +8 -8
  257. package/dist/guard/index.mjs.map +1 -1
  258. package/dist/guard/is-non-empty-string.mjs +39 -4
  259. package/dist/guard/is-non-empty-string.mjs.map +1 -1
  260. package/dist/guard/is-non-null-object.mjs +36 -4
  261. package/dist/guard/is-non-null-object.mjs.map +1 -1
  262. package/dist/guard/is-primitive.mjs +46 -15
  263. package/dist/guard/is-primitive.mjs.map +1 -1
  264. package/dist/guard/is-record.mjs +89 -6
  265. package/dist/guard/is-record.mjs.map +1 -1
  266. package/dist/guard/is-type.mjs +404 -19
  267. package/dist/guard/is-type.mjs.map +1 -1
  268. package/dist/guard/key-is-in.mjs +42 -4
  269. package/dist/guard/key-is-in.mjs.map +1 -1
  270. package/dist/index.mjs +12 -65
  271. package/dist/index.mjs.map +1 -1
  272. package/dist/iterator/index.mjs +2 -2
  273. package/dist/iterator/index.mjs.map +1 -1
  274. package/dist/iterator/range.mjs +19 -57
  275. package/dist/iterator/range.mjs.map +1 -1
  276. package/dist/json/index.mjs +2 -2
  277. package/dist/json/index.mjs.map +1 -1
  278. package/dist/json/json.mjs +346 -105
  279. package/dist/json/json.mjs.map +1 -1
  280. package/dist/number/branded-types/finite-number.mjs +148 -137
  281. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  282. package/dist/number/branded-types/index.mjs +33 -33
  283. package/dist/number/branded-types/index.mjs.map +1 -1
  284. package/dist/number/branded-types/int.mjs +245 -209
  285. package/dist/number/branded-types/int.mjs.map +1 -1
  286. package/dist/number/branded-types/int16.mjs +141 -131
  287. package/dist/number/branded-types/int16.mjs.map +1 -1
  288. package/dist/number/branded-types/int32.mjs +141 -131
  289. package/dist/number/branded-types/int32.mjs.map +1 -1
  290. package/dist/number/branded-types/negative-finite-number.mjs +155 -149
  291. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  292. package/dist/number/branded-types/negative-int.mjs +125 -110
  293. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  294. package/dist/number/branded-types/negative-safe-int.mjs +126 -115
  295. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  296. package/dist/number/branded-types/non-negative-finite-number.mjs +164 -154
  297. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  298. package/dist/number/branded-types/non-negative-int16.mjs +137 -125
  299. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  300. package/dist/number/branded-types/non-negative-int32.mjs +137 -125
  301. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  302. package/dist/number/branded-types/non-positive-finite-number.mjs +143 -139
  303. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  304. package/dist/number/branded-types/non-positive-int.mjs +116 -99
  305. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  306. package/dist/number/branded-types/non-positive-safe-int.mjs +118 -107
  307. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  308. package/dist/number/branded-types/non-zero-finite-number.mjs +144 -129
  309. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  310. package/dist/number/branded-types/non-zero-int.mjs +102 -82
  311. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  312. package/dist/number/branded-types/non-zero-int16.mjs +118 -105
  313. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  314. package/dist/number/branded-types/non-zero-int32.mjs +118 -105
  315. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  316. package/dist/number/branded-types/non-zero-safe-int.mjs +122 -108
  317. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  318. package/dist/number/branded-types/non-zero-uint16.mjs +118 -104
  319. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  320. package/dist/number/branded-types/non-zero-uint32.mjs +118 -104
  321. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  322. package/dist/number/branded-types/positive-finite-number.mjs +167 -160
  323. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  324. package/dist/number/branded-types/positive-int.mjs +260 -224
  325. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  326. package/dist/number/branded-types/positive-int16.mjs +134 -122
  327. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  328. package/dist/number/branded-types/positive-int32.mjs +134 -122
  329. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  330. package/dist/number/branded-types/positive-safe-int.mjs +292 -258
  331. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  332. package/dist/number/branded-types/positive-uint16.mjs +134 -122
  333. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  334. package/dist/number/branded-types/positive-uint32.mjs +134 -122
  335. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  336. package/dist/number/branded-types/safe-int.mjs +284 -255
  337. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  338. package/dist/number/branded-types/safe-uint.mjs +135 -124
  339. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  340. package/dist/number/branded-types/uint.mjs +248 -211
  341. package/dist/number/branded-types/uint.mjs.map +1 -1
  342. package/dist/number/branded-types/uint16.mjs +132 -121
  343. package/dist/number/branded-types/uint16.mjs.map +1 -1
  344. package/dist/number/branded-types/uint32.mjs +132 -121
  345. package/dist/number/branded-types/uint32.mjs.map +1 -1
  346. package/dist/number/enum/index.mjs +3 -3
  347. package/dist/number/enum/index.mjs.map +1 -1
  348. package/dist/number/enum/int8.mjs +146 -131
  349. package/dist/number/enum/int8.mjs.map +1 -1
  350. package/dist/number/enum/uint8.mjs +133 -119
  351. package/dist/number/enum/uint8.mjs.map +1 -1
  352. package/dist/number/index.mjs +6 -37
  353. package/dist/number/index.mjs.map +1 -1
  354. package/dist/number/num-arithmetic-types.mjs +42 -1
  355. package/dist/number/num-arithmetic-types.mjs.map +1 -1
  356. package/dist/number/num.mjs +541 -83
  357. package/dist/number/num.mjs.map +1 -1
  358. package/dist/number/refined-number-utils.mjs +294 -133
  359. package/dist/number/refined-number-utils.mjs.map +1 -1
  360. package/dist/object/index.mjs +2 -2
  361. package/dist/object/index.mjs.map +1 -1
  362. package/dist/object/object.mjs +355 -202
  363. package/dist/object/object.mjs.map +1 -1
  364. package/dist/others/cast-mutable.mjs +38 -11
  365. package/dist/others/cast-mutable.mjs.map +1 -1
  366. package/dist/others/cast-readonly.mjs +37 -11
  367. package/dist/others/cast-readonly.mjs.map +1 -1
  368. package/dist/others/debounce-function.mjs +22 -11
  369. package/dist/others/debounce-function.mjs.map +1 -1
  370. package/dist/others/fast-deep-equal.mjs +70 -51
  371. package/dist/others/fast-deep-equal.mjs.map +1 -1
  372. package/dist/others/if-then.mjs +32 -5
  373. package/dist/others/if-then.mjs.map +1 -1
  374. package/dist/others/index.mjs +10 -10
  375. package/dist/others/index.mjs.map +1 -1
  376. package/dist/others/map-nullable.mjs +11 -13
  377. package/dist/others/map-nullable.mjs.map +1 -1
  378. package/dist/others/memoize-function.mjs +14 -16
  379. package/dist/others/memoize-function.mjs.map +1 -1
  380. package/dist/others/tuple.mjs +52 -4
  381. package/dist/others/tuple.mjs.map +1 -1
  382. package/dist/others/unknown-to-string.mjs +91 -47
  383. package/dist/others/unknown-to-string.mjs.map +1 -1
  384. package/dist/promise/index.mjs +2 -2
  385. package/dist/promise/index.mjs.map +1 -1
  386. package/dist/promise/promise.mjs +51 -10
  387. package/dist/promise/promise.mjs.map +1 -1
  388. package/dist/string/index.mjs +2 -2
  389. package/dist/string/index.mjs.map +1 -1
  390. package/dist/string/str.mjs +250 -83
  391. package/dist/string/str.mjs.map +1 -1
  392. package/dist/types.mjs +3 -2
  393. package/dist/types.mjs.map +1 -1
  394. package/package.json +5 -6
  395. package/src/array/impl/array-utils-length-constraint-preservation.test.mts +2 -2
  396. package/src/collections/imap-mapped.mts +4 -4
  397. package/src/collections/imap.mts +1 -1
  398. package/src/collections/imap.test.mts +1 -1
  399. package/src/collections/iset-mapped.mts +2 -1
  400. package/src/collections/iset.mts +1 -1
  401. package/src/functional/async-result.test.mts +3 -2
  402. package/src/functional/optional.test.mts +2 -1
  403. package/src/functional/result.test.mts +0 -2
  404. package/src/guard/is-non-empty-string.test.mts +2 -2
  405. package/src/guard/is-non-null-object.test.mts +3 -3
  406. package/src/guard/is-primitive.test.mts +3 -3
  407. package/src/guard/is-type.test.mts +3 -3
  408. package/src/json/json.test.mts +1 -1
  409. package/src/number/enum/int8.mts +1 -1
@@ -1,146 +1,175 @@
1
- import { none } from '../functional/optional/impl/optional-none.mjs';
2
- import { some } from '../functional/optional/impl/optional-some.mjs';
3
- import '@sindresorhus/is';
4
- import { range } from '../iterator/range.mjs';
5
- import '../number/branded-types/finite-number.mjs';
6
- import '../number/branded-types/int.mjs';
7
- import '../number/branded-types/int16.mjs';
8
- import '../number/branded-types/int32.mjs';
9
- import '../number/branded-types/negative-finite-number.mjs';
10
- import '../number/branded-types/negative-int.mjs';
11
- import '../number/branded-types/negative-safe-int.mjs';
12
- import '../number/branded-types/non-negative-finite-number.mjs';
13
- import '../number/branded-types/non-negative-int16.mjs';
14
- import '../number/branded-types/non-negative-int32.mjs';
15
- import '../number/branded-types/non-positive-finite-number.mjs';
16
- import '../number/branded-types/non-positive-int.mjs';
17
- import '../number/branded-types/non-positive-safe-int.mjs';
18
- import '../number/branded-types/non-zero-finite-number.mjs';
19
- import '../number/branded-types/non-zero-int.mjs';
20
- import '../number/branded-types/non-zero-int16.mjs';
21
- import '../number/branded-types/non-zero-int32.mjs';
22
- import '../number/branded-types/non-zero-safe-int.mjs';
23
- import '../number/branded-types/non-zero-uint16.mjs';
24
- import '../number/branded-types/non-zero-uint32.mjs';
25
- import '../number/branded-types/positive-finite-number.mjs';
26
- import '../number/branded-types/positive-int.mjs';
27
- import '../number/branded-types/positive-int16.mjs';
28
- import '../number/branded-types/positive-int32.mjs';
29
- import '../number/branded-types/positive-safe-int.mjs';
30
- import '../number/branded-types/positive-uint16.mjs';
31
- import '../number/branded-types/positive-uint32.mjs';
32
- import '../number/branded-types/safe-int.mjs';
33
- import '../number/branded-types/safe-uint.mjs';
34
- import '../number/branded-types/uint.mjs';
35
- import '../number/branded-types/uint16.mjs';
36
- import { asUint32, Uint32 } from '../number/branded-types/uint32.mjs';
37
- import '../number/enum/int8.mjs';
38
- import '../number/enum/uint8.mjs';
39
- import '../number/num.mjs';
40
- import '../number/refined-number-utils.mjs';
41
-
1
+ import { Optional } from '../functional/index.mjs';
2
+ import { range } from '../iterator/index.mjs';
3
+ import { asUint32, Uint32 } from '../number/index.mjs';
4
+ /**
5
+ * Class implementation for a stack with LIFO (Last-In, First-Out) behavior
6
+ * using a dynamic array. This implementation provides O(1) amortized push and
7
+ * O(1) pop operations by using a resizable buffer that grows as needed.
8
+ *
9
+ * The underlying array automatically resizes when it becomes full, ensuring
10
+ * that the stack can grow to accommodate any number of elements while
11
+ * maintaining efficient operations.
12
+ *
13
+ * @template T The type of elements in the stack.
14
+ * @implements Stack
15
+ */
42
16
  class StackClass {
43
- /** @internal Initial capacity for new stacks. */
44
- static #INITIAL_CAPACITY = 8;
45
- /** @internal Dynamic array to store stack elements. */
46
- #mut_buffer;
47
- /** @internal Current number of elements in the stack. */
48
- #mut_size;
49
- /** @internal Current capacity of the buffer. */
50
- #mut_capacity;
51
- /**
52
- * Constructs a new StackClass instance.
53
- *
54
- * @param initialValues Optional initial values to populate the stack.
55
- */
56
- constructor(initialValues = []) {
57
- const initialCapacity = asUint32(
58
- Math.max(StackClass.#INITIAL_CAPACITY, initialValues.length * 2)
59
- );
60
- this.#mut_buffer = Array.from(
61
- { length: initialCapacity },
62
- () => void 0
63
- );
64
- this.#mut_size = asUint32(0);
65
- this.#mut_capacity = initialCapacity;
66
- for (const value of initialValues) {
67
- this.push(value);
17
+ /** @internal Initial capacity for new stacks. */
18
+ static #INITIAL_CAPACITY = 8;
19
+ /** @internal Dynamic array to store stack elements. */
20
+ #mut_buffer;
21
+ /** @internal Current number of elements in the stack. */
22
+ #mut_size;
23
+ /** @internal Current capacity of the buffer. */
24
+ #mut_capacity;
25
+ /**
26
+ * Constructs a new StackClass instance.
27
+ *
28
+ * @param initialValues Optional initial values to populate the stack.
29
+ */
30
+ constructor(initialValues = []) {
31
+ const initialCapacity = asUint32(Math.max(StackClass.#INITIAL_CAPACITY, initialValues.length * 2));
32
+ this.#mut_buffer = Array.from({ length: initialCapacity }, () => undefined);
33
+ this.#mut_size = asUint32(0);
34
+ this.#mut_capacity = initialCapacity;
35
+ // Add initial values
36
+ for (const value of initialValues) {
37
+ this.push(value);
38
+ }
68
39
  }
69
- }
70
- /**
71
- * @internal
72
- * Resizes the buffer when it becomes full.
73
- * Doubles the capacity while preserving all elements.
74
- */
75
- #resize() {
76
- const newCapacity = asUint32(this.#mut_capacity * 2);
77
- const newBuffer = Array.from(
78
- { length: newCapacity },
79
- () => void 0
80
- );
81
- for (const i of range(this.#mut_size)) {
82
- newBuffer[i] = this.#mut_buffer[i];
40
+ /**
41
+ * @internal
42
+ * Resizes the buffer when it becomes full.
43
+ * Doubles the capacity while preserving all elements.
44
+ */
45
+ #resize() {
46
+ const newCapacity = asUint32(this.#mut_capacity * 2);
47
+ const newBuffer = Array.from({ length: newCapacity }, () => undefined);
48
+ // Copy existing elements
49
+ for (const i of range(this.#mut_size)) {
50
+ newBuffer[i] = this.#mut_buffer[i];
51
+ }
52
+ this.#mut_buffer = newBuffer;
53
+ this.#mut_capacity = newCapacity;
83
54
  }
84
- this.#mut_buffer = newBuffer;
85
- this.#mut_capacity = newCapacity;
86
- }
87
- /** @inheritdoc */
88
- get isEmpty() {
89
- return this.#mut_size === 0;
90
- }
91
- /** @inheritdoc */
92
- get size() {
93
- return asUint32(this.#mut_size);
94
- }
95
- /**
96
- * Removes and returns the element at the top of the stack (LIFO).
97
- *
98
- * This operation removes the element that was added most recently (last-in)
99
- * and returns it. If the stack is empty, returns `Optional.none`. The
100
- * operation is guaranteed to be O(1) and does not require any array resizing
101
- * or memory reallocation.
102
- *
103
- * **Time Complexity:** O(1) - constant time operation **Space Complexity:**
104
- * O(1) - no additional memory allocation
105
- *
106
- * @returns An Optional containing the removed element, or `Optional.none` if
107
- * the stack is empty.
108
- */
109
- pop() {
110
- if (this.isEmpty) {
111
- return none;
55
+ /** @inheritdoc */
56
+ get isEmpty() {
57
+ return this.#mut_size === 0;
112
58
  }
113
- this.#mut_size = Uint32.sub(this.#mut_size, 1);
114
- const element = this.#mut_buffer[this.#mut_size];
115
- this.#mut_buffer[this.#mut_size] = void 0;
116
- return some(element);
117
- }
118
- /**
119
- * Adds an element to the top of the stack (LIFO).
120
- *
121
- * This operation adds the element to the top of the stack, where it will be
122
- * the first to be popped (last-in, first-out ordering). The operation is
123
- * amortized O(1), meaning it's O(1) for most operations with occasional O(n)
124
- * when the buffer needs resizing.
125
- *
126
- * **Time Complexity:** O(1) amortized - O(n) only when buffer resize is
127
- * needed **Space Complexity:** O(1) - constant additional memory per element
128
- *
129
- * **Buffer Resizing:** When the internal buffer becomes full, it
130
- * automatically doubles in size and copies existing elements to maintain the
131
- * stack structure.
132
- *
133
- * @param value The element to add to the top of the stack.
134
- */
135
- push(value) {
136
- if (this.#mut_size === this.#mut_capacity) {
137
- this.#resize();
59
+ /** @inheritdoc */
60
+ get size() {
61
+ return asUint32(this.#mut_size);
62
+ }
63
+ /**
64
+ * Removes and returns the element at the top of the stack (LIFO).
65
+ *
66
+ * This operation removes the element that was added most recently (last-in)
67
+ * and returns it. If the stack is empty, returns `Optional.none`. The
68
+ * operation is guaranteed to be O(1) and does not require any array resizing
69
+ * or memory reallocation.
70
+ *
71
+ * **Time Complexity:** O(1) - constant time operation **Space Complexity:**
72
+ * O(1) - no additional memory allocation
73
+ *
74
+ * @returns An Optional containing the removed element, or `Optional.none` if
75
+ * the stack is empty.
76
+ */
77
+ pop() {
78
+ if (this.isEmpty) {
79
+ return Optional.none;
80
+ }
81
+ this.#mut_size = Uint32.sub(this.#mut_size, 1);
82
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
83
+ const element = this.#mut_buffer[this.#mut_size];
84
+ this.#mut_buffer[this.#mut_size] = undefined; // Clear reference for garbage collection
85
+ return Optional.some(element);
86
+ }
87
+ /**
88
+ * Adds an element to the top of the stack (LIFO).
89
+ *
90
+ * This operation adds the element to the top of the stack, where it will be
91
+ * the first to be popped (last-in, first-out ordering). The operation is
92
+ * amortized O(1), meaning it's O(1) for most operations with occasional O(n)
93
+ * when the buffer needs resizing.
94
+ *
95
+ * **Time Complexity:** O(1) amortized - O(n) only when buffer resize is
96
+ * needed **Space Complexity:** O(1) - constant additional memory per element
97
+ *
98
+ * **Buffer Resizing:** When the internal buffer becomes full, it
99
+ * automatically doubles in size and copies existing elements to maintain the
100
+ * stack structure.
101
+ *
102
+ * @param value The element to add to the top of the stack.
103
+ */
104
+ push(value) {
105
+ // Resize if buffer is full
106
+ if (this.#mut_size === this.#mut_capacity) {
107
+ this.#resize();
108
+ }
109
+ this.#mut_buffer[this.#mut_size] = value;
110
+ this.#mut_size = Uint32.add(this.#mut_size, 1);
138
111
  }
139
- this.#mut_buffer[this.#mut_size] = value;
140
- this.#mut_size = Uint32.add(this.#mut_size, 1);
141
- }
142
112
  }
143
- const createStack = (initialValues) => new StackClass(initialValues);
144
-
145
- export { createStack };
146
- //# sourceMappingURL=stack.mjs.map
113
+ /**
114
+ * Creates a new Stack instance with LIFO (Last-In, First-Out) behavior using a
115
+ * high-performance dynamic array.
116
+ *
117
+ * This factory function creates an optimized stack implementation that
118
+ * maintains excellent performance characteristics for both push and pop
119
+ * operations. The underlying dynamic array automatically resizes to accommodate
120
+ * growing workloads while providing predictable O(1) operations.
121
+ *
122
+ * **Implementation Features:**
123
+ *
124
+ * - **O(1) push operations** (amortized - occasionally O(n) when resizing)
125
+ * - **O(1) pop operations** (always)
126
+ * - **Automatic buffer resizing** - starts at 8 elements, doubles when full
127
+ * - **Memory efficient** - garbage collects removed elements immediately
128
+ * - **Dynamic array design** - eliminates need for complex memory management
129
+ *
130
+ * **Performance Benefits:**
131
+ *
132
+ * - No array shifting required for stack operations
133
+ * - Minimal memory allocation overhead
134
+ * - Predictable performance under high load
135
+ * - Efficient memory usage with automatic cleanup
136
+ *
137
+ * @example
138
+ *
139
+ * ```ts
140
+ * const stack = createStack<string>();
141
+ *
142
+ * assert.isTrue(stack.isEmpty);
143
+ *
144
+ * assert.isTrue(stack.size === 0);
145
+ *
146
+ * stack.push('first');
147
+ *
148
+ * stack.push('second');
149
+ *
150
+ * assert.isFalse(stack.isEmpty);
151
+ *
152
+ * assert.isTrue(stack.size === 2);
153
+ *
154
+ * assert.deepStrictEqual(stack.pop(), Optional.some('second'));
155
+ *
156
+ * assert.deepStrictEqual(stack.pop(), Optional.some('first'));
157
+ *
158
+ * assert.deepStrictEqual(stack.pop(), Optional.none);
159
+ *
160
+ * const seededStack = createStack([10, 20, 30]);
161
+ *
162
+ * assert.isTrue(seededStack.size === 3);
163
+ *
164
+ * assert.deepStrictEqual(seededStack.pop(), Optional.some(30));
165
+ * ```
166
+ *
167
+ * @template T The type of elements stored in the stack.
168
+ * @param initialValues Optional array of initial elements to populate the
169
+ * stack. Elements will be popped in reverse order of how they appear in the
170
+ * array (last array element will be popped first). If provided, the initial
171
+ * buffer capacity will be at least twice the array length.
172
+ * @returns A new Stack instance optimized for high-performance LIFO operations.
173
+ */
174
+ export const createStack = (initialValues) => new StackClass(initialValues);
175
+ //# sourceMappingURL=stack.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"stack.mjs","sources":["../../src/collections/stack.mts"],"sourcesContent":["import { Optional } from '../functional/index.mjs';\nimport { range } from '../iterator/index.mjs';\nimport { asUint32, Uint32 } from '../number/index.mjs';\nimport { type SizeType } from '../types.mjs';\n\n/**\n * Interface for a high-performance stack with LIFO (Last-In, First-Out)\n * behavior.\n *\n * This interface defines a mutable stack data structure where elements are\n * added to and removed from the top, following the Last-In, First-Out\n * principle. The implementation uses a dynamic array for optimal performance,\n * providing O(1) operations for both push and pop operations.\n *\n * **LIFO Behavior:**\n *\n * - **push**: Adds elements to the top of the stack\n * - **pop**: Removes and returns elements from the top of the stack\n * - The last element added is the first element to be removed\n *\n * **Performance Characteristics:**\n *\n * - Push: O(1) amortized (O(n) when buffer needs resizing)\n * - Pop: O(1) always\n * - Size/isEmpty: O(1) always\n * - Memory efficient with automatic garbage collection of removed elements\n *\n * **Use Cases:**\n *\n * - Function call management and recursion\n * - Undo/redo functionality\n * - Expression evaluation and parsing\n * - Depth-first search algorithms\n * - Backtracking algorithms\n * - Browser history management\n *\n * @template T The type of elements stored in the stack.\n */\nexport type Stack<T> = Readonly<{\n /**\n * Checks if the stack is empty.\n *\n * @example\n *\n * ```ts\n * const stack = createStack<string>();\n *\n * assert.isTrue(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 0);\n *\n * stack.push('first');\n *\n * stack.push('second');\n *\n * assert.isFalse(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 2);\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('second'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('first'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.none);\n *\n * const seededStack = createStack([10, 20, 30]);\n *\n * assert.isTrue(seededStack.size === 3);\n *\n * assert.deepStrictEqual(seededStack.pop(), Optional.some(30));\n * ```\n */\n isEmpty: boolean;\n\n /**\n * The number of elements in the stack.\n *\n * @example\n *\n * ```ts\n * const stack = createStack<string>();\n *\n * assert.isTrue(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 0);\n *\n * stack.push('first');\n *\n * stack.push('second');\n *\n * assert.isFalse(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 2);\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('second'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('first'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.none);\n *\n * const seededStack = createStack([10, 20, 30]);\n *\n * assert.isTrue(seededStack.size === 3);\n *\n * assert.deepStrictEqual(seededStack.pop(), Optional.some(30));\n * ```\n */\n size: SizeType.Arr;\n\n /**\n * Removes and returns the element at the top of the stack.\n *\n * @example\n *\n * ```ts\n * const stack = createStack<string>();\n *\n * assert.isTrue(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 0);\n *\n * stack.push('first');\n *\n * stack.push('second');\n *\n * assert.isFalse(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 2);\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('second'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('first'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.none);\n *\n * const seededStack = createStack([10, 20, 30]);\n *\n * assert.isTrue(seededStack.size === 3);\n *\n * assert.deepStrictEqual(seededStack.pop(), Optional.some(30));\n * ```\n *\n * @returns The element at the top of the stack, or `Optional.none` if the\n * stack is empty.\n */\n pop: () => Optional<T>;\n\n /**\n * Adds an element to the top of the stack.\n *\n * @example\n *\n * ```ts\n * const stack = createStack<string>();\n *\n * assert.isTrue(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 0);\n *\n * stack.push('first');\n *\n * stack.push('second');\n *\n * assert.isFalse(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 2);\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('second'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('first'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.none);\n *\n * const seededStack = createStack([10, 20, 30]);\n *\n * assert.isTrue(seededStack.size === 3);\n *\n * assert.deepStrictEqual(seededStack.pop(), Optional.some(30));\n * ```\n *\n * @param value The element to add.\n */\n push: (value: T) => void;\n}>;\n\n/**\n * Class implementation for a stack with LIFO (Last-In, First-Out) behavior\n * using a dynamic array. This implementation provides O(1) amortized push and\n * O(1) pop operations by using a resizable buffer that grows as needed.\n *\n * The underlying array automatically resizes when it becomes full, ensuring\n * that the stack can grow to accommodate any number of elements while\n * maintaining efficient operations.\n *\n * @template T The type of elements in the stack.\n * @implements Stack\n */\nclass StackClass<T> implements Stack<T> {\n /** @internal Initial capacity for new stacks. */\n static readonly #INITIAL_CAPACITY = 8;\n\n /** @internal Dynamic array to store stack elements. */\n #mut_buffer: (T | undefined)[];\n\n /** @internal Current number of elements in the stack. */\n #mut_size: Uint32;\n\n /** @internal Current capacity of the buffer. */\n #mut_capacity: Uint32;\n\n /**\n * Constructs a new StackClass instance.\n *\n * @param initialValues Optional initial values to populate the stack.\n */\n constructor(initialValues: readonly T[] = []) {\n const initialCapacity = asUint32(\n Math.max(StackClass.#INITIAL_CAPACITY, initialValues.length * 2),\n );\n\n this.#mut_buffer = Array.from<unknown, T | undefined>(\n { length: initialCapacity },\n () => undefined,\n );\n\n this.#mut_size = asUint32(0);\n\n this.#mut_capacity = initialCapacity;\n\n // Add initial values\n for (const value of initialValues) {\n this.push(value);\n }\n }\n\n /**\n * @internal\n * Resizes the buffer when it becomes full.\n * Doubles the capacity while preserving all elements.\n */\n #resize(): void {\n const newCapacity = asUint32(this.#mut_capacity * 2);\n\n const newBuffer = Array.from<unknown, T | undefined>(\n { length: newCapacity },\n () => undefined,\n );\n\n // Copy existing elements\n for (const i of range(this.#mut_size)) {\n newBuffer[i] = this.#mut_buffer[i];\n }\n\n this.#mut_buffer = newBuffer;\n\n this.#mut_capacity = newCapacity;\n }\n\n /** @inheritdoc */\n get isEmpty(): boolean {\n return this.#mut_size === 0;\n }\n\n /** @inheritdoc */\n get size(): SizeType.Arr {\n return asUint32(this.#mut_size);\n }\n\n /**\n * Removes and returns the element at the top of the stack (LIFO).\n *\n * This operation removes the element that was added most recently (last-in)\n * and returns it. If the stack is empty, returns `Optional.none`. The\n * operation is guaranteed to be O(1) and does not require any array resizing\n * or memory reallocation.\n *\n * **Time Complexity:** O(1) - constant time operation **Space Complexity:**\n * O(1) - no additional memory allocation\n *\n * @returns An Optional containing the removed element, or `Optional.none` if\n * the stack is empty.\n */\n pop(): Optional<T> {\n if (this.isEmpty) {\n return Optional.none;\n }\n\n this.#mut_size = Uint32.sub(this.#mut_size, 1);\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const element = this.#mut_buffer[this.#mut_size]!;\n\n this.#mut_buffer[this.#mut_size] = undefined; // Clear reference for garbage collection\n\n return Optional.some(element);\n }\n\n /**\n * Adds an element to the top of the stack (LIFO).\n *\n * This operation adds the element to the top of the stack, where it will be\n * the first to be popped (last-in, first-out ordering). The operation is\n * amortized O(1), meaning it's O(1) for most operations with occasional O(n)\n * when the buffer needs resizing.\n *\n * **Time Complexity:** O(1) amortized - O(n) only when buffer resize is\n * needed **Space Complexity:** O(1) - constant additional memory per element\n *\n * **Buffer Resizing:** When the internal buffer becomes full, it\n * automatically doubles in size and copies existing elements to maintain the\n * stack structure.\n *\n * @param value The element to add to the top of the stack.\n */\n push(value: T): void {\n // Resize if buffer is full\n if (this.#mut_size === this.#mut_capacity) {\n this.#resize();\n }\n\n this.#mut_buffer[this.#mut_size] = value;\n\n this.#mut_size = Uint32.add(this.#mut_size, 1);\n }\n}\n\n/**\n * Creates a new Stack instance with LIFO (Last-In, First-Out) behavior using a\n * high-performance dynamic array.\n *\n * This factory function creates an optimized stack implementation that\n * maintains excellent performance characteristics for both push and pop\n * operations. The underlying dynamic array automatically resizes to accommodate\n * growing workloads while providing predictable O(1) operations.\n *\n * **Implementation Features:**\n *\n * - **O(1) push operations** (amortized - occasionally O(n) when resizing)\n * - **O(1) pop operations** (always)\n * - **Automatic buffer resizing** - starts at 8 elements, doubles when full\n * - **Memory efficient** - garbage collects removed elements immediately\n * - **Dynamic array design** - eliminates need for complex memory management\n *\n * **Performance Benefits:**\n *\n * - No array shifting required for stack operations\n * - Minimal memory allocation overhead\n * - Predictable performance under high load\n * - Efficient memory usage with automatic cleanup\n *\n * @example\n *\n * ```ts\n * const stack = createStack<string>();\n *\n * assert.isTrue(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 0);\n *\n * stack.push('first');\n *\n * stack.push('second');\n *\n * assert.isFalse(stack.isEmpty);\n *\n * assert.isTrue(stack.size === 2);\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('second'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.some('first'));\n *\n * assert.deepStrictEqual(stack.pop(), Optional.none);\n *\n * const seededStack = createStack([10, 20, 30]);\n *\n * assert.isTrue(seededStack.size === 3);\n *\n * assert.deepStrictEqual(seededStack.pop(), Optional.some(30));\n * ```\n *\n * @template T The type of elements stored in the stack.\n * @param initialValues Optional array of initial elements to populate the\n * stack. Elements will be popped in reverse order of how they appear in the\n * array (last array element will be popped first). If provided, the initial\n * buffer capacity will be at least twice the array length.\n * @returns A new Stack instance optimized for high-performance LIFO operations.\n */\nexport const createStack = <T,>(initialValues?: readonly T[]): Stack<T> =>\n new StackClass<T>(initialValues);\n"],"names":["Optional.none","Optional.some"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqMA,MAAM,UAAA,CAAkC;AAAA;AAAA,EAEtC,OAAgB,iBAAA,GAAoB,CAAA;AAAA;AAAA,EAGpC,WAAA;AAAA;AAAA,EAGA,SAAA;AAAA;AAAA,EAGA,aAAA;AAAA;AAAA;AAAA;A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1
- import * as index from './array/impl/index.mjs';
2
- export { index as Arr };
3
- import * as index$1 from './functional/async-result/impl/index.mjs';
4
- export { index$1 as AsyncResult };
5
- export { match } from './functional/match.mjs';
6
- import * as index$2 from './functional/optional/impl/index.mjs';
7
- export { index$2 as Optional };
8
- export { pipe } from './functional/pipe.mjs';
9
- import * as index$3 from './functional/result/impl/index.mjs';
10
- export { index$3 as Result };
11
- import * as index$4 from './functional/ternary-result/impl/index.mjs';
12
- export { index$4 as TernaryResult };
13
- export { IMapMapped } from './collections/imap-mapped.mjs';
14
- export { IMap } from './collections/imap.mjs';
15
- export { ISetMapped } from './collections/iset-mapped.mjs';
16
- export { ISet } from './collections/iset.mjs';
17
- export { createQueue } from './collections/queue.mjs';
18
- export { createStack } from './collections/stack.mjs';
19
- export { expectType } from './expect-type.mjs';
20
- export { hasKey } from './guard/has-key.mjs';
21
- export { isNonEmptyString } from './guard/is-non-empty-string.mjs';
22
- export { isNonNullObject } from './guard/is-non-null-object.mjs';
23
- export { isPrimitive } from './guard/is-primitive.mjs';
24
- export { isMutableRecord, isRecord } from './guard/is-record.mjs';
25
- export { isBigint, isBoolean, isNonNullish, isNotBigint, isNotBoolean, isNotNull, isNotNumber, isNotString, isNotSymbol, isNotUndefined, isNull, isNullish, isNumber, isString, isSymbol, isUndefined } from './guard/is-type.mjs';
26
- export { keyIsIn } from './guard/key-is-in.mjs';
27
- export { range } from './iterator/range.mjs';
28
- export { Json } from './json/json.mjs';
29
- export { FiniteNumber, asFiniteNumber, isFiniteNumber } from './number/branded-types/finite-number.mjs';
30
- export { Int, asInt, isInt } from './number/branded-types/int.mjs';
31
- export { Int16, asInt16, isInt16 } from './number/branded-types/int16.mjs';
32
- export { Int32, asInt32, isInt32 } from './number/branded-types/int32.mjs';
33
- export { NegativeFiniteNumber, asNegativeFiniteNumber, isNegativeFiniteNumber } from './number/branded-types/negative-finite-number.mjs';
34
- export { NegativeInt, asNegativeInt, isNegativeInt } from './number/branded-types/negative-int.mjs';
35
- export { NegativeSafeInt, asNegativeSafeInt, isNegativeSafeInt } from './number/branded-types/negative-safe-int.mjs';
36
- export { NonNegativeFiniteNumber, asNonNegativeFiniteNumber, isNonNegativeFiniteNumber } from './number/branded-types/non-negative-finite-number.mjs';
37
- export { NonNegativeInt16, asNonNegativeInt16, isNonNegativeInt16 } from './number/branded-types/non-negative-int16.mjs';
38
- export { NonNegativeInt32, asNonNegativeInt32, isNonNegativeInt32 } from './number/branded-types/non-negative-int32.mjs';
39
- export { NonPositiveFiniteNumber, asNonPositiveFiniteNumber, isNonPositiveFiniteNumber } from './number/branded-types/non-positive-finite-number.mjs';
40
- export { NonPositiveInt, asNonPositiveInt, isNonPositiveInt } from './number/branded-types/non-positive-int.mjs';
41
- export { NonPositiveSafeInt, asNonPositiveSafeInt, isNonPositiveSafeInt } from './number/branded-types/non-positive-safe-int.mjs';
42
- export { NonZeroFiniteNumber, asNonZeroFiniteNumber, isNonZeroFiniteNumber } from './number/branded-types/non-zero-finite-number.mjs';
43
- export { NonZeroInt, asNonZeroInt, isNonZeroInt } from './number/branded-types/non-zero-int.mjs';
44
- export { NonZeroInt16, asNonZeroInt16, isNonZeroInt16 } from './number/branded-types/non-zero-int16.mjs';
45
- export { NonZeroInt32, asNonZeroInt32, isNonZeroInt32 } from './number/branded-types/non-zero-int32.mjs';
46
- export { NonZeroSafeInt, asNonZeroSafeInt, isNonZeroSafeInt } from './number/branded-types/non-zero-safe-int.mjs';
47
- export { NonZeroUint16, asNonZeroUint16, isNonZeroUint16 } from './number/branded-types/non-zero-uint16.mjs';
48
- export { NonZeroUint32, asNonZeroUint32, isNonZeroUint32 } from './number/branded-types/non-zero-uint32.mjs';
49
- export { PositiveFiniteNumber, asPositiveFiniteNumber, isPositiveFiniteNumber } from './number/branded-types/positive-finite-number.mjs';
50
- export { PositiveInt, asPositiveInt, isPositiveInt } from './number/branded-types/positive-int.mjs';
51
- export { PositiveInt16, asPositiveInt16, isPositiveInt16 } from './number/branded-types/positive-int16.mjs';
52
- export { PositiveInt32, asPositiveInt32, isPositiveInt32 } from './number/branded-types/positive-int32.mjs';
53
- export { PositiveSafeInt, asPositiveSafeInt, isPositiveSafeInt } from './number/branded-types/positive-safe-int.mjs';
54
- export { PositiveUint16, asPositiveUint16, isPositiveUint16 } from './number/branded-types/positive-uint16.mjs';
55
- export { PositiveUint32, asPositiveUint32, isPositiveUint32 } from './number/branded-types/positive-uint32.mjs';
56
- export { SafeInt, asSafeInt, isSafeInt } from './number/branded-types/safe-int.mjs';
57
- export { SafeUint, asSafeUint, isSafeUint } from './number/branded-types/safe-uint.mjs';
58
- export { Uint, asUint, isUint } from './number/branded-types/uint.mjs';
59
- export { Uint16, asUint16, isUint16 } from './number/branded-types/uint16.mjs';
60
- export { Uint32, asUint32, isUint32 } from './number/branded-types/uint32.mjs';
61
- export { Int8, asInt8, isInt8 } from './number/enum/int8.mjs';
62
- export { Uint8, asUint8, isUint8 } from './number/enum/uint8.mjs';
63
- export { Num } from './number/num.mjs';
64
- export { TsDataForgeInternals } from './number/refined-number-utils.mjs';
65
- export { Obj } from './object/object.mjs';
66
- export { castDeepMutable, castMutable } from './others/cast-mutable.mjs';
67
- export { castDeepReadonly, castReadonly } from './others/cast-readonly.mjs';
68
- export { debounce } from './others/debounce-function.mjs';
69
- export { fastDeepEqual } from './others/fast-deep-equal.mjs';
70
- export { ifThen, implies } from './others/if-then.mjs';
71
- export { mapNullable } from './others/map-nullable.mjs';
72
- export { memoizeFunction } from './others/memoize-function.mjs';
73
- export { tp } from './others/tuple.mjs';
74
- export { unknownToString } from './others/unknown-to-string.mjs';
75
- export { createPromise } from './promise/promise.mjs';
76
- export { Str } from './string/str.mjs';
77
- //# sourceMappingURL=entry-point.mjs.map
1
+ export * from './array/index.mjs';
2
+ export * from './functional/index.mjs';
3
+ export * from './index.mjs';
4
+ //# sourceMappingURL=entry-point.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"entry-point.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"entry-point.mjs","sourceRoot":"","sources":["../src/entry-point.mts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC"}
@@ -1,4 +1,70 @@
1
- const expectType = (_relation) => void 0;
2
-
3
- export { expectType };
4
- //# sourceMappingURL=expect-type.mjs.map
1
+ /**
2
+ * Compile-time type assertion utility for TypeScript type testing.
3
+ *
4
+ * This function performs static type relationship checking at compile-time and
5
+ * has no runtime effect. It is primarily used in test files to verify that
6
+ * TypeScript's type inference and type relationships work as expected. The
7
+ * function will cause TypeScript compilation errors if the specified type
8
+ * relationship does not hold.
9
+ *
10
+ * ## Supported Type Relations
11
+ *
12
+ * ### Equality Relations
13
+ *
14
+ * - **`"="` (strict equality)**: Asserts that types `A` and `B` are exactly the
15
+ * same type. Uses TypeScript's internal type equality checking.
16
+ * - **`"!="` (strict inequality)**: Asserts that types `A` and `B` are not
17
+ * exactly the same type.
18
+ *
19
+ * ### Assignability Relations
20
+ *
21
+ * - **`"~="` (mutual assignability)**: Asserts that `A` extends `B` AND `B`
22
+ * extends `A`. Types are structurally equivalent and mutually assignable.
23
+ * - **`"<="` (subtype relation)**: Asserts that type `A` extends (is assignable
24
+ * to) type `B`. Type `A` is a subtype of `B`.
25
+ * - **`">="` (supertype relation)**: Asserts that type `B` extends (is assignable
26
+ * to) type `A`. Type `A` is a supertype of `B`.
27
+ *
28
+ * ### Negative Assignability Relations
29
+ *
30
+ * - **`"!<="` (not subtype)**: Asserts that type `A` does NOT extend type `B`.
31
+ * - **`"!>="` (not supertype)**: Asserts that type `B` does NOT extend type `A`.
32
+ *
33
+ * ## Type Parameter Constraints
34
+ *
35
+ * @since 1.0.0
36
+ * @template A - The first type for comparison. Can be any TypeScript type
37
+ * including:
38
+ *
39
+ * - Primitive types (string, number, boolean, etc.)
40
+ * - Object types and interfaces
41
+ * - Union and intersection types
42
+ * - Generic types and type parameters
43
+ * - Literal types and branded types
44
+ * - Function types and return types
45
+ *
46
+ * @template B - The second type for comparison. Same constraints as type `A`.
47
+ * @param _relation - A string literal representing the expected type
48
+ * relationship. TypeScript's type system automatically infers and restricts
49
+ * the available operators based on the actual relationship between types `A`
50
+ * and `B`. If an invalid relationship is specified, TypeScript will show a
51
+ * compilation error.
52
+ *
53
+ * Combine `expectType` with runtime assertions for comprehensive testing:
54
+ *
55
+ * ## Important Notes
56
+ *
57
+ * - **Compile-time only**: This function has no runtime behavior and will be
58
+ * optimized away.
59
+ * - **Type inference**: The available relation operators are automatically
60
+ * inferred by TypeScript based on the actual type relationship between
61
+ * `A` and `B`.
62
+ * - **Error feedback**: Invalid type relationships will cause clear TypeScript
63
+ * compilation errors.
64
+ * - **Test organization**: Typically used in `.test.mts` files alongside runtime
65
+ * assertions.
66
+ * - **Performance**: Has zero runtime overhead as it's purely a compile-time
67
+ * construct.
68
+ */
69
+ export const expectType = (_relation) => undefined;
70
+ //# sourceMappingURL=expect-type.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"expect-type.mjs","sources":["../src/expect-type.mts"],"sourcesContent":["import { type TypeEq, type TypeExtends } from 'ts-type-forge';\n\n/**\n * Compile-time type assertion utility for TypeScript type testing.\n *\n * This function performs static type relationship checking at compile-time and\n * has no runtime effect. It is primarily used in test files to verify that\n * TypeScript's type inference and type relationships work as expected. The\n * function will cause TypeScript compilation errors if the specified type\n * relationship does not hold.\n *\n * ## Supported Type Relations\n *\n * ### Equality Relations\n *\n * - **`\"=\"` (strict equality)**: Asserts that types `A` and `B` are exactly the\n * same type. Uses TypeScript's internal type equality checking.\n * - **`\"!=\"` (strict inequality)**: Asserts that types `A` and `B` are not\n * exactly the same type.\n *\n * ### Assignability Relations\n *\n * - **`\"~=\"` (mutual assignability)**: Asserts that `A` extends `B` AND `B`\n * extends `A`. Types are structurally equivalent and mutually assignable.\n * - **`\"<=\"` (subtype relation)**: Asserts that type `A` extends (is assignable\n * to) type `B`. Type `A` is a subtype of `B`.\n * - **`\">=\"` (supertype relation)**: Asserts that type `B` extends (is assignable\n * to) type `A`. Type `A` is a supertype of `B`.\n *\n * ### Negative Assignability Relations\n *\n * - **`\"!<=\"` (not subtype)**: Asserts that type `A` does NOT extend type `B`.\n * - **`\"!>=\"` (not supertype)**: Asserts that type `B` does NOT extend type `A`.\n *\n * ## Type Parameter Constraints\n *\n * @since 1.0.0\n * @template A - The first type for comparison. Can be any TypeScript type\n * including:\n *\n * - Primitive types (string, number, boolean, etc.)\n * - Object types and interfaces\n * - Union and intersection types\n * - Generic types and type parameters\n * - Literal types and branded types\n * - Function types and return types\n *\n * @template B - The second type for comparison. Same constraints as type `A`.\n * @param _relation - A string literal representing the expected type\n * relationship. TypeScript's type system automatically infers and restricts\n * the available operators based on the actual relationship between types `A`\n * and `B`. If an invalid relationship is specified, TypeScript will show a\n * compilation error.\n *\n * Combine `expectType` with runtime assertions for comprehensive testing:\n *\n * ## Important Notes\n *\n * - **Compile-time only**: This function has no runtime behavior and will be\n * optimized away.\n * - **Type inference**: The available relation operators are automatically\n * inferred by TypeScript based on the actual type relationship between\n * `A` and `B`.\n * - **Error feedback**: Invalid type relationships will cause clear TypeScript\n * compilation errors.\n * - **Test organization**: Typically used in `.test.mts` files alongside runtime\n * assertions.\n * - **Performance**: Has zero runtime overhead as it's purely a compile-time\n * construct.\n */\nexport const expectType = <A, B>(\n _relation: TypeEq<A, B> extends true\n ? '<=' | '=' | '>=' | '~='\n : | '!='\n | (TypeExtends<A, B> extends true\n ? '<=' | (TypeExtends<B, A> extends true ? '>=' | '~=' : '!>=')\n : '!<=' | (TypeExtends<B, A> extends true ? '>=' : '!>=')),\n): void => undefined;\n"],"names":[],"mappings":"AAsEO,MAAM,UAAA,GAAa,CACxB,SAAA,KAMS;;;;"}
1
+ {"version":3,"file":"expect-type.mjs","sourceRoot":"","sources":["../src/expect-type.mts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,SAKkE,EAC5D,EAAE,CAAC,SAAS,CAAC"}
@@ -1,3 +1,2 @@
1
- import * as index from './impl/index.mjs';
2
- export { index as AsyncResult };
3
- //# sourceMappingURL=async-result.mjs.map
1
+ export * as AsyncResult from './impl/index.mjs';
2
+ //# sourceMappingURL=async-result.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"async-result.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"async-result.mjs","sourceRoot":"","sources":["../../../src/functional/async-result/async-result.mts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC"}
@@ -1,25 +1,23 @@
1
- import { isErr } from '../../result/impl/result-is-err.mjs';
2
- import '@sindresorhus/is';
3
-
4
- function flatMap(...args) {
5
- switch (args.length) {
6
- case 2: {
7
- const [asyncResult, flatMapFn] = args;
8
- return flatMapImpl(asyncResult, flatMapFn);
1
+ import { Result } from '../../result/index.mjs';
2
+ export function flatMap(...args) {
3
+ switch (args.length) {
4
+ case 2: {
5
+ // Direct version: first argument is asyncResult
6
+ const [asyncResult, flatMapFn] = args;
7
+ return flatMapImpl(asyncResult, flatMapFn);
8
+ }
9
+ case 1: {
10
+ // Curried version
11
+ const [flatMapFn] = args;
12
+ return (asyncResult) => flatMapImpl(asyncResult, flatMapFn);
13
+ }
9
14
  }
10
- case 1: {
11
- const [flatMapFn] = args;
12
- return (asyncResult) => flatMapImpl(asyncResult, flatMapFn);
13
- }
14
- }
15
15
  }
16
16
  const flatMapImpl = async (asyncResult, flatMapFn) => {
17
- const result = await asyncResult;
18
- return isErr(result) ? result : (
19
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion
20
- await flatMapFn(result.value)
21
- );
17
+ const result = await asyncResult;
18
+ return Result.isErr(result)
19
+ ? result
20
+ : // eslint-disable-next-line total-functions/no-unsafe-type-assertion
21
+ (await flatMapFn(result.value));
22
22
  };
23
-
24
- export { flatMap };
25
- //# sourceMappingURL=async-result-flat-map.mjs.map
23
+ //# sourceMappingURL=async-result-flat-map.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"async-result-flat-map.mjs","sources":["../../../../src/functional/async-result/impl/async-result-flat-map.mts"],"sourcesContent":["import { Result, type UnknownResult } from '../../result/index.mjs';\nimport { type AsyncResult } from '../async-result.mjs';\nimport {\n type UnknownAsyncResult,\n type UnwrapErr,\n type UnwrapOk,\n} from './types.mjs';\n\n/**\n * Applies a function that returns an `AsyncResult` or a `Result` to the\n * success value of an `AsyncResult`. If the input resolves to `Err`, the\n * original `Err` is passed through and the function is not called. This is\n * the monadic bind operation for `AsyncResult`.\n *\n * @example\n *\n * ```ts\n * const parseNumber = (input: string): Result<number, string> => {\n * const num = Number.parseInt(input, 10);\n *\n * return Number.isNaN(num) ? Result.err('not a number') : Result.ok(num);\n * };\n *\n * const input = AsyncResult.fromPromise(\n * Promise.resolve('42'),\n * () => 'failed',\n * );\n *\n * const parsed = await AsyncResult.flatMap(input, parseNumber);\n *\n * assert.deepStrictEqual(parsed, Result.ok(42));\n * ```\n *\n * @template S The type of the success value of the input.\n * @template E The type of the error value of the input.\n * @template R2 The `AsyncResult` or `Result` type returned by the function.\n * @param asyncResult The `AsyncResult` to flat map.\n * @param flatMapFn The function to apply that returns an `AsyncResult` or a\n * `Result`.\n * @returns The result of applying the function, or the original `Err`.\n */\nexport function flatMap<S, E, R2 extends UnknownAsyncResult | UnknownResult>(\n asyncResult: AsyncResult<S, E>,\n flatMapFn: (value: S) => R2,\n): AsyncResult<UnwrapOk<R2>, E | UnwrapErr<R2>>;\n\n// Curried version\n//\n// The function's return type is captured as a whole (`R2`) and unwrapped with\n// `UnwrapOk` / `UnwrapErr`, instead of being written as\n// `AsyncResult<S2, E2> | Result<S2, E2>` with separate `S2` / `E2` type\n// parameters. With the union form, inference for `E2` collects a candidate\n// from matching `Ok<S2>` against `Err<E2>` (both have a `value` property), so\n// `E2` ends up as the success type and the call fails to type-check even for\n// a function annotated as returning `Result<S2, E2>`.\nexport function flatMap<S, R2 extends UnknownAsyncResult | UnknownResult>(\n flatMapFn: (value: S) => R2,\n): <E>(\n asyncResult: AsyncResult<S, E>,\n) => AsyncResult<UnwrapOk<R2>, E | UnwrapErr<R2>>;\n\nexport function flatMap<S, E, R2 extends UnknownAsyncResult | UnknownResult>(\n ...args:\n | readonly [asyncResult: AsyncResult<S, E>, flatMapFn: (value: S) => R2]\n | readonly [flatMapFn: (value: S) => R2]\n):\n | AsyncResult<UnwrapOk<R2>, E | UnwrapErr<R2>>\n | ((\n asyncResult: AsyncResult<S, E>,\n ) => AsyncResult<UnwrapOk<R2>, E | UnwrapErr<R2>>) {\n switch (args.length) {\n case 2: {\n // Direct version: first argument is asyncResult\n const [asyncResult, flatMapFn] = args;\n\n return flatMapImpl(asyncResult, flatMapFn);\n }\n\n case 1: {\n // Curried version\n const [flatMapFn] = args;\n\n return (asyncResult: AsyncResult<S, E>) =>\n flatMapImpl(asyncResult, flatMapFn);\n }\n }\n}\n\nconst flatMapImpl = async <S, E, R2 extends UnknownAsyncResult | UnknownResult>(\n asyncResult: AsyncResult<S, E>,\n flatMapFn: (value: S) => R2,\n): AsyncResult<UnwrapOk<R2>, E | UnwrapErr<R2>> => {\n const result = await asyncResult;\n\n return Result.isErr(result)\n ? result\n : // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n ((await flatMapFn(result.value)) as Result<UnwrapOk<R2>, UnwrapErr<R2>>);\n};\n"],"names":["Result.isErr"],"mappings":";;;AA6DO,SAAS,WACX,IAAA,EAOkD;AACrD,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,WAAA,EAAa,SAAS,CAAA,GAAI,IAAA;AAEjC,MAAA,OAAO,WAAA,CAAY,aAAa,SAAS,CAAA;AAAA,IAC3C;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,SAAS,CAAA,GAAI,IAAA;AAEpB,MAAA,OAAO,CAAC,WAAA,KACN,WAAA,CAAY,WAAA,EAAa,SAAS,CAAA;AAAA,IACtC;AAAA;AAEJ;AAEA,MAAM,WAAA,GAAc,OAClB,WAAA,EACA,SAAA,KACiD;AACjD,EAAA,MAAM,SAAS,MAAM,WAAA;AAErB,EAAA,OAAOA,KAAO,CAAM,MAAM,CAAA,GACtB,MAAA;AAAA;AAAA,IAEE,MAAM,SAAA,CAAU,MAAA,CAAO,KAAK;AAAA,GAAA;AACpC,CAAA;;;;"}
1
+ {"version":3,"file":"async-result-flat-map.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-flat-map.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAsB,MAAM,wBAAwB,CAAC;AA6DpE,MAAM,UAAU,OAAO,CACrB,GAAG,IAEuC;IAM1C,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,gDAAgD;YAChD,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC;YAEtC,OAAO,WAAW,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAC7C,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,kBAAkB;YAClB,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;YAEzB,OAAO,CAAC,WAA8B,EAAE,EAAE,CACxC,WAAW,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,WAAW,GAAG,KAAK,EACvB,WAA8B,EAC9B,SAA2B,EACmB,EAAE;IAChD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC;IAEjC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;QACzB,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,oEAAoE;YACnE,CAAC,MAAM,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAyC,CAAC;AAC/E,CAAC,CAAC"}
@@ -1,11 +1,10 @@
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 fromPromise(promise, mapError) {
6
- return mapError === void 0 ? fromPromiseImpl(promise, (error) => error) : fromPromiseImpl(promise, mapError);
1
+ import { Result } from '../../result/index.mjs';
2
+ export function fromPromise(promise, mapError) {
3
+ return mapError === undefined
4
+ ? fromPromiseImpl(promise, (error) => error)
5
+ : fromPromiseImpl(promise, mapError);
7
6
  }
8
- const fromPromiseImpl = (promise, mapError) => promise.then((value) => ok(value)).catch((error) => err(mapError(error)));
9
-
10
- export { fromPromise };
11
- //# sourceMappingURL=async-result-from-promise.mjs.map
7
+ const fromPromiseImpl = (promise, mapError) => promise
8
+ .then((value) => Result.ok(value))
9
+ .catch((error) => Result.err(mapError(error)));
10
+ //# sourceMappingURL=async-result-from-promise.mjs.map