ts-data-forge 9.0.0 → 10.0.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 (447) hide show
  1. package/README.md +1 -1
  2. package/dist/array/impl/array-utils-creation.d.mts +4 -4
  3. package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
  4. package/dist/array/impl/array-utils-creation.mjs +17 -112
  5. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  6. package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
  7. package/dist/array/impl/array-utils-element-access.mjs +22 -61
  8. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  9. package/dist/array/impl/array-utils-iterators.d.mts.map +1 -1
  10. package/dist/array/impl/array-utils-iterators.mjs +9 -63
  11. package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
  12. package/dist/array/impl/array-utils-modification.d.mts +7 -7
  13. package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
  14. package/dist/array/impl/array-utils-modification.mjs +78 -78
  15. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  16. package/dist/array/impl/array-utils-reducing-value.mjs +95 -89
  17. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  18. package/dist/array/impl/array-utils-search.mjs +100 -92
  19. package/dist/array/impl/array-utils-search.mjs.map +1 -1
  20. package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
  21. package/dist/array/impl/array-utils-set-op.mjs +31 -141
  22. package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
  23. package/dist/array/impl/array-utils-size.d.mts.map +1 -1
  24. package/dist/array/impl/array-utils-size.mjs +4 -8
  25. package/dist/array/impl/array-utils-size.mjs.map +1 -1
  26. package/dist/array/impl/array-utils-slice-clamped.mjs +11 -12
  27. package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
  28. package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
  29. package/dist/array/impl/array-utils-slicing.mjs +44 -96
  30. package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
  31. package/dist/array/impl/array-utils-transformation.d.mts +4 -4
  32. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
  33. package/dist/array/impl/array-utils-transformation.mjs +150 -292
  34. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  35. package/dist/array/impl/array-utils-validation.d.mts +17 -17
  36. package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
  37. package/dist/array/impl/array-utils-validation.mjs +23 -174
  38. package/dist/array/impl/array-utils-validation.mjs.map +1 -1
  39. package/dist/array/impl/index.mjs +1 -1
  40. package/dist/collections/imap-mapped.d.mts.map +1 -1
  41. package/dist/collections/imap-mapped.mjs +243 -330
  42. package/dist/collections/imap-mapped.mjs.map +1 -1
  43. package/dist/collections/imap.d.mts.map +1 -1
  44. package/dist/collections/imap.mjs +190 -275
  45. package/dist/collections/imap.mjs.map +1 -1
  46. package/dist/collections/iset-mapped.d.mts +1 -1
  47. package/dist/collections/iset-mapped.d.mts.map +1 -1
  48. package/dist/collections/iset-mapped.mjs +222 -444
  49. package/dist/collections/iset-mapped.mjs.map +1 -1
  50. package/dist/collections/iset.d.mts +1 -1
  51. package/dist/collections/iset.d.mts.map +1 -1
  52. package/dist/collections/iset.mjs +158 -324
  53. package/dist/collections/iset.mjs.map +1 -1
  54. package/dist/collections/queue.d.mts.map +1 -1
  55. package/dist/collections/queue.mjs +106 -178
  56. package/dist/collections/queue.mjs.map +1 -1
  57. package/dist/collections/stack.d.mts.map +1 -1
  58. package/dist/collections/stack.mjs +95 -165
  59. package/dist/collections/stack.mjs.map +1 -1
  60. package/dist/entry-point.mjs +2 -0
  61. package/dist/entry-point.mjs.map +1 -1
  62. package/dist/expect-type.d.mts +1 -1
  63. package/dist/expect-type.d.mts.map +1 -1
  64. package/dist/expect-type.mjs +1 -69
  65. package/dist/expect-type.mjs.map +1 -1
  66. package/dist/functional/match.mjs +9 -9
  67. package/dist/functional/match.mjs.map +1 -1
  68. package/dist/functional/optional/impl/optional-expect-to-be.mjs +13 -14
  69. package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
  70. package/dist/functional/optional/impl/optional-filter.mjs +14 -15
  71. package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
  72. package/dist/functional/optional/impl/optional-flat-map.mjs +10 -11
  73. package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
  74. package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +1 -1
  75. package/dist/functional/optional/impl/optional-from-nullable.mjs +1 -25
  76. package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
  77. package/dist/functional/optional/impl/optional-is-none.d.mts.map +1 -1
  78. package/dist/functional/optional/impl/optional-is-none.mjs +0 -19
  79. package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -1
  80. package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -1
  81. package/dist/functional/optional/impl/optional-is-optional.mjs +1 -23
  82. package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
  83. package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -1
  84. package/dist/functional/optional/impl/optional-is-some.mjs +0 -20
  85. package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
  86. package/dist/functional/optional/impl/optional-map.mjs +13 -14
  87. package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
  88. package/dist/functional/optional/impl/optional-none.mjs +0 -16
  89. package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
  90. package/dist/functional/optional/impl/optional-or-else.mjs +10 -11
  91. package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
  92. package/dist/functional/optional/impl/optional-some.d.mts.map +1 -1
  93. package/dist/functional/optional/impl/optional-some.mjs +2 -21
  94. package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
  95. package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -1
  96. package/dist/functional/optional/impl/optional-to-nullable.mjs +1 -27
  97. package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
  98. package/dist/functional/optional/impl/optional-unwrap-or.mjs +9 -10
  99. package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
  100. package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -1
  101. package/dist/functional/optional/impl/optional-unwrap-throw.mjs +4 -32
  102. package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
  103. package/dist/functional/optional/impl/optional-unwrap.mjs +4 -4
  104. package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
  105. package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -1
  106. package/dist/functional/optional/impl/optional-zip.mjs +1 -35
  107. package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
  108. package/dist/functional/optional/impl/tag.mjs +2 -3
  109. package/dist/functional/optional/impl/tag.mjs.map +1 -1
  110. package/dist/functional/pipe.d.mts.map +1 -1
  111. package/dist/functional/pipe.mjs +9 -34
  112. package/dist/functional/pipe.mjs.map +1 -1
  113. package/dist/functional/result/impl/result-err.d.mts.map +1 -1
  114. package/dist/functional/result/impl/result-err.mjs +2 -27
  115. package/dist/functional/result/impl/result-err.mjs.map +1 -1
  116. package/dist/functional/result/impl/result-expect-to-be.mjs +13 -15
  117. package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
  118. package/dist/functional/result/impl/result-flat-map.mjs +16 -16
  119. package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
  120. package/dist/functional/result/impl/result-fold.mjs +16 -16
  121. package/dist/functional/result/impl/result-fold.mjs.map +1 -1
  122. package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -1
  123. package/dist/functional/result/impl/result-from-promise.mjs +4 -31
  124. package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
  125. package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -1
  126. package/dist/functional/result/impl/result-from-throwable.mjs +8 -38
  127. package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
  128. package/dist/functional/result/impl/result-is-err.d.mts.map +1 -1
  129. package/dist/functional/result/impl/result-is-err.mjs +0 -19
  130. package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
  131. package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -1
  132. package/dist/functional/result/impl/result-is-ok.mjs +0 -19
  133. package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
  134. package/dist/functional/result/impl/result-is-result.d.mts.map +1 -1
  135. package/dist/functional/result/impl/result-is-result.mjs +1 -23
  136. package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
  137. package/dist/functional/result/impl/result-map-err.mjs +16 -16
  138. package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
  139. package/dist/functional/result/impl/result-map.mjs +16 -16
  140. package/dist/functional/result/impl/result-map.mjs.map +1 -1
  141. package/dist/functional/result/impl/result-ok.d.mts.map +1 -1
  142. package/dist/functional/result/impl/result-ok.mjs +2 -27
  143. package/dist/functional/result/impl/result-ok.mjs.map +1 -1
  144. package/dist/functional/result/impl/result-or-else.mjs +10 -12
  145. package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
  146. package/dist/functional/result/impl/result-swap.d.mts.map +1 -1
  147. package/dist/functional/result/impl/result-swap.mjs +4 -22
  148. package/dist/functional/result/impl/result-swap.mjs.map +1 -1
  149. package/dist/functional/result/impl/result-to-optional.d.mts.map +1 -1
  150. package/dist/functional/result/impl/result-to-optional.mjs +0 -27
  151. package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
  152. package/dist/functional/result/impl/result-unwrap-err-or.mjs +9 -11
  153. package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
  154. package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +1 -1
  155. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +13 -40
  156. package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
  157. package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -1
  158. package/dist/functional/result/impl/result-unwrap-err.mjs +4 -32
  159. package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
  160. package/dist/functional/result/impl/result-unwrap-ok-or.mjs +9 -11
  161. package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
  162. package/dist/functional/result/impl/result-unwrap-ok.mjs +4 -4
  163. package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
  164. package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -1
  165. package/dist/functional/result/impl/result-unwrap-throw.mjs +4 -35
  166. package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
  167. package/dist/functional/result/impl/result-zip.d.mts.map +1 -1
  168. package/dist/functional/result/impl/result-zip.mjs +1 -34
  169. package/dist/functional/result/impl/result-zip.mjs.map +1 -1
  170. package/dist/functional/result/impl/tag.mjs +2 -3
  171. package/dist/functional/result/impl/tag.mjs.map +1 -1
  172. package/dist/functional/ternary-result/impl/tag.mjs +3 -5
  173. package/dist/functional/ternary-result/impl/tag.mjs.map +1 -1
  174. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -1
  175. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +2 -15
  176. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
  177. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +13 -13
  178. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
  179. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +27 -26
  180. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
  181. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +21 -22
  182. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
  183. package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +1 -1
  184. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +4 -20
  185. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
  186. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -1
  187. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +7 -25
  188. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
  189. package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts.map +1 -1
  190. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +0 -17
  191. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -1
  192. package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +1 -1
  193. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +0 -19
  194. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -1
  195. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +1 -1
  196. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +1 -25
  197. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -1
  198. package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +1 -1
  199. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +0 -18
  200. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
  201. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +13 -15
  202. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
  203. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +18 -18
  204. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
  205. package/dist/functional/ternary-result/impl/ternary-result-map.mjs +21 -22
  206. package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
  207. package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -1
  208. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +2 -16
  209. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
  210. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +9 -9
  211. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
  212. package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +1 -1
  213. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +4 -22
  214. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -1
  215. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +9 -9
  216. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -1
  217. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +1 -1
  218. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +12 -27
  219. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
  220. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +1 -1
  221. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +4 -19
  222. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -1
  223. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +9 -9
  224. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -1
  225. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +4 -5
  226. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
  227. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -1
  228. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +15 -27
  229. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
  230. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +9 -9
  231. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -1
  232. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +1 -1
  233. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +10 -24
  234. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
  235. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +1 -1
  236. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +4 -19
  237. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
  238. package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -1
  239. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +3 -19
  240. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
  241. package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -1
  242. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +14 -45
  243. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
  244. package/dist/functional/ternary-result/impl/variant-name.d.mts +1 -1
  245. package/dist/functional/ternary-result/impl/variant-name.d.mts.map +1 -1
  246. package/dist/functional/ternary-result/impl/variant-name.mjs +8 -9
  247. package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -1
  248. package/dist/guard/as-length-bounded-array.d.mts +117 -0
  249. package/dist/guard/as-length-bounded-array.d.mts.map +1 -0
  250. package/dist/guard/as-length-bounded-array.mjs +37 -0
  251. package/dist/guard/as-length-bounded-array.mjs.map +1 -0
  252. package/dist/guard/has-key.d.mts.map +1 -1
  253. package/dist/guard/has-key.mjs +0 -41
  254. package/dist/guard/has-key.mjs.map +1 -1
  255. package/dist/guard/index.d.mts +2 -0
  256. package/dist/guard/index.d.mts.map +1 -1
  257. package/dist/guard/index.mjs +2 -0
  258. package/dist/guard/index.mjs.map +1 -1
  259. package/dist/guard/is-length-bounded-array.d.mts +159 -0
  260. package/dist/guard/is-length-bounded-array.d.mts.map +1 -0
  261. package/dist/guard/is-length-bounded-array.mjs +7 -0
  262. package/dist/guard/is-length-bounded-array.mjs.map +1 -0
  263. package/dist/guard/is-length-bounded-string.d.mts +5 -6
  264. package/dist/guard/is-length-bounded-string.d.mts.map +1 -1
  265. package/dist/guard/is-length-bounded-string.mjs +0 -157
  266. package/dist/guard/is-length-bounded-string.mjs.map +1 -1
  267. package/dist/guard/is-non-empty-string.d.mts +1 -1
  268. package/dist/guard/is-non-empty-string.d.mts.map +1 -1
  269. package/dist/guard/is-non-empty-string.mjs +1 -38
  270. package/dist/guard/is-non-empty-string.mjs.map +1 -1
  271. package/dist/guard/is-non-null-object.d.mts.map +1 -1
  272. package/dist/guard/is-non-null-object.mjs +1 -35
  273. package/dist/guard/is-non-null-object.mjs.map +1 -1
  274. package/dist/guard/is-primitive.d.mts.map +1 -1
  275. package/dist/guard/is-primitive.mjs +12 -43
  276. package/dist/guard/is-primitive.mjs.map +1 -1
  277. package/dist/guard/is-record.d.mts.map +1 -1
  278. package/dist/guard/is-record.mjs +0 -86
  279. package/dist/guard/is-record.mjs.map +1 -1
  280. package/dist/guard/is-type.d.mts.map +1 -1
  281. package/dist/guard/is-type.mjs +12 -399
  282. package/dist/guard/is-type.mjs.map +1 -1
  283. package/dist/guard/key-is-in.d.mts.map +1 -1
  284. package/dist/guard/key-is-in.mjs +0 -40
  285. package/dist/guard/key-is-in.mjs.map +1 -1
  286. package/dist/index.mjs +2 -0
  287. package/dist/index.mjs.map +1 -1
  288. package/dist/iterator/range.mjs +16 -16
  289. package/dist/iterator/range.mjs.map +1 -1
  290. package/dist/json/json.d.mts.map +1 -1
  291. package/dist/json/json.mjs +52 -340
  292. package/dist/json/json.mjs.map +1 -1
  293. package/dist/number/branded-types/finite-number.d.mts +3 -3
  294. package/dist/number/branded-types/finite-number.mjs +135 -154
  295. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  296. package/dist/number/branded-types/int.d.mts +4 -4
  297. package/dist/number/branded-types/int.mjs +205 -245
  298. package/dist/number/branded-types/int.mjs.map +1 -1
  299. package/dist/number/branded-types/int16.d.mts +15 -15
  300. package/dist/number/branded-types/int16.mjs +116 -123
  301. package/dist/number/branded-types/int16.mjs.map +1 -1
  302. package/dist/number/branded-types/int32.d.mts +11 -11
  303. package/dist/number/branded-types/int32.mjs +116 -123
  304. package/dist/number/branded-types/int32.mjs.map +1 -1
  305. package/dist/number/branded-types/negative-finite-number.d.mts +4 -4
  306. package/dist/number/branded-types/negative-finite-number.mjs +129 -144
  307. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  308. package/dist/number/branded-types/negative-int.d.mts +5 -5
  309. package/dist/number/branded-types/negative-int.mjs +94 -113
  310. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  311. package/dist/number/branded-types/negative-safe-int.d.mts +5 -5
  312. package/dist/number/branded-types/negative-safe-int.mjs +103 -124
  313. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  314. package/dist/number/branded-types/non-negative-finite-number.d.mts +5 -5
  315. package/dist/number/branded-types/non-negative-finite-number.mjs +136 -142
  316. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  317. package/dist/number/branded-types/non-negative-int16.d.mts +16 -16
  318. package/dist/number/branded-types/non-negative-int16.mjs +109 -118
  319. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  320. package/dist/number/branded-types/non-negative-int32.d.mts +12 -12
  321. package/dist/number/branded-types/non-negative-int32.mjs +110 -119
  322. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  323. package/dist/number/branded-types/non-positive-finite-number.d.mts +3 -3
  324. package/dist/number/branded-types/non-positive-finite-number.mjs +120 -124
  325. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  326. package/dist/number/branded-types/non-positive-int.d.mts +4 -4
  327. package/dist/number/branded-types/non-positive-int.mjs +167 -212
  328. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  329. package/dist/number/branded-types/non-positive-safe-int.d.mts +4 -4
  330. package/dist/number/branded-types/non-positive-safe-int.mjs +95 -106
  331. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  332. package/dist/number/branded-types/non-zero-finite-number.d.mts +4 -4
  333. package/dist/number/branded-types/non-zero-finite-number.mjs +114 -123
  334. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  335. package/dist/number/branded-types/non-zero-int.d.mts +2 -2
  336. package/dist/number/branded-types/non-zero-int.mjs +72 -83
  337. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  338. package/dist/number/branded-types/non-zero-int16.d.mts +7 -7
  339. package/dist/number/branded-types/non-zero-int16.mjs +96 -107
  340. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  341. package/dist/number/branded-types/non-zero-int32.d.mts +5 -5
  342. package/dist/number/branded-types/non-zero-int32.mjs +97 -108
  343. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  344. package/dist/number/branded-types/non-zero-safe-int.d.mts +2 -2
  345. package/dist/number/branded-types/non-zero-safe-int.mjs +100 -111
  346. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  347. package/dist/number/branded-types/non-zero-uint16.d.mts +8 -8
  348. package/dist/number/branded-types/non-zero-uint16.mjs +96 -107
  349. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  350. package/dist/number/branded-types/non-zero-uint32.d.mts +6 -6
  351. package/dist/number/branded-types/non-zero-uint32.mjs +96 -107
  352. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  353. package/dist/number/branded-types/positive-finite-number.d.mts +8 -8
  354. package/dist/number/branded-types/positive-finite-number.mjs +139 -141
  355. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  356. package/dist/number/branded-types/positive-int.d.mts +11 -11
  357. package/dist/number/branded-types/positive-int.mjs +228 -271
  358. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  359. package/dist/number/branded-types/positive-int16.d.mts +19 -19
  360. package/dist/number/branded-types/positive-int16.mjs +109 -118
  361. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  362. package/dist/number/branded-types/positive-int32.d.mts +15 -15
  363. package/dist/number/branded-types/positive-int32.mjs +109 -118
  364. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  365. package/dist/number/branded-types/positive-safe-int.d.mts +11 -11
  366. package/dist/number/branded-types/positive-safe-int.mjs +244 -275
  367. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  368. package/dist/number/branded-types/positive-uint16.d.mts +17 -17
  369. package/dist/number/branded-types/positive-uint16.mjs +109 -118
  370. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  371. package/dist/number/branded-types/positive-uint32.d.mts +13 -13
  372. package/dist/number/branded-types/positive-uint32.mjs +110 -119
  373. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  374. package/dist/number/branded-types/safe-int.d.mts +4 -4
  375. package/dist/number/branded-types/safe-int.mjs +251 -292
  376. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  377. package/dist/number/branded-types/safe-uint.d.mts +8 -8
  378. package/dist/number/branded-types/safe-uint.mjs +111 -119
  379. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  380. package/dist/number/branded-types/uint.d.mts +8 -8
  381. package/dist/number/branded-types/uint.mjs +198 -225
  382. package/dist/number/branded-types/uint.mjs.map +1 -1
  383. package/dist/number/branded-types/uint16.d.mts +14 -14
  384. package/dist/number/branded-types/uint16.mjs +109 -119
  385. package/dist/number/branded-types/uint16.mjs.map +1 -1
  386. package/dist/number/branded-types/uint32.d.mts +10 -10
  387. package/dist/number/branded-types/uint32.mjs +110 -117
  388. package/dist/number/branded-types/uint32.mjs.map +1 -1
  389. package/dist/number/enum/int8.mjs +119 -145
  390. package/dist/number/enum/int8.mjs.map +1 -1
  391. package/dist/number/enum/uint8.mjs +107 -121
  392. package/dist/number/enum/uint8.mjs.map +1 -1
  393. package/dist/number/num.d.mts +2 -2
  394. package/dist/number/num.d.mts.map +1 -1
  395. package/dist/number/num.mjs +76 -537
  396. package/dist/number/num.mjs.map +1 -1
  397. package/dist/number/refined-number-utils.d.mts +1 -1
  398. package/dist/number/refined-number-utils.d.mts.map +1 -1
  399. package/dist/number/refined-number-utils.mjs +127 -263
  400. package/dist/number/refined-number-utils.mjs.map +1 -1
  401. package/dist/object/object.d.mts.map +1 -1
  402. package/dist/object/object.mjs +107 -222
  403. package/dist/object/object.mjs.map +1 -1
  404. package/dist/others/cast-mutable.d.mts.map +1 -1
  405. package/dist/others/cast-mutable.mjs +8 -37
  406. package/dist/others/cast-mutable.mjs.map +1 -1
  407. package/dist/others/cast-readonly.d.mts.map +1 -1
  408. package/dist/others/cast-readonly.mjs +8 -36
  409. package/dist/others/cast-readonly.mjs.map +1 -1
  410. package/dist/others/debounce-function.d.mts.map +1 -1
  411. package/dist/others/debounce-function.mjs +7 -16
  412. package/dist/others/debounce-function.mjs.map +1 -1
  413. package/dist/others/fast-deep-equal.d.mts.map +1 -1
  414. package/dist/others/fast-deep-equal.mjs +43 -59
  415. package/dist/others/fast-deep-equal.mjs.map +1 -1
  416. package/dist/others/if-then.d.mts.map +1 -1
  417. package/dist/others/if-then.mjs +0 -29
  418. package/dist/others/if-then.mjs.map +1 -1
  419. package/dist/others/map-nullable.mjs +9 -9
  420. package/dist/others/map-nullable.mjs.map +1 -1
  421. package/dist/others/memoize-function.mjs +12 -12
  422. package/dist/others/memoize-function.mjs.map +1 -1
  423. package/dist/others/tuple.d.mts.map +1 -1
  424. package/dist/others/tuple.mjs +0 -50
  425. package/dist/others/tuple.mjs.map +1 -1
  426. package/dist/others/unknown-to-string.d.mts.map +1 -1
  427. package/dist/others/unknown-to-string.mjs +41 -88
  428. package/dist/others/unknown-to-string.mjs.map +1 -1
  429. package/dist/promise/promise.d.mts.map +1 -1
  430. package/dist/promise/promise.mjs +4 -49
  431. package/dist/promise/promise.mjs.map +1 -1
  432. package/package.json +14 -13
  433. package/src/array/impl/array-utils-creation.mts +3 -3
  434. package/src/array/impl/array-utils-modification.mts +7 -7
  435. package/src/array/impl/array-utils-modification.test.mts +4 -4
  436. package/src/array/impl/array-utils-transformation.mts +4 -4
  437. package/src/array/impl/array-utils-transformation.test.mts +7 -7
  438. package/src/array/impl/array-utils-validation.mts +24 -24
  439. package/src/array/impl/array-utils-validation.test.mts +94 -92
  440. package/src/collections/queue.test.mts +1 -1
  441. package/src/guard/as-length-bounded-array.mts +190 -0
  442. package/src/guard/as-length-bounded-array.test.mts +118 -0
  443. package/src/guard/index.mts +2 -0
  444. package/src/guard/is-length-bounded-array.mts +195 -0
  445. package/src/guard/is-length-bounded-array.test.mts +169 -0
  446. package/src/guard/is-length-bounded-string.mts +6 -6
  447. package/src/object/object.test.mts +3 -3
@@ -1,15 +1,14 @@
1
1
  import { ErrTypeTagName, WarnTypeTagName, OkTypeTagName } from './tag.mjs';
2
2
 
3
- /** @internal Returns the human readable variant label for the given tag. */
4
3
  const variantName = (tag) => {
5
- switch (tag) {
6
- case OkTypeTagName:
7
- return 'Ok';
8
- case WarnTypeTagName:
9
- return 'Warn';
10
- case ErrTypeTagName:
11
- return 'Err';
12
- }
4
+ switch (tag) {
5
+ case OkTypeTagName:
6
+ return "Ok";
7
+ case WarnTypeTagName:
8
+ return "Warn";
9
+ case ErrTypeTagName:
10
+ return "Err";
11
+ }
13
12
  };
14
13
 
15
14
  export { variantName };
@@ -1 +1 @@
1
- {"version":3,"file":"variant-name.mjs","sources":["../../../../src/functional/ternary-result/impl/variant-name.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;AACO,MAAM,WAAW,GAAG,CACzB,GAAkC,KACT;IACzB,QAAQ,GAAG;AACT,QAAA,KAAK,aAAa;AAChB,YAAA,OAAO,IAAI;AAEb,QAAA,KAAK,eAAe;AAClB,YAAA,OAAO,MAAM;AAEf,QAAA,KAAK,cAAc;AACjB,YAAA,OAAO,KAAK;;AAElB;;;;"}
1
+ {"version":3,"file":"variant-name.mjs","sources":["../../../../src/functional/ternary-result/impl/variant-name.mts"],"sourcesContent":["import { type UnknownTernaryResult } from '../ternary-result.mjs';\nimport { ErrTypeTagName, OkTypeTagName, WarnTypeTagName } from './tag.mjs';\n\n/** @internal Returns the human readable variant label for the given tag. */\nexport const variantName = (\n tag: UnknownTernaryResult['$$tag'],\n): 'Ok' | 'Warn' | 'Err' => {\n switch (tag) {\n case OkTypeTagName:\n return 'Ok';\n\n case WarnTypeTagName:\n return 'Warn';\n\n case ErrTypeTagName:\n return 'Err';\n }\n};\n"],"names":[],"mappings":";;AAIO,MAAM,WAAA,GAAc,CACzB,GAAA,KAC0B;AAC1B,EAAA,QAAQ,GAAA;AAAK,IACX,KAAK,aAAA;AACH,MAAA,OAAO,IAAA;AAAA,IAET,KAAK,eAAA;AACH,MAAA,OAAO,MAAA;AAAA,IAET,KAAK,cAAA;AACH,MAAA,OAAO,KAAA;AAAA;AAEb;;;;"}
@@ -0,0 +1,117 @@
1
+ import { type BoundedLengthArray, type FixedLengthArray, type MaxLengthArray, type MinLengthArray, type SupportedLength } from 'ts-type-forge';
2
+ /**
3
+ * Casts an array to `FixedLengthArray<Length, E>` after checking that it has
4
+ * exactly `length` elements.
5
+ *
6
+ * Use this instead of writing `xs as unknown as FixedLengthArray<N, E>`: the
7
+ * length is verified at runtime, and the original array type (e.g. tuple
8
+ * types) is preserved via intersection, so the result also benefits from the
9
+ * structural tuple prefix (in-range indexed access without `undefined` under
10
+ * `noUncheckedIndexedAccess`).
11
+ *
12
+ * @example
13
+ *
14
+ * ```ts
15
+ * const rgb = asFixedLengthArray([255, 128, 0], 3);
16
+ *
17
+ * const atMost5: MaxLengthArray<5, number> = rgb; // OK (3 <= 5)
18
+ * const red: number = rgb[0]; // OK — no `undefined`
19
+ *
20
+ * // asFixedLengthArray([255, 128], 3); // throws TypeError
21
+ * ```
22
+ *
23
+ * @template Xs - The input array type (tuple types are preserved).
24
+ * @template Length - The exact number of elements.
25
+ * @param xs - The array to cast.
26
+ * @param length - The exact number of elements.
27
+ * @returns `xs` typed as `FixedLengthArray<Length, Xs[number]> & Xs`.
28
+ * @throws {TypeError} If `xs.length !== length`.
29
+ */
30
+ export declare const asFixedLengthArray: <Xs extends readonly unknown[], Length extends SupportedLength>(xs: Xs, length: Length) => FixedLengthArray<Length, Xs[number]> & Xs;
31
+ /**
32
+ * Casts an array to `MinLengthArray<MinLength, E>` after checking that it has
33
+ * at least `minLength` elements.
34
+ *
35
+ * Use this instead of writing `xs as unknown as MinLengthArray<N, E>`: the
36
+ * length is verified at runtime, and the original array type (e.g. tuple
37
+ * types) is preserved via intersection, so the result also benefits from the
38
+ * structural tuple prefix (indexed access below `min(N, 10)` without
39
+ * `undefined` under `noUncheckedIndexedAccess`).
40
+ *
41
+ * @example
42
+ *
43
+ * ```ts
44
+ * const history = asMinLengthArray([0, 1, 2, 3], 3);
45
+ *
46
+ * const nonEmpty: MinLengthArray<1, number> = history; // OK (3 >= 1)
47
+ * const first: number = history[0]; // OK — no `undefined`
48
+ *
49
+ * // asMinLengthArray([0], 3); // throws TypeError
50
+ * ```
51
+ *
52
+ * @template Xs - The input array type (tuple types are preserved).
53
+ * @template MinLength - The minimum number of elements (inclusive).
54
+ * @param xs - The array to cast.
55
+ * @param minLength - The minimum number of elements (inclusive).
56
+ * @returns `xs` typed as `MinLengthArray<MinLength, Xs[number]> & Xs`.
57
+ * @throws {TypeError} If `xs.length < minLength`.
58
+ */
59
+ export declare const asMinLengthArray: <Xs extends readonly unknown[], MinLength extends SupportedLength>(xs: Xs, minLength: MinLength) => MinLengthArray<MinLength, Xs[number]> & Xs;
60
+ /**
61
+ * Casts an array to `MaxLengthArray<MaxLength, E>` after checking that it has
62
+ * at most `maxLength` elements.
63
+ *
64
+ * Use this instead of writing `xs as unknown as MaxLengthArray<N, E>`: the
65
+ * length is verified at runtime, and the original array type (e.g. tuple
66
+ * types) is preserved via intersection.
67
+ *
68
+ * @example
69
+ *
70
+ * ```ts
71
+ * const tags = asMaxLengthArray(['a', 'b', 'c'], 8);
72
+ *
73
+ * const relaxed: MaxLengthArray<16, string> = tags; // OK (8 <= 16)
74
+ *
75
+ * // asMaxLengthArray(['a', 'b', 'c'], 2); // throws TypeError
76
+ * ```
77
+ *
78
+ * @template Xs - The input array type (tuple types are preserved).
79
+ * @template MaxLength - The maximum number of elements (inclusive).
80
+ * @param xs - The array to cast.
81
+ * @param maxLength - The maximum number of elements (inclusive).
82
+ * @returns `xs` typed as `MaxLengthArray<MaxLength, Xs[number]> & Xs`.
83
+ * @throws {TypeError} If `xs.length > maxLength`.
84
+ */
85
+ export declare const asMaxLengthArray: <Xs extends readonly unknown[], MaxLength extends SupportedLength>(xs: Xs, maxLength: MaxLength) => MaxLengthArray<MaxLength, Xs[number]> & Xs;
86
+ /**
87
+ * Casts an array to `BoundedLengthArray<MinLength, MaxLength, E>` after
88
+ * checking that its length is within the inclusive range
89
+ * `[minLength, maxLength]`.
90
+ *
91
+ * Use this instead of writing
92
+ * `xs as unknown as BoundedLengthArray<Min, Max, E>`: the length is verified
93
+ * at runtime, and the original array type (e.g. tuple types) is preserved via
94
+ * intersection.
95
+ *
96
+ * @example
97
+ *
98
+ * ```ts
99
+ * const selection = asBoundedLengthArray([1, 2, 3], 1, 5);
100
+ *
101
+ * const relaxed: BoundedLengthArray<0, 100, number> = selection; // OK
102
+ *
103
+ * // asBoundedLengthArray([], 1, 5); // throws TypeError
104
+ * ```
105
+ *
106
+ * @template Xs - The input array type (tuple types are preserved).
107
+ * @template MinLength - The minimum number of elements (inclusive).
108
+ * @template MaxLength - The maximum number of elements (inclusive).
109
+ * @param xs - The array to cast.
110
+ * @param minLength - The minimum number of elements (inclusive).
111
+ * @param maxLength - The maximum number of elements (inclusive).
112
+ * @returns `xs` typed as
113
+ * `BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs`.
114
+ * @throws {TypeError} If `xs.length < minLength || xs.length > maxLength`.
115
+ */
116
+ export declare const asBoundedLengthArray: <Xs extends readonly unknown[], MinLength extends SupportedLength, MaxLength extends SupportedLength>(xs: Xs, minLength: MinLength, maxLength: MaxLength) => BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs;
117
+ //# sourceMappingURL=as-length-bounded-array.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"as-length-bounded-array.d.mts","sourceRoot":"","sources":["../../src/guard/as-length-bounded-array.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAQvB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,kBAAkB,GAC7B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,MAAM,SAAS,eAAe,MAE1B,EAAE,UACE,MAAM,KACb,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAQzC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,gBAAgB,GAC3B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,SAAS,eAAe,MAE7B,EAAE,aACK,SAAS,KACnB,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAQ1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,gBAAgB,GAC3B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,SAAS,eAAe,MAE7B,EAAE,aACK,SAAS,KACnB,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAQ1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,oBAAoB,GAC/B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,SAAS,eAAe,EACjC,SAAS,SAAS,eAAe,MAE7B,EAAE,aACK,SAAS,aACT,SAAS,KACnB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAQzD,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { isBoundedLengthArray, isFixedLengthArray, isMaxLengthArray, isMinLengthArray } from './is-length-bounded-array.mjs';
2
+
3
+ const asFixedLengthArray = (xs, length) => {
4
+ if (!isFixedLengthArray(xs, length)) {
5
+ throw new TypeError(
6
+ `Expected an array of length ${length}, got an array of length ${xs.length}`
7
+ );
8
+ }
9
+ return xs;
10
+ };
11
+ const asMinLengthArray = (xs, minLength) => {
12
+ if (!isMinLengthArray(xs, minLength)) {
13
+ throw new TypeError(
14
+ `Expected an array of length >= ${minLength}, got an array of length ${xs.length}`
15
+ );
16
+ }
17
+ return xs;
18
+ };
19
+ const asMaxLengthArray = (xs, maxLength) => {
20
+ if (!isMaxLengthArray(xs, maxLength)) {
21
+ throw new TypeError(
22
+ `Expected an array of length <= ${maxLength}, got an array of length ${xs.length}`
23
+ );
24
+ }
25
+ return xs;
26
+ };
27
+ const asBoundedLengthArray = (xs, minLength, maxLength) => {
28
+ if (!isBoundedLengthArray(xs, minLength, maxLength)) {
29
+ throw new TypeError(
30
+ `Expected an array of length in [${minLength}, ${maxLength}], got an array of length ${xs.length}`
31
+ );
32
+ }
33
+ return xs;
34
+ };
35
+
36
+ export { asBoundedLengthArray, asFixedLengthArray, asMaxLengthArray, asMinLengthArray };
37
+ //# sourceMappingURL=as-length-bounded-array.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"as-length-bounded-array.mjs","sources":["../../src/guard/as-length-bounded-array.mts"],"sourcesContent":["import {\n type BoundedLengthArray,\n type FixedLengthArray,\n type MaxLengthArray,\n type MinLengthArray,\n type SupportedLength,\n} from 'ts-type-forge';\nimport {\n isBoundedLengthArray,\n isFixedLengthArray,\n isMaxLengthArray,\n isMinLengthArray,\n} from './is-length-bounded-array.mjs';\n\n/**\n * Casts an array to `FixedLengthArray<Length, E>` after checking that it has\n * exactly `length` elements.\n *\n * Use this instead of writing `xs as unknown as FixedLengthArray<N, E>`: the\n * length is verified at runtime, and the original array type (e.g. tuple\n * types) is preserved via intersection, so the result also benefits from the\n * structural tuple prefix (in-range indexed access without `undefined` under\n * `noUncheckedIndexedAccess`).\n *\n * @example\n *\n * ```ts\n * const rgb = asFixedLengthArray([255, 128, 0], 3);\n *\n * const atMost5: MaxLengthArray<5, number> = rgb; // OK (3 <= 5)\n * const red: number = rgb[0]; // OK — no `undefined`\n *\n * // asFixedLengthArray([255, 128], 3); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template Length - The exact number of elements.\n * @param xs - The array to cast.\n * @param length - The exact number of elements.\n * @returns `xs` typed as `FixedLengthArray<Length, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length !== length`.\n */\nexport const asFixedLengthArray = <\n Xs extends readonly unknown[],\n Length extends SupportedLength,\n>(\n xs: Xs,\n length: Length,\n): FixedLengthArray<Length, Xs[number]> & Xs => {\n if (!isFixedLengthArray(xs, length)) {\n throw new TypeError(\n `Expected an array of length ${length}, got an array of length ${xs.length}`,\n );\n }\n\n return xs;\n};\n\n/**\n * Casts an array to `MinLengthArray<MinLength, E>` after checking that it has\n * at least `minLength` elements.\n *\n * Use this instead of writing `xs as unknown as MinLengthArray<N, E>`: the\n * length is verified at runtime, and the original array type (e.g. tuple\n * types) is preserved via intersection, so the result also benefits from the\n * structural tuple prefix (indexed access below `min(N, 10)` without\n * `undefined` under `noUncheckedIndexedAccess`).\n *\n * @example\n *\n * ```ts\n * const history = asMinLengthArray([0, 1, 2, 3], 3);\n *\n * const nonEmpty: MinLengthArray<1, number> = history; // OK (3 >= 1)\n * const first: number = history[0]; // OK — no `undefined`\n *\n * // asMinLengthArray([0], 3); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MinLength - The minimum number of elements (inclusive).\n * @param xs - The array to cast.\n * @param minLength - The minimum number of elements (inclusive).\n * @returns `xs` typed as `MinLengthArray<MinLength, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length < minLength`.\n */\nexport const asMinLengthArray = <\n Xs extends readonly unknown[],\n MinLength extends SupportedLength,\n>(\n xs: Xs,\n minLength: MinLength,\n): MinLengthArray<MinLength, Xs[number]> & Xs => {\n if (!isMinLengthArray(xs, minLength)) {\n throw new TypeError(\n `Expected an array of length >= ${minLength}, got an array of length ${xs.length}`,\n );\n }\n\n return xs;\n};\n\n/**\n * Casts an array to `MaxLengthArray<MaxLength, E>` after checking that it has\n * at most `maxLength` elements.\n *\n * Use this instead of writing `xs as unknown as MaxLengthArray<N, E>`: the\n * length is verified at runtime, and the original array type (e.g. tuple\n * types) is preserved via intersection.\n *\n * @example\n *\n * ```ts\n * const tags = asMaxLengthArray(['a', 'b', 'c'], 8);\n *\n * const relaxed: MaxLengthArray<16, string> = tags; // OK (8 <= 16)\n *\n * // asMaxLengthArray(['a', 'b', 'c'], 2); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MaxLength - The maximum number of elements (inclusive).\n * @param xs - The array to cast.\n * @param maxLength - The maximum number of elements (inclusive).\n * @returns `xs` typed as `MaxLengthArray<MaxLength, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length > maxLength`.\n */\nexport const asMaxLengthArray = <\n Xs extends readonly unknown[],\n MaxLength extends SupportedLength,\n>(\n xs: Xs,\n maxLength: MaxLength,\n): MaxLengthArray<MaxLength, Xs[number]> & Xs => {\n if (!isMaxLengthArray(xs, maxLength)) {\n throw new TypeError(\n `Expected an array of length <= ${maxLength}, got an array of length ${xs.length}`,\n );\n }\n\n return xs;\n};\n\n/**\n * Casts an array to `BoundedLengthArray<MinLength, MaxLength, E>` after\n * checking that its length is within the inclusive range\n * `[minLength, maxLength]`.\n *\n * Use this instead of writing\n * `xs as unknown as BoundedLengthArray<Min, Max, E>`: the length is verified\n * at runtime, and the original array type (e.g. tuple types) is preserved via\n * intersection.\n *\n * @example\n *\n * ```ts\n * const selection = asBoundedLengthArray([1, 2, 3], 1, 5);\n *\n * const relaxed: BoundedLengthArray<0, 100, number> = selection; // OK\n *\n * // asBoundedLengthArray([], 1, 5); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MinLength - The minimum number of elements (inclusive).\n * @template MaxLength - The maximum number of elements (inclusive).\n * @param xs - The array to cast.\n * @param minLength - The minimum number of elements (inclusive).\n * @param maxLength - The maximum number of elements (inclusive).\n * @returns `xs` typed as\n * `BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length < minLength || xs.length > maxLength`.\n */\nexport const asBoundedLengthArray = <\n Xs extends readonly unknown[],\n MinLength extends SupportedLength,\n MaxLength extends SupportedLength,\n>(\n xs: Xs,\n minLength: MinLength,\n maxLength: MaxLength,\n): BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs => {\n if (!isBoundedLengthArray(xs, minLength, maxLength)) {\n throw new TypeError(\n `Expected an array of length in [${minLength}, ${maxLength}], got an array of length ${xs.length}`,\n );\n }\n\n return xs;\n};\n"],"names":[],"mappings":";;AA0CO,MAAM,kBAAA,GAAqB,CAIhC,EAAA,EACA,MAAA,KAC8C;AAC9C,EAAA,IAAI,CAAC,kBAAA,CAAmB,EAAA,EAAI,MAAM,CAAA,EAAG;AACnC,IAAA,MAAM,IAAI,SAAA;AAAA,MACR,CAAA,4BAAA,EAA+B,MAAM,CAAA,yBAAA,EAA4B,EAAA,CAAG,MAAM,CAAA;AAAA,KAC5E;AAAA,EACF;AAEA,EAAA,OAAO,EAAA;AACT;AA8BO,MAAM,gBAAA,GAAmB,CAI9B,EAAA,EACA,SAAA,KAC+C;AAC/C,EAAA,IAAI,CAAC,gBAAA,CAAiB,EAAA,EAAI,SAAS,CAAA,EAAG;AACpC,IAAA,MAAM,IAAI,SAAA;AAAA,MACR,CAAA,+BAAA,EAAkC,SAAS,CAAA,yBAAA,EAA4B,EAAA,CAAG,MAAM,CAAA;AAAA,KAClF;AAAA,EACF;AAEA,EAAA,OAAO,EAAA;AACT;AA2BO,MAAM,gBAAA,GAAmB,CAI9B,EAAA,EACA,SAAA,KAC+C;AAC/C,EAAA,IAAI,CAAC,gBAAA,CAAiB,EAAA,EAAI,SAAS,CAAA,EAAG;AACpC,IAAA,MAAM,IAAI,SAAA;AAAA,MACR,CAAA,+BAAA,EAAkC,SAAS,CAAA,yBAAA,EAA4B,EAAA,CAAG,MAAM,CAAA;AAAA,KAClF;AAAA,EACF;AAEA,EAAA,OAAO,EAAA;AACT;AAgCO,MAAM,oBAAA,GAAuB,CAKlC,EAAA,EACA,SAAA,EACA,SAAA,KAC8D;AAC9D,EAAA,IAAI,CAAC,oBAAA,CAAqB,EAAA,EAAI,SAAA,EAAW,SAAS,CAAA,EAAG;AACnD,IAAA,MAAM,IAAI,SAAA;AAAA,MACR,mCAAmC,SAAS,CAAA,EAAA,EAAK,SAAS,CAAA,0BAAA,EAA6B,GAAG,MAAM,CAAA;AAAA,KAClG;AAAA,EACF;AAEA,EAAA,OAAO,EAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"has-key.d.mts","sourceRoot":"","sources":["../../src/guard/has-key.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,MAAM,GACjB,KAAK,CAAC,CAAC,SAAS,aAAa,EAC7B,KAAK,CAAC,CAAC,SAAS,WAAW,EAE3B,KAAK,CAAC,EACN,KAAK,CAAC,KACL,GAAG,IAAI,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAA4B,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,CAC1B,CAAC,SAAS,aAAa,EACvB,CAAC,SAAS,WAAW,IACnB,CAAC,SAAS,CAAC,GACX,CAAC,SAAS,MAAM,CAAC,GACf,MAAM,SAAS,MAAM,CAAC,GACpB,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GACjC,MAAM,SAAS,MAAM,CAAC,GACpB,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GACjC,MAAM,SAAS,MAAM,CAAC,GACpB,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GACjC,CAAC,GACP,KAAK,GACP,KAAK,CAAC"}
1
+ {"version":3,"file":"has-key.d.mts","sourceRoot":"","sources":["../../src/guard/has-key.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,MAAM,GACjB,KAAK,CAAC,CAAC,SAAS,aAAa,EAC7B,KAAK,CAAC,CAAC,SAAS,WAAW,OAEtB,CAAC,OACD,CAAC,KACL,GAAG,IAAI,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAA4B,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,CAC1B,CAAC,SAAS,aAAa,EACvB,CAAC,SAAS,WAAW,IACnB,CAAC,SAAS,CAAC,GACX,CAAC,SAAS,MAAM,CAAC,GACf,MAAM,SAAS,MAAM,CAAC,GACpB,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GACjC,MAAM,SAAS,MAAM,CAAC,GACpB,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GACjC,MAAM,SAAS,MAAM,CAAC,GACpB,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GACjC,CAAC,GACP,KAAK,GACP,KAAK,CAAC"}
@@ -1,44 +1,3 @@
1
- /**
2
- * Type guard function that checks if an object has a specific key as its own
3
- * property.
4
- *
5
- * This function uses `Object.hasOwn()` to check if the given object has the
6
- * specified key as its own property (not inherited). It acts as a type guard
7
- * that narrows the type of the object to guarantee the key exists, enabling
8
- * type-safe property access.
9
- *
10
- * **Type Narrowing Behavior:**
11
- *
12
- * - When the guard returns `true`, TypeScript narrows the object type to include
13
- * the checked key
14
- * - For union types, only union members that contain the key are preserved
15
- * - The key's value type is preserved from the original object type when possible
16
- *
17
- * @example
18
- *
19
- * ```ts
20
- * const maybeUser: Readonly<{ id?: number; name?: string }> = {
21
- * id: 42,
22
- * } as const;
23
- *
24
- * if (hasKey(maybeUser, 'id')) {
25
- * // `maybeUser` is now known to have an `id` property.
26
- * assert.isTrue(maybeUser.id === 42);
27
- * } else {
28
- * assert.fail();
29
- * }
30
- * ```
31
- *
32
- * @template R - The type of the input object, must extend UnknownRecord
33
- * @template K - The type of the key to check for, must extend PropertyKey
34
- * (string | number | symbol)
35
- * @param obj - The object to check for the presence of the key
36
- * @param key - The key to check for in the object
37
- * @returns `true` if the object has the specified key as its own property,
38
- * `false` otherwise. When `true`, TypeScript narrows the object type to
39
- * guarantee the key exists.
40
- * @see {@link keyIsIn} - Similar function that narrows the key type instead of the object type
41
- */
42
1
  const hasKey = (obj, key) => Object.hasOwn(obj, key);
43
2
 
44
3
  export { hasKey };
@@ -1 +1 @@
1
- {"version":3,"file":"has-key.mjs","sources":["../../src/guard/has-key.mts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCG;AACI,MAAM,MAAM,GAAG,CAIpB,GAAM,EACN,GAAM,KAC4B,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG;;;;"}
1
+ {"version":3,"file":"has-key.mjs","sources":["../../src/guard/has-key.mts"],"sourcesContent":["import { type ReadonlyRecord, type UnknownRecord } from 'ts-type-forge';\n\n/**\n * Type guard function that checks if an object has a specific key as its own\n * property.\n *\n * This function uses `Object.hasOwn()` to check if the given object has the\n * specified key as its own property (not inherited). It acts as a type guard\n * that narrows the type of the object to guarantee the key exists, enabling\n * type-safe property access.\n *\n * **Type Narrowing Behavior:**\n *\n * - When the guard returns `true`, TypeScript narrows the object type to include\n * the checked key\n * - For union types, only union members that contain the key are preserved\n * - The key's value type is preserved from the original object type when possible\n *\n * @example\n *\n * ```ts\n * const maybeUser: Readonly<{ id?: number; name?: string }> = {\n * id: 42,\n * } as const;\n *\n * if (hasKey(maybeUser, 'id')) {\n * // `maybeUser` is now known to have an `id` property.\n * assert.isTrue(maybeUser.id === 42);\n * } else {\n * assert.fail();\n * }\n * ```\n *\n * @template R - The type of the input object, must extend UnknownRecord\n * @template K - The type of the key to check for, must extend PropertyKey\n * (string | number | symbol)\n * @param obj - The object to check for the presence of the key\n * @param key - The key to check for in the object\n * @returns `true` if the object has the specified key as its own property,\n * `false` otherwise. When `true`, TypeScript narrows the object type to\n * guarantee the key exists.\n * @see {@link keyIsIn} - Similar function that narrows the key type instead of the object type\n */\nexport const hasKey = <\n const R extends UnknownRecord,\n const K extends PropertyKey,\n>(\n obj: R,\n key: K,\n): obj is HasKeyReturnType<R, K> => Object.hasOwn(obj, key);\n\n/**\n * @internal\n * When R is a union type (including the case with only one element), if any element in the union\n * contains K as a key, returns a type that narrows the union to only those elements that contain K as a key.\n * If none of the elements in the union contain K as a key, returns `ReadonlyRecord<K, unknown>`.\n * The result is made readonly.\n */\nexport type HasKeyReturnType<\n R extends UnknownRecord,\n K extends PropertyKey,\n> = R extends R // union distribution\n ? K extends keyof R\n ? string extends keyof R\n ? ReadonlyRecord<K, R[keyof R]> & R\n : number extends keyof R\n ? ReadonlyRecord<K, R[keyof R]> & R\n : symbol extends keyof R\n ? ReadonlyRecord<K, R[keyof R]> & R\n : R\n : never // omit union member that does not have key K\n : never; // dummy case for union distribution\n"],"names":[],"mappings":"AA2CO,MAAM,SAAS,CAIpB,GAAA,EACA,QACkC,MAAA,CAAO,MAAA,CAAO,KAAK,GAAG;;;;"}
@@ -1,4 +1,6 @@
1
+ export * from './as-length-bounded-array.mjs';
1
2
  export * from './has-key.mjs';
3
+ export * from './is-length-bounded-array.mjs';
2
4
  export * from './is-length-bounded-string.mjs';
3
5
  export * from './is-non-empty-string.mjs';
4
6
  export * from './is-non-null-object.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/guard/index.mts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/guard/index.mts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,eAAe,CAAC;AAC9B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC"}
@@ -1,4 +1,6 @@
1
+ export { asBoundedLengthArray, asFixedLengthArray, asMaxLengthArray, asMinLengthArray } from './as-length-bounded-array.mjs';
1
2
  export { hasKey } from './has-key.mjs';
3
+ export { isBoundedLengthArray, isFixedLengthArray, isMaxLengthArray, isMinLengthArray } from './is-length-bounded-array.mjs';
2
4
  export { isBoundedLengthString, isFixedLengthString, isMaxLengthString, isMinLengthString } from './is-length-bounded-string.mjs';
3
5
  export { isNonEmptyString } from './is-non-empty-string.mjs';
4
6
  export { isNonNullObject } from './is-non-null-object.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
@@ -0,0 +1,159 @@
1
+ import { type BoundedLengthArray, type FixedLengthArray, type MaxLengthArray, type MinLengthArray, type SupportedLength } from 'ts-type-forge';
2
+ /**
3
+ * Type guard that checks if an array has at least `minLength` elements.
4
+ *
5
+ * **Type Narrowing Behavior:**
6
+ *
7
+ * - Narrows the input to `MinLengthArray<MinLength, E>` while preserving the
8
+ * original array type (e.g. tuple types) via intersection.
9
+ * - The length constraint lives only in the brand, so this stays cheap for the
10
+ * type checker even when the element type is large — unlike
11
+ * `isMinLengthTuple`, which narrows to a structural tuple type.
12
+ * - The result participates in the length-constraint subtyping relation: for
13
+ * example, a value narrowed to `MinLengthArray<3, E>` is assignable to
14
+ * `MinLengthArray<1, E>`.
15
+ *
16
+ * @example
17
+ *
18
+ * ```ts
19
+ * const input: readonly number[] = [0, 1, 2, 3];
20
+ *
21
+ * assert.isTrue(isMinLengthArray(input, 3));
22
+ *
23
+ * assert.isFalse(isMinLengthArray([0], 3));
24
+ *
25
+ * if (isMinLengthArray(input, 3)) {
26
+ * const history: MinLengthArray<3, number> = input;
27
+ *
28
+ * const nonEmpty: MinLengthArray<1, number> = input; // OK (3 >= 1)
29
+ * }
30
+ * ```
31
+ *
32
+ * @template Xs - The input array type (tuple types are preserved).
33
+ * @template MinLength - The minimum number of elements (inclusive).
34
+ * @param xs - The array to check.
35
+ * @param minLength - The minimum number of elements (inclusive).
36
+ * @returns `true` if `xs.length >= minLength`, `false` otherwise. When `true`,
37
+ * TypeScript narrows `xs` to `MinLengthArray<MinLength, Xs[number]> & Xs`.
38
+ */
39
+ export declare const isMinLengthArray: <Xs extends readonly unknown[], MinLength extends SupportedLength>(xs: Xs, minLength: MinLength) => xs is MinLengthArray<MinLength, Xs[number]> & Xs;
40
+ /**
41
+ * Type guard that checks if an array has at most `maxLength` elements.
42
+ *
43
+ * **Type Narrowing Behavior:**
44
+ *
45
+ * - Narrows the input to `MaxLengthArray<MaxLength, E>` while preserving the
46
+ * original array type (e.g. tuple types) via intersection.
47
+ * - The length constraint lives only in the brand, so this stays cheap for the
48
+ * type checker even when the element type is large — unlike
49
+ * `isMaxLengthTuple`, which narrows to a union of tuple types.
50
+ * - The result participates in the length-constraint subtyping relation: for
51
+ * example, a value narrowed to `MaxLengthArray<8, E>` is assignable to
52
+ * `MaxLengthArray<16, E>`.
53
+ *
54
+ * @example
55
+ *
56
+ * ```ts
57
+ * const input: readonly string[] = ['a', 'b', 'c'];
58
+ *
59
+ * assert.isTrue(isMaxLengthArray(input, 8));
60
+ *
61
+ * assert.isFalse(isMaxLengthArray(input, 2));
62
+ *
63
+ * if (isMaxLengthArray(input, 8)) {
64
+ * const tags: MaxLengthArray<8, string> = input;
65
+ *
66
+ * const relaxed: MaxLengthArray<16, string> = input; // OK (8 <= 16)
67
+ * }
68
+ * ```
69
+ *
70
+ * @template Xs - The input array type (tuple types are preserved).
71
+ * @template MaxLength - The maximum number of elements (inclusive).
72
+ * @param xs - The array to check.
73
+ * @param maxLength - The maximum number of elements (inclusive).
74
+ * @returns `true` if `xs.length <= maxLength`, `false` otherwise. When `true`,
75
+ * TypeScript narrows `xs` to `MaxLengthArray<MaxLength, Xs[number]> & Xs`.
76
+ */
77
+ export declare const isMaxLengthArray: <Xs extends readonly unknown[], MaxLength extends SupportedLength>(xs: Xs, maxLength: MaxLength) => xs is MaxLengthArray<MaxLength, Xs[number]> & Xs;
78
+ /**
79
+ * Type guard that checks if an array's length is within the inclusive range
80
+ * `[minLength, maxLength]`.
81
+ *
82
+ * **Type Narrowing Behavior:**
83
+ *
84
+ * - Narrows the input to `BoundedLengthArray<MinLength, MaxLength, E>` while
85
+ * preserving the original array type (e.g. tuple types) via intersection.
86
+ * - Since `BoundedLengthArray` is the intersection of `MinLengthArray` and
87
+ * `MaxLengthArray`, the narrowed value is assignable to both, and both
88
+ * bounds can be weakened independently.
89
+ * - The length constraint lives only in the brand, so this stays cheap for the
90
+ * type checker even when the element type is large — unlike
91
+ * `isBoundedLengthTuple`, which narrows to a union of tuple types.
92
+ *
93
+ * @example
94
+ *
95
+ * ```ts
96
+ * const input: readonly number[] = [1, 2, 3];
97
+ *
98
+ * assert.isTrue(isBoundedLengthArray(input, 1, 5));
99
+ *
100
+ * assert.isFalse(isBoundedLengthArray([], 1, 5));
101
+ *
102
+ * if (isBoundedLengthArray(input, 1, 5)) {
103
+ * const selection: BoundedLengthArray<1, 5, number> = input;
104
+ *
105
+ * const relaxed: BoundedLengthArray<0, 100, number> = input; // OK ([1, 5] ⊆ [0, 100])
106
+ * }
107
+ * ```
108
+ *
109
+ * @template Xs - The input array type (tuple types are preserved).
110
+ * @template MinLength - The minimum number of elements (inclusive).
111
+ * @template MaxLength - The maximum number of elements (inclusive).
112
+ * @param xs - The array to check.
113
+ * @param minLength - The minimum number of elements (inclusive).
114
+ * @param maxLength - The maximum number of elements (inclusive).
115
+ * @returns `true` if `minLength <= xs.length && xs.length <= maxLength`,
116
+ * `false` otherwise. When `true`, TypeScript narrows `xs` to
117
+ * `BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs`.
118
+ */
119
+ export declare const isBoundedLengthArray: <Xs extends readonly unknown[], MinLength extends SupportedLength, MaxLength extends SupportedLength>(xs: Xs, minLength: MinLength, maxLength: MaxLength) => xs is BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs;
120
+ /**
121
+ * Type guard that checks if an array has exactly `length` elements.
122
+ *
123
+ * **Type Narrowing Behavior:**
124
+ *
125
+ * - Narrows the input to `FixedLengthArray<Length, E>` while preserving the
126
+ * original array type (e.g. tuple types) via intersection.
127
+ * - Since `FixedLengthArray<Length, E>` is defined as
128
+ * `BoundedLengthArray<Length, Length, E>`, the narrowed value is assignable
129
+ * to any `MinLengthArray<N, E>` with `N <= Length` and any
130
+ * `MaxLengthArray<N, E>` with `N >= Length`.
131
+ * - The length constraint lives only in the brand, so this stays cheap for the
132
+ * type checker even when the element type is large — unlike
133
+ * `isFixedLengthTuple`, which narrows to a structural tuple type.
134
+ *
135
+ * @example
136
+ *
137
+ * ```ts
138
+ * const input: readonly number[] = [255, 128, 0];
139
+ *
140
+ * assert.isTrue(isFixedLengthArray(input, 3));
141
+ *
142
+ * assert.isFalse(isFixedLengthArray(input, 4));
143
+ *
144
+ * if (isFixedLengthArray(input, 3)) {
145
+ * const rgb: FixedLengthArray<3, number> = input;
146
+ *
147
+ * const atMost5: MaxLengthArray<5, number> = input; // OK (3 <= 5)
148
+ * }
149
+ * ```
150
+ *
151
+ * @template Xs - The input array type (tuple types are preserved).
152
+ * @template Length - The exact number of elements.
153
+ * @param xs - The array to check.
154
+ * @param length - The exact number of elements.
155
+ * @returns `true` if `xs.length === length`, `false` otherwise. When `true`,
156
+ * TypeScript narrows `xs` to `FixedLengthArray<Length, Xs[number]> & Xs`.
157
+ */
158
+ export declare const isFixedLengthArray: <Xs extends readonly unknown[], Length extends SupportedLength>(xs: Xs, length: Length) => xs is FixedLengthArray<Length, Xs[number]> & Xs;
159
+ //# sourceMappingURL=is-length-bounded-array.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-length-bounded-array.d.mts","sourceRoot":"","sources":["../../src/guard/is-length-bounded-array.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,gBAAgB,GAC3B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,SAAS,eAAe,MAE7B,EAAE,aACK,SAAS,KACnB,EAAE,IAAI,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAA4B,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,gBAAgB,GAC3B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,SAAS,eAAe,MAE7B,EAAE,aACK,SAAS,KACnB,EAAE,IAAI,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAA4B,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,oBAAoB,GAC/B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,SAAS,eAAe,EACjC,SAAS,SAAS,eAAe,MAE7B,EAAE,aACK,SAAS,aACT,SAAS,KACnB,EAAE,IAAI,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EACd,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,kBAAkB,GAC7B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,MAAM,SAAS,eAAe,MAE1B,EAAE,UACE,MAAM,KACb,EAAE,IAAI,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAA0B,CAAC"}
@@ -0,0 +1,7 @@
1
+ const isMinLengthArray = (xs, minLength) => xs.length >= minLength;
2
+ const isMaxLengthArray = (xs, maxLength) => xs.length <= maxLength;
3
+ const isBoundedLengthArray = (xs, minLength, maxLength) => xs.length >= minLength && xs.length <= maxLength;
4
+ const isFixedLengthArray = (xs, length) => xs.length === length;
5
+
6
+ export { isBoundedLengthArray, isFixedLengthArray, isMaxLengthArray, isMinLengthArray };
7
+ //# sourceMappingURL=is-length-bounded-array.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-length-bounded-array.mjs","sources":["../../src/guard/is-length-bounded-array.mts"],"sourcesContent":["import {\n type BoundedLengthArray,\n type FixedLengthArray,\n type MaxLengthArray,\n type MinLengthArray,\n type SupportedLength,\n} from 'ts-type-forge';\n\n/**\n * Type guard that checks if an array has at least `minLength` elements.\n *\n * **Type Narrowing Behavior:**\n *\n * - Narrows the input to `MinLengthArray<MinLength, E>` while preserving the\n * original array type (e.g. tuple types) via intersection.\n * - The length constraint lives only in the brand, so this stays cheap for the\n * type checker even when the element type is large — unlike\n * `isMinLengthTuple`, which narrows to a structural tuple type.\n * - The result participates in the length-constraint subtyping relation: for\n * example, a value narrowed to `MinLengthArray<3, E>` is assignable to\n * `MinLengthArray<1, E>`.\n *\n * @example\n *\n * ```ts\n * const input: readonly number[] = [0, 1, 2, 3];\n *\n * assert.isTrue(isMinLengthArray(input, 3));\n *\n * assert.isFalse(isMinLengthArray([0], 3));\n *\n * if (isMinLengthArray(input, 3)) {\n * const history: MinLengthArray<3, number> = input;\n *\n * const nonEmpty: MinLengthArray<1, number> = input; // OK (3 >= 1)\n * }\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MinLength - The minimum number of elements (inclusive).\n * @param xs - The array to check.\n * @param minLength - The minimum number of elements (inclusive).\n * @returns `true` if `xs.length >= minLength`, `false` otherwise. When `true`,\n * TypeScript narrows `xs` to `MinLengthArray<MinLength, Xs[number]> & Xs`.\n */\nexport const isMinLengthArray = <\n Xs extends readonly unknown[],\n MinLength extends SupportedLength,\n>(\n xs: Xs,\n minLength: MinLength,\n): xs is MinLengthArray<MinLength, Xs[number]> & Xs => xs.length >= minLength;\n\n/**\n * Type guard that checks if an array has at most `maxLength` elements.\n *\n * **Type Narrowing Behavior:**\n *\n * - Narrows the input to `MaxLengthArray<MaxLength, E>` while preserving the\n * original array type (e.g. tuple types) via intersection.\n * - The length constraint lives only in the brand, so this stays cheap for the\n * type checker even when the element type is large — unlike\n * `isMaxLengthTuple`, which narrows to a union of tuple types.\n * - The result participates in the length-constraint subtyping relation: for\n * example, a value narrowed to `MaxLengthArray<8, E>` is assignable to\n * `MaxLengthArray<16, E>`.\n *\n * @example\n *\n * ```ts\n * const input: readonly string[] = ['a', 'b', 'c'];\n *\n * assert.isTrue(isMaxLengthArray(input, 8));\n *\n * assert.isFalse(isMaxLengthArray(input, 2));\n *\n * if (isMaxLengthArray(input, 8)) {\n * const tags: MaxLengthArray<8, string> = input;\n *\n * const relaxed: MaxLengthArray<16, string> = input; // OK (8 <= 16)\n * }\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MaxLength - The maximum number of elements (inclusive).\n * @param xs - The array to check.\n * @param maxLength - The maximum number of elements (inclusive).\n * @returns `true` if `xs.length <= maxLength`, `false` otherwise. When `true`,\n * TypeScript narrows `xs` to `MaxLengthArray<MaxLength, Xs[number]> & Xs`.\n */\nexport const isMaxLengthArray = <\n Xs extends readonly unknown[],\n MaxLength extends SupportedLength,\n>(\n xs: Xs,\n maxLength: MaxLength,\n): xs is MaxLengthArray<MaxLength, Xs[number]> & Xs => xs.length <= maxLength;\n\n/**\n * Type guard that checks if an array's length is within the inclusive range\n * `[minLength, maxLength]`.\n *\n * **Type Narrowing Behavior:**\n *\n * - Narrows the input to `BoundedLengthArray<MinLength, MaxLength, E>` while\n * preserving the original array type (e.g. tuple types) via intersection.\n * - Since `BoundedLengthArray` is the intersection of `MinLengthArray` and\n * `MaxLengthArray`, the narrowed value is assignable to both, and both\n * bounds can be weakened independently.\n * - The length constraint lives only in the brand, so this stays cheap for the\n * type checker even when the element type is large — unlike\n * `isBoundedLengthTuple`, which narrows to a union of tuple types.\n *\n * @example\n *\n * ```ts\n * const input: readonly number[] = [1, 2, 3];\n *\n * assert.isTrue(isBoundedLengthArray(input, 1, 5));\n *\n * assert.isFalse(isBoundedLengthArray([], 1, 5));\n *\n * if (isBoundedLengthArray(input, 1, 5)) {\n * const selection: BoundedLengthArray<1, 5, number> = input;\n *\n * const relaxed: BoundedLengthArray<0, 100, number> = input; // OK ([1, 5] ⊆ [0, 100])\n * }\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MinLength - The minimum number of elements (inclusive).\n * @template MaxLength - The maximum number of elements (inclusive).\n * @param xs - The array to check.\n * @param minLength - The minimum number of elements (inclusive).\n * @param maxLength - The maximum number of elements (inclusive).\n * @returns `true` if `minLength <= xs.length && xs.length <= maxLength`,\n * `false` otherwise. When `true`, TypeScript narrows `xs` to\n * `BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs`.\n */\nexport const isBoundedLengthArray = <\n Xs extends readonly unknown[],\n MinLength extends SupportedLength,\n MaxLength extends SupportedLength,\n>(\n xs: Xs,\n minLength: MinLength,\n maxLength: MaxLength,\n): xs is BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs =>\n xs.length >= minLength && xs.length <= maxLength;\n\n/**\n * Type guard that checks if an array has exactly `length` elements.\n *\n * **Type Narrowing Behavior:**\n *\n * - Narrows the input to `FixedLengthArray<Length, E>` while preserving the\n * original array type (e.g. tuple types) via intersection.\n * - Since `FixedLengthArray<Length, E>` is defined as\n * `BoundedLengthArray<Length, Length, E>`, the narrowed value is assignable\n * to any `MinLengthArray<N, E>` with `N <= Length` and any\n * `MaxLengthArray<N, E>` with `N >= Length`.\n * - The length constraint lives only in the brand, so this stays cheap for the\n * type checker even when the element type is large — unlike\n * `isFixedLengthTuple`, which narrows to a structural tuple type.\n *\n * @example\n *\n * ```ts\n * const input: readonly number[] = [255, 128, 0];\n *\n * assert.isTrue(isFixedLengthArray(input, 3));\n *\n * assert.isFalse(isFixedLengthArray(input, 4));\n *\n * if (isFixedLengthArray(input, 3)) {\n * const rgb: FixedLengthArray<3, number> = input;\n *\n * const atMost5: MaxLengthArray<5, number> = input; // OK (3 <= 5)\n * }\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template Length - The exact number of elements.\n * @param xs - The array to check.\n * @param length - The exact number of elements.\n * @returns `true` if `xs.length === length`, `false` otherwise. When `true`,\n * TypeScript narrows `xs` to `FixedLengthArray<Length, Xs[number]> & Xs`.\n */\nexport const isFixedLengthArray = <\n Xs extends readonly unknown[],\n Length extends SupportedLength,\n>(\n xs: Xs,\n length: Length,\n): xs is FixedLengthArray<Length, Xs[number]> & Xs => xs.length === length;\n"],"names":[],"mappings":"AA6CO,MAAM,gBAAA,GAAmB,CAI9B,EAAA,EACA,SAAA,KACqD,GAAG,MAAA,IAAU;AAuC7D,MAAM,gBAAA,GAAmB,CAI9B,EAAA,EACA,SAAA,KACqD,GAAG,MAAA,IAAU;AA2C7D,MAAM,oBAAA,GAAuB,CAKlC,EAAA,EACA,SAAA,EACA,cAEA,EAAA,CAAG,MAAA,IAAU,SAAA,IAAa,EAAA,CAAG,MAAA,IAAU;AAwClC,MAAM,kBAAA,GAAqB,CAIhC,EAAA,EACA,MAAA,KACoD,GAAG,MAAA,KAAW;;;;"}
@@ -1,5 +1,4 @@
1
- import { type BoundedLengthString, type FixedLengthString, type MaxLengthString, type MinLengthString } from 'ts-type-forge';
2
- import { type SizeType } from '../types.mjs';
1
+ import { type BoundedLengthString, type FixedLengthString, type MaxLengthString, type MinLengthString, type SupportedLength } from 'ts-type-forge';
3
2
  /**
4
3
  * Type guard that checks if a string has at least `minLength` characters.
5
4
  *
@@ -38,7 +37,7 @@ import { type SizeType } from '../types.mjs';
38
37
  * @returns `true` if `s.length >= minLength`, `false` otherwise. When `true`,
39
38
  * TypeScript narrows `s` to `MinLengthString<MinLength> & S`.
40
39
  */
41
- export declare const isMinLengthString: <S extends string, MinLength extends SizeType.ArgStr>(s: S, minLength: MinLength) => s is MinLengthString<MinLength> & S;
40
+ export declare const isMinLengthString: <S extends string, MinLength extends SupportedLength>(s: S, minLength: MinLength) => s is MinLengthString<MinLength> & S;
42
41
  /**
43
42
  * Type guard that checks if a string has at most `maxLength` characters.
44
43
  *
@@ -77,7 +76,7 @@ export declare const isMinLengthString: <S extends string, MinLength extends Siz
77
76
  * @returns `true` if `s.length <= maxLength`, `false` otherwise. When `true`,
78
77
  * TypeScript narrows `s` to `MaxLengthString<MaxLength> & S`.
79
78
  */
80
- export declare const isMaxLengthString: <S extends string, MaxLength extends SizeType.ArgStr>(s: S, maxLength: MaxLength) => s is MaxLengthString<MaxLength> & S;
79
+ export declare const isMaxLengthString: <S extends string, MaxLength extends SupportedLength>(s: S, maxLength: MaxLength) => s is MaxLengthString<MaxLength> & S;
81
80
  /**
82
81
  * Type guard that checks if a string's length is within the inclusive range
83
82
  * `[minLength, maxLength]`.
@@ -120,7 +119,7 @@ export declare const isMaxLengthString: <S extends string, MaxLength extends Siz
120
119
  * otherwise. When `true`, TypeScript narrows `s` to
121
120
  * `BoundedLengthString<MinLength, MaxLength> & S`.
122
121
  */
123
- export declare const isBoundedLengthString: <S extends string, MinLength extends SizeType.ArgStr, MaxLength extends SizeType.ArgStr>(s: S, minLength: MinLength, maxLength: MaxLength) => s is BoundedLengthString<MinLength, MaxLength> & S;
122
+ export declare const isBoundedLengthString: <S extends string, MinLength extends SupportedLength, MaxLength extends SupportedLength>(s: S, minLength: MinLength, maxLength: MaxLength) => s is BoundedLengthString<MinLength, MaxLength> & S;
124
123
  /**
125
124
  * Type guard that checks if a string has exactly `length` characters.
126
125
  *
@@ -160,5 +159,5 @@ export declare const isBoundedLengthString: <S extends string, MinLength extends
160
159
  * @returns `true` if `s.length === length`, `false` otherwise. When `true`,
161
160
  * TypeScript narrows `s` to `FixedLengthString<Length> & S`.
162
161
  */
163
- export declare const isFixedLengthString: <S extends string, Length extends SizeType.ArgStr>(s: S, length: Length) => s is FixedLengthString<Length> & S;
162
+ export declare const isFixedLengthString: <S extends string, Length extends SupportedLength>(s: S, length: Length) => s is FixedLengthString<Length> & S;
164
163
  //# sourceMappingURL=is-length-bounded-string.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-length-bounded-string.d.mts","sourceRoot":"","sources":["../../src/guard/is-length-bounded-string.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,iBAAiB,GAC5B,CAAC,SAAS,MAAM,EAChB,SAAS,SAAS,QAAQ,CAAC,MAAM,EAEjC,GAAG,CAAC,EACJ,WAAW,SAAS,KACnB,CAAC,IAAI,eAAe,CAAC,SAAS,CAAC,GAAG,CAA0B,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,iBAAiB,GAC5B,CAAC,SAAS,MAAM,EAChB,SAAS,SAAS,QAAQ,CAAC,MAAM,EAEjC,GAAG,CAAC,EACJ,WAAW,SAAS,KACnB,CAAC,IAAI,eAAe,CAAC,SAAS,CAAC,GAAG,CAA0B,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,qBAAqB,GAChC,CAAC,SAAS,MAAM,EAChB,SAAS,SAAS,QAAQ,CAAC,MAAM,EACjC,SAAS,SAAS,QAAQ,CAAC,MAAM,EAEjC,GAAG,CAAC,EACJ,WAAW,SAAS,EACpB,WAAW,SAAS,KACnB,CAAC,IAAI,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,GAAG,CACJ,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,mBAAmB,GAC9B,CAAC,SAAS,MAAM,EAChB,MAAM,SAAS,QAAQ,CAAC,MAAM,EAE9B,GAAG,CAAC,EACJ,QAAQ,MAAM,KACb,CAAC,IAAI,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAwB,CAAC"}
1
+ {"version":3,"file":"is-length-bounded-string.d.mts","sourceRoot":"","sources":["../../src/guard/is-length-bounded-string.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,iBAAiB,GAC5B,CAAC,SAAS,MAAM,EAChB,SAAS,SAAS,eAAe,KAE9B,CAAC,aACO,SAAS,KACnB,CAAC,IAAI,eAAe,CAAC,SAAS,CAAC,GAAG,CAA0B,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,iBAAiB,GAC5B,CAAC,SAAS,MAAM,EAChB,SAAS,SAAS,eAAe,KAE9B,CAAC,aACO,SAAS,KACnB,CAAC,IAAI,eAAe,CAAC,SAAS,CAAC,GAAG,CAA0B,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,qBAAqB,GAChC,CAAC,SAAS,MAAM,EAChB,SAAS,SAAS,eAAe,EACjC,SAAS,SAAS,eAAe,KAE9B,CAAC,aACO,SAAS,aACT,SAAS,KACnB,CAAC,IAAI,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,GAAG,CACJ,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,mBAAmB,GAC9B,CAAC,SAAS,MAAM,EAChB,MAAM,SAAS,eAAe,KAE3B,CAAC,UACI,MAAM,KACb,CAAC,IAAI,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAwB,CAAC"}