ts-data-forge 8.0.0 → 9.0.1

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 (429) hide show
  1. package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
  2. package/dist/array/impl/array-utils-creation.mjs +17 -112
  3. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  4. package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
  5. package/dist/array/impl/array-utils-element-access.mjs +22 -61
  6. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  7. package/dist/array/impl/array-utils-iterators.d.mts.map +1 -1
  8. package/dist/array/impl/array-utils-iterators.mjs +9 -63
  9. package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
  10. package/dist/array/impl/array-utils-modification.mjs +78 -78
  11. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  12. package/dist/array/impl/array-utils-reducing-value.mjs +95 -89
  13. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  14. package/dist/array/impl/array-utils-search.mjs +100 -92
  15. package/dist/array/impl/array-utils-search.mjs.map +1 -1
  16. package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
  17. package/dist/array/impl/array-utils-set-op.mjs +31 -141
  18. package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
  19. package/dist/array/impl/array-utils-size.d.mts.map +1 -1
  20. package/dist/array/impl/array-utils-size.mjs +4 -8
  21. package/dist/array/impl/array-utils-size.mjs.map +1 -1
  22. package/dist/array/impl/array-utils-slice-clamped.mjs +11 -12
  23. package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
  24. package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
  25. package/dist/array/impl/array-utils-slicing.mjs +44 -96
  26. package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
  27. package/dist/array/impl/array-utils-transformation.d.mts +1 -1
  28. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
  29. package/dist/array/impl/array-utils-transformation.mjs +150 -292
  30. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  31. package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
  32. package/dist/array/impl/array-utils-validation.mjs +18 -169
  33. package/dist/array/impl/array-utils-validation.mjs.map +1 -1
  34. package/dist/collections/imap-mapped.d.mts.map +1 -1
  35. package/dist/collections/imap-mapped.mjs +243 -330
  36. package/dist/collections/imap-mapped.mjs.map +1 -1
  37. package/dist/collections/imap.d.mts.map +1 -1
  38. package/dist/collections/imap.mjs +190 -275
  39. package/dist/collections/imap.mjs.map +1 -1
  40. package/dist/collections/iset-mapped.d.mts +1 -1
  41. package/dist/collections/iset-mapped.d.mts.map +1 -1
  42. package/dist/collections/iset-mapped.mjs +222 -444
  43. package/dist/collections/iset-mapped.mjs.map +1 -1
  44. package/dist/collections/iset.d.mts +1 -1
  45. package/dist/collections/iset.d.mts.map +1 -1
  46. package/dist/collections/iset.mjs +158 -324
  47. package/dist/collections/iset.mjs.map +1 -1
  48. package/dist/collections/queue.d.mts.map +1 -1
  49. package/dist/collections/queue.mjs +106 -178
  50. package/dist/collections/queue.mjs.map +1 -1
  51. package/dist/collections/stack.d.mts.map +1 -1
  52. package/dist/collections/stack.mjs +95 -165
  53. package/dist/collections/stack.mjs.map +1 -1
  54. package/dist/entry-point.mjs +1 -0
  55. package/dist/entry-point.mjs.map +1 -1
  56. package/dist/expect-type.d.mts +1 -1
  57. package/dist/expect-type.d.mts.map +1 -1
  58. package/dist/expect-type.mjs +1 -69
  59. package/dist/expect-type.mjs.map +1 -1
  60. package/dist/functional/match.mjs +9 -9
  61. package/dist/functional/match.mjs.map +1 -1
  62. package/dist/functional/optional/impl/optional-expect-to-be.mjs +13 -14
  63. package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
  64. package/dist/functional/optional/impl/optional-filter.mjs +14 -15
  65. package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
  66. package/dist/functional/optional/impl/optional-flat-map.mjs +10 -11
  67. package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
  68. package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +1 -1
  69. package/dist/functional/optional/impl/optional-from-nullable.mjs +1 -25
  70. package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
  71. package/dist/functional/optional/impl/optional-is-none.d.mts.map +1 -1
  72. package/dist/functional/optional/impl/optional-is-none.mjs +0 -19
  73. package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -1
  74. package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -1
  75. package/dist/functional/optional/impl/optional-is-optional.mjs +1 -23
  76. package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
  77. package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -1
  78. package/dist/functional/optional/impl/optional-is-some.mjs +0 -20
  79. package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
  80. package/dist/functional/optional/impl/optional-map.mjs +13 -14
  81. package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
  82. package/dist/functional/optional/impl/optional-none.mjs +0 -16
  83. package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
  84. package/dist/functional/optional/impl/optional-or-else.mjs +10 -11
  85. package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
  86. package/dist/functional/optional/impl/optional-some.d.mts.map +1 -1
  87. package/dist/functional/optional/impl/optional-some.mjs +2 -21
  88. package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
  89. package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -1
  90. package/dist/functional/optional/impl/optional-to-nullable.mjs +1 -27
  91. package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
  92. package/dist/functional/optional/impl/optional-unwrap-or.mjs +9 -10
  93. package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
  94. package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -1
  95. package/dist/functional/optional/impl/optional-unwrap-throw.mjs +4 -32
  96. package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
  97. package/dist/functional/optional/impl/optional-unwrap.mjs +4 -4
  98. package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
  99. package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -1
  100. package/dist/functional/optional/impl/optional-zip.mjs +1 -35
  101. package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
  102. package/dist/functional/optional/impl/tag.mjs +2 -3
  103. package/dist/functional/optional/impl/tag.mjs.map +1 -1
  104. package/dist/functional/pipe.d.mts.map +1 -1
  105. package/dist/functional/pipe.mjs +9 -34
  106. package/dist/functional/pipe.mjs.map +1 -1
  107. package/dist/functional/result/impl/result-err.d.mts.map +1 -1
  108. package/dist/functional/result/impl/result-err.mjs +2 -27
  109. package/dist/functional/result/impl/result-err.mjs.map +1 -1
  110. package/dist/functional/result/impl/result-expect-to-be.mjs +13 -15
  111. package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
  112. package/dist/functional/result/impl/result-flat-map.mjs +16 -16
  113. package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
  114. package/dist/functional/result/impl/result-fold.mjs +16 -16
  115. package/dist/functional/result/impl/result-fold.mjs.map +1 -1
  116. package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -1
  117. package/dist/functional/result/impl/result-from-promise.mjs +4 -31
  118. package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
  119. package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -1
  120. package/dist/functional/result/impl/result-from-throwable.mjs +8 -38
  121. package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
  122. package/dist/functional/result/impl/result-is-err.d.mts.map +1 -1
  123. package/dist/functional/result/impl/result-is-err.mjs +0 -19
  124. package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
  125. package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -1
  126. package/dist/functional/result/impl/result-is-ok.mjs +0 -19
  127. package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
  128. package/dist/functional/result/impl/result-is-result.d.mts.map +1 -1
  129. package/dist/functional/result/impl/result-is-result.mjs +1 -23
  130. package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
  131. package/dist/functional/result/impl/result-map-err.mjs +16 -16
  132. package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
  133. package/dist/functional/result/impl/result-map.mjs +16 -16
  134. package/dist/functional/result/impl/result-map.mjs.map +1 -1
  135. package/dist/functional/result/impl/result-ok.d.mts.map +1 -1
  136. package/dist/functional/result/impl/result-ok.mjs +2 -27
  137. package/dist/functional/result/impl/result-ok.mjs.map +1 -1
  138. package/dist/functional/result/impl/result-or-else.mjs +10 -12
  139. package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
  140. package/dist/functional/result/impl/result-swap.d.mts.map +1 -1
  141. package/dist/functional/result/impl/result-swap.mjs +4 -22
  142. package/dist/functional/result/impl/result-swap.mjs.map +1 -1
  143. package/dist/functional/result/impl/result-to-optional.d.mts.map +1 -1
  144. package/dist/functional/result/impl/result-to-optional.mjs +0 -27
  145. package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
  146. package/dist/functional/result/impl/result-unwrap-err-or.mjs +9 -11
  147. package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
  148. package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +1 -1
  149. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +13 -40
  150. package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
  151. package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -1
  152. package/dist/functional/result/impl/result-unwrap-err.mjs +4 -32
  153. package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
  154. package/dist/functional/result/impl/result-unwrap-ok-or.mjs +9 -11
  155. package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
  156. package/dist/functional/result/impl/result-unwrap-ok.mjs +4 -4
  157. package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
  158. package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -1
  159. package/dist/functional/result/impl/result-unwrap-throw.mjs +4 -35
  160. package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
  161. package/dist/functional/result/impl/result-zip.d.mts.map +1 -1
  162. package/dist/functional/result/impl/result-zip.mjs +1 -34
  163. package/dist/functional/result/impl/result-zip.mjs.map +1 -1
  164. package/dist/functional/result/impl/tag.mjs +2 -3
  165. package/dist/functional/result/impl/tag.mjs.map +1 -1
  166. package/dist/functional/ternary-result/impl/tag.mjs +3 -5
  167. package/dist/functional/ternary-result/impl/tag.mjs.map +1 -1
  168. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -1
  169. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +2 -15
  170. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
  171. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +13 -13
  172. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
  173. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +27 -26
  174. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
  175. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +21 -22
  176. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
  177. package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +1 -1
  178. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +4 -20
  179. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
  180. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -1
  181. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +7 -25
  182. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
  183. package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts.map +1 -1
  184. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +0 -17
  185. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -1
  186. package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +1 -1
  187. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +0 -19
  188. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -1
  189. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +1 -1
  190. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +1 -25
  191. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -1
  192. package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +1 -1
  193. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +0 -18
  194. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
  195. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +13 -15
  196. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
  197. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +18 -18
  198. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
  199. package/dist/functional/ternary-result/impl/ternary-result-map.mjs +21 -22
  200. package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
  201. package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -1
  202. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +2 -16
  203. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
  204. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +9 -9
  205. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
  206. package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +1 -1
  207. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +4 -22
  208. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -1
  209. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +9 -9
  210. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -1
  211. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +1 -1
  212. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +12 -27
  213. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
  214. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +1 -1
  215. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +4 -19
  216. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -1
  217. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +9 -9
  218. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -1
  219. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +4 -5
  220. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
  221. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -1
  222. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +15 -27
  223. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
  224. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +9 -9
  225. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -1
  226. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +1 -1
  227. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +10 -24
  228. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
  229. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +1 -1
  230. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +4 -19
  231. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
  232. package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -1
  233. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +3 -19
  234. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
  235. package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -1
  236. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +14 -45
  237. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
  238. package/dist/functional/ternary-result/impl/variant-name.d.mts +1 -1
  239. package/dist/functional/ternary-result/impl/variant-name.d.mts.map +1 -1
  240. package/dist/functional/ternary-result/impl/variant-name.mjs +8 -9
  241. package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -1
  242. package/dist/functional/ternary-result/ternary-result.d.mts.map +1 -1
  243. package/dist/guard/has-key.d.mts.map +1 -1
  244. package/dist/guard/has-key.mjs +0 -41
  245. package/dist/guard/has-key.mjs.map +1 -1
  246. package/dist/guard/index.d.mts +1 -0
  247. package/dist/guard/index.d.mts.map +1 -1
  248. package/dist/guard/index.mjs +1 -0
  249. package/dist/guard/index.mjs.map +1 -1
  250. package/dist/guard/is-length-bounded-string.d.mts +164 -0
  251. package/dist/guard/is-length-bounded-string.d.mts.map +1 -0
  252. package/dist/guard/is-length-bounded-string.mjs +7 -0
  253. package/dist/guard/is-length-bounded-string.mjs.map +1 -0
  254. package/dist/guard/is-non-empty-string.d.mts +1 -1
  255. package/dist/guard/is-non-empty-string.d.mts.map +1 -1
  256. package/dist/guard/is-non-empty-string.mjs +1 -38
  257. package/dist/guard/is-non-empty-string.mjs.map +1 -1
  258. package/dist/guard/is-non-null-object.d.mts.map +1 -1
  259. package/dist/guard/is-non-null-object.mjs +1 -35
  260. package/dist/guard/is-non-null-object.mjs.map +1 -1
  261. package/dist/guard/is-primitive.d.mts.map +1 -1
  262. package/dist/guard/is-primitive.mjs +12 -43
  263. package/dist/guard/is-primitive.mjs.map +1 -1
  264. package/dist/guard/is-record.d.mts.map +1 -1
  265. package/dist/guard/is-record.mjs +0 -86
  266. package/dist/guard/is-record.mjs.map +1 -1
  267. package/dist/guard/is-type.d.mts.map +1 -1
  268. package/dist/guard/is-type.mjs +12 -399
  269. package/dist/guard/is-type.mjs.map +1 -1
  270. package/dist/guard/key-is-in.d.mts.map +1 -1
  271. package/dist/guard/key-is-in.mjs +0 -40
  272. package/dist/guard/key-is-in.mjs.map +1 -1
  273. package/dist/index.mjs +1 -0
  274. package/dist/index.mjs.map +1 -1
  275. package/dist/iterator/range.mjs +16 -16
  276. package/dist/iterator/range.mjs.map +1 -1
  277. package/dist/json/json.d.mts.map +1 -1
  278. package/dist/json/json.mjs +52 -340
  279. package/dist/json/json.mjs.map +1 -1
  280. package/dist/number/branded-types/finite-number.d.mts +3 -3
  281. package/dist/number/branded-types/finite-number.mjs +135 -154
  282. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  283. package/dist/number/branded-types/int.d.mts +4 -4
  284. package/dist/number/branded-types/int.mjs +205 -245
  285. package/dist/number/branded-types/int.mjs.map +1 -1
  286. package/dist/number/branded-types/int16.d.mts +15 -15
  287. package/dist/number/branded-types/int16.mjs +116 -123
  288. package/dist/number/branded-types/int16.mjs.map +1 -1
  289. package/dist/number/branded-types/int32.d.mts +11 -11
  290. package/dist/number/branded-types/int32.mjs +116 -123
  291. package/dist/number/branded-types/int32.mjs.map +1 -1
  292. package/dist/number/branded-types/negative-finite-number.d.mts +4 -4
  293. package/dist/number/branded-types/negative-finite-number.mjs +129 -144
  294. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  295. package/dist/number/branded-types/negative-int.d.mts +5 -5
  296. package/dist/number/branded-types/negative-int.mjs +94 -113
  297. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  298. package/dist/number/branded-types/negative-safe-int.d.mts +5 -5
  299. package/dist/number/branded-types/negative-safe-int.mjs +103 -124
  300. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  301. package/dist/number/branded-types/non-negative-finite-number.d.mts +5 -5
  302. package/dist/number/branded-types/non-negative-finite-number.mjs +136 -142
  303. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  304. package/dist/number/branded-types/non-negative-int16.d.mts +16 -16
  305. package/dist/number/branded-types/non-negative-int16.mjs +109 -118
  306. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  307. package/dist/number/branded-types/non-negative-int32.d.mts +12 -12
  308. package/dist/number/branded-types/non-negative-int32.mjs +110 -119
  309. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  310. package/dist/number/branded-types/non-positive-finite-number.d.mts +3 -3
  311. package/dist/number/branded-types/non-positive-finite-number.mjs +120 -124
  312. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  313. package/dist/number/branded-types/non-positive-int.d.mts +4 -4
  314. package/dist/number/branded-types/non-positive-int.mjs +167 -212
  315. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  316. package/dist/number/branded-types/non-positive-safe-int.d.mts +4 -4
  317. package/dist/number/branded-types/non-positive-safe-int.mjs +95 -106
  318. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  319. package/dist/number/branded-types/non-zero-finite-number.d.mts +4 -4
  320. package/dist/number/branded-types/non-zero-finite-number.mjs +114 -123
  321. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  322. package/dist/number/branded-types/non-zero-int.d.mts +2 -2
  323. package/dist/number/branded-types/non-zero-int.mjs +72 -83
  324. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  325. package/dist/number/branded-types/non-zero-int16.d.mts +7 -7
  326. package/dist/number/branded-types/non-zero-int16.mjs +96 -107
  327. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  328. package/dist/number/branded-types/non-zero-int32.d.mts +5 -5
  329. package/dist/number/branded-types/non-zero-int32.mjs +97 -108
  330. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  331. package/dist/number/branded-types/non-zero-safe-int.d.mts +2 -2
  332. package/dist/number/branded-types/non-zero-safe-int.mjs +100 -111
  333. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  334. package/dist/number/branded-types/non-zero-uint16.d.mts +8 -8
  335. package/dist/number/branded-types/non-zero-uint16.mjs +96 -107
  336. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  337. package/dist/number/branded-types/non-zero-uint32.d.mts +6 -6
  338. package/dist/number/branded-types/non-zero-uint32.mjs +96 -107
  339. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  340. package/dist/number/branded-types/positive-finite-number.d.mts +8 -8
  341. package/dist/number/branded-types/positive-finite-number.mjs +139 -141
  342. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  343. package/dist/number/branded-types/positive-int.d.mts +11 -11
  344. package/dist/number/branded-types/positive-int.mjs +228 -271
  345. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  346. package/dist/number/branded-types/positive-int16.d.mts +19 -19
  347. package/dist/number/branded-types/positive-int16.mjs +109 -118
  348. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  349. package/dist/number/branded-types/positive-int32.d.mts +15 -15
  350. package/dist/number/branded-types/positive-int32.mjs +109 -118
  351. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  352. package/dist/number/branded-types/positive-safe-int.d.mts +11 -11
  353. package/dist/number/branded-types/positive-safe-int.mjs +244 -275
  354. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  355. package/dist/number/branded-types/positive-uint16.d.mts +17 -17
  356. package/dist/number/branded-types/positive-uint16.mjs +109 -118
  357. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  358. package/dist/number/branded-types/positive-uint32.d.mts +13 -13
  359. package/dist/number/branded-types/positive-uint32.mjs +110 -119
  360. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  361. package/dist/number/branded-types/safe-int.d.mts +4 -4
  362. package/dist/number/branded-types/safe-int.mjs +251 -292
  363. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  364. package/dist/number/branded-types/safe-uint.d.mts +8 -8
  365. package/dist/number/branded-types/safe-uint.mjs +111 -119
  366. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  367. package/dist/number/branded-types/uint.d.mts +8 -8
  368. package/dist/number/branded-types/uint.mjs +198 -225
  369. package/dist/number/branded-types/uint.mjs.map +1 -1
  370. package/dist/number/branded-types/uint16.d.mts +14 -14
  371. package/dist/number/branded-types/uint16.mjs +109 -119
  372. package/dist/number/branded-types/uint16.mjs.map +1 -1
  373. package/dist/number/branded-types/uint32.d.mts +10 -10
  374. package/dist/number/branded-types/uint32.mjs +110 -117
  375. package/dist/number/branded-types/uint32.mjs.map +1 -1
  376. package/dist/number/enum/int8.mjs +119 -145
  377. package/dist/number/enum/int8.mjs.map +1 -1
  378. package/dist/number/enum/uint8.mjs +107 -121
  379. package/dist/number/enum/uint8.mjs.map +1 -1
  380. package/dist/number/num.d.mts +2 -2
  381. package/dist/number/num.d.mts.map +1 -1
  382. package/dist/number/num.mjs +76 -537
  383. package/dist/number/num.mjs.map +1 -1
  384. package/dist/number/refined-number-utils.d.mts +1 -1
  385. package/dist/number/refined-number-utils.d.mts.map +1 -1
  386. package/dist/number/refined-number-utils.mjs +127 -263
  387. package/dist/number/refined-number-utils.mjs.map +1 -1
  388. package/dist/object/object.d.mts.map +1 -1
  389. package/dist/object/object.mjs +107 -222
  390. package/dist/object/object.mjs.map +1 -1
  391. package/dist/others/cast-mutable.d.mts.map +1 -1
  392. package/dist/others/cast-mutable.mjs +8 -37
  393. package/dist/others/cast-mutable.mjs.map +1 -1
  394. package/dist/others/cast-readonly.d.mts.map +1 -1
  395. package/dist/others/cast-readonly.mjs +8 -36
  396. package/dist/others/cast-readonly.mjs.map +1 -1
  397. package/dist/others/debounce-function.d.mts.map +1 -1
  398. package/dist/others/debounce-function.mjs +7 -16
  399. package/dist/others/debounce-function.mjs.map +1 -1
  400. package/dist/others/fast-deep-equal.d.mts.map +1 -1
  401. package/dist/others/fast-deep-equal.mjs +43 -59
  402. package/dist/others/fast-deep-equal.mjs.map +1 -1
  403. package/dist/others/if-then.d.mts.map +1 -1
  404. package/dist/others/if-then.mjs +0 -29
  405. package/dist/others/if-then.mjs.map +1 -1
  406. package/dist/others/map-nullable.mjs +9 -9
  407. package/dist/others/map-nullable.mjs.map +1 -1
  408. package/dist/others/memoize-function.mjs +12 -12
  409. package/dist/others/memoize-function.mjs.map +1 -1
  410. package/dist/others/tuple.d.mts.map +1 -1
  411. package/dist/others/tuple.mjs +0 -50
  412. package/dist/others/tuple.mjs.map +1 -1
  413. package/dist/others/unknown-to-string.d.mts.map +1 -1
  414. package/dist/others/unknown-to-string.mjs +41 -88
  415. package/dist/others/unknown-to-string.mjs.map +1 -1
  416. package/dist/promise/promise.d.mts.map +1 -1
  417. package/dist/promise/promise.mjs +4 -49
  418. package/dist/promise/promise.mjs.map +1 -1
  419. package/package.json +17 -16
  420. package/src/array/impl/array-utils-transformation.mts +1 -2
  421. package/src/array/impl/array-utils-transformation.test.mts +3 -36
  422. package/src/array/impl/array-utils-validation.test.mts +1 -3
  423. package/src/expect-type.mts +4 -5
  424. package/src/functional/ternary-result/ternary-result.mts +2 -6
  425. package/src/guard/index.mts +1 -0
  426. package/src/guard/is-length-bounded-string.mts +199 -0
  427. package/src/guard/is-length-bounded-string.test.mts +170 -0
  428. package/src/number/refined-number-utils.mts +1 -9
  429. package/src/object/object.mts +25 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-data-forge",
3
- "version": "8.0.0",
3
+ "version": "9.0.1",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "typescript",
@@ -77,16 +77,16 @@
77
77
  "test:cov:ui": "vite preview --outDir ./coverage",
78
78
  "test:ui": "pnpm run z:vitest:node --ui",
79
79
  "testw": "pnpm run z:vitest:node watch",
80
- "tsc": "tsc --noEmit",
81
- "tscw": "tsc --noEmit --watch -p ./tsconfig.json",
82
- "type-check": "tsc --noEmit",
80
+ "tsc": "node ./node_modules/typescript-native/bin/tsc --noEmit",
81
+ "tscw": "node ./node_modules/typescript-native/bin/tsc --noEmit --watch -p ./tsconfig.json",
82
+ "type-check": "node ./node_modules/typescript-native/bin/tsc --noEmit",
83
83
  "update-packages": "pnpm update --latest",
84
84
  "z:vitest": "vitest --config ./configs/vitest.config.mts",
85
85
  "z:vitest:node": "pnpm run z:vitest --project='Node.js'"
86
86
  },
87
87
  "dependencies": {
88
88
  "@sindresorhus/is": "^8.1.0",
89
- "ts-type-forge": "^4.0.0"
89
+ "ts-type-forge": "^5.0.0"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@emotion/react": "11.14.0",
@@ -94,15 +94,14 @@
94
94
  "@mui/material": "9.1.2",
95
95
  "@rollup/plugin-replace": "6.0.3",
96
96
  "@rollup/plugin-strip": "3.0.4",
97
- "@rollup/plugin-typescript": "12.3.0",
98
97
  "@semantic-release/changelog": "6.0.3",
99
98
  "@semantic-release/commit-analyzer": "13.0.1",
100
99
  "@semantic-release/exec": "7.1.0",
101
100
  "@semantic-release/git": "10.0.1",
102
- "@semantic-release/github": "12.0.8",
101
+ "@semantic-release/github": "12.0.9",
103
102
  "@semantic-release/npm": "13.1.5",
104
103
  "@semantic-release/release-notes-generator": "14.1.1",
105
- "@types/node": "26.0.1",
104
+ "@types/node": "26.1.0",
106
105
  "@types/react": "19.2.17",
107
106
  "@vitest/browser-playwright": "4.1.9",
108
107
  "@vitest/coverage-v8": "4.1.9",
@@ -110,35 +109,37 @@
110
109
  "conventional-changelog-conventionalcommits": "10.2.0",
111
110
  "cspell": "10.0.1",
112
111
  "dedent": "1.7.2",
112
+ "esbuild": "0.28.1",
113
113
  "eslint": "9.39.4",
114
114
  "eslint-config-typed": "5.3.0",
115
115
  "github-settings-as-code": "1.2.9",
116
- "immer": "11.1.8",
116
+ "immer": "11.1.9",
117
117
  "jiti": "2.7.0",
118
118
  "markdownlint": "0.41.0",
119
- "markdownlint-cli2": "0.22.1",
119
+ "markdownlint-cli2": "0.23.0",
120
120
  "npm-run-all2": "9.0.2",
121
- "playwright": "1.61.0",
122
- "prettier": "3.8.4",
121
+ "playwright": "1.61.1",
122
+ "prettier": "3.9.4",
123
123
  "prettier-plugin-organize-imports": "4.3.0",
124
124
  "prettier-plugin-packagejson": "3.0.2",
125
125
  "react": "19.2.7",
126
126
  "rollup": "4.62.2",
127
+ "rollup-plugin-esbuild": "6.2.1",
127
128
  "semantic-release": "25.0.5",
128
129
  "ts-codemod-lib": "2.2.1",
129
130
  "ts-repo-utils": "10.1.2",
130
- "tslib": "2.8.1",
131
131
  "tsx": "4.22.4",
132
132
  "typedoc": "0.28.19",
133
133
  "typedoc-github-theme": "0.4.0",
134
- "typescript": "5.9.3",
135
- "vite": "8.1.0",
134
+ "typescript": "6.0.3",
135
+ "typescript-native": "npm:typescript@7.0.1-rc",
136
+ "vite": "8.1.3",
136
137
  "vitest": "4.1.9"
137
138
  },
138
139
  "peerDependencies": {
139
140
  "typescript": ">=4.8"
140
141
  },
141
- "packageManager": "pnpm@10.34.4",
142
+ "packageManager": "pnpm@11.10.0",
142
143
  "engines": {
143
144
  "node": ">=22.22.2",
144
145
  "pnpm": ">=9.0.0"
@@ -651,8 +651,7 @@ export function partition<
651
651
  E,
652
652
  >(
653
653
  ...args:
654
- | readonly [array: readonly E[], chunkSize: N]
655
- | readonly [chunkSize: N]
654
+ readonly [array: readonly E[], chunkSize: N] | readonly [chunkSize: N]
656
655
  ):
657
656
  | readonly (readonly E[])[]
658
657
  | ((array: readonly E[]) => readonly (readonly E[])[]) {
@@ -645,18 +645,7 @@ describe('Arr transformations', () => {
645
645
  expectType<
646
646
  typeof result,
647
647
  readonly (readonly (
648
- | 1
649
- | 2
650
- | 3
651
- | 4
652
- | 5
653
- | 6
654
- | 7
655
- | 8
656
- | 9
657
- | 10
658
- | 11
659
- | 12
648
+ 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
660
649
  )[])[]
661
650
  >('=');
662
651
 
@@ -675,18 +664,7 @@ describe('Arr transformations', () => {
675
664
  expectType<
676
665
  typeof result,
677
666
  readonly (readonly (
678
- | 1
679
- | 2
680
- | 3
681
- | 4
682
- | 5
683
- | 6
684
- | 7
685
- | 8
686
- | 9
687
- | 10
688
- | 11
689
- | 12
667
+ 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
690
668
  )[])[]
691
669
  >('=');
692
670
 
@@ -706,18 +684,7 @@ describe('Arr transformations', () => {
706
684
  expectType<
707
685
  typeof result,
708
686
  readonly (readonly (
709
- | 1
710
- | 2
711
- | 3
712
- | 4
713
- | 5
714
- | 6
715
- | 7
716
- | 8
717
- | 9
718
- | 10
719
- | 11
720
- | 12
687
+ 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
721
688
  )[])[]
722
689
  >('=');
723
690
 
@@ -228,9 +228,7 @@ describe('Arr validations', () => {
228
228
 
229
229
  test('should handle union of array types', () => {
230
230
  type MixedArrayUnion =
231
- | readonly string[]
232
- | readonly number[]
233
- | readonly boolean[];
231
+ readonly string[] | readonly number[] | readonly boolean[];
234
232
 
235
233
  const mixedArray: MixedArrayUnion = [1, 2, 3] as const;
236
234
 
@@ -71,9 +71,8 @@ import { type TypeEq, type TypeExtends } from 'ts-type-forge';
71
71
  export const expectType = <A, B>(
72
72
  _relation: TypeEq<A, B> extends true
73
73
  ? '<=' | '=' | '>=' | '~='
74
- :
75
- | '!='
76
- | (TypeExtends<A, B> extends true
77
- ? '<=' | (TypeExtends<B, A> extends true ? '>=' | '~=' : '!>=')
78
- : '!<=' | (TypeExtends<B, A> extends true ? '>=' : '!>=')),
74
+ : | '!='
75
+ | (TypeExtends<A, B> extends true
76
+ ? '<=' | (TypeExtends<B, A> extends true ? '>=' | '~=' : '!>=')
77
+ : '!<=' | (TypeExtends<B, A> extends true ? '>=' : '!>=')),
79
78
  ): void => undefined;
@@ -39,16 +39,12 @@ export type TernaryErr<E> = Readonly<{
39
39
  * Represents a value that can be `Ok`, `Warn`, or `Err`.
40
40
  */
41
41
  export type TernaryResult<S, E, W = E> =
42
- | TernaryOk<S>
43
- | TernaryWarn<S, W>
44
- | TernaryErr<E>;
42
+ TernaryOk<S> | TernaryWarn<S, W> | TernaryErr<E>;
45
43
 
46
44
  /**
47
45
  * Base type for any `TernaryResult`, used for generic constraints.
48
46
  */
49
47
  export type UnknownTernaryResult =
50
- | TernaryOk<unknown>
51
- | TernaryWarn<unknown, unknown>
52
- | TernaryErr<unknown>;
48
+ TernaryOk<unknown> | TernaryWarn<unknown, unknown> | TernaryErr<unknown>;
53
49
 
54
50
  export * as TernaryResult from './impl/index.mjs';
@@ -1,4 +1,5 @@
1
1
  export * from './has-key.mjs';
2
+ export * from './is-length-bounded-string.mjs';
2
3
  export * from './is-non-empty-string.mjs';
3
4
  export * from './is-non-null-object.mjs';
4
5
  export * from './is-primitive.mjs';
@@ -0,0 +1,199 @@
1
+ import {
2
+ type BoundedLengthString,
3
+ type FixedLengthString,
4
+ type MaxLengthString,
5
+ type MinLengthString,
6
+ } from 'ts-type-forge';
7
+ import { type SizeType } from '../types.mjs';
8
+
9
+ /**
10
+ * Type guard that checks if a string has at least `minLength` characters.
11
+ *
12
+ * The length is measured in UTF-16 code units (the same unit as
13
+ * `String.prototype.length`), so characters outside the Basic Multilingual
14
+ * Plane (e.g. emoji) count as 2.
15
+ *
16
+ * **Type Narrowing Behavior:**
17
+ *
18
+ * - Narrows the input to `MinLengthString<MinLength>` while preserving the
19
+ * original string type (e.g. literal types) via intersection.
20
+ * - The result participates in the length-constraint subtyping relation: for
21
+ * example, a value narrowed to `MinLengthString<3>` is assignable to
22
+ * `MinLengthString<1>` (= `NonEmptyString`).
23
+ *
24
+ * @example
25
+ *
26
+ * ```ts
27
+ * const input: string = 'very-secret-password';
28
+ *
29
+ * assert.isTrue(isMinLengthString(input, 12));
30
+ *
31
+ * assert.isFalse(isMinLengthString('short', 12));
32
+ *
33
+ * if (isMinLengthString(input, 12)) {
34
+ * const password: MinLengthString<12> = input;
35
+ *
36
+ * const nonEmpty: NonEmptyString = input; // OK (12 >= 1)
37
+ * }
38
+ * ```
39
+ *
40
+ * @template S - The input string type (literal types are preserved).
41
+ * @template MinLength - The minimum number of characters (inclusive).
42
+ * @param s - The string to check.
43
+ * @param minLength - The minimum number of characters (inclusive).
44
+ * @returns `true` if `s.length >= minLength`, `false` otherwise. When `true`,
45
+ * TypeScript narrows `s` to `MinLengthString<MinLength> & S`.
46
+ */
47
+ export const isMinLengthString = <
48
+ S extends string,
49
+ MinLength extends SizeType.ArgStr,
50
+ >(
51
+ s: S,
52
+ minLength: MinLength,
53
+ ): s is MinLengthString<MinLength> & S => s.length >= minLength;
54
+
55
+ /**
56
+ * Type guard that checks if a string has at most `maxLength` characters.
57
+ *
58
+ * The length is measured in UTF-16 code units (the same unit as
59
+ * `String.prototype.length`), so characters outside the Basic Multilingual
60
+ * Plane (e.g. emoji) count as 2.
61
+ *
62
+ * **Type Narrowing Behavior:**
63
+ *
64
+ * - Narrows the input to `MaxLengthString<MaxLength>` while preserving the
65
+ * original string type (e.g. literal types) via intersection.
66
+ * - The result participates in the length-constraint subtyping relation: for
67
+ * example, a value narrowed to `MaxLengthString<16>` is assignable to
68
+ * `MaxLengthString<32>`.
69
+ *
70
+ * @example
71
+ *
72
+ * ```ts
73
+ * const input: string = 'noshiro';
74
+ *
75
+ * assert.isTrue(isMaxLengthString(input, 32));
76
+ *
77
+ * assert.isFalse(isMaxLengthString(input, 3));
78
+ *
79
+ * if (isMaxLengthString(input, 32)) {
80
+ * const userName: MaxLengthString<32> = input;
81
+ *
82
+ * const relaxed: MaxLengthString<64> = input; // OK (32 <= 64)
83
+ * }
84
+ * ```
85
+ *
86
+ * @template S - The input string type (literal types are preserved).
87
+ * @template MaxLength - The maximum number of characters (inclusive).
88
+ * @param s - The string to check.
89
+ * @param maxLength - The maximum number of characters (inclusive).
90
+ * @returns `true` if `s.length <= maxLength`, `false` otherwise. When `true`,
91
+ * TypeScript narrows `s` to `MaxLengthString<MaxLength> & S`.
92
+ */
93
+ export const isMaxLengthString = <
94
+ S extends string,
95
+ MaxLength extends SizeType.ArgStr,
96
+ >(
97
+ s: S,
98
+ maxLength: MaxLength,
99
+ ): s is MaxLengthString<MaxLength> & S => s.length <= maxLength;
100
+
101
+ /**
102
+ * Type guard that checks if a string's length is within the inclusive range
103
+ * `[minLength, maxLength]`.
104
+ *
105
+ * The length is measured in UTF-16 code units (the same unit as
106
+ * `String.prototype.length`), so characters outside the Basic Multilingual
107
+ * Plane (e.g. emoji) count as 2.
108
+ *
109
+ * **Type Narrowing Behavior:**
110
+ *
111
+ * - Narrows the input to `BoundedLengthString<MinLength, MaxLength>` while
112
+ * preserving the original string type (e.g. literal types) via intersection.
113
+ * - Since `BoundedLengthString` is the intersection of `MinLengthString` and
114
+ * `MaxLengthString`, the narrowed value is assignable to both, and both
115
+ * bounds can be weakened independently.
116
+ *
117
+ * @example
118
+ *
119
+ * ```ts
120
+ * const input: string = 'user-12345678';
121
+ *
122
+ * assert.isTrue(isBoundedLengthString(input, 8, 16));
123
+ *
124
+ * assert.isFalse(isBoundedLengthString('user', 8, 16));
125
+ *
126
+ * if (isBoundedLengthString(input, 8, 16)) {
127
+ * const userId: BoundedLengthString<8, 16> = input;
128
+ *
129
+ * const relaxed: BoundedLengthString<1, 255> = input; // OK ([8, 16] ⊆ [1, 255])
130
+ * }
131
+ * ```
132
+ *
133
+ * @template S - The input string type (literal types are preserved).
134
+ * @template MinLength - The minimum number of characters (inclusive).
135
+ * @template MaxLength - The maximum number of characters (inclusive).
136
+ * @param s - The string to check.
137
+ * @param minLength - The minimum number of characters (inclusive).
138
+ * @param maxLength - The maximum number of characters (inclusive).
139
+ * @returns `true` if `minLength <= s.length && s.length <= maxLength`, `false`
140
+ * otherwise. When `true`, TypeScript narrows `s` to
141
+ * `BoundedLengthString<MinLength, MaxLength> & S`.
142
+ */
143
+ export const isBoundedLengthString = <
144
+ S extends string,
145
+ MinLength extends SizeType.ArgStr,
146
+ MaxLength extends SizeType.ArgStr,
147
+ >(
148
+ s: S,
149
+ minLength: MinLength,
150
+ maxLength: MaxLength,
151
+ ): s is BoundedLengthString<MinLength, MaxLength> & S =>
152
+ s.length >= minLength && s.length <= maxLength;
153
+
154
+ /**
155
+ * Type guard that checks if a string has exactly `length` characters.
156
+ *
157
+ * The length is measured in UTF-16 code units (the same unit as
158
+ * `String.prototype.length`), so characters outside the Basic Multilingual
159
+ * Plane (e.g. emoji) count as 2.
160
+ *
161
+ * **Type Narrowing Behavior:**
162
+ *
163
+ * - Narrows the input to `FixedLengthString<Length>` while preserving the
164
+ * original string type (e.g. literal types) via intersection.
165
+ * - Since `FixedLengthString<Length>` is defined as
166
+ * `BoundedLengthString<Length, Length>`, the narrowed value is assignable to
167
+ * any `MinLengthString<N>` with `N <= Length` and any `MaxLengthString<N>`
168
+ * with `N >= Length`.
169
+ *
170
+ * @example
171
+ *
172
+ * ```ts
173
+ * const input: string = 'JP';
174
+ *
175
+ * assert.isTrue(isFixedLengthString(input, 2));
176
+ *
177
+ * assert.isFalse(isFixedLengthString(input, 3));
178
+ *
179
+ * if (isFixedLengthString(input, 2)) {
180
+ * const countryCode: FixedLengthString<2> = input;
181
+ *
182
+ * const atMost5: MaxLengthString<5> = input; // OK (2 <= 5)
183
+ * }
184
+ * ```
185
+ *
186
+ * @template S - The input string type (literal types are preserved).
187
+ * @template Length - The exact number of characters.
188
+ * @param s - The string to check.
189
+ * @param length - The exact number of characters.
190
+ * @returns `true` if `s.length === length`, `false` otherwise. When `true`,
191
+ * TypeScript narrows `s` to `FixedLengthString<Length> & S`.
192
+ */
193
+ export const isFixedLengthString = <
194
+ S extends string,
195
+ Length extends SizeType.ArgStr,
196
+ >(
197
+ s: S,
198
+ length: Length,
199
+ ): s is FixedLengthString<Length> & S => s.length === length;
@@ -0,0 +1,170 @@
1
+ import {
2
+ type BoundedLengthString,
3
+ type FixedLengthString,
4
+ type MaxLengthString,
5
+ type MinLengthString,
6
+ type NonEmptyString,
7
+ } from 'ts-type-forge';
8
+ import { expectType } from '../expect-type.mjs';
9
+ import {
10
+ isBoundedLengthString,
11
+ isFixedLengthString,
12
+ isMaxLengthString,
13
+ isMinLengthString,
14
+ } from './is-length-bounded-string.mjs';
15
+
16
+ describe(isMinLengthString, () => {
17
+ test('should return true when the string is long enough', () => {
18
+ assert.isTrue(isMinLengthString('hello', 3));
19
+
20
+ assert.isTrue(isMinLengthString('hello', 5));
21
+
22
+ assert.isTrue(isMinLengthString('', 0));
23
+
24
+ assert.isTrue(isMinLengthString(' ', 1)); // Space counts
25
+ });
26
+
27
+ test('should return false when the string is too short', () => {
28
+ assert.isFalse(isMinLengthString('hi', 3));
29
+
30
+ assert.isFalse(isMinLengthString('', 1));
31
+ });
32
+
33
+ test('should measure length in UTF-16 code units', () => {
34
+ assert.isTrue(isMinLengthString('🎉', 2)); // Surrogate pair
35
+
36
+ assert.isFalse(isMinLengthString('🎉', 3));
37
+ });
38
+
39
+ test('should act as a type guard', () => {
40
+ const value: string = 'very-secret-password';
41
+
42
+ if (isMinLengthString(value, 12)) {
43
+ expectType<typeof value, MinLengthString<12>>('<=');
44
+
45
+ expectType<typeof value, NonEmptyString>('<='); // 12 >= 1
46
+
47
+ expectType<typeof value, MinLengthString<16>>('!<=');
48
+
49
+ expect(value.length).toBeGreaterThanOrEqual(12);
50
+ }
51
+ });
52
+
53
+ test('should preserve literal string types', () => {
54
+ const literal = 'hello';
55
+
56
+ if (isMinLengthString(literal, 3)) {
57
+ expectType<typeof literal, 'hello'>('<=');
58
+
59
+ expectType<typeof literal, MinLengthString<3>>('<=');
60
+ }
61
+ });
62
+ });
63
+
64
+ describe(isMaxLengthString, () => {
65
+ test('should return true when the string is short enough', () => {
66
+ assert.isTrue(isMaxLengthString('hello', 10));
67
+
68
+ assert.isTrue(isMaxLengthString('hello', 5));
69
+
70
+ assert.isTrue(isMaxLengthString('', 0));
71
+ });
72
+
73
+ test('should return false when the string is too long', () => {
74
+ assert.isFalse(isMaxLengthString('hello', 3));
75
+
76
+ assert.isFalse(isMaxLengthString(' ', 0));
77
+ });
78
+
79
+ test('should measure length in UTF-16 code units', () => {
80
+ assert.isFalse(isMaxLengthString('🎉', 1)); // Surrogate pair
81
+
82
+ assert.isTrue(isMaxLengthString('🎉', 2));
83
+ });
84
+
85
+ test('should act as a type guard', () => {
86
+ const value: string = 'noshiro';
87
+
88
+ if (isMaxLengthString(value, 32)) {
89
+ expectType<typeof value, MaxLengthString<32>>('<=');
90
+
91
+ expectType<typeof value, MaxLengthString<64>>('<='); // 32 <= 64
92
+
93
+ expectType<typeof value, MaxLengthString<16>>('!<=');
94
+
95
+ expect(value.length).toBeLessThanOrEqual(32);
96
+ }
97
+ });
98
+ });
99
+
100
+ describe(isBoundedLengthString, () => {
101
+ test('should return true when the length is within the range', () => {
102
+ assert.isTrue(isBoundedLengthString('user-12345678', 8, 16));
103
+
104
+ assert.isTrue(isBoundedLengthString('12345678', 8, 16)); // Lower bound (inclusive)
105
+
106
+ assert.isTrue(isBoundedLengthString('1234567890123456', 8, 16)); // Upper bound (inclusive)
107
+
108
+ assert.isTrue(isBoundedLengthString('', 0, 0));
109
+ });
110
+
111
+ test('should return false when the length is out of range', () => {
112
+ assert.isFalse(isBoundedLengthString('user', 8, 16));
113
+
114
+ assert.isFalse(isBoundedLengthString('12345678901234567', 8, 16));
115
+ });
116
+
117
+ test('should act as a type guard', () => {
118
+ const value: string = 'user-12345678';
119
+
120
+ if (isBoundedLengthString(value, 8, 16)) {
121
+ expectType<typeof value, BoundedLengthString<8, 16>>('<=');
122
+
123
+ expectType<typeof value, BoundedLengthString<1, 255>>('<='); // [8, 16] ⊆ [1, 255]
124
+
125
+ expectType<typeof value, MinLengthString<8>>('<=');
126
+
127
+ expectType<typeof value, MaxLengthString<16>>('<=');
128
+
129
+ expectType<typeof value, NonEmptyString>('<='); // 8 >= 1
130
+
131
+ expectType<typeof value, BoundedLengthString<10, 16>>('!<=');
132
+ }
133
+ });
134
+ });
135
+
136
+ describe(isFixedLengthString, () => {
137
+ test('should return true only for the exact length', () => {
138
+ assert.isTrue(isFixedLengthString('JP', 2));
139
+
140
+ assert.isTrue(isFixedLengthString('', 0));
141
+
142
+ assert.isFalse(isFixedLengthString('JPN', 2));
143
+
144
+ assert.isFalse(isFixedLengthString('J', 2));
145
+ });
146
+
147
+ test('should measure length in UTF-16 code units', () => {
148
+ assert.isTrue(isFixedLengthString('🎉', 2)); // Surrogate pair
149
+
150
+ assert.isFalse(isFixedLengthString('🎉', 1));
151
+ });
152
+
153
+ test('should act as a type guard', () => {
154
+ const value: string = 'JP';
155
+
156
+ if (isFixedLengthString(value, 2)) {
157
+ expectType<typeof value, FixedLengthString<2>>('<=');
158
+
159
+ expectType<typeof value, BoundedLengthString<2, 2>>('<=');
160
+
161
+ expectType<typeof value, MaxLengthString<5>>('<='); // 2 <= 5
162
+
163
+ expectType<typeof value, MinLengthString<1>>('<='); // 2 >= 1
164
+
165
+ expectType<typeof value, NonEmptyString>('<=');
166
+
167
+ expectType<typeof value, FixedLengthString<3>>('!<=');
168
+ }
169
+ });
170
+ });
@@ -185,15 +185,7 @@ export namespace TsDataForgeInternals {
185
185
  }>;
186
186
 
187
187
  type BaseKeys =
188
- | 'add'
189
- | 'div'
190
- | 'is'
191
- | 'max'
192
- | 'min'
193
- | 'mul'
194
- | 'pow'
195
- | 'random'
196
- | 'sub';
188
+ 'add' | 'div' | 'is' | 'max' | 'min' | 'mul' | 'pow' | 'random' | 'sub';
197
189
 
198
190
  type FloatMethods = 'ceil' | 'floor' | 'round';
199
191
 
@@ -224,11 +224,9 @@ export namespace Obj {
224
224
  const Keys extends readonly (keyof R)[],
225
225
  >(
226
226
  ...args:
227
- | readonly [record: R, keys: Keys]
228
- | readonly [keys: readonly PropertyKey[]]
227
+ readonly [record: R, keys: Keys] | readonly [keys: readonly PropertyKey[]]
229
228
  ):
230
- | Omit<R, ArrayElement<Keys>>
231
- | ((record: R) => Omit<R, ArrayElement<Keys>>) {
229
+ Omit<R, ArrayElement<Keys>> | ((record: R) => Omit<R, ArrayElement<Keys>>) {
232
230
  switch (args.length) {
233
231
  case 2: {
234
232
  const [record, keys] = args;
@@ -644,32 +642,36 @@ declare namespace TsDataForgeInternals {
644
642
  readonly [K in keyof B as {} extends Pick<B, K> ? never : K]: B[K];
645
643
  } & {
646
644
  // 2. Optional properties from B that are NOT in A
647
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
648
- readonly [K in keyof B as {} extends Pick<B, K>
649
- ? K extends keyof A
650
- ? never
651
- : K
652
- : never]?: B[K];
645
+ readonly [
646
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
647
+ K in keyof B as {} extends Pick<B, K>
648
+ ? K extends keyof A
649
+ ? never
650
+ : K
651
+ : never
652
+ ]?: B[K];
653
653
  } & {
654
654
  // 3. Optional properties from B that ARE in A (create union)
655
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
656
- readonly [K in keyof B as {} extends Pick<B, K>
657
- ? K extends keyof A
658
- ? K
655
+ readonly [
656
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
657
+ K in keyof B as {} extends Pick<B, K>
658
+ ? K extends keyof A
659
+ ? K
660
+ : never
659
661
  : never
660
- : never]?: K extends keyof A ? A[K] | B[K] : never;
662
+ ]?: K extends keyof A ? A[K] | B[K] : never;
661
663
  } & {
662
664
  // 4. Required properties only in A (not overridden by B)
663
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
664
- readonly [K in Exclude<keyof A, keyof B> as {} extends Pick<A, K>
665
- ? never
666
- : K]: A[K];
665
+ readonly [
666
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
667
+ K in Exclude<keyof A, keyof B> as {} extends Pick<A, K> ? never : K
668
+ ]: A[K];
667
669
  } & {
668
670
  // 5. Optional properties only in A (not overridden by B)
669
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
670
- readonly [K in Exclude<keyof A, keyof B> as {} extends Pick<A, K>
671
- ? K
672
- : never]?: A[K];
671
+ readonly [
672
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
673
+ K in Exclude<keyof A, keyof B> as {} extends Pick<A, K> ? K : never
674
+ ]?: A[K];
673
675
  } extends infer O
674
676
  ? Readonly<
675
677
  {