ts-data-forge 4.0.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/dist/entry-point.mjs +2 -0
  2. package/dist/entry-point.mjs.map +1 -1
  3. package/dist/functional/index.d.mts +1 -0
  4. package/dist/functional/index.d.mts.map +1 -1
  5. package/dist/functional/index.mjs +2 -0
  6. package/dist/functional/index.mjs.map +1 -1
  7. package/dist/functional/ternary-result/impl/index.d.mts +29 -0
  8. package/dist/functional/ternary-result/impl/index.d.mts.map +1 -0
  9. package/dist/functional/ternary-result/impl/index.mjs +28 -0
  10. package/dist/functional/ternary-result/impl/index.mjs.map +1 -0
  11. package/dist/functional/ternary-result/impl/tag.d.mts +7 -0
  12. package/dist/functional/ternary-result/impl/tag.d.mts.map +1 -0
  13. package/dist/functional/ternary-result/impl/tag.mjs +9 -0
  14. package/dist/functional/ternary-result/impl/tag.mjs.map +1 -0
  15. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts +14 -0
  16. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -0
  17. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +21 -0
  18. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -0
  19. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts +18 -0
  20. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts.map +1 -0
  21. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +24 -0
  22. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -0
  23. package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts +29 -0
  24. package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts.map +1 -0
  25. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +41 -0
  26. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -0
  27. package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts +27 -0
  28. package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts.map +1 -0
  29. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +36 -0
  30. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -0
  31. package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts +20 -0
  32. package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +1 -0
  33. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +24 -0
  34. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -0
  35. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts +17 -0
  36. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -0
  37. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +33 -0
  38. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -0
  39. package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts +20 -0
  40. package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts.map +1 -0
  41. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +23 -0
  42. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -0
  43. package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts +21 -0
  44. package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +1 -0
  45. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +24 -0
  46. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -0
  47. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts +17 -0
  48. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +1 -0
  49. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +28 -0
  50. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -0
  51. package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts +21 -0
  52. package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +1 -0
  53. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +24 -0
  54. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -0
  55. package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts +23 -0
  56. package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts.map +1 -0
  57. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +26 -0
  58. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -0
  59. package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts +21 -0
  60. package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts.map +1 -0
  61. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +29 -0
  62. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -0
  63. package/dist/functional/ternary-result/impl/ternary-result-map.d.mts +29 -0
  64. package/dist/functional/ternary-result/impl/ternary-result-map.d.mts.map +1 -0
  65. package/dist/functional/ternary-result/impl/ternary-result-map.mjs +35 -0
  66. package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -0
  67. package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts +16 -0
  68. package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -0
  69. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +23 -0
  70. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -0
  71. package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts +26 -0
  72. package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts.map +1 -0
  73. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +19 -0
  74. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -0
  75. package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts +16 -0
  76. package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +1 -0
  77. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +25 -0
  78. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -0
  79. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts +22 -0
  80. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts.map +1 -0
  81. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +17 -0
  82. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -0
  83. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts +18 -0
  84. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +1 -0
  85. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +36 -0
  86. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -0
  87. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts +17 -0
  88. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +1 -0
  89. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +22 -0
  90. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -0
  91. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts +22 -0
  92. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts.map +1 -0
  93. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +17 -0
  94. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -0
  95. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts +17 -0
  96. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts.map +1 -0
  97. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +13 -0
  98. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -0
  99. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts +18 -0
  100. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -0
  101. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +36 -0
  102. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -0
  103. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts +19 -0
  104. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts.map +1 -0
  105. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +17 -0
  106. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -0
  107. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts +18 -0
  108. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +1 -0
  109. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +32 -0
  110. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -0
  111. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts +17 -0
  112. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +1 -0
  113. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +22 -0
  114. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -0
  115. package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts +18 -0
  116. package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -0
  117. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +26 -0
  118. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -0
  119. package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts +26 -0
  120. package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -0
  121. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +48 -0
  122. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -0
  123. package/dist/functional/ternary-result/impl/types.d.mts +25 -0
  124. package/dist/functional/ternary-result/impl/types.d.mts.map +1 -0
  125. package/dist/functional/ternary-result/impl/types.mjs +2 -0
  126. package/dist/functional/ternary-result/impl/types.mjs.map +1 -0
  127. package/dist/functional/ternary-result/impl/variant-name.d.mts +3 -0
  128. package/dist/functional/ternary-result/impl/variant-name.d.mts.map +1 -0
  129. package/dist/functional/ternary-result/impl/variant-name.mjs +16 -0
  130. package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -0
  131. package/dist/functional/ternary-result/index.d.mts +2 -0
  132. package/dist/functional/ternary-result/index.d.mts.map +1 -0
  133. package/dist/functional/ternary-result/index.mjs +3 -0
  134. package/dist/functional/ternary-result/index.mjs.map +1 -0
  135. package/dist/globals.d.mts +55 -2
  136. package/dist/json/json.d.mts +9 -3
  137. package/dist/json/json.d.mts.map +1 -1
  138. package/dist/json/json.mjs +6 -0
  139. package/dist/json/json.mjs.map +1 -1
  140. package/package.json +13 -13
  141. package/src/array/impl/array-utils-creation.test.mts +187 -74
  142. package/src/array/impl/array-utils-element-access.test.mts +19 -3
  143. package/src/array/impl/array-utils-iterators.test.mts +44 -24
  144. package/src/array/impl/array-utils-modification.test.mts +36 -33
  145. package/src/array/impl/array-utils-reducing-value.test.mts +47 -16
  146. package/src/array/impl/array-utils-search.test.mts +42 -9
  147. package/src/array/impl/array-utils-set-op.test.mts +54 -26
  148. package/src/array/impl/array-utils-size.test.mts +1 -0
  149. package/src/array/impl/array-utils-slice-clamped.test.mts +20 -11
  150. package/src/array/impl/array-utils-slicing.test.mts +27 -21
  151. package/src/array/impl/array-utils-transformation.test.mts +140 -92
  152. package/src/array/impl/array-utils-validation.test.mts +58 -10
  153. package/src/array/impl/array.test.mts +5 -5
  154. package/src/collections/imap-mapped.test.mts +63 -18
  155. package/src/collections/imap.test.mts +74 -26
  156. package/src/collections/iset-mapped.test.mts +81 -30
  157. package/src/collections/iset.test.mts +168 -68
  158. package/src/collections/queue.test.mts +32 -1
  159. package/src/collections/stack.test.mts +22 -8
  160. package/src/functional/index.mts +1 -0
  161. package/src/functional/match.test.mts +1 -1
  162. package/src/functional/optional.test.mts +61 -4
  163. package/src/functional/pipe.test.mts +10 -1
  164. package/src/functional/result.test.mts +127 -4
  165. package/src/functional/ternary-result/impl/index.mts +28 -0
  166. package/src/functional/ternary-result/impl/tag.mts +11 -0
  167. package/src/functional/ternary-result/impl/ternary-result-err.mts +18 -0
  168. package/src/functional/ternary-result/impl/ternary-result-expect-to-be.mts +53 -0
  169. package/src/functional/ternary-result/impl/ternary-result-flat-map.mts +95 -0
  170. package/src/functional/ternary-result/impl/ternary-result-fold.mts +93 -0
  171. package/src/functional/ternary-result/impl/ternary-result-from-promise.mts +27 -0
  172. package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +31 -0
  173. package/src/functional/ternary-result/impl/ternary-result-is-err.mts +23 -0
  174. package/src/functional/ternary-result/impl/ternary-result-is-ok.mts +24 -0
  175. package/src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts +27 -0
  176. package/src/functional/ternary-result/impl/ternary-result-is-warn.mts +24 -0
  177. package/src/functional/ternary-result/impl/ternary-result-map-err.mts +64 -0
  178. package/src/functional/ternary-result/impl/ternary-result-map-warn.mts +66 -0
  179. package/src/functional/ternary-result/impl/ternary-result-map.mts +81 -0
  180. package/src/functional/ternary-result/impl/ternary-result-ok.mts +20 -0
  181. package/src/functional/ternary-result/impl/ternary-result-or-else.mts +66 -0
  182. package/src/functional/ternary-result/impl/ternary-result-to-optional.mts +25 -0
  183. package/src/functional/ternary-result/impl/ternary-result-unwrap-err-or.mts +45 -0
  184. package/src/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mts +40 -0
  185. package/src/functional/ternary-result/impl/ternary-result-unwrap-err.mts +22 -0
  186. package/src/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mts +45 -0
  187. package/src/functional/ternary-result/impl/ternary-result-unwrap-ok.mts +32 -0
  188. package/src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts +45 -0
  189. package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mts +42 -0
  190. package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mts +38 -0
  191. package/src/functional/ternary-result/impl/ternary-result-unwrap-warn.mts +22 -0
  192. package/src/functional/ternary-result/impl/ternary-result-warn.mts +23 -0
  193. package/src/functional/ternary-result/impl/ternary-result-zip.mts +53 -0
  194. package/src/functional/ternary-result/impl/types.mts +39 -0
  195. package/src/functional/ternary-result/impl/variant-name.mts +17 -0
  196. package/src/functional/ternary-result/index.mts +1 -0
  197. package/src/functional/ternary-result.test.mts +214 -0
  198. package/src/globals.d.mts +55 -2
  199. package/src/guard/is-non-empty-string.test.mts +5 -2
  200. package/src/guard/is-non-null-object.test.mts +3 -5
  201. package/src/guard/is-primitive.test.mts +5 -3
  202. package/src/guard/is-record.test.mts +1 -1
  203. package/src/guard/is-type.test.mts +35 -20
  204. package/src/guard/key-is-in.test.mts +1 -1
  205. package/src/iterator/range.test.mts +22 -16
  206. package/src/json/json.mts +9 -3
  207. package/src/json/json.test.mts +140 -64
  208. package/src/number/branded-types/finite-number.test.mts +3 -2
  209. package/src/number/branded-types/int.test.mts +4 -3
  210. package/src/number/branded-types/int16.test.mts +9 -3
  211. package/src/number/branded-types/int32.test.mts +9 -3
  212. package/src/number/branded-types/non-negative-finite-number.test.mts +6 -4
  213. package/src/number/branded-types/non-negative-int16.test.mts +8 -3
  214. package/src/number/branded-types/non-negative-int32.test.mts +8 -3
  215. package/src/number/branded-types/non-zero-finite-number.test.mts +6 -3
  216. package/src/number/branded-types/non-zero-int.test.mts +6 -3
  217. package/src/number/branded-types/non-zero-int16.test.mts +9 -3
  218. package/src/number/branded-types/non-zero-int32.test.mts +9 -3
  219. package/src/number/branded-types/non-zero-safe-int.test.mts +10 -3
  220. package/src/number/branded-types/non-zero-uint16.test.mts +8 -3
  221. package/src/number/branded-types/non-zero-uint32.test.mts +8 -3
  222. package/src/number/branded-types/positive-finite-number.test.mts +7 -3
  223. package/src/number/branded-types/positive-int.test.mts +5 -3
  224. package/src/number/branded-types/positive-int16.test.mts +8 -3
  225. package/src/number/branded-types/positive-int32.test.mts +8 -3
  226. package/src/number/branded-types/positive-safe-int.test.mts +8 -3
  227. package/src/number/branded-types/positive-uint16.test.mts +8 -3
  228. package/src/number/branded-types/positive-uint32.test.mts +8 -3
  229. package/src/number/branded-types/safe-int.test.mts +8 -2
  230. package/src/number/branded-types/safe-uint.test.mts +8 -3
  231. package/src/number/branded-types/uint.test.mts +5 -3
  232. package/src/number/branded-types/uint16.test.mts +8 -3
  233. package/src/number/branded-types/uint32.test.mts +8 -3
  234. package/src/number/enum/int8.test.mts +8 -3
  235. package/src/number/enum/uint8.test.mts +6 -3
  236. package/src/number/num.test.mts +16 -2
  237. package/src/object/object.test.mts +26 -13
  238. package/src/others/cast-mutable.test.mts +10 -8
  239. package/src/others/cast-readonly.test.mts +9 -5
  240. package/src/others/if-then.test.mts +4 -1
  241. package/src/others/map-nullable.test.mts +28 -1
  242. package/src/others/memoize-function.test.mts +20 -17
  243. package/src/others/tuple.test.mts +3 -2
  244. package/src/others/unknown-to-string.test.mts +15 -2
  245. package/src/promise/promise.test.mts +6 -1
@@ -9,12 +9,13 @@ import {
9
9
  } from './array-utils-set-op.mjs';
10
10
 
11
11
  describe('Arr set operations', () => {
12
- describe('eq', () => {
12
+ describe(eq, () => {
13
13
  {
14
14
  const xs = [1, 2, 3] as const;
15
15
  const ys = [1, 2, 3] as const;
16
16
  const result = eq(xs, ys);
17
17
  expectType<typeof result, boolean>('=');
18
+
18
19
  test('should return true for equal arrays of numbers', () => {
19
20
  expect(result).toBe(true);
20
21
  });
@@ -24,6 +25,7 @@ describe('Arr set operations', () => {
24
25
  const ys = [1, 2, 4] as const;
25
26
  const result = eq(xs, ys);
26
27
  expectType<typeof result, boolean>('=');
28
+
27
29
  test('should return false for different arrays of numbers', () => {
28
30
  expect(result).toBe(false);
29
31
  });
@@ -33,6 +35,7 @@ describe('Arr set operations', () => {
33
35
  const ys = [1, 2] as const;
34
36
  const result = eq(xs, ys);
35
37
  expectType<typeof result, boolean>('=');
38
+
36
39
  test('should return false for arrays of different lengths', () => {
37
40
  expect(result).toBe(false);
38
41
  });
@@ -42,6 +45,7 @@ describe('Arr set operations', () => {
42
45
  const ys = ['a', 'b'] as const;
43
46
  const result = eq(xs, ys);
44
47
  expectType<typeof result, boolean>('=');
48
+
45
49
  test('should return true for equal arrays of strings', () => {
46
50
  expect(result).toBe(true);
47
51
  });
@@ -51,6 +55,7 @@ describe('Arr set operations', () => {
51
55
  const ys = [] as const;
52
56
  const result = eq(xs, ys);
53
57
  expectType<typeof result, boolean>('=');
58
+
54
59
  test('should return true for empty arrays', () => {
55
60
  expect(result).toBe(true);
56
61
  });
@@ -61,6 +66,7 @@ describe('Arr set operations', () => {
61
66
  // Default eq uses reference equality for objects
62
67
  const result = eq(xs, ys);
63
68
  expectType<typeof result, boolean>('=');
69
+
64
70
  test('should return false for arrays of objects with default equality (reference check)', () => {
65
71
  expect(result).toBe(false);
66
72
  });
@@ -72,6 +78,7 @@ describe('Arr set operations', () => {
72
78
  const ys = [objA, objB] as const;
73
79
  const result = eq(xs, ys);
74
80
  expectType<typeof result, boolean>('=');
81
+
75
82
  test('should return true for arrays of same object references', () => {
76
83
  expect(result).toBe(true);
77
84
  });
@@ -85,13 +92,14 @@ describe('Arr set operations', () => {
85
92
  (o1, o2) => JSON.stringify(o1) === JSON.stringify(o2),
86
93
  );
87
94
  expectType<typeof result, boolean>('=');
95
+
88
96
  test('should return true for arrays of objects with custom equality function', () => {
89
97
  expect(result).toBe(true);
90
98
  });
91
99
  }
92
100
  });
93
101
 
94
- describe('isSubset', () => {
102
+ describe(isSubset, () => {
95
103
  {
96
104
  const xs = [1, 2, 3] as const;
97
105
  const ys = [3, 2] as const;
@@ -118,7 +126,7 @@ describe('Arr set operations', () => {
118
126
  }
119
127
  });
120
128
 
121
- describe('isSuperset', () => {
129
+ describe(isSuperset, () => {
122
130
  {
123
131
  const xs = [1, 2, 3] as const;
124
132
  const ys = [3, 2] as const;
@@ -151,14 +159,15 @@ describe('Arr set operations', () => {
151
159
  }
152
160
  });
153
161
 
154
- describe('setIntersection', () => {
162
+ describe(setIntersection, () => {
155
163
  {
156
164
  const xs = [1, 2, 3] as const;
157
165
  const ys = [2, 3, 4] as const;
158
166
  const result = setIntersection(xs, ys);
159
167
  expectType<typeof result, readonly (2 | 3)[]>('=');
168
+
160
169
  test('should return the intersection of two number arrays', () => {
161
- expect(result).toStrictEqual([2, 3]);
170
+ assert.deepStrictEqual(result, [2, 3]);
162
171
  });
163
172
  }
164
173
  {
@@ -166,8 +175,9 @@ describe('Arr set operations', () => {
166
175
  const ys = ['b', 'c', 'd'] as const;
167
176
  const result = setIntersection(xs, ys);
168
177
  expectType<typeof result, readonly ('b' | 'c')[]>('=');
178
+
169
179
  test('should return the intersection of two string arrays', () => {
170
- expect(result).toStrictEqual(['b', 'c']);
180
+ assert.deepStrictEqual(result, ['b', 'c']);
171
181
  });
172
182
  }
173
183
  {
@@ -175,8 +185,9 @@ describe('Arr set operations', () => {
175
185
  const ys = [4, 5, 6] as const;
176
186
  const result = setIntersection(xs, ys);
177
187
  expectType<typeof result, readonly never[]>('=');
188
+
178
189
  test('should return an empty array if there is no intersection', () => {
179
- expect(result).toStrictEqual([]);
190
+ assert.deepStrictEqual(result, []);
180
191
  });
181
192
  }
182
193
  {
@@ -184,8 +195,9 @@ describe('Arr set operations', () => {
184
195
  const ys = [] as const;
185
196
  const result = setIntersection(xs, ys);
186
197
  expectType<typeof result, readonly never[]>('=');
198
+
187
199
  test('should return an empty array if one array is empty', () => {
188
- expect(result).toStrictEqual([]);
200
+ assert.deepStrictEqual(result, []);
189
201
  });
190
202
  }
191
203
  {
@@ -193,20 +205,22 @@ describe('Arr set operations', () => {
193
205
  const ys = [1, 2, 3] as const;
194
206
  const result = setIntersection(xs, ys);
195
207
  expectType<typeof result, readonly never[]>('=');
208
+
196
209
  test('should return an empty array if the first array is empty', () => {
197
- expect(result).toStrictEqual([]);
210
+ assert.deepStrictEqual(result, []);
198
211
  });
199
212
  }
200
213
  });
201
214
 
202
- describe('setDifference', () => {
215
+ describe(setDifference, () => {
203
216
  {
204
217
  const xs = [1, 2, 3] as const;
205
218
  const ys = [2, 3, 4] as const;
206
219
  const result = setDifference(xs, ys);
207
220
  expectType<typeof result, readonly (1 | 2 | 3 | 4)[]>('=');
221
+
208
222
  test('should return the difference xs - ys for number arrays', () => {
209
- expect(result).toStrictEqual([1]);
223
+ assert.deepStrictEqual(result, [1]);
210
224
  });
211
225
  }
212
226
  {
@@ -214,8 +228,9 @@ describe('Arr set operations', () => {
214
228
  const ys = ['b', 'c', 'd'] as const;
215
229
  const result = setDifference(xs, ys);
216
230
  expectType<typeof result, readonly ('a' | 'b' | 'c' | 'd')[]>('=');
231
+
217
232
  test('should return the difference xs - ys for string arrays', () => {
218
- expect(result).toStrictEqual(['a']);
233
+ assert.deepStrictEqual(result, ['a']);
219
234
  });
220
235
  }
221
236
  {
@@ -223,8 +238,9 @@ describe('Arr set operations', () => {
223
238
  const ys = [1, 2, 3] as const;
224
239
  const result = setDifference(xs, ys);
225
240
  expectType<typeof result, readonly (1 | 2 | 3)[]>('=');
241
+
226
242
  test('should return an empty array if xs is a subset of ys', () => {
227
- expect(result).toStrictEqual([]);
243
+ assert.deepStrictEqual(result, []);
228
244
  });
229
245
  }
230
246
  {
@@ -232,8 +248,9 @@ describe('Arr set operations', () => {
232
248
  const ys = [4, 5, 6] as const;
233
249
  const result = setDifference(xs, ys);
234
250
  expectType<typeof result, readonly (1 | 2 | 3 | 4 | 5 | 6)[]>('=');
251
+
235
252
  test('should return xs if there is no intersection', () => {
236
- expect(result).toStrictEqual([1, 2, 3]);
253
+ assert.deepStrictEqual(result, [1, 2, 3]);
237
254
  });
238
255
  }
239
256
  {
@@ -241,8 +258,9 @@ describe('Arr set operations', () => {
241
258
  const ys = [] as const;
242
259
  const result = setDifference(xs, ys);
243
260
  expectType<typeof result, readonly (1 | 2 | 3)[]>('=');
261
+
244
262
  test('should return xs if ys is empty', () => {
245
- expect(result).toStrictEqual([1, 2, 3]);
263
+ assert.deepStrictEqual(result, [1, 2, 3]);
246
264
  });
247
265
  }
248
266
  {
@@ -250,20 +268,22 @@ describe('Arr set operations', () => {
250
268
  const ys = [1, 2, 3] as const;
251
269
  const result = setDifference(xs, ys);
252
270
  expectType<typeof result, readonly (1 | 2 | 3)[]>('=');
271
+
253
272
  test('should return an empty array if xs is empty', () => {
254
- expect(result).toStrictEqual([]);
273
+ assert.deepStrictEqual(result, []);
255
274
  });
256
275
  }
257
276
  });
258
277
 
259
- describe('sortedNumSetDifference', () => {
278
+ describe(sortedNumSetDifference, () => {
260
279
  {
261
280
  const xs = [1, 2, 3, 5] as const;
262
281
  const ys = [2, 3, 4] as const;
263
282
  const result = sortedNumSetDifference(xs, ys);
264
283
  expectType<typeof result, readonly (1 | 2 | 3 | 4 | 5)[]>('=');
284
+
265
285
  test('should return the difference for sorted number arrays (xs - ys)', () => {
266
- expect(result).toStrictEqual([1, 5]);
286
+ assert.deepStrictEqual(result, [1, 5]);
267
287
  });
268
288
  }
269
289
  {
@@ -271,8 +291,9 @@ describe('Arr set operations', () => {
271
291
  const ys = [1, 2, 3] as const;
272
292
  const result = sortedNumSetDifference(xs, ys);
273
293
  expectType<typeof result, readonly (1 | 2 | 3)[]>('=');
294
+
274
295
  test('should return an empty array if sets are equal', () => {
275
- expect(result).toStrictEqual([]);
296
+ assert.deepStrictEqual(result, []);
276
297
  });
277
298
  }
278
299
  {
@@ -280,8 +301,9 @@ describe('Arr set operations', () => {
280
301
  const ys = [4, 5, 6] as const;
281
302
  const result = sortedNumSetDifference(xs, ys);
282
303
  expectType<typeof result, readonly (1 | 2 | 3 | 4 | 5 | 6)[]>('=');
304
+
283
305
  test('should return xs if no common elements', () => {
284
- expect(result).toStrictEqual([1, 2, 3]);
306
+ assert.deepStrictEqual(result, [1, 2, 3]);
285
307
  });
286
308
  }
287
309
  {
@@ -289,8 +311,9 @@ describe('Arr set operations', () => {
289
311
  const ys = [1, 2, 3] as const;
290
312
  const result = sortedNumSetDifference(xs, ys);
291
313
  expectType<typeof result, readonly (1 | 2 | 3 | 4 | 5 | 6)[]>('=');
314
+
292
315
  test('should return xs if no common elements (ys < xs)', () => {
293
- expect(result).toStrictEqual([4, 5, 6]);
316
+ assert.deepStrictEqual(result, [4, 5, 6]);
294
317
  });
295
318
  }
296
319
  {
@@ -298,8 +321,9 @@ describe('Arr set operations', () => {
298
321
  const ys = [2, 4] as const;
299
322
  const result = sortedNumSetDifference(xs, ys);
300
323
  expectType<typeof result, readonly (1 | 2 | 3 | 4 | 5)[]>('=');
324
+
301
325
  test('should return correct difference when ys is subset of xs', () => {
302
- expect(result).toStrictEqual([1, 3, 5]);
326
+ assert.deepStrictEqual(result, [1, 3, 5]);
303
327
  });
304
328
  }
305
329
  {
@@ -307,8 +331,9 @@ describe('Arr set operations', () => {
307
331
  const ys = [1, 2, 3, 4, 5] as const;
308
332
  const result = sortedNumSetDifference(xs, ys);
309
333
  expectType<typeof result, readonly (1 | 2 | 3 | 4 | 5)[]>('=');
334
+
310
335
  test('should return empty array when xs is subset of ys', () => {
311
- expect(result).toStrictEqual([]);
336
+ assert.deepStrictEqual(result, []);
312
337
  });
313
338
  }
314
339
  {
@@ -316,8 +341,9 @@ describe('Arr set operations', () => {
316
341
  const ys = [1, 2, 3] as const;
317
342
  const result = sortedNumSetDifference(xs, ys);
318
343
  expectType<typeof result, readonly (1 | 2 | 3)[]>('='); // Type is `readonly number[]` due to `ys`
344
+
319
345
  test('should return an empty array if xs is empty', () => {
320
- expect(result).toStrictEqual([]);
346
+ assert.deepStrictEqual(result, []);
321
347
  });
322
348
  }
323
349
  {
@@ -325,8 +351,9 @@ describe('Arr set operations', () => {
325
351
  const ys = [] as const;
326
352
  const result = sortedNumSetDifference(xs, ys);
327
353
  expectType<typeof result, readonly (1 | 2 | 3)[]>('=');
354
+
328
355
  test('should return xs if ys is empty', () => {
329
- expect(result).toStrictEqual([1, 2, 3]);
356
+ assert.deepStrictEqual(result, [1, 2, 3]);
330
357
  });
331
358
  }
332
359
  {
@@ -334,8 +361,9 @@ describe('Arr set operations', () => {
334
361
  const ys = [] as const;
335
362
  const result = sortedNumSetDifference(xs, ys);
336
363
  expectType<typeof result, readonly never[]>('='); // Type is `readonly number[]`
364
+
337
365
  test('should return an empty array if both are empty', () => {
338
- expect(result).toStrictEqual([]);
366
+ assert.deepStrictEqual(result, []);
339
367
  });
340
368
  }
341
369
  });
@@ -3,6 +3,7 @@ import { length, size } from './array-utils-size.mjs';
3
3
  describe('size/length', () => {
4
4
  test('size should return the array length', () => {
5
5
  const array = [1, 2, 3];
6
+
6
7
  expect(size(array)).toBe(array.length);
7
8
  expect(length(array)).toBe(3);
8
9
  });
@@ -2,7 +2,7 @@ import { asInt32, asUint32 } from '../../number/index.mjs';
2
2
  import { sliceClamped } from './array-utils-slice-clamped.mjs';
3
3
 
4
4
  describe('Arr', () => {
5
- describe('sliceClamped', () => {
5
+ describe(sliceClamped, () => {
6
6
  {
7
7
  const list: readonly number[] = [0, 1, 2, 3, 4] as const;
8
8
 
@@ -73,7 +73,7 @@ describe('Arr', () => {
73
73
  expected: [],
74
74
  },
75
75
  ] as const)('sliceClamped($start, $end)', ({ end, expected, start }) => {
76
- expect(sliceClamped(list, start, end)).toStrictEqual(expected);
76
+ assert.deepStrictEqual(sliceClamped(list, start, end), expected);
77
77
  });
78
78
  }
79
79
 
@@ -82,56 +82,65 @@ describe('Arr', () => {
82
82
  const array = [1, 2, 3, 4, 5] as const;
83
83
  // @ts-expect-error end index is out of bounds
84
84
  const result = sliceClamped(array, 0, 6);
85
- expect(result).toStrictEqual(array);
85
+
86
+ assert.deepStrictEqual(result, array);
86
87
  }
87
88
  {
88
89
  const array = [1, 2, 3, 4, 5] as const;
89
90
  // @ts-expect-error end index is out of bounds
90
91
  const result = sliceClamped(array, 0, -6);
91
- expect(result).toStrictEqual([]);
92
+
93
+ assert.deepStrictEqual(result, []);
92
94
  }
93
95
  {
94
96
  const array = [1, 2, 3, 4, 5] as const;
95
97
  // @ts-expect-error start index is out of bounds
96
98
  const result = sliceClamped(array, -6, 5);
97
- expect(result).toStrictEqual(array);
99
+
100
+ assert.deepStrictEqual(result, array);
98
101
  }
99
102
  {
100
103
  const array = [1, 2, 3, 4, 5] as const;
101
104
  // @ts-expect-error start index is out of bounds
102
105
  const result = sliceClamped(array, 6, 5);
103
- expect(result).toStrictEqual([]);
106
+
107
+ assert.deepStrictEqual(result, []);
104
108
  }
105
109
  });
106
110
 
107
111
  test('should slice with clamped indices', () => {
108
112
  const array = [1, 2, 3, 4, 5];
109
113
  const result = sliceClamped(array, 1, 3);
110
- expect(result).toStrictEqual([2, 3]);
114
+
115
+ assert.deepStrictEqual(result, [2, 3]);
111
116
  });
112
117
 
113
118
  test('should clamp start index below 0', () => {
114
119
  const array = [1, 2, 3, 4, 5];
115
120
  const result = sliceClamped(array, -10, 3);
116
- expect(result).toStrictEqual([1, 2, 3]);
121
+
122
+ assert.deepStrictEqual(result, [1, 2, 3]);
117
123
  });
118
124
 
119
125
  test('should clamp end index above length', () => {
120
126
  const array = [1, 2, 3, 4, 5];
121
127
  const result = sliceClamped(array, asUint32(2), asUint32(100));
122
- expect(result).toStrictEqual([3, 4, 5]);
128
+
129
+ assert.deepStrictEqual(result, [3, 4, 5]);
123
130
  });
124
131
 
125
132
  test('should work with both indices out of range', () => {
126
133
  const array = [1, 2, 3];
127
134
  const result = sliceClamped(array, asInt32(-10), asUint32(100));
128
- expect(result).toStrictEqual([1, 2, 3]);
135
+
136
+ assert.deepStrictEqual(result, [1, 2, 3]);
129
137
  });
130
138
 
131
139
  test('should work with empty array', () => {
132
140
  const array: readonly number[] = [];
133
141
  const result = sliceClamped(array, 0, 5);
134
- expect(result).toStrictEqual([]);
142
+
143
+ assert.deepStrictEqual(result, []);
135
144
  });
136
145
  });
137
146
  });
@@ -9,62 +9,68 @@ import {
9
9
  } from './array-utils-slicing.mjs';
10
10
 
11
11
  describe('Arr slicing', () => {
12
- describe('tail', () => {
12
+ describe(tail, () => {
13
13
  test('should return all elements except the first', () => {
14
14
  const array = [1, 2, 3, 4] as const;
15
15
  const result = tail(array);
16
16
  expectType<typeof result, readonly [2, 3, 4]>('=');
17
- expect(result).toStrictEqual([2, 3, 4]);
17
+
18
+ assert.deepStrictEqual(result, [2, 3, 4]);
18
19
  });
19
20
 
20
21
  test('should work with single element array', () => {
21
22
  const array = [1] as const;
22
23
  const result = tail(array);
23
24
  expectType<typeof result, readonly []>('=');
24
- expect(result).toStrictEqual([]);
25
+
26
+ assert.deepStrictEqual(result, []);
25
27
  });
26
28
 
27
29
  test('should work with empty array', () => {
28
30
  const array = [] as const;
29
31
  const result = tail(array);
30
32
  expectType<typeof result, readonly []>('=');
31
- expect(result).toStrictEqual([]);
33
+
34
+ assert.deepStrictEqual(result, []);
32
35
  });
33
36
  });
34
37
 
35
- describe('butLast', () => {
38
+ describe(butLast, () => {
36
39
  test('readonly number[] type', () => {
37
40
  const xs: readonly number[] = [1, 2, 3];
38
41
  const bl = butLast(xs);
39
42
 
40
43
  expectType<typeof bl, readonly number[]>('=');
41
44
 
42
- expect(bl).toStrictEqual([1, 2]);
45
+ assert.deepStrictEqual(bl, [1, 2]);
43
46
  });
44
47
 
45
48
  test('should return all elements except the last', () => {
46
49
  const array = [1, 2, 3, 4] as const;
47
50
  const result = butLast(array);
48
51
  expectType<typeof result, readonly [1, 2, 3]>('=');
49
- expect(result).toStrictEqual([1, 2, 3]);
52
+
53
+ assert.deepStrictEqual(result, [1, 2, 3]);
50
54
  });
51
55
 
52
56
  test('should work with single element array', () => {
53
57
  const array = [1] as const;
54
58
  const result = butLast(array);
55
59
  expectType<typeof result, readonly []>('=');
56
- expect(result).toStrictEqual([]);
60
+
61
+ assert.deepStrictEqual(result, []);
57
62
  });
58
63
 
59
64
  test('should work with empty array', () => {
60
65
  const array = [] as const;
61
66
  const result = butLast(array);
62
67
  expectType<typeof result, readonly []>('=');
63
- expect(result).toStrictEqual([]);
68
+
69
+ assert.deepStrictEqual(result, []);
64
70
  });
65
71
  });
66
72
 
67
- describe('take', () => {
73
+ describe(take, () => {
68
74
  {
69
75
  const xs = [1, 2, 3] as const;
70
76
  const t = take(xs, 2);
@@ -72,7 +78,7 @@ describe('Arr slicing', () => {
72
78
  expectType<typeof t, readonly [1, 2]>('=');
73
79
 
74
80
  test('case 1', () => {
75
- expect(t).toStrictEqual([1, 2]);
81
+ assert.deepStrictEqual(t, [1, 2]);
76
82
  });
77
83
  }
78
84
  {
@@ -82,12 +88,12 @@ describe('Arr slicing', () => {
82
88
  expectType<typeof t, readonly number[]>('=');
83
89
 
84
90
  test('case 2', () => {
85
- expect(t).toStrictEqual([1, 2]);
91
+ assert.deepStrictEqual(t, [1, 2]);
86
92
  });
87
93
  }
88
94
  });
89
95
 
90
- describe('takeLast', () => {
96
+ describe(takeLast, () => {
91
97
  {
92
98
  const xs = [1, 2, 3] as const;
93
99
  const t = takeLast(xs, 2);
@@ -95,7 +101,7 @@ describe('Arr slicing', () => {
95
101
  expectType<typeof t, readonly [2, 3]>('=');
96
102
 
97
103
  test('case 1', () => {
98
- expect(t).toStrictEqual([2, 3]);
104
+ assert.deepStrictEqual(t, [2, 3]);
99
105
  });
100
106
  }
101
107
  {
@@ -105,12 +111,12 @@ describe('Arr slicing', () => {
105
111
  expectType<typeof t, readonly number[]>('=');
106
112
 
107
113
  test('case 2', () => {
108
- expect(t).toStrictEqual([2, 3]);
114
+ assert.deepStrictEqual(t, [2, 3]);
109
115
  });
110
116
  }
111
117
  });
112
118
 
113
- describe('skip', () => {
119
+ describe(skip, () => {
114
120
  {
115
121
  const xs = [1, 2, 3] as const;
116
122
  const t = skip(xs, 2);
@@ -118,7 +124,7 @@ describe('Arr slicing', () => {
118
124
  expectType<typeof t, readonly [3]>('=');
119
125
 
120
126
  test('case 1', () => {
121
- expect(t).toStrictEqual([3]);
127
+ assert.deepStrictEqual(t, [3]);
122
128
  });
123
129
  }
124
130
  {
@@ -128,12 +134,12 @@ describe('Arr slicing', () => {
128
134
  expectType<typeof t, readonly number[]>('=');
129
135
 
130
136
  test('case 2', () => {
131
- expect(t).toStrictEqual([3]);
137
+ assert.deepStrictEqual(t, [3]);
132
138
  });
133
139
  }
134
140
  });
135
141
 
136
- describe('skipLast', () => {
142
+ describe(skipLast, () => {
137
143
  {
138
144
  const xs = [1, 2, 3] as const;
139
145
  const t = skipLast(xs, 2);
@@ -141,7 +147,7 @@ describe('Arr slicing', () => {
141
147
  expectType<typeof t, readonly [1]>('=');
142
148
 
143
149
  test('case 1', () => {
144
- expect(t).toStrictEqual([1]);
150
+ assert.deepStrictEqual(t, [1]);
145
151
  });
146
152
  }
147
153
  {
@@ -151,7 +157,7 @@ describe('Arr slicing', () => {
151
157
  expectType<typeof t, readonly number[]>('=');
152
158
 
153
159
  test('case 2', () => {
154
- expect(t).toStrictEqual([1]);
160
+ assert.deepStrictEqual(t, [1]);
155
161
  });
156
162
  }
157
163
  });