ts-data-forge 14.7.1 → 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 (281) 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 +1 -1
  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-guard.d.mts +9 -9
  14. package/dist/array/impl/array-utils-length-bounded-array-guard.d.mts.map +1 -1
  15. package/dist/array/impl/array-utils-length-bounded-array-guard.mjs +1 -1
  16. package/dist/array/impl/array-utils-length-bounded-array-guard.mjs.map +1 -1
  17. package/dist/array/impl/array-utils-length-bounded-tuple-cast.d.mts +2 -2
  18. package/dist/array/impl/array-utils-length-bounded-tuple-cast.d.mts.map +1 -1
  19. package/dist/array/impl/array-utils-length-bounded-tuple-guard.d.mts +3 -3
  20. package/dist/array/impl/array-utils-length-bounded-tuple-guard.d.mts.map +1 -1
  21. package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs +1 -1
  22. package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs.map +1 -1
  23. package/dist/array/impl/array-utils-modification.d.mts +2 -2
  24. package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
  25. package/dist/array/impl/array-utils-reducing-value.d.mts +2 -2
  26. package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
  27. package/dist/array/impl/array-utils-reducing-value.mjs +3 -4
  28. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  29. package/dist/array/impl/array-utils-search.d.mts +1 -1
  30. package/dist/array/impl/array-utils-search.d.mts.map +1 -1
  31. package/dist/array/impl/array-utils-set-op.d.mts +1 -1
  32. package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
  33. package/dist/array/impl/array-utils-size.d.mts +2 -2
  34. package/dist/array/impl/array-utils-size.d.mts.map +1 -1
  35. package/dist/array/impl/array-utils-slice-clamped.d.mts +1 -1
  36. package/dist/array/impl/array-utils-slice-clamped.d.mts.map +1 -1
  37. package/dist/array/impl/array-utils-slicing.d.mts +2 -2
  38. package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
  39. package/dist/array/impl/array-utils-transformation.d.mts +2 -2
  40. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
  41. package/dist/array/impl/array-utils-transformation.mjs +6 -3
  42. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  43. package/dist/array/impl/array-utils-validation.d.mts +2 -2
  44. package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
  45. package/dist/collections/imap-mapped.d.mts +2 -2
  46. package/dist/collections/imap-mapped.d.mts.map +1 -1
  47. package/dist/collections/imap-mapped.mjs +10 -7
  48. package/dist/collections/imap-mapped.mjs.map +1 -1
  49. package/dist/collections/imap.d.mts +2 -2
  50. package/dist/collections/imap.d.mts.map +1 -1
  51. package/dist/collections/imap.mjs +10 -7
  52. package/dist/collections/imap.mjs.map +1 -1
  53. package/dist/collections/iset-mapped.d.mts +2 -2
  54. package/dist/collections/iset-mapped.d.mts.map +1 -1
  55. package/dist/collections/iset-mapped.mjs +6 -3
  56. package/dist/collections/iset-mapped.mjs.map +1 -1
  57. package/dist/collections/iset.d.mts +2 -2
  58. package/dist/collections/iset.d.mts.map +1 -1
  59. package/dist/collections/iset.mjs +5 -5
  60. package/dist/collections/iset.mjs.map +1 -1
  61. package/dist/collections/queue.d.mts +1 -1
  62. package/dist/collections/queue.d.mts.map +1 -1
  63. package/dist/collections/stack.d.mts +1 -1
  64. package/dist/collections/stack.d.mts.map +1 -1
  65. package/dist/guard/is-non-empty-string.d.mts +1 -1
  66. package/dist/guard/is-non-empty-string.d.mts.map +1 -1
  67. package/dist/guard/is-primitive.d.mts +1 -1
  68. package/dist/guard/is-primitive.d.mts.map +1 -1
  69. package/dist/guard/is-type.d.mts +1 -1
  70. package/dist/guard/is-type.d.mts.map +1 -1
  71. package/dist/iterator/range.d.mts +5 -4
  72. package/dist/iterator/range.d.mts.map +1 -1
  73. package/dist/iterator/range.mjs.map +1 -1
  74. package/dist/json/json.d.mts +29 -32
  75. package/dist/json/json.d.mts.map +1 -1
  76. package/dist/json/json.mjs +1 -4
  77. package/dist/json/json.mjs.map +1 -1
  78. package/dist/number/branded-types/finite-number.d.mts +1 -1
  79. package/dist/number/branded-types/finite-number.d.mts.map +1 -1
  80. package/dist/number/branded-types/int.d.mts +2 -2
  81. package/dist/number/branded-types/int.d.mts.map +1 -1
  82. package/dist/number/branded-types/int16.d.mts +1 -1
  83. package/dist/number/branded-types/int16.d.mts.map +1 -1
  84. package/dist/number/branded-types/int32.d.mts +1 -1
  85. package/dist/number/branded-types/int32.d.mts.map +1 -1
  86. package/dist/number/branded-types/negative-finite-number.d.mts +1 -1
  87. package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
  88. package/dist/number/branded-types/negative-int.d.mts +1 -1
  89. package/dist/number/branded-types/negative-int.d.mts.map +1 -1
  90. package/dist/number/branded-types/negative-safe-int.d.mts +1 -1
  91. package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
  92. package/dist/number/branded-types/non-negative-finite-number.d.mts +1 -1
  93. package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
  94. package/dist/number/branded-types/non-negative-int16.d.mts +1 -1
  95. package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
  96. package/dist/number/branded-types/non-negative-int32.d.mts +1 -1
  97. package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
  98. package/dist/number/branded-types/non-positive-finite-number.d.mts +1 -1
  99. package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
  100. package/dist/number/branded-types/non-positive-int.d.mts +1 -1
  101. package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
  102. package/dist/number/branded-types/non-positive-safe-int.d.mts +1 -1
  103. package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
  104. package/dist/number/branded-types/non-zero-finite-number.d.mts +1 -1
  105. package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
  106. package/dist/number/branded-types/non-zero-int.d.mts +1 -1
  107. package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
  108. package/dist/number/branded-types/non-zero-int16.d.mts +1 -1
  109. package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
  110. package/dist/number/branded-types/non-zero-int32.d.mts +1 -1
  111. package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
  112. package/dist/number/branded-types/non-zero-safe-int.d.mts +1 -1
  113. package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
  114. package/dist/number/branded-types/non-zero-uint16.d.mts +1 -1
  115. package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
  116. package/dist/number/branded-types/non-zero-uint32.d.mts +1 -1
  117. package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
  118. package/dist/number/branded-types/positive-finite-number.d.mts +1 -1
  119. package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
  120. package/dist/number/branded-types/positive-int.d.mts +2 -2
  121. package/dist/number/branded-types/positive-int.d.mts.map +1 -1
  122. package/dist/number/branded-types/positive-int16.d.mts +1 -1
  123. package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
  124. package/dist/number/branded-types/positive-int32.d.mts +1 -1
  125. package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
  126. package/dist/number/branded-types/positive-safe-int.d.mts +2 -2
  127. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
  128. package/dist/number/branded-types/positive-uint16.d.mts +1 -1
  129. package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
  130. package/dist/number/branded-types/positive-uint32.d.mts +1 -1
  131. package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
  132. package/dist/number/branded-types/safe-int.d.mts +2 -2
  133. package/dist/number/branded-types/safe-int.d.mts.map +1 -1
  134. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  135. package/dist/number/branded-types/safe-uint.d.mts +1 -1
  136. package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
  137. package/dist/number/branded-types/uint.d.mts +2 -2
  138. package/dist/number/branded-types/uint.d.mts.map +1 -1
  139. package/dist/number/branded-types/uint16.d.mts +1 -1
  140. package/dist/number/branded-types/uint16.d.mts.map +1 -1
  141. package/dist/number/branded-types/uint32.d.mts +1 -1
  142. package/dist/number/branded-types/uint32.d.mts.map +1 -1
  143. package/dist/number/enum/int8.d.mts +1 -1
  144. package/dist/number/enum/int8.d.mts.map +1 -1
  145. package/dist/number/enum/uint8.d.mts +1 -1
  146. package/dist/number/enum/uint8.d.mts.map +1 -1
  147. package/dist/number/num-arithmetic-types.d.mts +1 -1
  148. package/dist/number/num-arithmetic-types.d.mts.map +1 -1
  149. package/dist/number/num.d.mts +3 -3
  150. package/dist/number/num.d.mts.map +1 -1
  151. package/dist/number/refined-number-utils.d.mts +2 -2
  152. package/dist/number/refined-number-utils.d.mts.map +1 -1
  153. package/dist/number/refined-number-utils.mjs +6 -4
  154. package/dist/number/refined-number-utils.mjs.map +1 -1
  155. package/dist/object/object.d.mts +5 -8
  156. package/dist/object/object.d.mts.map +1 -1
  157. package/dist/object/object.mjs +16 -13
  158. package/dist/object/object.mjs.map +1 -1
  159. package/dist/others/cast-mutable.d.mts +1 -1
  160. package/dist/others/cast-mutable.d.mts.map +1 -1
  161. package/dist/others/cast-readonly.d.mts +1 -1
  162. package/dist/others/cast-readonly.d.mts.map +1 -1
  163. package/dist/others/debounce-function.d.mts.map +1 -1
  164. package/dist/others/debounce-function.mjs +1 -5
  165. package/dist/others/debounce-function.mjs.map +1 -1
  166. package/dist/others/memoize-function.d.mts +1 -1
  167. package/dist/others/memoize-function.d.mts.map +1 -1
  168. package/dist/string/str.d.mts +26 -18
  169. package/dist/string/str.d.mts.map +1 -1
  170. package/dist/string/str.mjs +9 -1
  171. package/dist/string/str.mjs.map +1 -1
  172. package/dist/types.d.mts +1 -1
  173. package/dist/types.d.mts.map +1 -1
  174. package/package.json +31 -30
  175. package/src/array/impl/array-utils-creation.mts +24 -22
  176. package/src/array/impl/array-utils-creation.test.mts +25 -22
  177. package/src/array/impl/array-utils-element-access.mts +7 -7
  178. package/src/array/impl/array-utils-element-access.test.mts +2 -2
  179. package/src/array/impl/array-utils-iterators.mts +1 -1
  180. package/src/array/impl/array-utils-iterators.test.mts +1 -1
  181. package/src/array/impl/array-utils-length-bounded-array-cast.mts +7 -7
  182. package/src/array/impl/array-utils-length-bounded-array-cast.test.mts +6 -6
  183. package/src/array/impl/array-utils-length-bounded-array-guard.mts +15 -15
  184. package/src/array/impl/array-utils-length-bounded-array-guard.test.mts +66 -54
  185. package/src/array/impl/array-utils-length-bounded-tuple-cast.mts +6 -6
  186. package/src/array/impl/array-utils-length-bounded-tuple-cast.test.mts +10 -10
  187. package/src/array/impl/array-utils-length-bounded-tuple-guard.mts +8 -8
  188. package/src/array/impl/array-utils-length-bounded-tuple-guard.test.mts +38 -28
  189. package/src/array/impl/array-utils-length-constraint-preservation.test.mts +14 -14
  190. package/src/array/impl/array-utils-modification.mts +12 -12
  191. package/src/array/impl/array-utils-modification.test.mts +7 -7
  192. package/src/array/impl/array-utils-overload-type-error.test.mts +1 -1
  193. package/src/array/impl/array-utils-reducing-value.mts +9 -11
  194. package/src/array/impl/array-utils-reducing-value.test.mts +2 -2
  195. package/src/array/impl/array-utils-search.mts +4 -4
  196. package/src/array/impl/array-utils-search.test.mts +25 -17
  197. package/src/array/impl/array-utils-set-op.mts +1 -1
  198. package/src/array/impl/array-utils-shape-invariants.test.mts +8 -8
  199. package/src/array/impl/array-utils-size.mts +5 -5
  200. package/src/array/impl/array-utils-slice-clamped.mts +2 -2
  201. package/src/array/impl/array-utils-slicing.mts +8 -8
  202. package/src/array/impl/array-utils-slicing.test.mts +1 -1
  203. package/src/array/impl/array-utils-transformation.mts +26 -24
  204. package/src/array/impl/array-utils-transformation.test.mts +12 -10
  205. package/src/array/impl/array-utils-validation.mts +7 -7
  206. package/src/array/impl/array-utils-validation.test.mts +39 -39
  207. package/src/array/impl/array.test.mts +1 -1
  208. package/src/collections/imap-mapped.mts +15 -9
  209. package/src/collections/imap-mapped.test.mts +1 -1
  210. package/src/collections/imap.mts +15 -9
  211. package/src/collections/imap.test.mts +7 -5
  212. package/src/collections/iset-mapped.mts +14 -8
  213. package/src/collections/iset.mts +12 -10
  214. package/src/collections/iset.test.mts +14 -12
  215. package/src/collections/queue.mts +1 -1
  216. package/src/collections/stack.mts +1 -1
  217. package/src/collections/stack.test.mts +8 -6
  218. package/src/guard/is-error.test.mts +6 -4
  219. package/src/guard/is-non-empty-string.mts +1 -1
  220. package/src/guard/is-non-empty-string.test.mts +15 -11
  221. package/src/guard/is-primitive.mts +1 -1
  222. package/src/guard/is-type.mts +1 -1
  223. package/src/guard/is-type.test.mts +87 -59
  224. package/src/iterator/range.mts +5 -9
  225. package/src/iterator/range.test.mts +29 -0
  226. package/src/json/json.mts +32 -35
  227. package/src/json/json.test.mts +106 -89
  228. package/src/number/branded-types/finite-number.mts +4 -4
  229. package/src/number/branded-types/int.mts +2 -2
  230. package/src/number/branded-types/int16.mts +1 -1
  231. package/src/number/branded-types/int32.mts +1 -1
  232. package/src/number/branded-types/negative-finite-number.mts +1 -1
  233. package/src/number/branded-types/negative-finite-number.test.mts +4 -4
  234. package/src/number/branded-types/negative-int.mts +3 -3
  235. package/src/number/branded-types/negative-int.test.mts +1 -1
  236. package/src/number/branded-types/negative-safe-int.mts +3 -3
  237. package/src/number/branded-types/negative-safe-int.test.mts +1 -1
  238. package/src/number/branded-types/non-negative-finite-number.mts +3 -3
  239. package/src/number/branded-types/non-negative-int16.mts +1 -1
  240. package/src/number/branded-types/non-negative-int32.mts +1 -1
  241. package/src/number/branded-types/non-positive-finite-number.mts +1 -1
  242. package/src/number/branded-types/non-positive-int.mts +1 -1
  243. package/src/number/branded-types/non-positive-safe-int.mts +1 -1
  244. package/src/number/branded-types/non-zero-finite-number.mts +5 -5
  245. package/src/number/branded-types/non-zero-int.mts +1 -1
  246. package/src/number/branded-types/non-zero-int16.mts +1 -1
  247. package/src/number/branded-types/non-zero-int32.mts +1 -1
  248. package/src/number/branded-types/non-zero-safe-int.mts +4 -4
  249. package/src/number/branded-types/non-zero-uint16.mts +1 -1
  250. package/src/number/branded-types/non-zero-uint32.mts +1 -1
  251. package/src/number/branded-types/positive-finite-number.mts +4 -4
  252. package/src/number/branded-types/positive-int.mts +2 -2
  253. package/src/number/branded-types/positive-int16.mts +1 -1
  254. package/src/number/branded-types/positive-int32.mts +1 -1
  255. package/src/number/branded-types/positive-safe-int.mts +4 -4
  256. package/src/number/branded-types/positive-uint16.mts +1 -1
  257. package/src/number/branded-types/positive-uint32.mts +1 -1
  258. package/src/number/branded-types/safe-int.mts +2 -5
  259. package/src/number/branded-types/safe-uint.mts +1 -1
  260. package/src/number/branded-types/uint.mts +2 -2
  261. package/src/number/branded-types/uint16.mts +1 -1
  262. package/src/number/branded-types/uint32.mts +1 -1
  263. package/src/number/enum/int8.mts +5 -5
  264. package/src/number/enum/uint8.mts +4 -4
  265. package/src/number/num-arithmetic-types.mts +27 -27
  266. package/src/number/num-arithmetic-types.test.mts +21 -21
  267. package/src/number/num-arithmetic.test.mts +6 -6
  268. package/src/number/num.mts +24 -24
  269. package/src/number/num.test.mts +1 -1
  270. package/src/number/refined-number-utils.mts +25 -21
  271. package/src/object/object.mts +46 -34
  272. package/src/object/object.test.mts +5 -5
  273. package/src/others/cast-mutable.mts +1 -1
  274. package/src/others/cast-readonly.mts +1 -1
  275. package/src/others/debounce-function.mts +1 -5
  276. package/src/others/fast-deep-equal.test.mts +1 -1
  277. package/src/others/map-nullable.test.mts +1 -1
  278. package/src/others/memoize-function.mts +1 -1
  279. package/src/string/str.mts +33 -25
  280. package/src/string/str.test.mts +48 -38
  281. package/src/types.mts +14 -14
@@ -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,
@@ -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
@@ -1,8 +1,8 @@
1
- import {
2
- type BoundedLengthArray,
3
- type FixedLengthArray,
4
- type MaxLengthArray,
5
- type MinLengthArray,
1
+ import type {
2
+ BoundedLengthArray,
3
+ FixedLengthArray,
4
+ MaxLengthArray,
5
+ MinLengthArray,
6
6
  } from 'ts-type-forge';
7
7
  import { expectType } from '../../expect-type.mjs';
8
8
  import {
@@ -32,39 +32,43 @@ describe(isMinLengthArray, () => {
32
32
  test('should act as a type guard', () => {
33
33
  const value: readonly number[] = [0, 1, 2, 3] as const;
34
34
 
35
- if (isMinLengthArray(3, value)) {
36
- expectType<typeof value, MinLengthArray<3, number>>('<=');
35
+ if (!isMinLengthArray(3, value)) {
36
+ return;
37
+ }
37
38
 
38
- expectType<typeof value, MinLengthArray<1, number>>('<='); // 3 >= 1
39
+ expectType<typeof value, MinLengthArray<3, number>>('<=');
39
40
 
40
- expectType<typeof value, MinLengthArray<5, number>>('!<=');
41
+ expectType<typeof value, MinLengthArray<1, number>>('<='); // 3 >= 1
41
42
 
42
- // indexed access below the minimum length does not include `undefined`
43
- // (even under `noUncheckedIndexedAccess`)
44
- const _first = value[0];
43
+ expectType<typeof value, MinLengthArray<5, number>>('!<=');
45
44
 
46
- expectType<typeof _first, number>('=');
45
+ // indexed access below the minimum length does not include `undefined`
46
+ // (even under `noUncheckedIndexedAccess`)
47
+ const _first = value[0];
47
48
 
48
- const _third = value[2];
49
+ expectType<typeof _first, number>('=');
49
50
 
50
- expectType<typeof _third, number>('=');
51
+ const _third = value[2];
51
52
 
52
- const _fourth = value[3];
53
+ expectType<typeof _third, number>('=');
53
54
 
54
- expectType<typeof _fourth, number | undefined>('=');
55
+ const _fourth = value[3];
55
56
 
56
- expect(value.length).toBeGreaterThanOrEqual(3);
57
- }
57
+ expectType<typeof _fourth, number | undefined>('=');
58
+
59
+ expect(value.length).toBeGreaterThanOrEqual(3);
58
60
  });
59
61
 
60
62
  test('should preserve the original array type', () => {
61
63
  const tuple = [1, 2, 3] as const;
62
64
 
63
- if (isMinLengthArray(2, tuple)) {
64
- expectType<typeof tuple, readonly [1, 2, 3]>('<=');
65
-
66
- expectType<typeof tuple, MinLengthArray<2, 1 | 2 | 3>>('<=');
65
+ if (!isMinLengthArray(2, tuple)) {
66
+ return;
67
67
  }
68
+
69
+ expectType<typeof tuple, readonly [1, 2, 3]>('<=');
70
+
71
+ expectType<typeof tuple, MinLengthArray<2, 1 | 2 | 3>>('<=');
68
72
  });
69
73
  });
70
74
 
@@ -86,15 +90,17 @@ describe(isMaxLengthArray, () => {
86
90
  test('should act as a type guard', () => {
87
91
  const value: readonly number[] = [0, 1, 2] as const;
88
92
 
89
- if (isMaxLengthArray(8, value)) {
90
- expectType<typeof value, MaxLengthArray<8, number>>('<=');
93
+ if (!isMaxLengthArray(8, value)) {
94
+ return;
95
+ }
91
96
 
92
- expectType<typeof value, MaxLengthArray<16, number>>('<='); // 8 <= 16
97
+ expectType<typeof value, MaxLengthArray<8, number>>('<=');
93
98
 
94
- expectType<typeof value, MaxLengthArray<2, number>>('!<=');
99
+ expectType<typeof value, MaxLengthArray<16, number>>('<='); // 8 <= 16
95
100
 
96
- expect(value.length).toBeLessThanOrEqual(8);
97
- }
101
+ expectType<typeof value, MaxLengthArray<2, number>>('!<=');
102
+
103
+ expect(value.length).toBeLessThanOrEqual(8);
98
104
  });
99
105
  });
100
106
 
@@ -116,17 +122,19 @@ describe(isBoundedLengthArray, () => {
116
122
  test('should act as a type guard', () => {
117
123
  const value: readonly number[] = [1, 2, 3] as const;
118
124
 
119
- if (isBoundedLengthArray(1, 5, value)) {
120
- expectType<typeof value, BoundedLengthArray<1, 5, number>>('<=');
125
+ if (!isBoundedLengthArray(1, 5, value)) {
126
+ return;
127
+ }
121
128
 
122
- expectType<typeof value, BoundedLengthArray<0, 100, number>>('<=');
129
+ expectType<typeof value, BoundedLengthArray<1, 5, number>>('<=');
123
130
 
124
- expectType<typeof value, MinLengthArray<1, number>>('<=');
131
+ expectType<typeof value, BoundedLengthArray<0, 100, number>>('<=');
125
132
 
126
- expectType<typeof value, MaxLengthArray<5, number>>('<=');
133
+ expectType<typeof value, MinLengthArray<1, number>>('<=');
127
134
 
128
- expectType<typeof value, BoundedLengthArray<2, 5, number>>('!<=');
129
- }
135
+ expectType<typeof value, MaxLengthArray<5, number>>('<=');
136
+
137
+ expectType<typeof value, BoundedLengthArray<2, 5, number>>('!<=');
130
138
  });
131
139
  });
132
140
 
@@ -146,27 +154,29 @@ describe(isFixedLengthArray, () => {
146
154
  test('should act as a type guard', () => {
147
155
  const value: readonly number[] = [255, 128, 0] as const;
148
156
 
149
- if (isFixedLengthArray(3, value)) {
150
- expectType<typeof value, FixedLengthArray<3, number>>('<=');
157
+ if (!isFixedLengthArray(3, value)) {
158
+ return;
159
+ }
151
160
 
152
- expectType<typeof value, MaxLengthArray<5, number>>('<='); // 3 <= 5
161
+ expectType<typeof value, FixedLengthArray<3, number>>('<=');
153
162
 
154
- expectType<typeof value, MinLengthArray<1, number>>('<='); // 3 >= 1
163
+ expectType<typeof value, MaxLengthArray<5, number>>('<='); // 3 <= 5
155
164
 
156
- expectType<typeof value, FixedLengthArray<4, number>>('!<=');
165
+ expectType<typeof value, MinLengthArray<1, number>>('<='); // 3 >= 1
157
166
 
158
- // `length` is narrowed to the literal and in-range indexed access does
159
- // not include `undefined` (even under `noUncheckedIndexedAccess`)
160
- const _len = value.length;
167
+ expectType<typeof value, FixedLengthArray<4, number>>('!<=');
161
168
 
162
- expectType<typeof _len, 3>('=');
169
+ // `length` is narrowed to the literal and in-range indexed access does
170
+ // not include `undefined` (even under `noUncheckedIndexedAccess`)
171
+ const _len = value.length;
163
172
 
164
- const _second = value[1];
173
+ expectType<typeof _len, 3>('=');
165
174
 
166
- expectType<typeof _second, number>('=');
175
+ const _second = value[1];
167
176
 
168
- expect(value).toHaveLength(3);
169
- }
177
+ expectType<typeof _second, number>('=');
178
+
179
+ expect(value).toHaveLength(3);
170
180
  });
171
181
  });
172
182
 
@@ -182,13 +192,15 @@ describe('curried length guards', () => {
182
192
 
183
193
  assert.isTrue(hasThree(value));
184
194
 
185
- if (hasThree(value)) {
186
- expectType<typeof value, MinLengthArray<3, number>>('<=');
195
+ if (!hasThree(value)) {
196
+ return;
197
+ }
187
198
 
188
- const _first = value[0];
199
+ expectType<typeof value, MinLengthArray<3, number>>('<=');
189
200
 
190
- expectType<typeof _first, number>('=');
191
- }
201
+ const _first = value[0];
202
+
203
+ expectType<typeof _first, number>('=');
192
204
  });
193
205
 
194
206
  test('isMaxLengthArray narrows when applied later', () => {
@@ -1,10 +1,10 @@
1
- import {
2
- type BoundedLengthTuple,
3
- type FixedLengthTuple,
4
- type MaxLengthTuple,
5
- type MinLengthTuple,
1
+ import type {
2
+ BoundedLengthTuple,
3
+ FixedLengthTuple,
4
+ MaxLengthTuple,
5
+ MinLengthTuple,
6
6
  } from 'ts-type-forge';
7
- import { type SizeType } from '../../types.mjs';
7
+ import type { SizeType } from '../../types.mjs';
8
8
  import {
9
9
  isBoundedLengthTuple,
10
10
  isEmptyTuple,
@@ -1,8 +1,8 @@
1
- import {
2
- type BoundedLengthTuple,
3
- type FixedLengthTuple,
4
- type MaxLengthTuple,
5
- type MinLengthTuple,
1
+ import type {
2
+ BoundedLengthTuple,
3
+ FixedLengthTuple,
4
+ MaxLengthTuple,
5
+ MinLengthTuple,
6
6
  } from 'ts-type-forge';
7
7
  import { expectType } from '../../expect-type.mjs';
8
8
  import {
@@ -24,7 +24,7 @@ describe(asFixedLengthTuple, () => {
24
24
 
25
25
  const red: number = casted[0];
26
26
 
27
- assert.deepStrictEqual(red, 255);
27
+ assert.strictEqual(red, 255);
28
28
  });
29
29
 
30
30
  test('is the same value it was handed', () => {
@@ -69,7 +69,7 @@ describe(asMinLengthTuple, () => {
69
69
 
70
70
  const first: number = casted[0];
71
71
 
72
- assert.deepStrictEqual(first, 0);
72
+ assert.strictEqual(first, 0);
73
73
  });
74
74
 
75
75
  test('throws when the array is too short', () => {
@@ -168,7 +168,7 @@ describe(asNonEmptyTuple, () => {
168
168
 
169
169
  const first: number = casted[0];
170
170
 
171
- assert.deepStrictEqual(first, 1);
171
+ assert.strictEqual(first, 1);
172
172
  });
173
173
 
174
174
  test('throws when the array is empty', () => {
@@ -190,7 +190,7 @@ describe('tuple casts preserve the input type, like their branded counterparts',
190
190
 
191
191
  const length: 5 = casted.length;
192
192
 
193
- assert.deepStrictEqual(length, 5);
193
+ assert.strictEqual(length, 5);
194
194
 
195
195
  assert.deepStrictEqual<readonly number[]>(casted, [1, 2, 3, 4, 5]);
196
196
  });
@@ -202,6 +202,6 @@ describe('tuple casts preserve the input type, like their branded counterparts',
202
202
 
203
203
  const first: 1 = casted[0];
204
204
 
205
- assert.deepStrictEqual(first, 1);
205
+ assert.strictEqual(first, 1);
206
206
  });
207
207
  });
@@ -1,10 +1,10 @@
1
- import {
2
- type BoundedLengthTuple,
3
- type FixedLengthTuple,
4
- type MaxLengthTuple,
5
- type MinLengthTuple,
1
+ import type {
2
+ BoundedLengthTuple,
3
+ FixedLengthTuple,
4
+ MaxLengthTuple,
5
+ MinLengthTuple,
6
6
  } from 'ts-type-forge';
7
- import { type SizeType } from '../../types.mjs';
7
+ import type { SizeType } from '../../types.mjs';
8
8
 
9
9
  /**
10
10
  * Type guard that checks if an array is empty, narrowing it to the structural
@@ -218,7 +218,7 @@ const hasMaxLength = (
218
218
  * assert.isFalse(Arr.isBoundedLengthTuple(1, 3, quad));
219
219
  *
220
220
  * if (Arr.isBoundedLengthTuple(1, 3, pair)) {
221
- * assert.isTrue(pair.length >= 1 && pair.length <= 3);
221
+ * assert.isTrue(1 <= pair.length && pair.length <= 3);
222
222
  * }
223
223
  * ```
224
224
  */
@@ -263,4 +263,4 @@ const isWithinBounds = (
263
263
  min: SizeType.ArgArr,
264
264
  max: SizeType.ArgArr,
265
265
  array: readonly unknown[],
266
- ): boolean => array.length >= min && array.length <= max;
266
+ ): boolean => min <= array.length && array.length <= max;
@@ -1,8 +1,8 @@
1
- import {
2
- type BoundedLengthTuple,
3
- type FixedLengthTuple,
4
- type MaxLengthTuple,
5
- type MinLengthTuple,
1
+ import type {
2
+ BoundedLengthTuple,
3
+ FixedLengthTuple,
4
+ MaxLengthTuple,
5
+ MinLengthTuple,
6
6
  } from 'ts-type-forge';
7
7
  import { expectType } from '../../expect-type.mjs';
8
8
  import {
@@ -92,11 +92,13 @@ describe('Arr structural tuple length guards', () => {
92
92
  test('should work as type guard with exact length (additional)', () => {
93
93
  const array: readonly number[] = [1, 2, 3] as const;
94
94
 
95
- if (isFixedLengthTuple(3, array)) {
96
- expectType<typeof array, FixedLengthTuple<3, number>>('=');
97
-
98
- expect(array).toHaveLength(3);
95
+ if (!isFixedLengthTuple(3, array)) {
96
+ return;
99
97
  }
98
+
99
+ expectType<typeof array, FixedLengthTuple<3, number>>('=');
100
+
101
+ expect(array).toHaveLength(3);
100
102
  });
101
103
  });
102
104
 
@@ -180,11 +182,13 @@ describe('Arr structural tuple length guards', () => {
180
182
  test('should work as type guard for at least length (additional)', () => {
181
183
  const array: readonly number[] = [1, 2, 3] as const;
182
184
 
183
- if (isMinLengthTuple(2, array)) {
184
- expectType<typeof array, MinLengthTuple<2, number>>('=');
185
-
186
- expect(array.length).toBeGreaterThanOrEqual(2);
185
+ if (!isMinLengthTuple(2, array)) {
186
+ return;
187
187
  }
188
+
189
+ expectType<typeof array, MinLengthTuple<2, number>>('=');
190
+
191
+ expect(array.length).toBeGreaterThanOrEqual(2);
188
192
  });
189
193
  });
190
194
 
@@ -255,11 +259,13 @@ describe('Arr structural tuple length guards', () => {
255
259
  test('should work as type guard for at most length (additional)', () => {
256
260
  const array: readonly number[] = [1, 2] as const;
257
261
 
258
- if (isMaxLengthTuple(3, array)) {
259
- expectType<typeof array, MaxLengthTuple<3, number>>('=');
260
-
261
- expect(array.length).toBeLessThanOrEqual(3);
262
+ if (!isMaxLengthTuple(3, array)) {
263
+ return;
262
264
  }
265
+
266
+ expectType<typeof array, MaxLengthTuple<3, number>>('=');
267
+
268
+ expect(array.length).toBeLessThanOrEqual(3);
263
269
  });
264
270
  });
265
271
 
@@ -332,13 +338,15 @@ describe('Arr structural tuple length guards', () => {
332
338
  test('should work as type guard for bounded length (additional)', () => {
333
339
  const array: readonly number[] = [1, 2] as const;
334
340
 
335
- if (isBoundedLengthTuple(1, 3, array)) {
336
- expectType<typeof array, BoundedLengthTuple<1, 3, number>>('=');
341
+ if (!isBoundedLengthTuple(1, 3, array)) {
342
+ return;
343
+ }
337
344
 
338
- expect(array.length).toBeGreaterThanOrEqual(1);
345
+ expectType<typeof array, BoundedLengthTuple<1, 3, number>>('=');
339
346
 
340
- expect(array.length).toBeLessThanOrEqual(3);
341
- }
347
+ expect(array.length).toBeGreaterThanOrEqual(1);
348
+
349
+ expect(array.length).toBeLessThanOrEqual(3);
342
350
  });
343
351
  });
344
352
 
@@ -364,14 +372,16 @@ describe('Arr structural tuple length guards', () => {
364
372
 
365
373
  assert.isTrue(isNonEmptyTuple(values));
366
374
 
367
- if (isNonEmptyTuple(values)) {
368
- expectType<typeof values, MinLengthTuple<1, number>>('=');
375
+ if (!isNonEmptyTuple(values)) {
376
+ return;
377
+ }
378
+
379
+ expectType<typeof values, MinLengthTuple<1, number>>('=');
369
380
 
370
- // The structural prefix makes the first element defined.
371
- const first: number = values[0];
381
+ // The structural prefix makes the first element defined.
382
+ const first: number = values[0];
372
383
 
373
- assert.deepStrictEqual(first, 1);
374
- }
384
+ assert.strictEqual(first, 1);
375
385
  });
376
386
 
377
387
  test('rejects an empty array', () => {
@@ -1,10 +1,10 @@
1
- import {
2
- type BoundedLengthArray,
3
- type FixedLengthArray,
4
- type FixedLengthTuple,
5
- type MaxLengthArray,
6
- type MinLengthArray,
7
- type Seq,
1
+ import type {
2
+ BoundedLengthArray,
3
+ FixedLengthArray,
4
+ FixedLengthTuple,
5
+ MaxLengthArray,
6
+ MinLengthArray,
7
+ Seq,
8
8
  } from 'ts-type-forge';
9
9
  import { expectType } from '../../expect-type.mjs';
10
10
  import { copy, create, seq, zeros } from './array-utils-creation.mjs';
@@ -39,7 +39,7 @@ describe('map preserves length constraints', () => {
39
39
  // The structural prefix survives, so in-range access is not `undefined`.
40
40
  const first: string = result[0];
41
41
 
42
- assert.deepStrictEqual(first, '#0');
42
+ assert.strictEqual(first, '#0');
43
43
 
44
44
  assert.deepStrictEqual<readonly string[]>(result, ['#0', '#1', '#2', '#3']);
45
45
  });
@@ -56,7 +56,7 @@ describe('map preserves length constraints', () => {
56
56
 
57
57
  const length: 3 = result.length;
58
58
 
59
- assert.deepStrictEqual(length, 3);
59
+ assert.strictEqual(length, 3);
60
60
  });
61
61
 
62
62
  test('a minimum above the structural prefix cap survives, clamped like MinLengthArray itself', () => {
@@ -199,7 +199,7 @@ describe('other length-preserving utilities preserve length constraints', () =>
199
199
  // The structural prefix survives the reversal too.
200
200
  const first: number = result[0];
201
201
 
202
- assert.deepStrictEqual(first, 4);
202
+ assert.strictEqual(first, 4);
203
203
 
204
204
  assert.deepStrictEqual<readonly number[]>(result, [4, 3, 2, 1]);
205
205
  });
@@ -242,7 +242,7 @@ describe('partition reports the bounds of each chunk', () => {
242
242
 
243
243
  const first: 1 | 2 | 3 | 4 | 5 = firstChunk[0];
244
244
 
245
- assert.deepStrictEqual(first, 1);
245
+ assert.strictEqual(first, 1);
246
246
 
247
247
  assert.deepStrictEqual<readonly (readonly number[])[]>(result, [
248
248
  [1, 2],
@@ -262,7 +262,7 @@ describe('creation utilities report an exact length past their tuple range', ()
262
262
 
263
263
  expectType<typeof result, FixedLengthArray<12, 'x'>>('~=');
264
264
 
265
- assert.deepStrictEqual(result.length, 12);
265
+ assert.strictEqual(result.length, 12);
266
266
  });
267
267
 
268
268
  test('a length still inside the tuple range keeps its exact tuple type', () => {
@@ -280,8 +280,8 @@ describe('creation utilities report an exact length past their tuple range', ()
280
280
 
281
281
  expectType<typeof seq12, Seq<12>>('=');
282
282
 
283
- assert.deepStrictEqual(zeros12.length, 12);
283
+ assert.strictEqual(zeros12.length, 12);
284
284
 
285
- assert.deepStrictEqual(seq12.length, 12);
285
+ assert.strictEqual(seq12.length, 12);
286
286
  });
287
287
  });
@@ -1,18 +1,18 @@
1
- import {
2
- type ChangeArrayElement,
3
- type ConstrainedList,
4
- type FixedLengthTuple,
5
- type Increment,
6
- type IsFixedLengthList,
7
- type NonEmptyArray,
8
- type UnknownBrand,
1
+ import type {
2
+ ChangeArrayElement,
3
+ ConstrainedList,
4
+ FixedLengthTuple,
5
+ Increment,
6
+ IsFixedLengthList,
7
+ NonEmptyArray,
8
+ UnknownBrand,
9
9
  } from 'ts-type-forge';
10
10
  import { asPositiveUint32 } from '../../number/index.mjs';
11
11
  import { castMutable } from '../../others/index.mjs';
12
- import {
13
- type ArgArrayIndex,
14
- type ArgArrayIndexWithNegative,
15
- type SizeType,
12
+ import type {
13
+ ArgArrayIndex,
14
+ ArgArrayIndexWithNegative,
15
+ SizeType,
16
16
  } from '../../types.mjs';
17
17
  import { copy, create } from './array-utils-creation.mjs';
18
18
 
@@ -1,13 +1,13 @@
1
- import {
2
- type BoundedLengthArray,
3
- type FixedLengthArray,
4
- type FixedLengthTuple,
5
- type MinLengthArray,
6
- type NonEmptyArray,
1
+ import type {
2
+ BoundedLengthArray,
3
+ FixedLengthArray,
4
+ FixedLengthTuple,
5
+ MinLengthArray,
6
+ NonEmptyArray,
7
7
  } from 'ts-type-forge';
8
8
  import { expectType } from '../../expect-type.mjs';
9
9
  import { asUint32 } from '../../number/index.mjs';
10
- import { type SizeType } from '../../types.mjs';
10
+ import type { SizeType } from '../../types.mjs';
11
11
  import {
12
12
  asBoundedLengthArray,
13
13
  asFixedLengthArray,
@@ -1,6 +1,6 @@
1
1
  import { expectType } from '../../expect-type.mjs';
2
2
  import { pipe } from '../../functional/index.mjs';
3
- import { type SizeType } from '../../types.mjs';
3
+ import type { SizeType } from '../../types.mjs';
4
4
  import { range } from './array-utils-creation.mjs';
5
5
  import { findIndex } from './array-utils-search.mjs';
6
6
  import { filterNot, partition } from './array-utils-transformation.mjs';