ts-data-forge 14.7.0 → 14.8.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 (290) hide show
  1. package/README.md +21 -34
  2. package/dist/array/impl/array-utils-creation.d.mts +3 -3
  3. package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
  4. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  5. package/dist/array/impl/array-utils-element-access.d.mts +2 -2
  6. package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
  7. package/dist/array/impl/array-utils-element-access.mjs +1 -1
  8. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  9. package/dist/array/impl/array-utils-iterators.d.mts +1 -1
  10. package/dist/array/impl/array-utils-iterators.d.mts.map +1 -1
  11. package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts +37 -7
  12. package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts.map +1 -1
  13. package/dist/array/impl/array-utils-length-bounded-array-cast.mjs +4 -0
  14. package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -1
  15. package/dist/array/impl/array-utils-length-bounded-array-guard.d.mts +9 -9
  16. package/dist/array/impl/array-utils-length-bounded-array-guard.d.mts.map +1 -1
  17. package/dist/array/impl/array-utils-length-bounded-array-guard.mjs +1 -1
  18. package/dist/array/impl/array-utils-length-bounded-array-guard.mjs.map +1 -1
  19. package/dist/array/impl/array-utils-length-bounded-tuple-cast.d.mts +28 -8
  20. package/dist/array/impl/array-utils-length-bounded-tuple-cast.d.mts.map +1 -1
  21. package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs +4 -0
  22. package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs.map +1 -1
  23. package/dist/array/impl/array-utils-length-bounded-tuple-guard.d.mts +3 -3
  24. package/dist/array/impl/array-utils-length-bounded-tuple-guard.d.mts.map +1 -1
  25. package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs +1 -1
  26. package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs.map +1 -1
  27. package/dist/array/impl/array-utils-modification.d.mts +2 -2
  28. package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
  29. package/dist/array/impl/array-utils-reducing-value.d.mts +2 -2
  30. package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
  31. package/dist/array/impl/array-utils-reducing-value.mjs +3 -4
  32. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  33. package/dist/array/impl/array-utils-search.d.mts +1 -1
  34. package/dist/array/impl/array-utils-search.d.mts.map +1 -1
  35. package/dist/array/impl/array-utils-set-op.d.mts +1 -1
  36. package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
  37. package/dist/array/impl/array-utils-size.d.mts +2 -2
  38. package/dist/array/impl/array-utils-size.d.mts.map +1 -1
  39. package/dist/array/impl/array-utils-slice-clamped.d.mts +1 -1
  40. package/dist/array/impl/array-utils-slice-clamped.d.mts.map +1 -1
  41. package/dist/array/impl/array-utils-slicing.d.mts +2 -2
  42. package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
  43. package/dist/array/impl/array-utils-transformation.d.mts +2 -2
  44. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
  45. package/dist/array/impl/array-utils-transformation.mjs +6 -3
  46. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  47. package/dist/array/impl/array-utils-validation.d.mts +2 -2
  48. package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
  49. package/dist/collections/imap-mapped.d.mts +2 -2
  50. package/dist/collections/imap-mapped.d.mts.map +1 -1
  51. package/dist/collections/imap-mapped.mjs +10 -7
  52. package/dist/collections/imap-mapped.mjs.map +1 -1
  53. package/dist/collections/imap.d.mts +2 -2
  54. package/dist/collections/imap.d.mts.map +1 -1
  55. package/dist/collections/imap.mjs +10 -7
  56. package/dist/collections/imap.mjs.map +1 -1
  57. package/dist/collections/iset-mapped.d.mts +2 -2
  58. package/dist/collections/iset-mapped.d.mts.map +1 -1
  59. package/dist/collections/iset-mapped.mjs +6 -3
  60. package/dist/collections/iset-mapped.mjs.map +1 -1
  61. package/dist/collections/iset.d.mts +2 -2
  62. package/dist/collections/iset.d.mts.map +1 -1
  63. package/dist/collections/iset.mjs +5 -5
  64. package/dist/collections/iset.mjs.map +1 -1
  65. package/dist/collections/queue.d.mts +1 -1
  66. package/dist/collections/queue.d.mts.map +1 -1
  67. package/dist/collections/stack.d.mts +1 -1
  68. package/dist/collections/stack.d.mts.map +1 -1
  69. package/dist/guard/is-non-empty-string.d.mts +1 -1
  70. package/dist/guard/is-non-empty-string.d.mts.map +1 -1
  71. package/dist/guard/is-primitive.d.mts +1 -1
  72. package/dist/guard/is-primitive.d.mts.map +1 -1
  73. package/dist/guard/is-type.d.mts +1 -1
  74. package/dist/guard/is-type.d.mts.map +1 -1
  75. package/dist/index.d.mts +2 -0
  76. package/dist/index.d.mts.map +1 -1
  77. package/dist/index.mjs +2 -0
  78. package/dist/index.mjs.map +1 -1
  79. package/dist/iterator/range.d.mts +5 -4
  80. package/dist/iterator/range.d.mts.map +1 -1
  81. package/dist/iterator/range.mjs.map +1 -1
  82. package/dist/json/json.d.mts +29 -32
  83. package/dist/json/json.d.mts.map +1 -1
  84. package/dist/json/json.mjs +1 -4
  85. package/dist/json/json.mjs.map +1 -1
  86. package/dist/number/branded-types/finite-number.d.mts +1 -1
  87. package/dist/number/branded-types/finite-number.d.mts.map +1 -1
  88. package/dist/number/branded-types/int.d.mts +2 -2
  89. package/dist/number/branded-types/int.d.mts.map +1 -1
  90. package/dist/number/branded-types/int16.d.mts +1 -1
  91. package/dist/number/branded-types/int16.d.mts.map +1 -1
  92. package/dist/number/branded-types/int32.d.mts +1 -1
  93. package/dist/number/branded-types/int32.d.mts.map +1 -1
  94. package/dist/number/branded-types/negative-finite-number.d.mts +1 -1
  95. package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
  96. package/dist/number/branded-types/negative-int.d.mts +1 -1
  97. package/dist/number/branded-types/negative-int.d.mts.map +1 -1
  98. package/dist/number/branded-types/negative-safe-int.d.mts +1 -1
  99. package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
  100. package/dist/number/branded-types/non-negative-finite-number.d.mts +1 -1
  101. package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
  102. package/dist/number/branded-types/non-negative-int16.d.mts +1 -1
  103. package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
  104. package/dist/number/branded-types/non-negative-int32.d.mts +1 -1
  105. package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
  106. package/dist/number/branded-types/non-positive-finite-number.d.mts +1 -1
  107. package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
  108. package/dist/number/branded-types/non-positive-int.d.mts +1 -1
  109. package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
  110. package/dist/number/branded-types/non-positive-safe-int.d.mts +1 -1
  111. package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
  112. package/dist/number/branded-types/non-zero-finite-number.d.mts +1 -1
  113. package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
  114. package/dist/number/branded-types/non-zero-int.d.mts +1 -1
  115. package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
  116. package/dist/number/branded-types/non-zero-int16.d.mts +1 -1
  117. package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
  118. package/dist/number/branded-types/non-zero-int32.d.mts +1 -1
  119. package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
  120. package/dist/number/branded-types/non-zero-safe-int.d.mts +1 -1
  121. package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
  122. package/dist/number/branded-types/non-zero-uint16.d.mts +1 -1
  123. package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
  124. package/dist/number/branded-types/non-zero-uint32.d.mts +1 -1
  125. package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
  126. package/dist/number/branded-types/positive-finite-number.d.mts +1 -1
  127. package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
  128. package/dist/number/branded-types/positive-int.d.mts +2 -2
  129. package/dist/number/branded-types/positive-int.d.mts.map +1 -1
  130. package/dist/number/branded-types/positive-int16.d.mts +1 -1
  131. package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
  132. package/dist/number/branded-types/positive-int32.d.mts +1 -1
  133. package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
  134. package/dist/number/branded-types/positive-safe-int.d.mts +2 -2
  135. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
  136. package/dist/number/branded-types/positive-uint16.d.mts +1 -1
  137. package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
  138. package/dist/number/branded-types/positive-uint32.d.mts +1 -1
  139. package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
  140. package/dist/number/branded-types/safe-int.d.mts +2 -2
  141. package/dist/number/branded-types/safe-int.d.mts.map +1 -1
  142. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  143. package/dist/number/branded-types/safe-uint.d.mts +1 -1
  144. package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
  145. package/dist/number/branded-types/uint.d.mts +2 -2
  146. package/dist/number/branded-types/uint.d.mts.map +1 -1
  147. package/dist/number/branded-types/uint16.d.mts +1 -1
  148. package/dist/number/branded-types/uint16.d.mts.map +1 -1
  149. package/dist/number/branded-types/uint32.d.mts +1 -1
  150. package/dist/number/branded-types/uint32.d.mts.map +1 -1
  151. package/dist/number/enum/int8.d.mts +1 -1
  152. package/dist/number/enum/int8.d.mts.map +1 -1
  153. package/dist/number/enum/uint8.d.mts +1 -1
  154. package/dist/number/enum/uint8.d.mts.map +1 -1
  155. package/dist/number/num-arithmetic-types.d.mts +1 -1
  156. package/dist/number/num-arithmetic-types.d.mts.map +1 -1
  157. package/dist/number/num.d.mts +3 -3
  158. package/dist/number/num.d.mts.map +1 -1
  159. package/dist/number/refined-number-utils.d.mts +2 -2
  160. package/dist/number/refined-number-utils.d.mts.map +1 -1
  161. package/dist/number/refined-number-utils.mjs +6 -4
  162. package/dist/number/refined-number-utils.mjs.map +1 -1
  163. package/dist/object/object.d.mts +5 -8
  164. package/dist/object/object.d.mts.map +1 -1
  165. package/dist/object/object.mjs +16 -13
  166. package/dist/object/object.mjs.map +1 -1
  167. package/dist/others/cast-mutable.d.mts +1 -1
  168. package/dist/others/cast-mutable.d.mts.map +1 -1
  169. package/dist/others/cast-readonly.d.mts +1 -1
  170. package/dist/others/cast-readonly.d.mts.map +1 -1
  171. package/dist/others/debounce-function.d.mts.map +1 -1
  172. package/dist/others/debounce-function.mjs +1 -5
  173. package/dist/others/debounce-function.mjs.map +1 -1
  174. package/dist/others/memoize-function.d.mts +1 -1
  175. package/dist/others/memoize-function.d.mts.map +1 -1
  176. package/dist/string/str.d.mts +26 -18
  177. package/dist/string/str.d.mts.map +1 -1
  178. package/dist/string/str.mjs +9 -1
  179. package/dist/string/str.mjs.map +1 -1
  180. package/dist/types.d.mts +1 -1
  181. package/dist/types.d.mts.map +1 -1
  182. package/package.json +33 -32
  183. package/src/array/impl/array-utils-creation.mts +24 -22
  184. package/src/array/impl/array-utils-creation.test.mts +25 -22
  185. package/src/array/impl/array-utils-element-access.mts +7 -7
  186. package/src/array/impl/array-utils-element-access.test.mts +2 -2
  187. package/src/array/impl/array-utils-iterators.mts +1 -1
  188. package/src/array/impl/array-utils-iterators.test.mts +1 -1
  189. package/src/array/impl/array-utils-length-bounded-array-cast.mts +43 -13
  190. package/src/array/impl/array-utils-length-bounded-array-cast.test.mts +6 -6
  191. package/src/array/impl/array-utils-length-bounded-array-guard.mts +15 -15
  192. package/src/array/impl/array-utils-length-bounded-array-guard.test.mts +66 -54
  193. package/src/array/impl/array-utils-length-bounded-tuple-cast.mts +32 -12
  194. package/src/array/impl/array-utils-length-bounded-tuple-cast.test.mts +10 -10
  195. package/src/array/impl/array-utils-length-bounded-tuple-guard.mts +8 -8
  196. package/src/array/impl/array-utils-length-bounded-tuple-guard.test.mts +38 -28
  197. package/src/array/impl/array-utils-length-constraint-preservation.test.mts +14 -14
  198. package/src/array/impl/array-utils-modification.mts +12 -12
  199. package/src/array/impl/array-utils-modification.test.mts +7 -7
  200. package/src/array/impl/array-utils-overload-type-error.test.mts +1 -1
  201. package/src/array/impl/array-utils-reducing-value.mts +9 -11
  202. package/src/array/impl/array-utils-reducing-value.test.mts +2 -2
  203. package/src/array/impl/array-utils-search.mts +4 -4
  204. package/src/array/impl/array-utils-search.test.mts +25 -17
  205. package/src/array/impl/array-utils-set-op.mts +1 -1
  206. package/src/array/impl/array-utils-shape-invariants.test.mts +8 -8
  207. package/src/array/impl/array-utils-size.mts +5 -5
  208. package/src/array/impl/array-utils-slice-clamped.mts +2 -2
  209. package/src/array/impl/array-utils-slicing.mts +8 -8
  210. package/src/array/impl/array-utils-slicing.test.mts +1 -1
  211. package/src/array/impl/array-utils-transformation.mts +26 -24
  212. package/src/array/impl/array-utils-transformation.test.mts +12 -10
  213. package/src/array/impl/array-utils-validation.mts +7 -7
  214. package/src/array/impl/array-utils-validation.test.mts +39 -39
  215. package/src/array/impl/array.test.mts +1 -1
  216. package/src/collections/imap-mapped.mts +15 -9
  217. package/src/collections/imap-mapped.test.mts +1 -1
  218. package/src/collections/imap.mts +15 -9
  219. package/src/collections/imap.test.mts +7 -5
  220. package/src/collections/iset-mapped.mts +14 -8
  221. package/src/collections/iset.mts +12 -10
  222. package/src/collections/iset.test.mts +14 -12
  223. package/src/collections/queue.mts +1 -1
  224. package/src/collections/stack.mts +1 -1
  225. package/src/collections/stack.test.mts +8 -6
  226. package/src/guard/is-error.test.mts +6 -4
  227. package/src/guard/is-non-empty-string.mts +1 -1
  228. package/src/guard/is-non-empty-string.test.mts +15 -11
  229. package/src/guard/is-primitive.mts +1 -1
  230. package/src/guard/is-type.mts +1 -1
  231. package/src/guard/is-type.test.mts +87 -59
  232. package/src/index.mts +2 -0
  233. package/src/iterator/range.mts +5 -9
  234. package/src/iterator/range.test.mts +29 -0
  235. package/src/json/json.mts +32 -35
  236. package/src/json/json.test.mts +106 -89
  237. package/src/number/branded-types/finite-number.mts +4 -4
  238. package/src/number/branded-types/int.mts +2 -2
  239. package/src/number/branded-types/int16.mts +1 -1
  240. package/src/number/branded-types/int32.mts +1 -1
  241. package/src/number/branded-types/negative-finite-number.mts +1 -1
  242. package/src/number/branded-types/negative-finite-number.test.mts +4 -4
  243. package/src/number/branded-types/negative-int.mts +3 -3
  244. package/src/number/branded-types/negative-int.test.mts +1 -1
  245. package/src/number/branded-types/negative-safe-int.mts +3 -3
  246. package/src/number/branded-types/negative-safe-int.test.mts +1 -1
  247. package/src/number/branded-types/non-negative-finite-number.mts +3 -3
  248. package/src/number/branded-types/non-negative-int16.mts +1 -1
  249. package/src/number/branded-types/non-negative-int32.mts +1 -1
  250. package/src/number/branded-types/non-positive-finite-number.mts +1 -1
  251. package/src/number/branded-types/non-positive-int.mts +1 -1
  252. package/src/number/branded-types/non-positive-safe-int.mts +1 -1
  253. package/src/number/branded-types/non-zero-finite-number.mts +5 -5
  254. package/src/number/branded-types/non-zero-int.mts +1 -1
  255. package/src/number/branded-types/non-zero-int16.mts +1 -1
  256. package/src/number/branded-types/non-zero-int32.mts +1 -1
  257. package/src/number/branded-types/non-zero-safe-int.mts +4 -4
  258. package/src/number/branded-types/non-zero-uint16.mts +1 -1
  259. package/src/number/branded-types/non-zero-uint32.mts +1 -1
  260. package/src/number/branded-types/positive-finite-number.mts +4 -4
  261. package/src/number/branded-types/positive-int.mts +2 -2
  262. package/src/number/branded-types/positive-int16.mts +1 -1
  263. package/src/number/branded-types/positive-int32.mts +1 -1
  264. package/src/number/branded-types/positive-safe-int.mts +4 -4
  265. package/src/number/branded-types/positive-uint16.mts +1 -1
  266. package/src/number/branded-types/positive-uint32.mts +1 -1
  267. package/src/number/branded-types/safe-int.mts +2 -5
  268. package/src/number/branded-types/safe-uint.mts +1 -1
  269. package/src/number/branded-types/uint.mts +2 -2
  270. package/src/number/branded-types/uint16.mts +1 -1
  271. package/src/number/branded-types/uint32.mts +1 -1
  272. package/src/number/enum/int8.mts +5 -5
  273. package/src/number/enum/uint8.mts +4 -4
  274. package/src/number/num-arithmetic-types.mts +27 -27
  275. package/src/number/num-arithmetic-types.test.mts +21 -21
  276. package/src/number/num-arithmetic.test.mts +6 -6
  277. package/src/number/num.mts +24 -24
  278. package/src/number/num.test.mts +1 -1
  279. package/src/number/refined-number-utils.mts +25 -21
  280. package/src/object/object.mts +46 -34
  281. package/src/object/object.test.mts +5 -5
  282. package/src/others/cast-mutable.mts +1 -1
  283. package/src/others/cast-readonly.mts +1 -1
  284. package/src/others/debounce-function.mts +1 -5
  285. package/src/others/fast-deep-equal.test.mts +1 -1
  286. package/src/others/map-nullable.test.mts +1 -1
  287. package/src/others/memoize-function.mts +1 -1
  288. package/src/string/str.mts +33 -25
  289. package/src/string/str.test.mts +48 -38
  290. package/src/types.mts +14 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-data-forge",
3
- "version": "14.7.0",
3
+ "version": "14.8.0",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "typescript",
@@ -37,28 +37,28 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "@sindresorhus/is": "^8.1.0",
40
- "ts-std-forge": "^0.5.0",
40
+ "ts-std-forge": "^0.5.1",
41
41
  "ts-type-forge": "~9.2.2"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@emotion/react": "11.14.0",
45
45
  "@emotion/styled": "11.14.1",
46
46
  "@mui/material": "9.4.0",
47
- "@types/react": "19.2.18",
48
- "@vitest/browser-playwright": "4.1.11",
49
- "eslint-config-typed": "5.11.6",
50
- "eslint-plugin-ts-fortress": "1.2.2",
51
- "eslint-plugin-ts-type-forge": "0.8.3",
52
- "immer": "11.1.18",
53
- "playwright": "1.62.1",
54
- "prettier": "3.9.6",
47
+ "@types/react": "19.3.0",
48
+ "@vitest/browser-playwright": "5.0.3",
49
+ "eslint-config-typed": "5.19.0",
50
+ "eslint-plugin-ts-fortress": "1.3.4",
51
+ "eslint-plugin-ts-type-forge": "0.8.9",
52
+ "immer": "11.1.21",
53
+ "playwright": "1.64.0",
54
+ "prettier": "3.9.9",
55
55
  "prettier-plugin-organize-imports": "4.3.0",
56
56
  "prettier-plugin-packagejson": "3.0.2",
57
- "react": "19.2.8",
58
- "ts-repo-utils": "10.6.1",
57
+ "react": "19.3.0",
58
+ "ts-repo-utils": "10.7.1",
59
59
  "typedoc": "0.28.20",
60
60
  "typedoc-github-theme": "0.4.0",
61
- "vite": "8.2.2"
61
+ "vite": "8.3.3"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "typescript": ">=4.8"
@@ -73,30 +73,31 @@
73
73
  },
74
74
  "scripts": {
75
75
  "build": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/build.mts",
76
- "build:min": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/build.mts --skip-check",
77
76
  "check:ext": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/check-ext.mts",
77
+ "check:lint": "node ../../tools/scripts/cmd/assert-deps-built.mts && oxlint . && eslint .",
78
+ "check:test": "node ../../tools/scripts/cmd/assert-deps-built.mts && pnpm run z:vitest:node run",
79
+ "check:test:browser": "node ../../tools/scripts/cmd/assert-deps-built.mts && pnpm run z:vitest --project='Browser' run",
80
+ "check:test:cov": "node ../../tools/scripts/cmd/assert-deps-built.mts && pnpm run z:vitest:node run --coverage",
81
+ "check:types": "node ../../tools/scripts/cmd/assert-deps-built.mts && node ../../node_modules/typescript-native/bin/tsc --noEmit",
78
82
  "doc": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/gen-docs.mts",
79
- "doc:embed": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/embed-examples.mts",
80
- "doc:embed:jsdoc": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/embed-examples-in-jsdoc.mts",
81
83
  "doc:preview": "vite preview --config ./configs/vite.doc.config.mts",
82
- "doc:watch": "typedoc --options ./configs/typedoc.config.mjs --watch",
83
- "fmt": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../../libs/ts-repo-utils/src/cmd/format-uncommitted.mts --cwd .",
84
- "fmt:diff": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../../libs/ts-repo-utils/src/cmd/format-diff-from.mts origin/main --cwd .",
85
- "fmt:full": "pnpm run z:prettier .",
86
- "gen:branded-number": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/gen-branded-number/generate.mts && pnpm run doc:embed:jsdoc && pnpm run z:prettier 'src/number/branded-types/*.mts' 'src/number/enum/*.mts'",
87
- "gi": "run-s gi:src fmt",
88
- "gi:src": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json scripts/cmd/gen-index.mts",
89
- "lint": "eslint .",
90
- "lint:fix": "eslint . --fix",
91
- "test": "pnpm run z:vitest:node run",
92
- "test:browser": "pnpm run z:vitest --project='Browser' run",
93
- "test:cov": "pnpm run z:vitest:node run --coverage",
84
+ "fix:fmt": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../../libs/ts-repo-utils/src/cmd/format-uncommitted.mts --cwd .",
85
+ "fix:fmt:diff": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../../libs/ts-repo-utils/src/cmd/format-diff-from.mts origin/main --cwd .",
86
+ "fix:fmt:full": "pnpm run z:prettier .",
87
+ "fix:lint": "node ../../tools/scripts/cmd/assert-deps-built.mts && oxlint . --fix && eslint . --fix",
88
+ "fmt": "pnpm run fix:fmt",
89
+ "gen": "run-s gen:index gen:branded-number gen:readme gen:jsdoc",
90
+ "gen:branded-number": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/gen-branded-number/generate.mts && pnpm run gen:jsdoc && pnpm run z:prettier 'src/number/branded-types/*.mts' 'src/number/enum/*.mts'",
91
+ "gen:index": "run-s gen:index:src fix:fmt",
92
+ "gen:index:src": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../../libs/ts-repo-utils/src/cmd/gen-index-ts.mts ./src --index-ext .mts --export-ext .mjs --target-ext .mts --exclude entry-point.mts --preserve 'array/index.mts' --preserve 'functional/index.mts'",
93
+ "gen:jsdoc": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/embed-examples-in-jsdoc.mts",
94
+ "gen:readme": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/embed-examples.mts",
95
+ "test": "pnpm run check:test",
94
96
  "test:cov:ui": "vite preview --outDir ./coverage",
95
97
  "test:ui": "pnpm run z:vitest:node --ui",
96
- "testw": "pnpm run z:vitest:node watch",
97
- "tsc": "node ../../node_modules/typescript-native/bin/tsc --noEmit",
98
- "tscw": "node ../../node_modules/typescript-native/bin/tsc --noEmit --watch -p ./tsconfig.json",
99
- "type-check": "node ../../node_modules/typescript-native/bin/tsc --noEmit",
98
+ "watch:doc": "typedoc --options ./configs/typedoc.config.mjs --watch",
99
+ "watch:test": "pnpm run z:vitest:node watch",
100
+ "watch:types": "node ../../node_modules/typescript-native/bin/tsc --noEmit --watch -p ./tsconfig.json",
100
101
  "z:prettier": "prettier --config ../../.prettierrc --ignore-path ../../.prettierignore --ignore-path ../../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --write",
101
102
  "z:vitest": "vitest --config ./configs/vitest.config.mts",
102
103
  "z:vitest:node": "pnpm run z:vitest --project='Node.js'"
@@ -1,27 +1,26 @@
1
- import {
2
- type BoolOr,
3
- type FixedLengthArray,
4
- type FixedLengthTuple,
5
- type Index,
6
- type IsUnion,
7
- type List,
8
- type Min,
9
- type NonEmptyArray,
10
- type NonZeroSafeIntWithSmallInt,
11
- type PositiveSafeIntWithSmallInt,
12
- type RelaxedExclude,
13
- type SafeInt,
14
- type SafeIntWithSmallInt,
15
- type SafeUint,
16
- type SafeUintWithSmallInt,
17
- type Seq,
18
- type SmallUint,
19
- type StructuralPrefixLength,
20
- type SupportedLength,
1
+ import type {
2
+ BoolOr,
3
+ FixedLengthArray,
4
+ FixedLengthTuple,
5
+ Index,
6
+ IsUnion,
7
+ List,
8
+ Min,
9
+ NonEmptyArray,
10
+ NonZeroSafeIntWithSmallInt,
11
+ RelaxedExclude,
12
+ SafeInt,
13
+ SafeIntWithSmallInt,
14
+ SafeUint,
15
+ SafeUintWithSmallInt,
16
+ Seq,
17
+ SmallUint,
18
+ StructuralPrefixLength,
19
+ SupportedLength,
21
20
  } from 'ts-type-forge';
22
21
  import { expectType } from '../../expect-type.mjs';
23
22
  import { range as rangeIterator } from '../../iterator/index.mjs';
24
- import { type SizeType } from '../../types.mjs';
23
+ import type { SizeType } from '../../types.mjs';
25
24
 
26
25
  /**
27
26
  * Creates an array of zeros with the specified length.
@@ -216,7 +215,10 @@ export function range<S extends SmallUint, E extends SmallUint>(
216
215
  export function range(
217
216
  start: SafeUintWithSmallInt,
218
217
  end: SafeUintWithSmallInt,
219
- step?: PositiveSafeIntWithSmallInt,
218
+ // Every value lies between `start` and `end`, so a negative step yields
219
+ // non-negative numbers too.
220
+
221
+ step?: NonZeroSafeIntWithSmallInt,
220
222
  ): readonly SafeUint[];
221
223
 
222
224
  export function range(
@@ -1,18 +1,13 @@
1
- import {
2
- type FixedLengthTuple,
3
- type SafeInt,
4
- type SafeUint,
5
- type SmallUint,
1
+ import type {
2
+ FixedLengthTuple,
3
+ SafeInt,
4
+ SafeUint,
5
+ SmallUint,
6
6
  } from 'ts-type-forge';
7
7
  import { expectType } from '../../expect-type.mjs';
8
8
  import { range as rangeIterator } from '../../iterator/index.mjs';
9
- import {
10
- asNonZeroSafeInt,
11
- asSafeInt,
12
- asSafeUint,
13
- asUint32,
14
- } from '../../number/index.mjs';
15
- import { type SizeType } from '../../types.mjs';
9
+ import { asNonZeroSafeInt, asSafeUint, asUint32 } from '../../number/index.mjs';
10
+ import type { SizeType } from '../../types.mjs';
16
11
  import {
17
12
  copy,
18
13
  create,
@@ -380,18 +375,26 @@ describe('Arr creations', () => {
380
375
  const result = range(5, 0, -1);
381
376
 
382
377
  assert.deepStrictEqual(result, [
383
- asSafeInt(5),
384
- asSafeInt(4),
385
- asSafeInt(3),
386
- asSafeInt(2),
387
- asSafeInt(1),
378
+ asSafeUint(5),
379
+ asSafeUint(4),
380
+ asSafeUint(3),
381
+ asSafeUint(2),
382
+ asSafeUint(1),
388
383
  ]);
389
384
  });
390
385
 
386
+ test('a negative step from non-negative bounds gives SafeUint', () => {
387
+ const result = range(asSafeUint(5), asSafeUint(1), asNonZeroSafeInt(-2));
388
+
389
+ expectType<typeof result, readonly SafeUint[]>('=');
390
+
391
+ assert.deepStrictEqual(result, [asSafeUint(5), asSafeUint(3)]);
392
+ });
393
+
391
394
  test('start > end, step < 0, not reaching end', () => {
392
395
  const result = range(5, 1, -2);
393
396
 
394
- assert.deepStrictEqual(result, [asSafeInt(5), asSafeInt(3)]);
397
+ assert.deepStrictEqual(result, [asSafeUint(5), asSafeUint(3)]);
395
398
  });
396
399
 
397
400
  test('start < end, step < 0 (empty result)', () => {
@@ -419,12 +422,12 @@ describe('Arr creations', () => {
419
422
  asNonZeroSafeInt(step),
420
423
  );
421
424
 
422
- expectType<typeof result, readonly SafeInt[]>('=');
425
+ expectType<typeof result, readonly SafeUint[]>('=');
423
426
 
424
427
  assert.deepStrictEqual(result, [
425
- asSafeInt(1),
426
- asSafeInt(2),
427
- asSafeInt(3),
428
+ asSafeUint(1),
429
+ asSafeUint(2),
430
+ asSafeUint(3),
428
431
  ]);
429
432
  });
430
433
 
@@ -1,10 +1,10 @@
1
- import { type NonEmptyTuple } from 'ts-type-forge';
1
+ import type { NonEmptyTuple } from 'ts-type-forge';
2
2
  import { Optional, pipe } from '../../functional/index.mjs';
3
- import {
4
- type ArgArrayIndexWithNegative,
5
- type None,
6
- type SizeType,
7
- type Some,
3
+ import type {
4
+ ArgArrayIndexWithNegative,
5
+ None,
6
+ SizeType,
7
+ Some,
8
8
  } from '../../types.mjs';
9
9
 
10
10
  /**
@@ -58,7 +58,7 @@ const atImpl = <E,>(
58
58
  index: SizeType.ArgArrWithNegative,
59
59
  ): Optional<E> =>
60
60
  pipe(index < 0 ? array.length + index : index).map((normalizedIndex) =>
61
- normalizedIndex < 0 || normalizedIndex >= array.length
61
+ normalizedIndex < 0 || array.length <= normalizedIndex
62
62
  ? Optional.none
63
63
  : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
64
64
  Optional.some(array[normalizedIndex]!),
@@ -1,8 +1,8 @@
1
- import { type NonEmptyTuple } from 'ts-type-forge';
1
+ import type { NonEmptyTuple } from 'ts-type-forge';
2
2
  import { expectType } from '../../expect-type.mjs';
3
3
  import { Optional } from '../../functional/index.mjs';
4
4
  import { asInt32, asUint32 } from '../../number/index.mjs';
5
- import { type None, type Some } from '../../types.mjs';
5
+ import type { None, Some } from '../../types.mjs';
6
6
  import { at, head, last } from './array-utils-element-access.mjs';
7
7
 
8
8
  describe('Arr element access', () => {
@@ -1,5 +1,5 @@
1
1
  import { asUint32 } from '../../number/index.mjs';
2
- import { type SizeType } from '../../types.mjs';
2
+ import type { SizeType } from '../../types.mjs';
3
3
 
4
4
  /**
5
5
  * Returns an iterator of `[index, value]` pairs for an array.
@@ -1,4 +1,4 @@
1
- import { type Uint32 } from 'ts-type-forge';
1
+ import type { Uint32 } from 'ts-type-forge';
2
2
  import { expectType } from '../../expect-type.mjs';
3
3
  import { asUint32 } from '../../number/index.mjs';
4
4
  import { entries, indices, values } from './array-utils-iterators.mjs';
@@ -1,10 +1,10 @@
1
- import {
2
- type BoundedLengthArray,
3
- type FixedLengthArray,
4
- type MaxLengthArray,
5
- type MinLengthArray,
6
- type NonEmptyArray,
7
- type SupportedLength,
1
+ import type {
2
+ BoundedLengthArray,
3
+ FixedLengthArray,
4
+ MaxLengthArray,
5
+ MinLengthArray,
6
+ NonEmptyArray,
7
+ SupportedLength,
8
8
  } from 'ts-type-forge';
9
9
  import {
10
10
  isBoundedLengthArray,
@@ -33,13 +33,21 @@ import {
33
33
  * const rgb = Arr.asFixedLengthArray(3, [255, 128, 0]);
34
34
  *
35
35
  * const atMost5: MaxLengthArray<5, number> = rgb; // OK (3 <= 5)
36
+ *
36
37
  * const red: number = rgb[0]; // OK — no `undefined`
37
38
  *
38
39
  * // curried version
39
40
  * const asRgb = Arr.asFixedLengthArray(3);
41
+ *
40
42
  * const green = asRgb([0, 255, 0]);
41
43
  *
42
- * // Arr.asFixedLengthArray(3, [255, 128]); // throws TypeError
44
+ * assert.deepStrictEqual(Array.from(atMost5), [255, 128, 0]);
45
+ *
46
+ * assert.strictEqual(red, 255);
47
+ *
48
+ * assert.deepStrictEqual(green, [0, 255, 0]);
49
+ *
50
+ * assert.throws(() => Arr.asFixedLengthArray(3, [255, 128]), TypeError);
43
51
  * ```
44
52
  *
45
53
  * @template Length - The exact number of elements.
@@ -110,13 +118,21 @@ const asFixedLengthArrayImpl = <E,>(
110
118
  * const history = Arr.asMinLengthArray(3, [0, 1, 2, 3]);
111
119
  *
112
120
  * const nonEmpty: MinLengthArray<1, number> = history; // OK (3 >= 1)
121
+ *
113
122
  * const first: number = history[0]; // OK — no `undefined`
114
123
  *
115
124
  * // curried version
116
125
  * const asHistory = Arr.asMinLengthArray(3);
126
+ *
117
127
  * const next = asHistory([4, 5, 6, 7]);
118
128
  *
119
- * // Arr.asMinLengthArray(3, [0]); // throws TypeError
129
+ * assert.deepStrictEqual(Array.from(nonEmpty), [0, 1, 2, 3]);
130
+ *
131
+ * assert.strictEqual(first, 0);
132
+ *
133
+ * assert.deepStrictEqual(next, [4, 5, 6, 7]);
134
+ *
135
+ * assert.throws(() => Arr.asMinLengthArray(3, [0]), TypeError);
120
136
  * ```
121
137
  *
122
138
  * @template MinLength - The minimum number of elements (inclusive).
@@ -188,9 +204,14 @@ const asMinLengthArrayImpl = <E,>(
188
204
  *
189
205
  * // curried version
190
206
  * const asTags = Arr.asMaxLengthArray(8);
207
+ *
191
208
  * const more = asTags(['d', 'e']);
192
209
  *
193
- * // Arr.asMaxLengthArray(2, ['a', 'b', 'c']); // throws TypeError
210
+ * assert.deepStrictEqual(Array.from(relaxed), ['a', 'b', 'c']);
211
+ *
212
+ * assert.deepStrictEqual(more, ['d', 'e']);
213
+ *
214
+ * assert.throws(() => Arr.asMaxLengthArray(2, ['a', 'b', 'c']), TypeError);
194
215
  * ```
195
216
  *
196
217
  * @template MaxLength - The maximum number of elements (inclusive).
@@ -264,9 +285,14 @@ const asMaxLengthArrayImpl = <E,>(
264
285
  *
265
286
  * // curried version
266
287
  * const asSelection = Arr.asBoundedLengthArray(1, 5);
288
+ *
267
289
  * const next = asSelection([4, 5]);
268
290
  *
269
- * // Arr.asBoundedLengthArray(1, 5, []); // throws TypeError
291
+ * assert.deepStrictEqual(Array.from(relaxed), [1, 2, 3]);
292
+ *
293
+ * assert.deepStrictEqual(next, [4, 5]);
294
+ *
295
+ * assert.throws(() => Arr.asBoundedLengthArray(1, 5, []), TypeError);
270
296
  * ```
271
297
  *
272
298
  * @template MinLength - The minimum number of elements (inclusive).
@@ -349,7 +375,9 @@ const asBoundedLengthArrayImpl = <E,>(
349
375
  *
350
376
  * const atMost5: MaxLengthArray<5, never> = nothing; // OK (0 <= 5)
351
377
  *
352
- * // Arr.asEmptyArray([1]); // throws TypeError
378
+ * assert.deepStrictEqual(Array.from(atMost5), []);
379
+ *
380
+ * assert.throws(() => Arr.asEmptyArray([1]), TypeError);
353
381
  * ```
354
382
  *
355
383
  * @template Xs - The input array type (tuple types are preserved).
@@ -387,7 +415,9 @@ export const asEmptyArray = <Xs extends readonly unknown[]>(
387
415
  *
388
416
  * const first: number = history[0]; // OK — no `undefined`
389
417
  *
390
- * // Arr.asNonEmptyArray([]); // throws TypeError
418
+ * assert.strictEqual(first, 0);
419
+ *
420
+ * assert.throws(() => Arr.asNonEmptyArray([]), TypeError);
391
421
  * ```
392
422
  *
393
423
  * @template Xs - The input array type (tuple types are preserved).
@@ -1,9 +1,9 @@
1
- import {
2
- type BoundedLengthArray,
3
- type FixedLengthArray,
4
- type MaxLengthArray,
5
- type MinLengthArray,
6
- type NonEmptyArray,
1
+ import type {
2
+ BoundedLengthArray,
3
+ FixedLengthArray,
4
+ MaxLengthArray,
5
+ MinLengthArray,
6
+ NonEmptyArray,
7
7
  } from 'ts-type-forge';
8
8
  import { expectType } from '../../expect-type.mjs';
9
9
  import {
@@ -1,9 +1,9 @@
1
- import {
2
- type BoundedLengthArray,
3
- type FixedLengthArray,
4
- type MaxLengthArray,
5
- type MinLengthArray,
6
- type SupportedLength,
1
+ import type {
2
+ BoundedLengthArray,
3
+ FixedLengthArray,
4
+ MaxLengthArray,
5
+ MinLengthArray,
6
+ SupportedLength,
7
7
  } from 'ts-type-forge';
8
8
 
9
9
  /**
@@ -38,9 +38,9 @@ import {
38
38
  *
39
39
  * const nonEmpty: MinLengthArray<1, number> = input; // OK (3 >= 1)
40
40
  *
41
- * assert.deepStrictEqual(history[0], 0);
41
+ * assert.strictEqual(history[0], 0);
42
42
  *
43
- * assert.deepStrictEqual(nonEmpty[0], 0);
43
+ * assert.strictEqual(nonEmpty[0], 0);
44
44
  * }
45
45
  *
46
46
  * // curried version
@@ -122,9 +122,9 @@ const hasMinLength = (
122
122
  *
123
123
  * const relaxed: MaxLengthArray<16, string> = input; // OK (8 <= 16)
124
124
  *
125
- * assert.deepStrictEqual(tags.length, 3);
125
+ * assert.strictEqual(tags.length, 3);
126
126
  *
127
- * assert.deepStrictEqual(relaxed.length, 3);
127
+ * assert.strictEqual(relaxed.length, 3);
128
128
  * }
129
129
  *
130
130
  * // curried version
@@ -207,9 +207,9 @@ const hasMaxLength = (
207
207
  *
208
208
  * const relaxed: BoundedLengthArray<0, 100, number> = input; // OK ([1, 5] ⊆ [0, 100])
209
209
  *
210
- * assert.deepStrictEqual(selection[0], 1);
210
+ * assert.strictEqual(selection[0], 1);
211
211
  *
212
- * assert.deepStrictEqual(relaxed.length, 3);
212
+ * assert.strictEqual(relaxed.length, 3);
213
213
  * }
214
214
  *
215
215
  * // curried version
@@ -271,7 +271,7 @@ const hasBoundedLength = (
271
271
  minLength: SupportedLength,
272
272
  maxLength: SupportedLength,
273
273
  xs: readonly unknown[],
274
- ): boolean => xs.length >= minLength && xs.length <= maxLength;
274
+ ): boolean => minLength <= xs.length && xs.length <= maxLength;
275
275
 
276
276
  /**
277
277
  * Type guard that checks if an array has exactly `length` elements.
@@ -306,9 +306,9 @@ const hasBoundedLength = (
306
306
  *
307
307
  * const atMost5: MaxLengthArray<5, number> = input; // OK (3 <= 5)
308
308
  *
309
- * assert.deepStrictEqual(rgb[0], 255);
309
+ * assert.strictEqual(rgb[0], 255);
310
310
  *
311
- * assert.deepStrictEqual(atMost5.length, 3);
311
+ * assert.strictEqual(atMost5.length, 3);
312
312
  * }
313
313
  *
314
314
  * // curried version