ts-data-forge 5.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (532) hide show
  1. package/README.md +55 -6
  2. package/dist/array/impl/array-utils-creation.d.mts +14 -0
  3. package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
  4. package/dist/array/impl/array-utils-creation.mjs +12 -0
  5. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  6. package/dist/array/impl/array-utils-element-access.d.mts +10 -0
  7. package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
  8. package/dist/array/impl/array-utils-element-access.mjs +7 -0
  9. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  10. package/dist/array/impl/array-utils-modification.d.mts +14 -0
  11. package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
  12. package/dist/array/impl/array-utils-modification.mjs +1 -0
  13. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  14. package/dist/array/impl/array-utils-reducing-value.d.mts +26 -2
  15. package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
  16. package/dist/array/impl/array-utils-reducing-value.mjs +2 -1
  17. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  18. package/dist/array/impl/array-utils-search.d.mts +30 -0
  19. package/dist/array/impl/array-utils-search.d.mts.map +1 -1
  20. package/dist/array/impl/array-utils-search.mjs +1 -0
  21. package/dist/array/impl/array-utils-search.mjs.map +1 -1
  22. package/dist/array/impl/array-utils-set-op.d.mts +13 -0
  23. package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
  24. package/dist/array/impl/array-utils-set-op.mjs +13 -0
  25. package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
  26. package/dist/array/impl/array-utils-size.d.mts +3 -0
  27. package/dist/array/impl/array-utils-size.d.mts.map +1 -1
  28. package/dist/array/impl/array-utils-size.mjs +3 -0
  29. package/dist/array/impl/array-utils-size.mjs.map +1 -1
  30. package/dist/array/impl/array-utils-slice-clamped.d.mts +2 -0
  31. package/dist/array/impl/array-utils-slice-clamped.d.mts.map +1 -1
  32. package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
  33. package/dist/array/impl/array-utils-slicing.d.mts +15 -0
  34. package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
  35. package/dist/array/impl/array-utils-slicing.mjs +7 -0
  36. package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
  37. package/dist/array/impl/array-utils-transformation.d.mts +27 -0
  38. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
  39. package/dist/array/impl/array-utils-transformation.mjs +7 -0
  40. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  41. package/dist/array/impl/array-utils-validation.d.mts +17 -0
  42. package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
  43. package/dist/array/impl/array-utils-validation.mjs +11 -0
  44. package/dist/array/impl/array-utils-validation.mjs.map +1 -1
  45. package/dist/collections/imap-mapped.mjs +1 -0
  46. package/dist/collections/imap-mapped.mjs.map +1 -1
  47. package/dist/collections/imap.d.mts +20 -0
  48. package/dist/collections/imap.d.mts.map +1 -1
  49. package/dist/collections/imap.mjs +3 -0
  50. package/dist/collections/imap.mjs.map +1 -1
  51. package/dist/collections/iset-mapped.d.mts +27 -0
  52. package/dist/collections/iset-mapped.d.mts.map +1 -1
  53. package/dist/collections/iset-mapped.mjs +7 -0
  54. package/dist/collections/iset-mapped.mjs.map +1 -1
  55. package/dist/collections/iset.d.mts +29 -0
  56. package/dist/collections/iset.d.mts.map +1 -1
  57. package/dist/collections/iset.mjs +7 -0
  58. package/dist/collections/iset.mjs.map +1 -1
  59. package/dist/collections/queue.d.mts +40 -0
  60. package/dist/collections/queue.d.mts.map +1 -1
  61. package/dist/collections/queue.mjs +9 -0
  62. package/dist/collections/queue.mjs.map +1 -1
  63. package/dist/collections/stack.d.mts +35 -0
  64. package/dist/collections/stack.d.mts.map +1 -1
  65. package/dist/collections/stack.mjs +8 -0
  66. package/dist/collections/stack.mjs.map +1 -1
  67. package/dist/entry-point.mjs +1 -1
  68. package/dist/functional/match.d.mts.map +1 -1
  69. package/dist/functional/match.mjs.map +1 -1
  70. package/dist/functional/optional/impl/optional-expect-to-be.d.mts +1 -0
  71. package/dist/functional/optional/impl/optional-expect-to-be.d.mts.map +1 -1
  72. package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
  73. package/dist/functional/optional/impl/optional-filter.d.mts +3 -0
  74. package/dist/functional/optional/impl/optional-filter.d.mts.map +1 -1
  75. package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
  76. package/dist/functional/optional/impl/optional-flat-map.d.mts +2 -0
  77. package/dist/functional/optional/impl/optional-flat-map.d.mts.map +1 -1
  78. package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
  79. package/dist/functional/optional/impl/optional-from-nullable.d.mts +2 -0
  80. package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +1 -1
  81. package/dist/functional/optional/impl/optional-from-nullable.mjs +2 -0
  82. package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
  83. package/dist/functional/optional/impl/optional-is-optional.d.mts +2 -0
  84. package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -1
  85. package/dist/functional/optional/impl/optional-is-optional.mjs +2 -0
  86. package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
  87. package/dist/functional/optional/impl/optional-is-some.d.mts +1 -0
  88. package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -1
  89. package/dist/functional/optional/impl/optional-is-some.mjs +1 -0
  90. package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
  91. package/dist/functional/optional/impl/optional-map.d.mts +2 -0
  92. package/dist/functional/optional/impl/optional-map.d.mts.map +1 -1
  93. package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
  94. package/dist/functional/optional/impl/optional-none.d.mts +2 -0
  95. package/dist/functional/optional/impl/optional-none.d.mts.map +1 -1
  96. package/dist/functional/optional/impl/optional-none.mjs +2 -0
  97. package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
  98. package/dist/functional/optional/impl/optional-or-else.d.mts +4 -0
  99. package/dist/functional/optional/impl/optional-or-else.d.mts.map +1 -1
  100. package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
  101. package/dist/functional/optional/impl/optional-some.d.mts +3 -1
  102. package/dist/functional/optional/impl/optional-some.d.mts.map +1 -1
  103. package/dist/functional/optional/impl/optional-some.mjs +2 -0
  104. package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
  105. package/dist/functional/optional/impl/optional-to-nullable.d.mts +2 -0
  106. package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -1
  107. package/dist/functional/optional/impl/optional-to-nullable.mjs +2 -0
  108. package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
  109. package/dist/functional/optional/impl/optional-unwrap-or.d.mts +3 -0
  110. package/dist/functional/optional/impl/optional-unwrap-or.d.mts.map +1 -1
  111. package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
  112. package/dist/functional/optional/impl/optional-unwrap-throw.d.mts +1 -0
  113. package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -1
  114. package/dist/functional/optional/impl/optional-unwrap-throw.mjs +1 -0
  115. package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
  116. package/dist/functional/optional/impl/optional-unwrap.d.mts +2 -0
  117. package/dist/functional/optional/impl/optional-unwrap.d.mts.map +1 -1
  118. package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
  119. package/dist/functional/optional/impl/optional-zip.d.mts +2 -0
  120. package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -1
  121. package/dist/functional/optional/impl/optional-zip.mjs +2 -0
  122. package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
  123. package/dist/functional/result/impl/result-err.d.mts +3 -1
  124. package/dist/functional/result/impl/result-err.d.mts.map +1 -1
  125. package/dist/functional/result/impl/result-err.mjs +2 -0
  126. package/dist/functional/result/impl/result-err.mjs.map +1 -1
  127. package/dist/functional/result/impl/result-expect-to-be.d.mts +1 -0
  128. package/dist/functional/result/impl/result-expect-to-be.d.mts.map +1 -1
  129. package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
  130. package/dist/functional/result/impl/result-flat-map.d.mts +5 -0
  131. package/dist/functional/result/impl/result-flat-map.d.mts.map +1 -1
  132. package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
  133. package/dist/functional/result/impl/result-fold.d.mts +4 -0
  134. package/dist/functional/result/impl/result-fold.d.mts.map +1 -1
  135. package/dist/functional/result/impl/result-fold.mjs.map +1 -1
  136. package/dist/functional/result/impl/result-from-promise.d.mts +3 -0
  137. package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -1
  138. package/dist/functional/result/impl/result-from-promise.mjs +3 -0
  139. package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
  140. package/dist/functional/result/impl/result-from-throwable.d.mts +2 -0
  141. package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -1
  142. package/dist/functional/result/impl/result-from-throwable.mjs +4 -1
  143. package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
  144. package/dist/functional/result/impl/result-is-err.d.mts +2 -0
  145. package/dist/functional/result/impl/result-is-err.d.mts.map +1 -1
  146. package/dist/functional/result/impl/result-is-err.mjs +2 -0
  147. package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
  148. package/dist/functional/result/impl/result-is-ok.d.mts +2 -0
  149. package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -1
  150. package/dist/functional/result/impl/result-is-ok.mjs +2 -0
  151. package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
  152. package/dist/functional/result/impl/result-is-result.d.mts +4 -0
  153. package/dist/functional/result/impl/result-is-result.d.mts.map +1 -1
  154. package/dist/functional/result/impl/result-is-result.mjs +4 -0
  155. package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
  156. package/dist/functional/result/impl/result-map-err.d.mts +3 -0
  157. package/dist/functional/result/impl/result-map-err.d.mts.map +1 -1
  158. package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
  159. package/dist/functional/result/impl/result-map.d.mts +4 -0
  160. package/dist/functional/result/impl/result-map.d.mts.map +1 -1
  161. package/dist/functional/result/impl/result-map.mjs.map +1 -1
  162. package/dist/functional/result/impl/result-ok.d.mts +3 -1
  163. package/dist/functional/result/impl/result-ok.d.mts.map +1 -1
  164. package/dist/functional/result/impl/result-ok.mjs +2 -0
  165. package/dist/functional/result/impl/result-ok.mjs.map +1 -1
  166. package/dist/functional/result/impl/result-or-else.d.mts +4 -0
  167. package/dist/functional/result/impl/result-or-else.d.mts.map +1 -1
  168. package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
  169. package/dist/functional/result/impl/result-swap.d.mts +2 -0
  170. package/dist/functional/result/impl/result-swap.d.mts.map +1 -1
  171. package/dist/functional/result/impl/result-swap.mjs +2 -0
  172. package/dist/functional/result/impl/result-swap.mjs.map +1 -1
  173. package/dist/functional/result/impl/result-to-optional.d.mts +2 -0
  174. package/dist/functional/result/impl/result-to-optional.d.mts.map +1 -1
  175. package/dist/functional/result/impl/result-to-optional.mjs +2 -0
  176. package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
  177. package/dist/functional/result/impl/result-unwrap-err-or.d.mts +3 -0
  178. package/dist/functional/result/impl/result-unwrap-err-or.d.mts.map +1 -1
  179. package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
  180. package/dist/functional/result/impl/result-unwrap-err-throw.d.mts +2 -0
  181. package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +1 -1
  182. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +2 -0
  183. package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
  184. package/dist/functional/result/impl/result-unwrap-err.d.mts +1 -0
  185. package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -1
  186. package/dist/functional/result/impl/result-unwrap-err.mjs +1 -0
  187. package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
  188. package/dist/functional/result/impl/result-unwrap-ok-or.d.mts +3 -0
  189. package/dist/functional/result/impl/result-unwrap-ok-or.d.mts.map +1 -1
  190. package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
  191. package/dist/functional/result/impl/result-unwrap-ok.d.mts +1 -0
  192. package/dist/functional/result/impl/result-unwrap-ok.d.mts.map +1 -1
  193. package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
  194. package/dist/functional/result/impl/result-unwrap-throw.d.mts +2 -0
  195. package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -1
  196. package/dist/functional/result/impl/result-unwrap-throw.mjs +2 -0
  197. package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
  198. package/dist/functional/result/impl/result-zip.d.mts +3 -1
  199. package/dist/functional/result/impl/result-zip.d.mts.map +1 -1
  200. package/dist/functional/result/impl/result-zip.mjs +3 -1
  201. package/dist/functional/result/impl/result-zip.mjs.map +1 -1
  202. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts +2 -1
  203. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -1
  204. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +1 -0
  205. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
  206. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts +1 -0
  207. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts.map +1 -1
  208. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
  209. package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts +4 -0
  210. package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts.map +1 -1
  211. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
  212. package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts +2 -0
  213. package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts.map +1 -1
  214. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
  215. package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts +2 -0
  216. package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +1 -1
  217. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +2 -0
  218. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
  219. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts +2 -0
  220. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -1
  221. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +4 -1
  222. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
  223. package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts +1 -0
  224. package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +1 -1
  225. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +1 -0
  226. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -1
  227. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts +4 -0
  228. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +1 -1
  229. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +4 -0
  230. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -1
  231. package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts +1 -0
  232. package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +1 -1
  233. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +1 -0
  234. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
  235. package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts +3 -0
  236. package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts.map +1 -1
  237. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
  238. package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts +3 -0
  239. package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts.map +1 -1
  240. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
  241. package/dist/functional/ternary-result/impl/ternary-result-map.d.mts +6 -0
  242. package/dist/functional/ternary-result/impl/ternary-result-map.d.mts.map +1 -1
  243. package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
  244. package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts +1 -1
  245. package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -1
  246. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
  247. package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts +2 -0
  248. package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts.map +1 -1
  249. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
  250. package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts +2 -0
  251. package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +1 -1
  252. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +2 -0
  253. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -1
  254. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts +2 -0
  255. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts.map +1 -1
  256. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -1
  257. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts +1 -0
  258. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +1 -1
  259. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +1 -0
  260. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
  261. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts +2 -0
  262. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +1 -1
  263. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +2 -0
  264. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -1
  265. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts +2 -0
  266. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts.map +1 -1
  267. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -1
  268. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts +2 -0
  269. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts.map +1 -1
  270. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
  271. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts +1 -0
  272. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -1
  273. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +1 -0
  274. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
  275. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts +2 -0
  276. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts.map +1 -1
  277. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -1
  278. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts +1 -0
  279. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +1 -1
  280. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +1 -0
  281. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
  282. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts +2 -0
  283. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +1 -1
  284. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +2 -0
  285. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
  286. package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts +1 -1
  287. package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -1
  288. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
  289. package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts +4 -0
  290. package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -1
  291. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +4 -0
  292. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
  293. package/dist/globals.d.mts +10 -0
  294. package/dist/guard/index.mjs +1 -1
  295. package/dist/guard/is-record.d.mts +31 -0
  296. package/dist/guard/is-record.d.mts.map +1 -1
  297. package/dist/guard/is-record.mjs +32 -1
  298. package/dist/guard/is-record.mjs.map +1 -1
  299. package/dist/guard/is-type.d.mts +3 -0
  300. package/dist/guard/is-type.d.mts.map +1 -1
  301. package/dist/guard/is-type.mjs +3 -0
  302. package/dist/guard/is-type.mjs.map +1 -1
  303. package/dist/guard/key-is-in.d.mts +1 -0
  304. package/dist/guard/key-is-in.d.mts.map +1 -1
  305. package/dist/guard/key-is-in.mjs +1 -0
  306. package/dist/guard/key-is-in.mjs.map +1 -1
  307. package/dist/index.mjs +1 -1
  308. package/dist/iterator/range.d.mts +4 -0
  309. package/dist/iterator/range.d.mts.map +1 -1
  310. package/dist/iterator/range.mjs +1 -0
  311. package/dist/iterator/range.mjs.map +1 -1
  312. package/dist/json/json.d.mts +21 -0
  313. package/dist/json/json.d.mts.map +1 -1
  314. package/dist/json/json.mjs +22 -0
  315. package/dist/json/json.mjs.map +1 -1
  316. package/dist/number/branded-types/int.d.mts +14 -0
  317. package/dist/number/branded-types/int.d.mts.map +1 -1
  318. package/dist/number/branded-types/int.mjs +14 -0
  319. package/dist/number/branded-types/int.mjs.map +1 -1
  320. package/dist/number/branded-types/non-zero-safe-int.mjs +2 -2
  321. package/dist/number/branded-types/positive-int.d.mts +14 -0
  322. package/dist/number/branded-types/positive-int.d.mts.map +1 -1
  323. package/dist/number/branded-types/positive-int.mjs +14 -0
  324. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  325. package/dist/number/branded-types/positive-safe-int.d.mts +21 -0
  326. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
  327. package/dist/number/branded-types/positive-safe-int.mjs +22 -1
  328. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  329. package/dist/number/branded-types/safe-int.d.mts +21 -0
  330. package/dist/number/branded-types/safe-int.d.mts.map +1 -1
  331. package/dist/number/branded-types/safe-int.mjs +23 -2
  332. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  333. package/dist/number/branded-types/safe-uint.mjs +1 -1
  334. package/dist/number/branded-types/uint.d.mts +12 -0
  335. package/dist/number/branded-types/uint.d.mts.map +1 -1
  336. package/dist/number/branded-types/uint.mjs +12 -0
  337. package/dist/number/branded-types/uint.mjs.map +1 -1
  338. package/dist/number/num.d.mts +9 -0
  339. package/dist/number/num.d.mts.map +1 -1
  340. package/dist/number/num.mjs +8 -1
  341. package/dist/number/num.mjs.map +1 -1
  342. package/dist/number/refined-number-utils.d.mts +22 -0
  343. package/dist/number/refined-number-utils.d.mts.map +1 -1
  344. package/dist/number/refined-number-utils.mjs +23 -0
  345. package/dist/number/refined-number-utils.mjs.map +1 -1
  346. package/dist/object/object.d.mts +9 -0
  347. package/dist/object/object.d.mts.map +1 -1
  348. package/dist/object/object.mjs +7 -0
  349. package/dist/object/object.mjs.map +1 -1
  350. package/dist/others/map-nullable.mjs.map +1 -1
  351. package/dist/others/tuple.d.mts +11 -0
  352. package/dist/others/tuple.d.mts.map +1 -1
  353. package/dist/others/tuple.mjs +11 -0
  354. package/dist/others/tuple.mjs.map +1 -1
  355. package/dist/others/unknown-to-string.d.mts.map +1 -1
  356. package/dist/others/unknown-to-string.mjs +2 -1
  357. package/dist/others/unknown-to-string.mjs.map +1 -1
  358. package/dist/promise/promise.d.mts +4 -0
  359. package/dist/promise/promise.d.mts.map +1 -1
  360. package/dist/promise/promise.mjs +5 -0
  361. package/dist/promise/promise.mjs.map +1 -1
  362. package/package.json +20 -24
  363. package/src/array/impl/array-utils-creation.mts +20 -0
  364. package/src/array/impl/array-utils-creation.test.mts +71 -0
  365. package/src/array/impl/array-utils-element-access.mts +13 -0
  366. package/src/array/impl/array-utils-element-access.test.mts +21 -0
  367. package/src/array/impl/array-utils-iterators.test.mts +17 -0
  368. package/src/array/impl/array-utils-modification.mts +40 -0
  369. package/src/array/impl/array-utils-modification.test.mts +75 -0
  370. package/src/array/impl/array-utils-overload-type-error.test.mts +19 -0
  371. package/src/array/impl/array-utils-reducing-value.mts +55 -9
  372. package/src/array/impl/array-utils-reducing-value.test.mts +90 -0
  373. package/src/array/impl/array-utils-search.mts +53 -0
  374. package/src/array/impl/array-utils-search.test.mts +51 -0
  375. package/src/array/impl/array-utils-set-op.mts +19 -0
  376. package/src/array/impl/array-utils-set-op.test.mts +116 -0
  377. package/src/array/impl/array-utils-size.mts +3 -0
  378. package/src/array/impl/array-utils-size.test.mts +1 -0
  379. package/src/array/impl/array-utils-slice-clamped.mts +7 -0
  380. package/src/array/impl/array-utils-slice-clamped.test.mts +20 -0
  381. package/src/array/impl/array-utils-slicing.mts +27 -0
  382. package/src/array/impl/array-utils-slicing.test.mts +57 -0
  383. package/src/array/impl/array-utils-transformation.mts +58 -0
  384. package/src/array/impl/array-utils-transformation.test.mts +113 -1
  385. package/src/array/impl/array-utils-validation.mts +23 -0
  386. package/src/array/impl/array-utils-validation.test.mts +96 -0
  387. package/src/array/impl/array.test.mts +12 -0
  388. package/src/collections/imap-mapped.mts +11 -0
  389. package/src/collections/imap-mapped.test.mts +70 -0
  390. package/src/collections/imap.mts +32 -0
  391. package/src/collections/imap.test.mts +106 -0
  392. package/src/collections/iset-mapped.mts +35 -0
  393. package/src/collections/iset-mapped.test.mts +111 -0
  394. package/src/collections/iset.mts +34 -0
  395. package/src/collections/iset.test.mts +193 -0
  396. package/src/collections/queue.mts +53 -0
  397. package/src/collections/queue.test.mts +32 -0
  398. package/src/collections/stack.mts +42 -0
  399. package/src/collections/stack.test.mts +44 -0
  400. package/src/functional/match.mts +16 -0
  401. package/src/functional/match.test.mts +2 -0
  402. package/src/functional/optional/impl/optional-expect-to-be.mts +3 -0
  403. package/src/functional/optional/impl/optional-filter.mts +6 -0
  404. package/src/functional/optional/impl/optional-flat-map.mts +4 -0
  405. package/src/functional/optional/impl/optional-from-nullable.mts +2 -0
  406. package/src/functional/optional/impl/optional-is-optional.mts +2 -0
  407. package/src/functional/optional/impl/optional-is-some.mts +1 -0
  408. package/src/functional/optional/impl/optional-map.mts +5 -0
  409. package/src/functional/optional/impl/optional-none.mts +2 -0
  410. package/src/functional/optional/impl/optional-or-else.mts +6 -0
  411. package/src/functional/optional/impl/optional-some.mts +3 -1
  412. package/src/functional/optional/impl/optional-to-nullable.mts +2 -0
  413. package/src/functional/optional/impl/optional-unwrap-or.mts +5 -0
  414. package/src/functional/optional/impl/optional-unwrap-throw.mts +1 -0
  415. package/src/functional/optional/impl/optional-unwrap.mts +2 -0
  416. package/src/functional/optional/impl/optional-zip.mts +2 -0
  417. package/src/functional/optional.test.mts +73 -0
  418. package/src/functional/pipe.test.mts +3 -0
  419. package/src/functional/result/impl/result-err.mts +3 -1
  420. package/src/functional/result/impl/result-expect-to-be.mts +3 -0
  421. package/src/functional/result/impl/result-flat-map.mts +7 -0
  422. package/src/functional/result/impl/result-fold.mts +6 -0
  423. package/src/functional/result/impl/result-from-promise.mts +3 -0
  424. package/src/functional/result/impl/result-from-throwable.mts +6 -1
  425. package/src/functional/result/impl/result-is-err.mts +2 -0
  426. package/src/functional/result/impl/result-is-ok.mts +2 -0
  427. package/src/functional/result/impl/result-is-result.mts +4 -0
  428. package/src/functional/result/impl/result-map-err.mts +5 -0
  429. package/src/functional/result/impl/result-map.mts +6 -0
  430. package/src/functional/result/impl/result-ok.mts +3 -1
  431. package/src/functional/result/impl/result-or-else.mts +6 -0
  432. package/src/functional/result/impl/result-swap.mts +2 -0
  433. package/src/functional/result/impl/result-to-optional.mts +2 -0
  434. package/src/functional/result/impl/result-unwrap-err-or.mts +5 -0
  435. package/src/functional/result/impl/result-unwrap-err-throw.mts +2 -0
  436. package/src/functional/result/impl/result-unwrap-err.mts +1 -0
  437. package/src/functional/result/impl/result-unwrap-ok-or.mts +5 -0
  438. package/src/functional/result/impl/result-unwrap-ok.mts +2 -0
  439. package/src/functional/result/impl/result-unwrap-throw.mts +2 -0
  440. package/src/functional/result/impl/result-zip.mts +3 -1
  441. package/src/functional/result.test.mts +88 -0
  442. package/src/functional/ternary-result/impl/ternary-result-err.mts +2 -1
  443. package/src/functional/ternary-result/impl/ternary-result-expect-to-be.mts +4 -0
  444. package/src/functional/ternary-result/impl/ternary-result-flat-map.mts +7 -0
  445. package/src/functional/ternary-result/impl/ternary-result-fold.mts +5 -0
  446. package/src/functional/ternary-result/impl/ternary-result-from-promise.mts +2 -0
  447. package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +5 -1
  448. package/src/functional/ternary-result/impl/ternary-result-is-ok.mts +1 -0
  449. package/src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts +4 -0
  450. package/src/functional/ternary-result/impl/ternary-result-is-warn.mts +1 -0
  451. package/src/functional/ternary-result/impl/ternary-result-map-err.mts +6 -0
  452. package/src/functional/ternary-result/impl/ternary-result-map-warn.mts +6 -0
  453. package/src/functional/ternary-result/impl/ternary-result-map.mts +9 -0
  454. package/src/functional/ternary-result/impl/ternary-result-ok.mts +1 -1
  455. package/src/functional/ternary-result/impl/ternary-result-or-else.mts +5 -0
  456. package/src/functional/ternary-result/impl/ternary-result-to-optional.mts +2 -0
  457. package/src/functional/ternary-result/impl/ternary-result-unwrap-err-or.mts +5 -0
  458. package/src/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mts +1 -0
  459. package/src/functional/ternary-result/impl/ternary-result-unwrap-err.mts +2 -0
  460. package/src/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mts +5 -0
  461. package/src/functional/ternary-result/impl/ternary-result-unwrap-ok.mts +3 -0
  462. package/src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts +1 -0
  463. package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mts +5 -0
  464. package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mts +1 -0
  465. package/src/functional/ternary-result/impl/ternary-result-unwrap-warn.mts +2 -0
  466. package/src/functional/ternary-result/impl/ternary-result-warn.mts +4 -1
  467. package/src/functional/ternary-result/impl/ternary-result-zip.mts +4 -0
  468. package/src/functional/ternary-result.test.mts +91 -0
  469. package/src/globals.d.mts +10 -0
  470. package/src/guard/has-key.test.mts +9 -0
  471. package/src/guard/is-non-empty-string.test.mts +20 -0
  472. package/src/guard/is-non-null-object.test.mts +19 -0
  473. package/src/guard/is-primitive.test.mts +23 -0
  474. package/src/guard/is-record.mts +34 -0
  475. package/src/guard/is-record.test.mts +21 -0
  476. package/src/guard/is-type.mts +3 -0
  477. package/src/guard/is-type.test.mts +134 -0
  478. package/src/guard/key-is-in.mts +1 -0
  479. package/src/iterator/range.mts +9 -0
  480. package/src/json/json.mts +29 -0
  481. package/src/json/json.test.mts +87 -0
  482. package/src/number/branded-types/finite-number.test.mts +38 -0
  483. package/src/number/branded-types/int.mts +14 -0
  484. package/src/number/branded-types/int.test.mts +42 -0
  485. package/src/number/branded-types/int16.test.mts +47 -0
  486. package/src/number/branded-types/int32.test.mts +47 -0
  487. package/src/number/branded-types/non-negative-finite-number.test.mts +40 -0
  488. package/src/number/branded-types/non-negative-int16.test.mts +43 -0
  489. package/src/number/branded-types/non-negative-int32.test.mts +43 -0
  490. package/src/number/branded-types/non-zero-finite-number.test.mts +51 -0
  491. package/src/number/branded-types/non-zero-int.test.mts +53 -0
  492. package/src/number/branded-types/non-zero-int16.test.mts +44 -0
  493. package/src/number/branded-types/non-zero-int32.test.mts +44 -0
  494. package/src/number/branded-types/non-zero-safe-int.mts +2 -2
  495. package/src/number/branded-types/non-zero-safe-int.test.mts +62 -0
  496. package/src/number/branded-types/non-zero-uint16.test.mts +37 -0
  497. package/src/number/branded-types/non-zero-uint32.test.mts +37 -0
  498. package/src/number/branded-types/positive-finite-number.test.mts +45 -0
  499. package/src/number/branded-types/positive-int.mts +14 -0
  500. package/src/number/branded-types/positive-int.test.mts +47 -0
  501. package/src/number/branded-types/positive-int16.test.mts +35 -0
  502. package/src/number/branded-types/positive-int32.test.mts +35 -0
  503. package/src/number/branded-types/positive-safe-int.mts +22 -1
  504. package/src/number/branded-types/positive-safe-int.test.mts +49 -0
  505. package/src/number/branded-types/positive-uint16.test.mts +37 -0
  506. package/src/number/branded-types/positive-uint32.test.mts +37 -0
  507. package/src/number/branded-types/safe-int.mts +23 -2
  508. package/src/number/branded-types/safe-int.test.mts +52 -0
  509. package/src/number/branded-types/safe-uint.mts +1 -1
  510. package/src/number/branded-types/safe-uint.test.mts +48 -0
  511. package/src/number/branded-types/uint.mts +12 -0
  512. package/src/number/branded-types/uint.test.mts +43 -0
  513. package/src/number/branded-types/uint16.test.mts +41 -0
  514. package/src/number/branded-types/uint32.test.mts +41 -0
  515. package/src/number/enum/int8.test.mts +6 -0
  516. package/src/number/enum/uint8.test.mts +6 -0
  517. package/src/number/num.mts +12 -1
  518. package/src/number/num.test.mts +62 -0
  519. package/src/number/refined-number-utils.mts +25 -0
  520. package/src/object/object.mts +15 -0
  521. package/src/object/object.test.mts +10 -0
  522. package/src/others/cast-mutable.test.mts +7 -0
  523. package/src/others/cast-readonly.test.mts +17 -0
  524. package/src/others/if-then.test.mts +16 -0
  525. package/src/others/map-nullable.mts +3 -0
  526. package/src/others/map-nullable.test.mts +27 -0
  527. package/src/others/memoize-function.test.mts +41 -0
  528. package/src/others/tuple.mts +11 -0
  529. package/src/others/unknown-to-string.mts +4 -1
  530. package/src/others/unknown-to-string.test.mts +10 -0
  531. package/src/promise/promise.mts +4 -0
  532. package/src/promise/promise.test.mts +1 -0
@@ -9,11 +9,15 @@ import { Optional, pipe } from '../../functional/index.mjs';
9
9
  * const letters: readonly string[] = ['a', 'b', 'c'];
10
10
  *
11
11
  * const two = Arr.at(letters, 1);
12
+ *
12
13
  * const last = Arr.at(-1)(letters);
14
+ *
13
15
  * const missing = Arr.at(letters, 5);
14
16
  *
15
17
  * assert.deepStrictEqual(two, Optional.some('b'));
18
+ *
16
19
  * assert.deepStrictEqual(last, Optional.some('c'));
20
+ *
17
21
  * assert.deepStrictEqual(missing, Optional.none);
18
22
  * ```
19
23
  */
@@ -36,6 +40,7 @@ export function at<E>(
36
40
  switch (args.length) {
37
41
  case 2: {
38
42
  const [array, index] = args;
43
+
39
44
  return pipe(index < 0 ? array.length + index : index).map(
40
45
  (normalizedIndex) =>
41
46
  normalizedIndex < 0 || normalizedIndex >= array.length
@@ -44,8 +49,10 @@ export function at<E>(
44
49
  Optional.some(array[normalizedIndex]!),
45
50
  ).value;
46
51
  }
52
+
47
53
  case 1: {
48
54
  const [index] = args;
55
+
49
56
  return (array) => at(array, index);
50
57
  }
51
58
  }
@@ -58,12 +65,15 @@ export function at<E>(
58
65
  *
59
66
  * ```ts
60
67
  * const users = [{ id: 1 }, { id: 2 }];
68
+ *
61
69
  * const empty: { id: number }[] = [];
62
70
  *
63
71
  * const first = Arr.head(users);
72
+ *
64
73
  * const none = Arr.head(empty);
65
74
  *
66
75
  * assert.deepStrictEqual(first, Optional.some({ id: 1 }));
76
+ *
67
77
  * assert.deepStrictEqual(none, Optional.none);
68
78
  * ```
69
79
  */
@@ -86,12 +96,15 @@ export const head = <const Ar extends readonly unknown[]>(
86
96
  *
87
97
  * ```ts
88
98
  * const queue = ['first', 'second'];
99
+ *
89
100
  * const emptyQueue: string[] = [];
90
101
  *
91
102
  * const lastValue = Arr.last(queue);
103
+ *
92
104
  * const none = Arr.last(emptyQueue);
93
105
  *
94
106
  * assert.deepStrictEqual(lastValue, Optional.some('second'));
107
+ *
95
108
  * assert.deepStrictEqual(none, Optional.none);
96
109
  * ```
97
110
  */
@@ -7,6 +7,7 @@ describe('Arr element access', () => {
7
7
  describe(at, () => {
8
8
  test('should handle very large positive indices', () => {
9
9
  const array = [1, 2, 3];
10
+
10
11
  const result = at(array, asUint32(1000));
11
12
 
12
13
  expect(Optional.isNone(result)).toBe(true);
@@ -14,6 +15,7 @@ describe('Arr element access', () => {
14
15
 
15
16
  test('should handle very large negative indices', () => {
16
17
  const array = [1, 2, 3];
18
+
17
19
  const result = at(array, asInt32(-1000));
18
20
 
19
21
  expect(Optional.isNone(result)).toBe(true);
@@ -21,6 +23,7 @@ describe('Arr element access', () => {
21
23
 
22
24
  test('should work with valid indices', () => {
23
25
  const array = [10, 20, 30];
26
+
24
27
  const result = at(array, 1);
25
28
 
26
29
  expect(Optional.isSome(result)).toBe(true);
@@ -29,11 +32,24 @@ describe('Arr element access', () => {
29
32
  expect(result.value).toBe(20);
30
33
  }
31
34
  });
35
+
36
+ test('should work with curried version', () => {
37
+ const atIndex2 = at(2);
38
+
39
+ const result = atIndex2([10, 20, 30, 40]);
40
+
41
+ expect(Optional.isSome(result)).toBe(true);
42
+
43
+ if (Optional.isSome(result)) {
44
+ expect(result.value).toBe(30);
45
+ }
46
+ });
32
47
  });
33
48
 
34
49
  describe(head, () => {
35
50
  test('case 1', () => {
36
51
  const xs = [1, 2, 3] as const;
52
+
37
53
  const h = head(xs);
38
54
 
39
55
  expectType<typeof h, Some<1>>('=');
@@ -47,6 +63,7 @@ describe('Arr element access', () => {
47
63
 
48
64
  test('case 2', () => {
49
65
  const xs: MutableNonEmptyArray<number> = [1, 2, 3];
66
+
50
67
  const h = head(xs);
51
68
 
52
69
  expectType<typeof h, Some<number>>('=');
@@ -60,6 +77,7 @@ describe('Arr element access', () => {
60
77
 
61
78
  test('case 3', () => {
62
79
  const mut_xs: number[] = [1, 2, 3];
80
+
63
81
  const h = head(mut_xs);
64
82
 
65
83
  expectType<typeof h, Optional<number>>('=');
@@ -101,6 +119,7 @@ describe('Arr element access', () => {
101
119
  describe(last, () => {
102
120
  test('case 1', () => {
103
121
  const xs = [1, 2, 3] as const;
122
+
104
123
  const l = last(xs);
105
124
 
106
125
  expectType<typeof l, Some<3>>('=');
@@ -114,6 +133,7 @@ describe('Arr element access', () => {
114
133
 
115
134
  test('case 2', () => {
116
135
  const xs: MutableNonEmptyArray<number> = [1, 2, 3];
136
+
117
137
  const l = last(xs);
118
138
 
119
139
  expectType<typeof l, Some<number>>('=');
@@ -127,6 +147,7 @@ describe('Arr element access', () => {
127
147
 
128
148
  test('case 3', () => {
129
149
  const mut_xs: number[] = [1, 2, 3];
150
+
130
151
  const l = last(mut_xs);
131
152
 
132
153
  expectType<typeof l, Optional<number>>('=');
@@ -5,6 +5,7 @@ import { entries, indices, values } from './array-utils-iterators.mjs';
5
5
  describe(entries, () => {
6
6
  test('should return array of index-value pairs', () => {
7
7
  const fruits = ['apple', 'banana', 'cherry'];
8
+
8
9
  const es = Array.from(entries(fruits));
9
10
 
10
11
  assert.deepStrictEqual(es, [
@@ -16,7 +17,9 @@ describe(entries, () => {
16
17
 
17
18
  test('should work with tuples', () => {
18
19
  const tuple = [10, 20, 30] as const;
20
+
19
21
  const es = Array.from(entries(tuple));
22
+
20
23
  expectType<typeof es, (readonly [Uint32, 10 | 20 | 30])[]>('=');
21
24
 
22
25
  assert.deepStrictEqual(es, [
@@ -28,6 +31,7 @@ describe(entries, () => {
28
31
 
29
32
  test('should work with empty array', () => {
30
33
  const empty: string[] = [];
34
+
31
35
  const es = Array.from(entries(empty));
32
36
 
33
37
  assert.deepStrictEqual(es, []);
@@ -35,7 +39,9 @@ describe(entries, () => {
35
39
 
36
40
  test('should preserve mixed types', () => {
37
41
  const mixed = [1, 'hello', true] as const;
42
+
38
43
  const es = Array.from(entries(mixed));
44
+
39
45
  expectType<typeof es, (readonly [Uint32, 1 | 'hello' | true])[]>('=');
40
46
 
41
47
  assert.deepStrictEqual(es, [
@@ -49,6 +55,7 @@ describe(entries, () => {
49
55
  describe(values, () => {
50
56
  test('should return copy of array values', () => {
51
57
  const numbers = [1, 2, 3];
58
+
52
59
  const vs = Array.from(values(numbers));
53
60
 
54
61
  assert.deepStrictEqual(vs, [1, 2, 3]);
@@ -58,7 +65,9 @@ describe(values, () => {
58
65
 
59
66
  test('should work with tuples', () => {
60
67
  const tuple = ['a', 'b', 'c'] as const;
68
+
61
69
  const vs = Array.from(values(tuple));
70
+
62
71
  expectType<typeof vs, ('a' | 'b' | 'c')[]>('=');
63
72
 
64
73
  assert.deepStrictEqual(vs, ['a', 'b', 'c']);
@@ -66,6 +75,7 @@ describe(values, () => {
66
75
 
67
76
  test('should work with empty array', () => {
68
77
  const empty: number[] = [];
78
+
69
79
  const vs = Array.from(values(empty));
70
80
 
71
81
  assert.deepStrictEqual(vs, []);
@@ -73,7 +83,9 @@ describe(values, () => {
73
83
 
74
84
  test('should preserve mixed types', () => {
75
85
  const mixed = [1, 'hello', null] as const;
86
+
76
87
  const vs = Array.from(values(mixed));
88
+
77
89
  expectType<typeof vs, (1 | 'hello' | null)[]>('=');
78
90
 
79
91
  assert.deepStrictEqual(vs, [1, 'hello', null]);
@@ -83,6 +95,7 @@ describe(values, () => {
83
95
  describe(indices, () => {
84
96
  test('should return array of indices', () => {
85
97
  const fruits = ['apple', 'banana', 'cherry'];
98
+
86
99
  const ks = Array.from(indices(fruits));
87
100
 
88
101
  assert.deepStrictEqual(ks, [asUint32(0), asUint32(1), asUint32(2)]);
@@ -90,7 +103,9 @@ describe(indices, () => {
90
103
 
91
104
  test('should work with tuples', () => {
92
105
  const tuple = ['a', 'b'] as const;
106
+
93
107
  const ks = Array.from(indices(tuple));
108
+
94
109
  expectType<typeof ks, Uint32[]>('=');
95
110
 
96
111
  assert.deepStrictEqual(ks, [asUint32(0), asUint32(1)]);
@@ -98,6 +113,7 @@ describe(indices, () => {
98
113
 
99
114
  test('should work with empty array', () => {
100
115
  const empty: string[] = [];
116
+
101
117
  const ks = Array.from(indices(empty));
102
118
 
103
119
  assert.deepStrictEqual(ks, []);
@@ -105,6 +121,7 @@ describe(indices, () => {
105
121
 
106
122
  test('should work with larger arrays', () => {
107
123
  const large = Array.from({ length: 5 }, () => 'x');
124
+
108
125
  const ks = Array.from(indices(large));
109
126
 
110
127
  assert.deepStrictEqual(ks, [
@@ -45,11 +45,14 @@ export function set<E, const V = E>(
45
45
  switch (args.length) {
46
46
  case 3: {
47
47
  const [array, index, newValue] = args;
48
+
48
49
  // eslint-disable-next-line total-functions/no-unsafe-type-assertion
49
50
  return (array as (E | V)[]).with(index, newValue);
50
51
  }
52
+
51
53
  case 2: {
52
54
  const [index, newValue] = args;
55
+
53
56
  return (array) => set(array, index, newValue);
54
57
  }
55
58
  }
@@ -64,12 +67,14 @@ export function set<E, const V = E>(
64
67
  * const temperatures: number[] = [20, 21, 22];
65
68
  *
66
69
  * const increased = Arr.toUpdated(temperatures, 1, (value) => value + 5);
70
+ *
67
71
  * const incrementLast = Arr.toUpdated<number>(
68
72
  * 2,
69
73
  * (value) => value + 1,
70
74
  * )(temperatures);
71
75
  *
72
76
  * assert.deepStrictEqual(increased, [20, 26, 22]);
77
+ *
73
78
  * assert.deepStrictEqual(incrementLast, [20, 21, 23]);
74
79
  * ```
75
80
  */
@@ -110,11 +115,14 @@ export function toUpdated<E, V = E>(
110
115
  switch (args.length) {
111
116
  case 3: {
112
117
  const [array, index, updater] = args;
118
+
113
119
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, total-functions/no-unsafe-type-assertion
114
120
  return (array as (E | V)[]).with(index, updater(array[index]!));
115
121
  }
122
+
116
123
  case 2: {
117
124
  const [index, updater] = args;
125
+
118
126
  return (array) => toUpdated(array, index, updater);
119
127
  }
120
128
  }
@@ -129,9 +137,11 @@ export function toUpdated<E, V = E>(
129
137
  * const numbers = [1, 2, 4] as const;
130
138
  *
131
139
  * const withThree = Arr.toInserted(numbers, 2, 3);
140
+ *
132
141
  * const appendFive = Arr.toInserted(3, 5)(numbers);
133
142
  *
134
143
  * assert.deepStrictEqual(withThree, [1, 2, 3, 4]);
144
+ *
135
145
  * assert.deepStrictEqual(appendFive, [1, 2, 4, 5]);
136
146
  * ```
137
147
  */
@@ -168,6 +178,7 @@ export function toInserted<E, const V = E>(
168
178
  switch (args.length) {
169
179
  case 3: {
170
180
  const [array, index, newValue] = args;
181
+
171
182
  // eslint-disable-next-line total-functions/no-unsafe-type-assertion
172
183
  return (array as readonly (E | V)[]).toSpliced(
173
184
  index,
@@ -175,8 +186,10 @@ export function toInserted<E, const V = E>(
175
186
  newValue,
176
187
  ) as unknown as NonEmptyArray<E | V>;
177
188
  }
189
+
178
190
  case 2: {
179
191
  const [index, newValue] = args;
192
+
180
193
  return (array) => toInserted(array, index, newValue);
181
194
  }
182
195
  }
@@ -193,9 +206,11 @@ type CastToNumber<T> = T extends number ? T : never;
193
206
  * const letters = ['a', 'b', 'c', 'd'] as const;
194
207
  *
195
208
  * const withoutSecond = Arr.toRemoved(letters, 1);
209
+ *
196
210
  * const withoutFirstCurried = Arr.toRemoved(0)(letters);
197
211
  *
198
212
  * assert.deepStrictEqual(withoutSecond, ['a', 'c', 'd']);
213
+ *
199
214
  * assert.deepStrictEqual(withoutFirstCurried, ['b', 'c', 'd']);
200
215
  * ```
201
216
  */
@@ -216,10 +231,13 @@ export function toRemoved<E>(
216
231
  switch (args.length) {
217
232
  case 2: {
218
233
  const [array, index] = args;
234
+
219
235
  return array.toSpliced(index, 1);
220
236
  }
237
+
221
238
  case 1: {
222
239
  const [index] = args;
240
+
223
241
  return (array) => toRemoved(array, index);
224
242
  }
225
243
  }
@@ -234,9 +252,11 @@ export function toRemoved<E>(
234
252
  * const base = [1, 2] as const;
235
253
  *
236
254
  * const appended = Arr.toPushed(base, 3);
255
+ *
237
256
  * const appendedCurried = Arr.toPushed(4)(base);
238
257
  *
239
258
  * assert.deepStrictEqual(appended, [1, 2, 3]);
259
+ *
240
260
  * assert.deepStrictEqual(appendedCurried, [1, 2, 4]);
241
261
  * ```
242
262
  */
@@ -255,14 +275,17 @@ export function toPushed<const Ar extends readonly unknown[], const V>(
255
275
  switch (args.length) {
256
276
  case 2: {
257
277
  const [array, newValue] = args;
278
+
258
279
  // eslint-disable-next-line total-functions/no-unsafe-type-assertion
259
280
  return array.toSpliced(array.length, 0, newValue) as unknown as readonly [
260
281
  ...Ar,
261
282
  V,
262
283
  ];
263
284
  }
285
+
264
286
  case 1: {
265
287
  const [newValue] = args;
288
+
266
289
  return (array) => toPushed(array, newValue);
267
290
  }
268
291
  }
@@ -277,9 +300,11 @@ export function toPushed<const Ar extends readonly unknown[], const V>(
277
300
  * const base = [2, 3] as const;
278
301
  *
279
302
  * const prefixed = Arr.toUnshifted(base, 1);
303
+ *
280
304
  * const prefixedCurried = Arr.toUnshifted(0)(base);
281
305
  *
282
306
  * assert.deepStrictEqual(prefixed, [1, 2, 3]);
307
+ *
283
308
  * assert.deepStrictEqual(prefixedCurried, [0, 2, 3]);
284
309
  * ```
285
310
  */
@@ -298,11 +323,14 @@ export function toUnshifted<Ar extends readonly unknown[], const V>(
298
323
  switch (args.length) {
299
324
  case 2: {
300
325
  const [array, newValue] = args;
326
+
301
327
  // eslint-disable-next-line total-functions/no-unsafe-type-assertion
302
328
  return array.toSpliced(0, 0, newValue) as unknown as readonly [V, ...Ar];
303
329
  }
330
+
304
331
  case 1: {
305
332
  const [newValue] = args;
333
+
306
334
  return (array) => toUnshifted(array, newValue);
307
335
  }
308
336
  }
@@ -317,9 +345,11 @@ export function toUnshifted<Ar extends readonly unknown[], const V>(
317
345
  * const base = [1, 2, 3];
318
346
  *
319
347
  * const filled = Arr.toFilled(base, 0);
348
+ *
320
349
  * const filledCurried = Arr.toFilled('x')(base);
321
350
  *
322
351
  * assert.deepStrictEqual(filled, [0, 0, 0]);
352
+ *
323
353
  * assert.deepStrictEqual(filledCurried, ['x', 'x', 'x']);
324
354
  * ```
325
355
  */
@@ -349,10 +379,13 @@ export function toFilled<E>(
349
379
  switch (args.length) {
350
380
  case 2: {
351
381
  const [array, value] = args;
382
+
352
383
  return create(asPositiveUint32(array.length), value);
353
384
  }
385
+
354
386
  case 1: {
355
387
  const [value] = args;
388
+
356
389
  return (array) => toFilled(array, value);
357
390
  }
358
391
  }
@@ -367,9 +400,11 @@ export function toFilled<E>(
367
400
  * const base = [0, 1, 2, 3, 4];
368
401
  *
369
402
  * const filledMiddle = Arr.toRangeFilled(base, 9, [1, 4]);
403
+ *
370
404
  * const filledPrefix = Arr.toRangeFilled(8, [0, 2])(base);
371
405
  *
372
406
  * assert.deepStrictEqual(filledMiddle, [0, 9, 9, 9, 4]);
407
+ *
373
408
  * assert.deepStrictEqual(filledPrefix, [8, 8, 2, 3, 4]);
374
409
  * ```
375
410
  */
@@ -422,12 +457,17 @@ export function toRangeFilled<E, const V>(
422
457
  switch (args.length) {
423
458
  case 3: {
424
459
  const [array, value, [start, end]] = args;
460
+
425
461
  const mut_cp: (E | V)[] = castMutable(copy(array));
462
+
426
463
  mut_cp.fill(value, start, end);
464
+
427
465
  return mut_cp;
428
466
  }
467
+
429
468
  case 2: {
430
469
  const [value, fillRange] = args;
470
+
431
471
  return (array) => toRangeFilled(array, value, fillRange);
432
472
  }
433
473
  }
@@ -14,6 +14,7 @@ import {
14
14
  describe('Arr modifications', () => {
15
15
  describe(toUpdated, () => {
16
16
  const xs = [1, 2, 3] as const;
17
+
17
18
  const result = toUpdated(xs, 1, (x) => x + 2);
18
19
 
19
20
  expectType<typeof result, ArrayOfLength<3, number>>('=');
@@ -21,6 +22,14 @@ describe('Arr modifications', () => {
21
22
  test('case 1', () => {
22
23
  assert.deepStrictEqual(result, [1, 4, 3]);
23
24
  });
25
+
26
+ test('should work with curried version', () => {
27
+ const updater = toUpdated(1, (x: number) => x * 2);
28
+
29
+ const r = updater([10, 20, 30]);
30
+
31
+ assert.deepStrictEqual(r, [10, 40, 30]);
32
+ });
24
33
  });
25
34
 
26
35
  describe(toInserted, () => {
@@ -53,11 +62,20 @@ describe('Arr modifications', () => {
53
62
 
54
63
  assert.deepStrictEqual(result, ['a', 'b', 'c', 5]);
55
64
  });
65
+
66
+ test('should work with curried version', () => {
67
+ const inserter = toInserted(2, 99);
68
+
69
+ const result = inserter([1, 2, 3]);
70
+
71
+ assert.deepStrictEqual(result, [1, 2, 99, 3]);
72
+ });
56
73
  });
57
74
 
58
75
  describe(toRemoved, () => {
59
76
  test('case 1', () => {
60
77
  const xs = [1, 2, 3] as const;
78
+
61
79
  const result = toRemoved(xs, 1);
62
80
 
63
81
  expectType<typeof result, readonly (1 | 2 | 3)[]>('=');
@@ -67,6 +85,7 @@ describe('Arr modifications', () => {
67
85
 
68
86
  test('case 2 (remove head)', () => {
69
87
  const xs = [1, 2, 3] as const;
88
+
70
89
  const result = toRemoved(xs, 0);
71
90
 
72
91
  expectType<typeof result, readonly (1 | 2 | 3)[]>('=');
@@ -76,6 +95,7 @@ describe('Arr modifications', () => {
76
95
 
77
96
  test('case 3 (remove tail)', () => {
78
97
  const xs = [1, 2, 3] as const;
98
+
79
99
  const result = toRemoved(xs, 2);
80
100
 
81
101
  expectType<typeof result, readonly (1 | 2 | 3)[]>('=');
@@ -85,17 +105,27 @@ describe('Arr modifications', () => {
85
105
 
86
106
  test('case 4 (number[])', () => {
87
107
  const xs: number[] = [1, 2, 3];
108
+
88
109
  const result = toRemoved(xs, 5);
89
110
 
90
111
  expectType<typeof result, readonly number[]>('=');
91
112
 
92
113
  assert.deepStrictEqual(result, [1, 2, 3]);
93
114
  });
115
+
116
+ test('should work with curried version', () => {
117
+ const removeFirst = toRemoved(0);
118
+
119
+ const result = removeFirst([10, 20, 30]);
120
+
121
+ assert.deepStrictEqual(result, [20, 30]);
122
+ });
94
123
  });
95
124
 
96
125
  describe(toPushed, () => {
97
126
  test('case 1', () => {
98
127
  const xs = [1, 2, 3] as const;
128
+
99
129
  const result = toPushed(xs, 4 as const);
100
130
 
101
131
  expectType<typeof result, readonly [1, 2, 3, 4]>('=');
@@ -105,12 +135,21 @@ describe('Arr modifications', () => {
105
135
 
106
136
  test('case 2', () => {
107
137
  const xs: number[] = [1, 2, 3];
138
+
108
139
  const result = toPushed(xs, 4 as const);
109
140
 
110
141
  expectType<typeof result, readonly [...number[], 4]>('=');
111
142
 
112
143
  assert.deepStrictEqual(result, [1, 2, 3, 4]);
113
144
  });
145
+
146
+ test('should work with curried version', () => {
147
+ const pushFive = toPushed(5);
148
+
149
+ const result = pushFive([1, 2, 3]);
150
+
151
+ assert.deepStrictEqual(result, [1, 2, 3, 5]);
152
+ });
114
153
  });
115
154
 
116
155
  describe(toUnshifted, () => {
@@ -133,11 +172,20 @@ describe('Arr modifications', () => {
133
172
 
134
173
  assert.deepStrictEqual(result, [4, 1, 2, 3]);
135
174
  });
175
+
176
+ test('should work with curried version', () => {
177
+ const unshiftZero = toUnshifted(0);
178
+
179
+ const result = unshiftZero([1, 2, 3]);
180
+
181
+ assert.deepStrictEqual(result, [0, 1, 2, 3]);
182
+ });
136
183
  });
137
184
 
138
185
  describe(toFilled, () => {
139
186
  test('should fill entire array with value', () => {
140
187
  const arr = [1, 2, 3, 4, 5];
188
+
141
189
  const result = toFilled(arr, 0);
142
190
 
143
191
  assert.deepStrictEqual(result, [0, 0, 0, 0, 0]);
@@ -145,7 +193,9 @@ describe('Arr modifications', () => {
145
193
 
146
194
  test('should work with curried version', () => {
147
195
  const fillWithZero = toFilled(0);
196
+
148
197
  const arr = [1, 2, 3];
198
+
149
199
  const result = fillWithZero(arr);
150
200
 
151
201
  assert.deepStrictEqual(result, [0, 0, 0]);
@@ -155,6 +205,7 @@ describe('Arr modifications', () => {
155
205
  describe(toRangeFilled, () => {
156
206
  test('should fill array with range', () => {
157
207
  const arr = [1, 2, 3, 4, 5];
208
+
158
209
  const result = toRangeFilled(arr, 0, [1, 4]);
159
210
 
160
211
  assert.deepStrictEqual(result, [1, 0, 0, 0, 5]);
@@ -162,6 +213,7 @@ describe('Arr modifications', () => {
162
213
 
163
214
  test('should fill with range starting from 0', () => {
164
215
  const arr = [1, 2, 3, 4, 5];
216
+
165
217
  const result = toRangeFilled(arr, 9, [0, 3]);
166
218
 
167
219
  assert.deepStrictEqual(result, [9, 9, 9, 4, 5]);
@@ -169,6 +221,7 @@ describe('Arr modifications', () => {
169
221
 
170
222
  test('should handle empty range', () => {
171
223
  const arr = [1, 2, 3];
224
+
172
225
  const result = toRangeFilled(arr, 0, [2, 2]);
173
226
 
174
227
  assert.deepStrictEqual(result, [1, 2, 3]);
@@ -176,6 +229,7 @@ describe('Arr modifications', () => {
176
229
 
177
230
  test('should clamp range to array bounds', () => {
178
231
  const arr = [1, 2, 3];
232
+
179
233
  const result = toRangeFilled(arr, 0, [1, 10]);
180
234
 
181
235
  assert.deepStrictEqual(result, [1, 0, 0]);
@@ -183,11 +237,20 @@ describe('Arr modifications', () => {
183
237
 
184
238
  test('should handle negative start (clamped to 0)', () => {
185
239
  const arr = [1, 2, 3];
240
+
186
241
  const result = toRangeFilled(arr, 9, [-5, 2]);
187
242
 
188
243
  assert.deepStrictEqual(result, [9, 9, 3]);
189
244
  });
190
245
 
246
+ test('should work with curried version', () => {
247
+ const fillMiddle = toRangeFilled(7, [1, 3]);
248
+
249
+ const result = fillMiddle([1, 2, 3, 4]);
250
+
251
+ assert.deepStrictEqual(result, [1, 7, 7, 4]);
252
+ });
253
+
191
254
  test('A non-integer starting value should result in a type error', () => {
192
255
  const arr = [1, 2, 3];
193
256
 
@@ -214,7 +277,9 @@ describe('Arr modifications', () => {
214
277
 
215
278
  test('should work with different value types', () => {
216
279
  const nums = [1, 2, 3] as const;
280
+
217
281
  const withString = set(nums, 1, 'two');
282
+
218
283
  expectType<typeof withString, readonly [1 | 'two', 2 | 'two', 3 | 'two']>(
219
284
  '=',
220
285
  );
@@ -224,6 +289,7 @@ describe('Arr modifications', () => {
224
289
 
225
290
  test('should work at index 0', () => {
226
291
  const tuple = ['a', 'b', 'c'] as const;
292
+
227
293
  const updated = set(tuple, 0, 'A');
228
294
 
229
295
  assert.deepStrictEqual(updated, ['A', 'b', 'c']);
@@ -231,9 +297,18 @@ describe('Arr modifications', () => {
231
297
 
232
298
  test('should work at last index', () => {
233
299
  const tuple = ['a', 'b', 'c'] as const;
300
+
234
301
  const updated = set(tuple, 2, 'C');
235
302
 
236
303
  assert.deepStrictEqual(updated, ['a', 'b', 'C']);
237
304
  });
305
+
306
+ test('should work with curried version', () => {
307
+ const setIndex1To99 = set(1, 99);
308
+
309
+ const r = setIndex1To99([10, 20, 30]);
310
+
311
+ assert.deepStrictEqual(r, [10, 99, 30]);
312
+ });
238
313
  });
239
314
  });