ts-data-forge 14.6.1 → 14.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (420) hide show
  1. package/dist/array/impl/array-utils-creation.mjs +126 -26
  2. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  3. package/dist/array/impl/array-utils-element-access.mjs +63 -30
  4. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  5. package/dist/array/impl/array-utils-iterators.mjs +68 -52
  6. package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
  7. package/dist/array/impl/array-utils-length-bounded-array-cast.mjs +109 -73
  8. package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -1
  9. package/dist/array/impl/array-utils-length-bounded-array-guard.mjs +70 -32
  10. package/dist/array/impl/array-utils-length-bounded-array-guard.mjs.map +1 -1
  11. package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs +102 -73
  12. package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs.map +1 -1
  13. package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs +77 -33
  14. package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs.map +1 -1
  15. package/dist/array/impl/array-utils-modification.mjs +75 -122
  16. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  17. package/dist/array/impl/array-utils-reducing-value.mjs +99 -149
  18. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  19. package/dist/array/impl/array-utils-search.mjs +112 -136
  20. package/dist/array/impl/array-utils-search.mjs.map +1 -1
  21. package/dist/array/impl/array-utils-set-op.mjs +146 -38
  22. package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
  23. package/dist/array/impl/array-utils-size.mjs +10 -8
  24. package/dist/array/impl/array-utils-size.mjs.map +1 -1
  25. package/dist/array/impl/array-utils-slice-clamped.mjs +13 -50
  26. package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
  27. package/dist/array/impl/array-utils-slicing.mjs +92 -76
  28. package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
  29. package/dist/array/impl/array-utils-transformation.mjs +291 -199
  30. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  31. package/dist/array/impl/array-utils-validation.mjs +53 -55
  32. package/dist/array/impl/array-utils-validation.mjs.map +1 -1
  33. package/dist/array/impl/index.mjs +17 -17
  34. package/dist/array/impl/index.mjs.map +1 -1
  35. package/dist/array/index.mjs +2 -3
  36. package/dist/array/index.mjs.map +1 -1
  37. package/dist/collections/imap-mapped.mjs +335 -292
  38. package/dist/collections/imap-mapped.mjs.map +1 -1
  39. package/dist/collections/imap.mjs +280 -239
  40. package/dist/collections/imap.mjs.map +1 -1
  41. package/dist/collections/index.mjs +7 -7
  42. package/dist/collections/index.mjs.map +1 -1
  43. package/dist/collections/iset-mapped.mjs +448 -265
  44. package/dist/collections/iset-mapped.mjs.map +1 -1
  45. package/dist/collections/iset.mjs +328 -201
  46. package/dist/collections/iset.mjs.map +1 -1
  47. package/dist/collections/queue.mjs +181 -149
  48. package/dist/collections/queue.mjs.map +1 -1
  49. package/dist/collections/stack.mjs +167 -138
  50. package/dist/collections/stack.mjs.map +1 -1
  51. package/dist/entry-point.mjs +4 -77
  52. package/dist/entry-point.mjs.map +1 -1
  53. package/dist/expect-type.mjs +69 -3
  54. package/dist/expect-type.mjs.map +1 -1
  55. package/dist/functional/async-result/async-result.mjs +2 -3
  56. package/dist/functional/async-result/async-result.mjs.map +1 -1
  57. package/dist/functional/async-result/impl/async-result-flat-map.mjs +18 -20
  58. package/dist/functional/async-result/impl/async-result-flat-map.mjs.map +1 -1
  59. package/dist/functional/async-result/impl/async-result-from-promise.mjs +9 -10
  60. package/dist/functional/async-result/impl/async-result-from-promise.mjs.map +1 -1
  61. package/dist/functional/async-result/impl/async-result-from-throwable.mjs +12 -14
  62. package/dist/functional/async-result/impl/async-result-from-throwable.mjs.map +1 -1
  63. package/dist/functional/async-result/impl/async-result-map-err.mjs +15 -18
  64. package/dist/functional/async-result/impl/async-result-map-err.mjs.map +1 -1
  65. package/dist/functional/async-result/impl/async-result-map.mjs +15 -18
  66. package/dist/functional/async-result/impl/async-result-map.mjs.map +1 -1
  67. package/dist/functional/async-result/impl/async-result-unwrap-or.mjs +35 -8
  68. package/dist/functional/async-result/impl/async-result-unwrap-or.mjs.map +1 -1
  69. package/dist/functional/async-result/impl/index.mjs +8 -7
  70. package/dist/functional/async-result/impl/index.mjs.map +1 -1
  71. package/dist/functional/async-result/impl/types.mjs +2 -2
  72. package/dist/functional/async-result/impl/types.mjs.map +1 -1
  73. package/dist/functional/async-result/index.mjs +2 -3
  74. package/dist/functional/async-result/index.mjs.map +1 -1
  75. package/dist/functional/index.mjs +7 -11
  76. package/dist/functional/index.mjs.map +1 -1
  77. package/dist/functional/match.mjs +27 -13
  78. package/dist/functional/match.mjs.map +1 -1
  79. package/dist/functional/optional/impl/index.mjs +19 -18
  80. package/dist/functional/optional/impl/index.mjs.map +1 -1
  81. package/dist/functional/optional/impl/optional-expect-to-be.mjs +15 -17
  82. package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
  83. package/dist/functional/optional/impl/optional-filter.mjs +16 -18
  84. package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
  85. package/dist/functional/optional/impl/optional-flat-map.mjs +12 -14
  86. package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
  87. package/dist/functional/optional/impl/optional-from-nullable.mjs +24 -3
  88. package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
  89. package/dist/functional/optional/impl/optional-is-none.mjs +19 -3
  90. package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -1
  91. package/dist/functional/optional/impl/optional-is-optional.mjs +24 -6
  92. package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
  93. package/dist/functional/optional/impl/optional-is-some.mjs +20 -3
  94. package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
  95. package/dist/functional/optional/impl/optional-map.mjs +15 -17
  96. package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
  97. package/dist/functional/optional/impl/optional-match.mjs +15 -17
  98. package/dist/functional/optional/impl/optional-match.mjs.map +1 -1
  99. package/dist/functional/optional/impl/optional-none.mjs +16 -3
  100. package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
  101. package/dist/functional/optional/impl/optional-or-else.mjs +12 -14
  102. package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
  103. package/dist/functional/optional/impl/optional-some.mjs +22 -6
  104. package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
  105. package/dist/functional/optional/impl/optional-to-nullable.mjs +26 -3
  106. package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
  107. package/dist/functional/optional/impl/optional-unwrap-or.mjs +11 -13
  108. package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
  109. package/dist/functional/optional/impl/optional-unwrap-throw.mjs +33 -8
  110. package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
  111. package/dist/functional/optional/impl/optional-unwrap.mjs +6 -9
  112. package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
  113. package/dist/functional/optional/impl/optional-zip.mjs +34 -3
  114. package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
  115. package/dist/functional/optional/impl/tag.mjs +3 -4
  116. package/dist/functional/optional/impl/tag.mjs.map +1 -1
  117. package/dist/functional/optional/impl/types.mjs +2 -2
  118. package/dist/functional/optional/impl/types.mjs.map +1 -1
  119. package/dist/functional/optional/index.mjs +2 -3
  120. package/dist/functional/optional/index.mjs.map +1 -1
  121. package/dist/functional/optional/optional.mjs +2 -3
  122. package/dist/functional/optional/optional.mjs.map +1 -1
  123. package/dist/functional/pipe.mjs +42 -14
  124. package/dist/functional/pipe.mjs.map +1 -1
  125. package/dist/functional/result/impl/index.mjs +28 -27
  126. package/dist/functional/result/impl/index.mjs.map +1 -1
  127. package/dist/functional/result/impl/result-err.mjs +28 -6
  128. package/dist/functional/result/impl/result-err.mjs.map +1 -1
  129. package/dist/functional/result/impl/result-expect-to-be.mjs +16 -17
  130. package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
  131. package/dist/functional/result/impl/result-flat-map.mjs +17 -20
  132. package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
  133. package/dist/functional/result/impl/result-fold.mjs +17 -20
  134. package/dist/functional/result/impl/result-fold.mjs.map +1 -1
  135. package/dist/functional/result/impl/result-from-optional.mjs +16 -19
  136. package/dist/functional/result/impl/result-from-optional.mjs.map +1 -1
  137. package/dist/functional/result/impl/result-from-promise.mjs +35 -6
  138. package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
  139. package/dist/functional/result/impl/result-from-throwable.mjs +40 -13
  140. package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
  141. package/dist/functional/result/impl/result-is-err.mjs +19 -3
  142. package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
  143. package/dist/functional/result/impl/result-is-ok.mjs +19 -3
  144. package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
  145. package/dist/functional/result/impl/result-is-result.mjs +23 -5
  146. package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
  147. package/dist/functional/result/impl/result-map-err.mjs +17 -20
  148. package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
  149. package/dist/functional/result/impl/result-map.mjs +17 -20
  150. package/dist/functional/result/impl/result-map.mjs.map +1 -1
  151. package/dist/functional/result/impl/result-match.mjs +16 -20
  152. package/dist/functional/result/impl/result-match.mjs.map +1 -1
  153. package/dist/functional/result/impl/result-ok.mjs +28 -6
  154. package/dist/functional/result/impl/result-ok.mjs.map +1 -1
  155. package/dist/functional/result/impl/result-or-else.mjs +13 -14
  156. package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
  157. package/dist/functional/result/impl/result-safe-try.mjs +32 -21
  158. package/dist/functional/result/impl/result-safe-try.mjs.map +1 -1
  159. package/dist/functional/result/impl/result-safe-unwrap.mjs +39 -11
  160. package/dist/functional/result/impl/result-safe-unwrap.mjs.map +1 -1
  161. package/dist/functional/result/impl/result-swap.mjs +21 -6
  162. package/dist/functional/result/impl/result-swap.mjs.map +1 -1
  163. package/dist/functional/result/impl/result-to-optional.mjs +28 -5
  164. package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
  165. package/dist/functional/result/impl/result-unwrap-err-or.mjs +12 -13
  166. package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
  167. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +42 -19
  168. package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
  169. package/dist/functional/result/impl/result-unwrap-err.mjs +31 -6
  170. package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
  171. package/dist/functional/result/impl/result-unwrap-ok-or.mjs +12 -13
  172. package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
  173. package/dist/functional/result/impl/result-unwrap-ok.mjs +6 -9
  174. package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
  175. package/dist/functional/result/impl/result-unwrap-throw.mjs +37 -10
  176. package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
  177. package/dist/functional/result/impl/result-zip.mjs +33 -3
  178. package/dist/functional/result/impl/result-zip.mjs.map +1 -1
  179. package/dist/functional/result/impl/tag.mjs +3 -4
  180. package/dist/functional/result/impl/tag.mjs.map +1 -1
  181. package/dist/functional/result/impl/types.mjs +2 -2
  182. package/dist/functional/result/impl/types.mjs.map +1 -1
  183. package/dist/functional/result/index.mjs +2 -3
  184. package/dist/functional/result/index.mjs.map +1 -1
  185. package/dist/functional/result/result.mjs +2 -3
  186. package/dist/functional/result/result.mjs.map +1 -1
  187. package/dist/functional/ternary-result/impl/index.mjs +29 -28
  188. package/dist/functional/ternary-result/impl/index.mjs.map +1 -1
  189. package/dist/functional/ternary-result/impl/tag.mjs +5 -5
  190. package/dist/functional/ternary-result/impl/tag.mjs.map +1 -1
  191. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +16 -6
  192. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
  193. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +15 -18
  194. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
  195. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +29 -33
  196. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
  197. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +24 -26
  198. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
  199. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +19 -6
  200. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
  201. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +27 -12
  202. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
  203. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +17 -3
  204. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -1
  205. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +19 -3
  206. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -1
  207. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +26 -6
  208. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -1
  209. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +18 -3
  210. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
  211. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +17 -18
  212. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
  213. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +20 -23
  214. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
  215. package/dist/functional/ternary-result/impl/ternary-result-map.mjs +24 -26
  216. package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
  217. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +17 -6
  218. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
  219. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +11 -14
  220. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
  221. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +22 -8
  222. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -1
  223. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +11 -14
  224. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -1
  225. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +29 -18
  226. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
  227. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +18 -6
  228. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -1
  229. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +11 -14
  230. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -1
  231. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +6 -8
  232. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
  233. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +31 -23
  234. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
  235. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +11 -14
  236. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -1
  237. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +26 -16
  238. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
  239. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +18 -6
  240. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
  241. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +20 -7
  242. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
  243. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +46 -18
  244. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
  245. package/dist/functional/ternary-result/impl/types.mjs +2 -2
  246. package/dist/functional/ternary-result/impl/types.mjs.map +1 -1
  247. package/dist/functional/ternary-result/impl/variant-name.mjs +11 -13
  248. package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -1
  249. package/dist/functional/ternary-result/index.mjs +2 -3
  250. package/dist/functional/ternary-result/index.mjs.map +1 -1
  251. package/dist/functional/ternary-result/ternary-result.mjs +2 -3
  252. package/dist/functional/ternary-result/ternary-result.mjs.map +1 -1
  253. package/dist/guard/has-key.mjs +42 -3
  254. package/dist/guard/has-key.mjs.map +1 -1
  255. package/dist/guard/index.mjs +8 -8
  256. package/dist/guard/index.mjs.map +1 -1
  257. package/dist/guard/is-non-empty-string.mjs +38 -3
  258. package/dist/guard/is-non-empty-string.mjs.map +1 -1
  259. package/dist/guard/is-non-null-object.mjs +35 -3
  260. package/dist/guard/is-non-null-object.mjs.map +1 -1
  261. package/dist/guard/is-primitive.mjs +46 -15
  262. package/dist/guard/is-primitive.mjs.map +1 -1
  263. package/dist/guard/is-record.mjs +87 -4
  264. package/dist/guard/is-record.mjs.map +1 -1
  265. package/dist/guard/is-type.mjs +404 -19
  266. package/dist/guard/is-type.mjs.map +1 -1
  267. package/dist/guard/key-is-in.mjs +41 -3
  268. package/dist/guard/key-is-in.mjs.map +1 -1
  269. package/dist/index.mjs +12 -65
  270. package/dist/index.mjs.map +1 -1
  271. package/dist/iterator/index.mjs +2 -2
  272. package/dist/iterator/index.mjs.map +1 -1
  273. package/dist/iterator/range.mjs +18 -56
  274. package/dist/iterator/range.mjs.map +1 -1
  275. package/dist/json/index.mjs +2 -2
  276. package/dist/json/index.mjs.map +1 -1
  277. package/dist/json/json.mjs +346 -105
  278. package/dist/json/json.mjs.map +1 -1
  279. package/dist/number/branded-types/finite-number.mjs +148 -137
  280. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  281. package/dist/number/branded-types/index.mjs +33 -33
  282. package/dist/number/branded-types/index.mjs.map +1 -1
  283. package/dist/number/branded-types/int.mjs +245 -209
  284. package/dist/number/branded-types/int.mjs.map +1 -1
  285. package/dist/number/branded-types/int16.mjs +141 -131
  286. package/dist/number/branded-types/int16.mjs.map +1 -1
  287. package/dist/number/branded-types/int32.mjs +141 -131
  288. package/dist/number/branded-types/int32.mjs.map +1 -1
  289. package/dist/number/branded-types/negative-finite-number.mjs +155 -149
  290. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  291. package/dist/number/branded-types/negative-int.mjs +125 -110
  292. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  293. package/dist/number/branded-types/negative-safe-int.mjs +126 -115
  294. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  295. package/dist/number/branded-types/non-negative-finite-number.mjs +164 -154
  296. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  297. package/dist/number/branded-types/non-negative-int16.mjs +137 -125
  298. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  299. package/dist/number/branded-types/non-negative-int32.mjs +137 -125
  300. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  301. package/dist/number/branded-types/non-positive-finite-number.mjs +143 -139
  302. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  303. package/dist/number/branded-types/non-positive-int.mjs +116 -99
  304. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  305. package/dist/number/branded-types/non-positive-safe-int.mjs +118 -107
  306. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  307. package/dist/number/branded-types/non-zero-finite-number.mjs +144 -129
  308. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  309. package/dist/number/branded-types/non-zero-int.mjs +102 -82
  310. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  311. package/dist/number/branded-types/non-zero-int16.mjs +118 -105
  312. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  313. package/dist/number/branded-types/non-zero-int32.mjs +118 -105
  314. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  315. package/dist/number/branded-types/non-zero-safe-int.mjs +121 -107
  316. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  317. package/dist/number/branded-types/non-zero-uint16.mjs +118 -104
  318. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  319. package/dist/number/branded-types/non-zero-uint32.mjs +118 -104
  320. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  321. package/dist/number/branded-types/positive-finite-number.mjs +167 -160
  322. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  323. package/dist/number/branded-types/positive-int.mjs +260 -224
  324. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  325. package/dist/number/branded-types/positive-int16.mjs +134 -122
  326. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  327. package/dist/number/branded-types/positive-int32.mjs +134 -122
  328. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  329. package/dist/number/branded-types/positive-safe-int.mjs +291 -257
  330. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  331. package/dist/number/branded-types/positive-uint16.mjs +134 -122
  332. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  333. package/dist/number/branded-types/positive-uint32.mjs +134 -122
  334. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  335. package/dist/number/branded-types/safe-int.mjs +283 -254
  336. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  337. package/dist/number/branded-types/safe-uint.mjs +134 -123
  338. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  339. package/dist/number/branded-types/uint.mjs +248 -211
  340. package/dist/number/branded-types/uint.mjs.map +1 -1
  341. package/dist/number/branded-types/uint16.mjs +132 -121
  342. package/dist/number/branded-types/uint16.mjs.map +1 -1
  343. package/dist/number/branded-types/uint32.mjs +132 -121
  344. package/dist/number/branded-types/uint32.mjs.map +1 -1
  345. package/dist/number/enum/index.mjs +3 -3
  346. package/dist/number/enum/index.mjs.map +1 -1
  347. package/dist/number/enum/int8.mjs +146 -131
  348. package/dist/number/enum/int8.mjs.map +1 -1
  349. package/dist/number/enum/uint8.mjs +133 -119
  350. package/dist/number/enum/uint8.mjs.map +1 -1
  351. package/dist/number/index.mjs +6 -37
  352. package/dist/number/index.mjs.map +1 -1
  353. package/dist/number/num-arithmetic-types.mjs +42 -1
  354. package/dist/number/num-arithmetic-types.mjs.map +1 -1
  355. package/dist/number/num.mjs +549 -91
  356. package/dist/number/num.mjs.map +1 -1
  357. package/dist/number/refined-number-utils.mjs +294 -133
  358. package/dist/number/refined-number-utils.mjs.map +1 -1
  359. package/dist/object/index.mjs +2 -2
  360. package/dist/object/index.mjs.map +1 -1
  361. package/dist/object/object.mjs +356 -203
  362. package/dist/object/object.mjs.map +1 -1
  363. package/dist/others/cast-mutable.mjs +38 -11
  364. package/dist/others/cast-mutable.mjs.map +1 -1
  365. package/dist/others/cast-readonly.mjs +37 -11
  366. package/dist/others/cast-readonly.mjs.map +1 -1
  367. package/dist/others/debounce-function.mjs +22 -11
  368. package/dist/others/debounce-function.mjs.map +1 -1
  369. package/dist/others/fast-deep-equal.mjs +70 -51
  370. package/dist/others/fast-deep-equal.mjs.map +1 -1
  371. package/dist/others/if-then.mjs +31 -4
  372. package/dist/others/if-then.mjs.map +1 -1
  373. package/dist/others/index.mjs +10 -10
  374. package/dist/others/index.mjs.map +1 -1
  375. package/dist/others/map-nullable.mjs +11 -13
  376. package/dist/others/map-nullable.mjs.map +1 -1
  377. package/dist/others/memoize-function.mjs +14 -16
  378. package/dist/others/memoize-function.mjs.map +1 -1
  379. package/dist/others/tuple.mjs +51 -3
  380. package/dist/others/tuple.mjs.map +1 -1
  381. package/dist/others/unknown-to-string.mjs +91 -47
  382. package/dist/others/unknown-to-string.mjs.map +1 -1
  383. package/dist/promise/index.mjs +2 -2
  384. package/dist/promise/index.mjs.map +1 -1
  385. package/dist/promise/promise.mjs +49 -8
  386. package/dist/promise/promise.mjs.map +1 -1
  387. package/dist/string/index.mjs +2 -2
  388. package/dist/string/index.mjs.map +1 -1
  389. package/dist/string/str.mjs +250 -83
  390. package/dist/string/str.mjs.map +1 -1
  391. package/dist/types.mjs +2 -1
  392. package/dist/types.mjs.map +1 -1
  393. package/package.json +6 -7
  394. package/src/guard/is-type.test.mts +2 -2
  395. package/src/number/branded-types/finite-number.test.mts +1 -1
  396. package/src/number/branded-types/int.test.mts +1 -1
  397. package/src/number/branded-types/int16.test.mts +1 -1
  398. package/src/number/branded-types/int32.test.mts +1 -1
  399. package/src/number/branded-types/non-negative-finite-number.test.mts +1 -1
  400. package/src/number/branded-types/non-negative-int16.test.mts +1 -1
  401. package/src/number/branded-types/non-negative-int32.test.mts +1 -1
  402. package/src/number/branded-types/non-zero-finite-number.test.mts +1 -1
  403. package/src/number/branded-types/non-zero-int.test.mts +1 -1
  404. package/src/number/branded-types/non-zero-int16.test.mts +1 -1
  405. package/src/number/branded-types/non-zero-int32.test.mts +1 -1
  406. package/src/number/branded-types/non-zero-safe-int.test.mts +1 -1
  407. package/src/number/branded-types/non-zero-uint16.test.mts +1 -1
  408. package/src/number/branded-types/non-zero-uint32.test.mts +1 -1
  409. package/src/number/branded-types/positive-finite-number.test.mts +1 -1
  410. package/src/number/branded-types/positive-int.test.mts +1 -1
  411. package/src/number/branded-types/positive-int16.test.mts +1 -1
  412. package/src/number/branded-types/positive-int32.test.mts +1 -1
  413. package/src/number/branded-types/positive-safe-int.test.mts +1 -1
  414. package/src/number/branded-types/positive-uint16.test.mts +1 -1
  415. package/src/number/branded-types/positive-uint32.test.mts +1 -1
  416. package/src/number/branded-types/safe-int.test.mts +1 -1
  417. package/src/number/branded-types/safe-uint.test.mts +1 -1
  418. package/src/number/branded-types/uint.test.mts +1 -1
  419. package/src/number/branded-types/uint16.test.mts +1 -1
  420. package/src/number/branded-types/uint32.test.mts +1 -1
@@ -1,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';
1
+ import { Optional } from '../functional/index.mjs';
2
+ import { range } from '../iterator/index.mjs';
3
+ import { asUint32, Uint32 } from '../number/index.mjs';
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
41
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
+
18
+ static #INITIAL_CAPACITY = 8;
19
+
20
+ #mut_buffer;
21
+
22
+ #mut_size;
23
+
24
+ #mut_capacity;
25
+
26
+
27
+
28
+
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
+
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
+
42
+
43
+
44
+
45
+ #resize() {
46
+ const newCapacity = asUint32(this.#mut_capacity * 2);
47
+ const newBuffer = Array.from({ length: newCapacity }, () => undefined);
48
+
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;
54
+ }
55
+
56
+ get isEmpty() {
57
+ return this.#mut_size === 0;
58
+ }
59
+
60
+ get size() {
61
+ return asUint32(this.#mut_size);
83
62
  }
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;
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+ pop() {
78
+ if (this.isEmpty) {
79
+ return Optional.none;
80
+ }
81
+ this.#mut_size = Uint32.sub(this.#mut_size, 1);
82
+
83
+ const element = this.#mut_buffer[this.#mut_size];
84
+ this.#mut_buffer[this.#mut_size] = undefined;
85
+ return Optional.some(element);
112
86
  }
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();
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+ push(value) {
105
+
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
113
 
145
- export { createStack };
146
- //# sourceMappingURL=stack.mjs.map
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
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":"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"}
1
+ {"version":3,"file":"stack.mjs","sourceRoot":"","sources":["../../src/collections/stack.mts"],"names":[],"mappings":"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"}
@@ -1,77 +1,4 @@
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
1
 
3
- export { expectType };
4
- //# sourceMappingURL=expect-type.mjs.map
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
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';
1
+ import { Result } from '../../result/index.mjs';
2
+ export function flatMap(...args) {
3
+ switch (args.length) {
4
+ case 2: {
3
5
 
4
- function flatMap(...args) {
5
- switch (args.length) {
6
- case 2: {
7
- const [asyncResult, flatMapFn] = args;
8
- return flatMapImpl(asyncResult, flatMapFn);
9
- }
10
- case 1: {
11
- const [flatMapFn] = args;
12
- return (asyncResult) => flatMapImpl(asyncResult, flatMapFn);
6
+ const [asyncResult, flatMapFn] = args;
7
+ return flatMapImpl(asyncResult, flatMapFn);
8
+ }
9
+ case 1: {
10
+
11
+ const [flatMapFn] = args;
12
+ return (asyncResult) => flatMapImpl(asyncResult, flatMapFn);
13
+ }
13
14
  }
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
+ :
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
@@ -1 +1 @@
1
- {"version":3,"file":"async-result-from-promise.mjs","sources":["../../../../src/functional/async-result/impl/async-result-from-promise.mts"],"sourcesContent":["import { Result } from '../../result/index.mjs';\nimport { type AsyncResult } from '../async-result.mjs';\n\n/**\n * Converts a `Promise` into an `AsyncResult`. If the input Promise resolves,\n * the `AsyncResult` resolves to `Ok` with the resolved value. If the input\n * Promise rejects, the rejection reason is passed through `mapError` and the\n * `AsyncResult` resolves to `Err` with the mapped error.\n *\n * Passing `mapError` is what gives the error channel a concrete type `E`.\n * Omitting it carries the rejection reason through untouched, leaving the\n * error channel as `unknown` — the same contract as `Result.fromPromise`.\n *\n * @example\n *\n * ```ts\n * const resolved = await AsyncResult.fromPromise(\n * Promise.resolve('ok'),\n * (error) => `failed: ${String(error)}`,\n * );\n *\n * const rejected = await AsyncResult.fromPromise(\n * Promise.reject(new Error('boom')),\n * (error) => (isError(error) ? error.message : 'unknown'),\n * );\n *\n * assert.deepStrictEqual(resolved, Result.ok('ok'));\n *\n * assert.deepStrictEqual(rejected, Result.err('boom'));\n *\n * // Without `mapError`, the rejection reason is carried as-is.\n * const untyped = await AsyncResult.fromPromise(\n * Promise.reject(new Error('boom')),\n * );\n *\n * assert.isTrue(Result.isErr(untyped));\n * ```\n *\n * @template S The type of the success value.\n * @template E The type of the error value.\n * @param promise The Promise to convert.\n * @param mapError The function applied to the rejection reason to produce the\n * error value. Omit it to carry the rejection reason as `unknown`.\n * @returns An `AsyncResult<S, E>` that never rejects for the input Promise's\n * failure.\n */\nexport function fromPromise<S>(promise: Promise<S>): AsyncResult<S, unknown>;\n\nexport function fromPromise<S, E>(\n promise: Promise<S>,\n mapError: (error: unknown) => E,\n): AsyncResult<S, E>;\n\nexport function fromPromise<S, E>(\n promise: Promise<S>,\n mapError?: (error: unknown) => E,\n): AsyncResult<S, E> | AsyncResult<S, unknown> {\n return mapError === undefined\n ? fromPromiseImpl(promise, (error: unknown) => error)\n : fromPromiseImpl(promise, mapError);\n}\n\nconst fromPromiseImpl = <S, E>(\n promise: Promise<S>,\n mapError: (error: unknown) => E,\n): AsyncResult<S, E> =>\n promise\n .then((value) => Result.ok(value))\n .catch((error: unknown) => Result.err(mapError(error)));\n"],"names":["Result.ok","Result.err"],"mappings":";;;;AAqDO,SAAS,WAAA,CACd,SACA,QAAA,EAC6C;AAC7C,EAAA,OAAO,QAAA,KAAa,MAAA,GAChB,eAAA,CAAgB,OAAA,EAAS,CAAC,UAAmB,KAAK,CAAA,GAClD,eAAA,CAAgB,OAAA,EAAS,QAAQ,CAAA;AACvC;AAEA,MAAM,eAAA,GAAkB,CACtB,OAAA,EACA,QAAA,KAEA,QACG,IAAA,CAAK,CAAC,UAAUA,EAAO,CAAG,KAAK,CAAC,CAAA,CAChC,MAAM,CAAC,KAAA,KAAmBC,GAAO,CAAI,QAAA,CAAS,KAAK,CAAC,CAAC,CAAA;;;;"}
1
+ {"version":3,"file":"async-result-from-promise.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-from-promise.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAqDhD,MAAM,UAAU,WAAW,CACzB,OAAmB,EACnB,QAAgC;IAEhC,OAAO,QAAQ,KAAK,SAAS;QAC3B,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,KAAK,CAAC;QACrD,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,eAAe,GAAG,CACtB,OAAmB,EACnB,QAA+B,EACZ,EAAE,CACrB,OAAO;KACJ,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;KACjC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC"}