ts-data-forge 4.1.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/array/impl/array-utils-element-access.mjs +1 -0
  2. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  3. package/dist/array/impl/array-utils-modification.mjs +1 -0
  4. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  5. package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
  6. package/dist/array/impl/array-utils-reducing-value.mjs +2 -1
  7. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  8. package/dist/array/impl/array-utils-search.mjs +1 -0
  9. package/dist/array/impl/array-utils-search.mjs.map +1 -1
  10. package/dist/array/impl/array-utils-transformation.mjs +1 -0
  11. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  12. package/dist/collections/imap-mapped.mjs +1 -0
  13. package/dist/collections/imap-mapped.mjs.map +1 -1
  14. package/dist/collections/imap.mjs +1 -0
  15. package/dist/collections/imap.mjs.map +1 -1
  16. package/dist/collections/queue.mjs +1 -0
  17. package/dist/collections/queue.mjs.map +1 -1
  18. package/dist/collections/stack.mjs +1 -0
  19. package/dist/collections/stack.mjs.map +1 -1
  20. package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -1
  21. package/dist/functional/result/impl/result-from-throwable.mjs +2 -1
  22. package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
  23. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -1
  24. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +2 -1
  25. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
  26. package/dist/json/json.d.mts +9 -3
  27. package/dist/json/json.d.mts.map +1 -1
  28. package/dist/json/json.mjs +7 -0
  29. package/dist/json/json.mjs.map +1 -1
  30. package/dist/number/refined-number-utils.mjs +1 -0
  31. package/dist/number/refined-number-utils.mjs.map +1 -1
  32. package/dist/others/unknown-to-string.d.mts.map +1 -1
  33. package/dist/others/unknown-to-string.mjs +2 -1
  34. package/dist/others/unknown-to-string.mjs.map +1 -1
  35. package/dist/promise/promise.mjs +1 -0
  36. package/dist/promise/promise.mjs.map +1 -1
  37. package/package.json +18 -18
  38. package/src/array/impl/array-utils-creation.test.mts +187 -74
  39. package/src/array/impl/array-utils-element-access.test.mts +19 -3
  40. package/src/array/impl/array-utils-iterators.test.mts +44 -24
  41. package/src/array/impl/array-utils-modification.test.mts +36 -33
  42. package/src/array/impl/array-utils-reducing-value.mts +2 -1
  43. package/src/array/impl/array-utils-reducing-value.test.mts +47 -16
  44. package/src/array/impl/array-utils-search.test.mts +42 -9
  45. package/src/array/impl/array-utils-set-op.test.mts +54 -26
  46. package/src/array/impl/array-utils-size.test.mts +1 -0
  47. package/src/array/impl/array-utils-slice-clamped.test.mts +20 -11
  48. package/src/array/impl/array-utils-slicing.test.mts +27 -21
  49. package/src/array/impl/array-utils-transformation.test.mts +140 -92
  50. package/src/array/impl/array-utils-validation.test.mts +58 -10
  51. package/src/array/impl/array.test.mts +5 -5
  52. package/src/collections/imap-mapped.test.mts +63 -18
  53. package/src/collections/imap.test.mts +74 -26
  54. package/src/collections/iset-mapped.test.mts +81 -30
  55. package/src/collections/iset.test.mts +168 -68
  56. package/src/collections/queue.test.mts +32 -1
  57. package/src/collections/stack.test.mts +22 -8
  58. package/src/functional/match.test.mts +1 -1
  59. package/src/functional/optional.test.mts +61 -4
  60. package/src/functional/pipe.test.mts +10 -1
  61. package/src/functional/result/impl/result-from-throwable.mts +2 -1
  62. package/src/functional/result.test.mts +127 -4
  63. package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +2 -1
  64. package/src/functional/ternary-result.test.mts +34 -18
  65. package/src/guard/is-non-empty-string.test.mts +5 -2
  66. package/src/guard/is-non-null-object.test.mts +3 -5
  67. package/src/guard/is-primitive.test.mts +5 -3
  68. package/src/guard/is-record.test.mts +1 -1
  69. package/src/guard/is-type.test.mts +35 -20
  70. package/src/guard/key-is-in.test.mts +1 -1
  71. package/src/iterator/range.test.mts +22 -16
  72. package/src/json/json.mts +9 -3
  73. package/src/json/json.test.mts +140 -64
  74. package/src/number/branded-types/finite-number.test.mts +3 -2
  75. package/src/number/branded-types/int.test.mts +4 -3
  76. package/src/number/branded-types/int16.test.mts +9 -3
  77. package/src/number/branded-types/int32.test.mts +9 -3
  78. package/src/number/branded-types/non-negative-finite-number.test.mts +6 -4
  79. package/src/number/branded-types/non-negative-int16.test.mts +8 -3
  80. package/src/number/branded-types/non-negative-int32.test.mts +8 -3
  81. package/src/number/branded-types/non-zero-finite-number.test.mts +6 -3
  82. package/src/number/branded-types/non-zero-int.test.mts +6 -3
  83. package/src/number/branded-types/non-zero-int16.test.mts +9 -3
  84. package/src/number/branded-types/non-zero-int32.test.mts +9 -3
  85. package/src/number/branded-types/non-zero-safe-int.test.mts +10 -3
  86. package/src/number/branded-types/non-zero-uint16.test.mts +8 -3
  87. package/src/number/branded-types/non-zero-uint32.test.mts +8 -3
  88. package/src/number/branded-types/positive-finite-number.test.mts +7 -3
  89. package/src/number/branded-types/positive-int.test.mts +5 -3
  90. package/src/number/branded-types/positive-int16.test.mts +8 -3
  91. package/src/number/branded-types/positive-int32.test.mts +8 -3
  92. package/src/number/branded-types/positive-safe-int.test.mts +8 -3
  93. package/src/number/branded-types/positive-uint16.test.mts +8 -3
  94. package/src/number/branded-types/positive-uint32.test.mts +8 -3
  95. package/src/number/branded-types/safe-int.test.mts +8 -2
  96. package/src/number/branded-types/safe-uint.test.mts +8 -3
  97. package/src/number/branded-types/uint.test.mts +5 -3
  98. package/src/number/branded-types/uint16.test.mts +8 -3
  99. package/src/number/branded-types/uint32.test.mts +8 -3
  100. package/src/number/enum/int8.test.mts +8 -3
  101. package/src/number/enum/uint8.test.mts +6 -3
  102. package/src/number/num.test.mts +16 -2
  103. package/src/object/object.test.mts +26 -13
  104. package/src/others/cast-mutable.test.mts +10 -8
  105. package/src/others/cast-readonly.test.mts +9 -5
  106. package/src/others/if-then.test.mts +4 -1
  107. package/src/others/map-nullable.test.mts +28 -1
  108. package/src/others/memoize-function.test.mts +20 -17
  109. package/src/others/tuple.test.mts +3 -2
  110. package/src/others/unknown-to-string.mts +2 -1
  111. package/src/others/unknown-to-string.test.mts +15 -2
  112. package/src/promise/promise.test.mts +6 -1
@@ -4,30 +4,34 @@ import { asInt32, asUint32 } from '../../number/index.mjs';
4
4
  import { at, head, last } from './array-utils-element-access.mjs';
5
5
 
6
6
  describe('Arr element access', () => {
7
- describe('at', () => {
7
+ describe(at, () => {
8
8
  test('should handle very large positive indices', () => {
9
9
  const array = [1, 2, 3];
10
10
  const result = at(array, asUint32(1000));
11
+
11
12
  expect(Optional.isNone(result)).toBe(true);
12
13
  });
13
14
 
14
15
  test('should handle very large negative indices', () => {
15
16
  const array = [1, 2, 3];
16
17
  const result = at(array, asInt32(-1000));
18
+
17
19
  expect(Optional.isNone(result)).toBe(true);
18
20
  });
19
21
 
20
22
  test('should work with valid indices', () => {
21
23
  const array = [10, 20, 30];
22
24
  const result = at(array, 1);
25
+
23
26
  expect(Optional.isSome(result)).toBe(true);
27
+
24
28
  if (Optional.isSome(result)) {
25
29
  expect(result.value).toBe(20);
26
30
  }
27
31
  });
28
32
  });
29
33
 
30
- describe('head', () => {
34
+ describe(head, () => {
31
35
  test('case 1', () => {
32
36
  const xs = [1, 2, 3] as const;
33
37
  const h = head(xs);
@@ -35,6 +39,7 @@ describe('Arr element access', () => {
35
39
  expectType<typeof h, Some<1>>('=');
36
40
 
37
41
  expect(Optional.isSome(h)).toBe(true);
42
+
38
43
  if (Optional.isSome(h)) {
39
44
  expect(h.value).toBe(1);
40
45
  }
@@ -47,6 +52,7 @@ describe('Arr element access', () => {
47
52
  expectType<typeof h, Some<number>>('=');
48
53
 
49
54
  expect(Optional.isSome(h)).toBe(true);
55
+
50
56
  if (Optional.isSome(h)) {
51
57
  expect(h.value).toBe(1);
52
58
  }
@@ -59,6 +65,7 @@ describe('Arr element access', () => {
59
65
  expectType<typeof h, Optional<number>>('=');
60
66
 
61
67
  expect(Optional.isSome(h)).toBe(true);
68
+
62
69
  if (Optional.isSome(h)) {
63
70
  expect(h.value).toBe(1);
64
71
  }
@@ -76,19 +83,22 @@ describe('Arr element access', () => {
76
83
 
77
84
  test('should return none for empty array', () => {
78
85
  const result = head([]);
86
+
79
87
  expect(Optional.isNone(result)).toBe(true);
80
88
  });
81
89
 
82
90
  test('should work with single element array', () => {
83
91
  const result = head([42]);
92
+
84
93
  expect(Optional.isSome(result)).toBe(true);
94
+
85
95
  if (Optional.isSome(result)) {
86
96
  expect(result.value).toBe(42);
87
97
  }
88
98
  });
89
99
  });
90
100
 
91
- describe('last', () => {
101
+ describe(last, () => {
92
102
  test('case 1', () => {
93
103
  const xs = [1, 2, 3] as const;
94
104
  const l = last(xs);
@@ -96,6 +106,7 @@ describe('Arr element access', () => {
96
106
  expectType<typeof l, Some<3>>('=');
97
107
 
98
108
  expect(Optional.isSome(l)).toBe(true);
109
+
99
110
  if (Optional.isSome(l)) {
100
111
  expect(l.value).toBe(3);
101
112
  }
@@ -108,6 +119,7 @@ describe('Arr element access', () => {
108
119
  expectType<typeof l, Some<number>>('=');
109
120
 
110
121
  expect(Optional.isSome(l)).toBe(true);
122
+
111
123
  if (Optional.isSome(l)) {
112
124
  expect(l.value).toBe(3);
113
125
  }
@@ -120,6 +132,7 @@ describe('Arr element access', () => {
120
132
  expectType<typeof l, Optional<number>>('=');
121
133
 
122
134
  expect(Optional.isSome(l)).toBe(true);
135
+
123
136
  if (Optional.isSome(l)) {
124
137
  expect(l.value).toBe(3);
125
138
  }
@@ -137,12 +150,15 @@ describe('Arr element access', () => {
137
150
 
138
151
  test('should return none for empty array', () => {
139
152
  const result = last([]);
153
+
140
154
  expect(Optional.isNone(result)).toBe(true);
141
155
  });
142
156
 
143
157
  test('should work with single element array', () => {
144
158
  const result = last([42]);
159
+
145
160
  expect(Optional.isSome(result)).toBe(true);
161
+
146
162
  if (Optional.isSome(result)) {
147
163
  expect(result.value).toBe(42);
148
164
  }
@@ -1,14 +1,16 @@
1
1
  import { expectType } from '../../expect-type.mjs';
2
+ import { asUint32 } from '../../number/index.mjs';
2
3
  import { entries, indices, values } from './array-utils-iterators.mjs';
3
4
 
4
- describe('entries', () => {
5
+ describe(entries, () => {
5
6
  test('should return array of index-value pairs', () => {
6
7
  const fruits = ['apple', 'banana', 'cherry'];
7
8
  const es = Array.from(entries(fruits));
8
- expect(es).toStrictEqual([
9
- [0, 'apple'],
10
- [1, 'banana'],
11
- [2, 'cherry'],
9
+
10
+ assert.deepStrictEqual(es, [
11
+ [asUint32(0), 'apple'],
12
+ [asUint32(1), 'banana'],
13
+ [asUint32(2), 'cherry'],
12
14
  ]);
13
15
  });
14
16
 
@@ -16,36 +18,41 @@ describe('entries', () => {
16
18
  const tuple = [10, 20, 30] as const;
17
19
  const es = Array.from(entries(tuple));
18
20
  expectType<typeof es, (readonly [Uint32, 10 | 20 | 30])[]>('=');
19
- expect(es).toStrictEqual([
20
- [0, 10],
21
- [1, 20],
22
- [2, 30],
21
+
22
+ assert.deepStrictEqual(es, [
23
+ [asUint32(0), 10],
24
+ [asUint32(1), 20],
25
+ [asUint32(2), 30],
23
26
  ]);
24
27
  });
25
28
 
26
29
  test('should work with empty array', () => {
27
30
  const empty: string[] = [];
28
31
  const es = Array.from(entries(empty));
29
- expect(es).toStrictEqual([]);
32
+
33
+ assert.deepStrictEqual(es, []);
30
34
  });
31
35
 
32
36
  test('should preserve mixed types', () => {
33
37
  const mixed = [1, 'hello', true] as const;
34
38
  const es = Array.from(entries(mixed));
35
39
  expectType<typeof es, (readonly [Uint32, 1 | 'hello' | true])[]>('=');
36
- expect(es).toStrictEqual([
37
- [0, 1],
38
- [1, 'hello'],
39
- [2, true],
40
+
41
+ assert.deepStrictEqual(es, [
42
+ [asUint32(0), 1],
43
+ [asUint32(1), 'hello'],
44
+ [asUint32(2), true],
40
45
  ]);
41
46
  });
42
47
  });
43
48
 
44
- describe('values', () => {
49
+ describe(values, () => {
45
50
  test('should return copy of array values', () => {
46
51
  const numbers = [1, 2, 3];
47
52
  const vs = Array.from(values(numbers));
48
- expect(vs).toStrictEqual([1, 2, 3]);
53
+
54
+ assert.deepStrictEqual(vs, [1, 2, 3]);
55
+
49
56
  expect(vs).not.toBe(numbers); // Should be a copy
50
57
  });
51
58
 
@@ -53,46 +60,59 @@ describe('values', () => {
53
60
  const tuple = ['a', 'b', 'c'] as const;
54
61
  const vs = Array.from(values(tuple));
55
62
  expectType<typeof vs, ('a' | 'b' | 'c')[]>('=');
56
- expect(vs).toStrictEqual(['a', 'b', 'c']);
63
+
64
+ assert.deepStrictEqual(vs, ['a', 'b', 'c']);
57
65
  });
58
66
 
59
67
  test('should work with empty array', () => {
60
68
  const empty: number[] = [];
61
69
  const vs = Array.from(values(empty));
62
- expect(vs).toStrictEqual([]);
70
+
71
+ assert.deepStrictEqual(vs, []);
63
72
  });
64
73
 
65
74
  test('should preserve mixed types', () => {
66
75
  const mixed = [1, 'hello', null] as const;
67
76
  const vs = Array.from(values(mixed));
68
77
  expectType<typeof vs, (1 | 'hello' | null)[]>('=');
69
- expect(vs).toStrictEqual([1, 'hello', null]);
78
+
79
+ assert.deepStrictEqual(vs, [1, 'hello', null]);
70
80
  });
71
81
  });
72
82
 
73
- describe('indices', () => {
83
+ describe(indices, () => {
74
84
  test('should return array of indices', () => {
75
85
  const fruits = ['apple', 'banana', 'cherry'];
76
86
  const ks = Array.from(indices(fruits));
77
- expect(ks).toStrictEqual([0, 1, 2]);
87
+
88
+ assert.deepStrictEqual(ks, [asUint32(0), asUint32(1), asUint32(2)]);
78
89
  });
79
90
 
80
91
  test('should work with tuples', () => {
81
92
  const tuple = ['a', 'b'] as const;
82
93
  const ks = Array.from(indices(tuple));
83
94
  expectType<typeof ks, Uint32[]>('=');
84
- expect(ks).toStrictEqual([0, 1]);
95
+
96
+ assert.deepStrictEqual(ks, [asUint32(0), asUint32(1)]);
85
97
  });
86
98
 
87
99
  test('should work with empty array', () => {
88
100
  const empty: string[] = [];
89
101
  const ks = Array.from(indices(empty));
90
- expect(ks).toStrictEqual([]);
102
+
103
+ assert.deepStrictEqual(ks, []);
91
104
  });
92
105
 
93
106
  test('should work with larger arrays', () => {
94
107
  const large = Array.from({ length: 5 }, () => 'x');
95
108
  const ks = Array.from(indices(large));
96
- expect(ks).toStrictEqual([0, 1, 2, 3, 4]);
109
+
110
+ assert.deepStrictEqual(ks, [
111
+ asUint32(0),
112
+ asUint32(1),
113
+ asUint32(2),
114
+ asUint32(3),
115
+ asUint32(4),
116
+ ]);
97
117
  });
98
118
  });
@@ -12,18 +12,18 @@ import {
12
12
  } from './array-utils-modification.mjs';
13
13
 
14
14
  describe('Arr modifications', () => {
15
- describe('toUpdated', () => {
15
+ describe(toUpdated, () => {
16
16
  const xs = [1, 2, 3] as const;
17
17
  const result = toUpdated(xs, 1, (x) => x + 2);
18
18
 
19
19
  expectType<typeof result, ArrayOfLength<3, number>>('=');
20
20
 
21
21
  test('case 1', () => {
22
- expect(result).toStrictEqual([1, 4, 3]);
22
+ assert.deepStrictEqual(result, [1, 4, 3]);
23
23
  });
24
24
  });
25
25
 
26
- describe('toInserted', () => {
26
+ describe(toInserted, () => {
27
27
  const xs = [1, 2, 3] as const;
28
28
 
29
29
  test('case 1', () => {
@@ -31,7 +31,7 @@ describe('Arr modifications', () => {
31
31
 
32
32
  expectType<typeof result, ArrayOfLength<4, 1 | 2 | 3 | 5>>('=');
33
33
 
34
- expect(result).toStrictEqual([1, 5, 2, 3]);
34
+ assert.deepStrictEqual(result, [1, 5, 2, 3]);
35
35
  });
36
36
 
37
37
  test('case 2 (insert head)', () => {
@@ -39,7 +39,7 @@ describe('Arr modifications', () => {
39
39
 
40
40
  expectType<typeof result, ArrayOfLength<4, 1 | 2 | 3 | 5>>('=');
41
41
 
42
- expect(result).toStrictEqual([5, 1, 2, 3]);
42
+ assert.deepStrictEqual(result, [5, 1, 2, 3]);
43
43
  });
44
44
 
45
45
  test('case 3 (insert tail)', () => {
@@ -51,18 +51,18 @@ describe('Arr modifications', () => {
51
51
 
52
52
  expectType<typeof result, NonEmptyArray<string | 5>>('=');
53
53
 
54
- expect(result).toStrictEqual(['a', 'b', 'c', 5]);
54
+ assert.deepStrictEqual(result, ['a', 'b', 'c', 5]);
55
55
  });
56
56
  });
57
57
 
58
- describe('toRemoved', () => {
58
+ describe(toRemoved, () => {
59
59
  test('case 1', () => {
60
60
  const xs = [1, 2, 3] as const;
61
61
  const result = toRemoved(xs, 1);
62
62
 
63
63
  expectType<typeof result, readonly (1 | 2 | 3)[]>('=');
64
64
 
65
- expect(result).toStrictEqual([1, 3]);
65
+ assert.deepStrictEqual(result, [1, 3]);
66
66
  });
67
67
 
68
68
  test('case 2 (remove head)', () => {
@@ -71,7 +71,7 @@ describe('Arr modifications', () => {
71
71
 
72
72
  expectType<typeof result, readonly (1 | 2 | 3)[]>('=');
73
73
 
74
- expect(result).toStrictEqual([2, 3]);
74
+ assert.deepStrictEqual(result, [2, 3]);
75
75
  });
76
76
 
77
77
  test('case 3 (remove tail)', () => {
@@ -80,7 +80,7 @@ describe('Arr modifications', () => {
80
80
 
81
81
  expectType<typeof result, readonly (1 | 2 | 3)[]>('=');
82
82
 
83
- expect(result).toStrictEqual([1, 2]);
83
+ assert.deepStrictEqual(result, [1, 2]);
84
84
  });
85
85
 
86
86
  test('case 4 (number[])', () => {
@@ -89,18 +89,18 @@ describe('Arr modifications', () => {
89
89
 
90
90
  expectType<typeof result, readonly number[]>('=');
91
91
 
92
- expect(result).toStrictEqual([1, 2, 3]);
92
+ assert.deepStrictEqual(result, [1, 2, 3]);
93
93
  });
94
94
  });
95
95
 
96
- describe('toPushed', () => {
96
+ describe(toPushed, () => {
97
97
  test('case 1', () => {
98
98
  const xs = [1, 2, 3] as const;
99
99
  const result = toPushed(xs, 4 as const);
100
100
 
101
101
  expectType<typeof result, readonly [1, 2, 3, 4]>('=');
102
102
 
103
- expect(result).toStrictEqual([1, 2, 3, 4]);
103
+ assert.deepStrictEqual(result, [1, 2, 3, 4]);
104
104
  });
105
105
 
106
106
  test('case 2', () => {
@@ -109,11 +109,11 @@ describe('Arr modifications', () => {
109
109
 
110
110
  expectType<typeof result, readonly [...number[], 4]>('=');
111
111
 
112
- expect(result).toStrictEqual([1, 2, 3, 4]);
112
+ assert.deepStrictEqual(result, [1, 2, 3, 4]);
113
113
  });
114
114
  });
115
115
 
116
- describe('toUnshifted', () => {
116
+ describe(toUnshifted, () => {
117
117
  test('case 1', () => {
118
118
  const xs = [1, 2, 3] as const;
119
119
 
@@ -121,7 +121,7 @@ describe('Arr modifications', () => {
121
121
 
122
122
  expectType<typeof result, readonly [4, 1, 2, 3]>('=');
123
123
 
124
- expect(result).toStrictEqual([4, 1, 2, 3]);
124
+ assert.deepStrictEqual(result, [4, 1, 2, 3]);
125
125
  });
126
126
 
127
127
  test('case 2', () => {
@@ -131,16 +131,16 @@ describe('Arr modifications', () => {
131
131
 
132
132
  expectType<typeof result, readonly [4, ...number[]]>('=');
133
133
 
134
- expect(result).toStrictEqual([4, 1, 2, 3]);
134
+ assert.deepStrictEqual(result, [4, 1, 2, 3]);
135
135
  });
136
136
  });
137
137
 
138
- describe('toFilled', () => {
138
+ describe(toFilled, () => {
139
139
  test('should fill entire array with value', () => {
140
140
  const arr = [1, 2, 3, 4, 5];
141
141
  const result = toFilled(arr, 0);
142
142
 
143
- expect(result).toStrictEqual([0, 0, 0, 0, 0]);
143
+ assert.deepStrictEqual(result, [0, 0, 0, 0, 0]);
144
144
  });
145
145
 
146
146
  test('should work with curried version', () => {
@@ -148,68 +148,68 @@ describe('Arr modifications', () => {
148
148
  const arr = [1, 2, 3];
149
149
  const result = fillWithZero(arr);
150
150
 
151
- expect(result).toStrictEqual([0, 0, 0]);
151
+ assert.deepStrictEqual(result, [0, 0, 0]);
152
152
  });
153
153
  });
154
154
 
155
- describe('toRangeFilled', () => {
155
+ describe(toRangeFilled, () => {
156
156
  test('should fill array with range', () => {
157
157
  const arr = [1, 2, 3, 4, 5];
158
158
  const result = toRangeFilled(arr, 0, [1, 4]);
159
159
 
160
- expect(result).toStrictEqual([1, 0, 0, 0, 5]);
160
+ assert.deepStrictEqual(result, [1, 0, 0, 0, 5]);
161
161
  });
162
162
 
163
163
  test('should fill with range starting from 0', () => {
164
164
  const arr = [1, 2, 3, 4, 5];
165
165
  const result = toRangeFilled(arr, 9, [0, 3]);
166
166
 
167
- expect(result).toStrictEqual([9, 9, 9, 4, 5]);
167
+ assert.deepStrictEqual(result, [9, 9, 9, 4, 5]);
168
168
  });
169
169
 
170
170
  test('should handle empty range', () => {
171
171
  const arr = [1, 2, 3];
172
172
  const result = toRangeFilled(arr, 0, [2, 2]);
173
173
 
174
- expect(result).toStrictEqual([1, 2, 3]);
174
+ assert.deepStrictEqual(result, [1, 2, 3]);
175
175
  });
176
176
 
177
177
  test('should clamp range to array bounds', () => {
178
178
  const arr = [1, 2, 3];
179
179
  const result = toRangeFilled(arr, 0, [1, 10]);
180
180
 
181
- expect(result).toStrictEqual([1, 0, 0]);
181
+ assert.deepStrictEqual(result, [1, 0, 0]);
182
182
  });
183
183
 
184
184
  test('should handle negative start (clamped to 0)', () => {
185
185
  const arr = [1, 2, 3];
186
186
  const result = toRangeFilled(arr, 9, [-5, 2]);
187
187
 
188
- expect(result).toStrictEqual([9, 9, 3]);
188
+ assert.deepStrictEqual(result, [9, 9, 3]);
189
189
  });
190
190
 
191
191
  test('A non-integer starting value should result in a type error', () => {
192
192
  const arr = [1, 2, 3];
193
193
 
194
194
  // @ts-expect-error start must be an integer
195
- expect(toRangeFilled(arr, 0, [1.5, 3])).toStrictEqual([1, 0, 0]);
195
+ assert.deepStrictEqual(toRangeFilled(arr, 0, [1.5, 3]), [1, 0, 0]);
196
196
  });
197
197
 
198
198
  test('A non-integer ending value should result in a type error', () => {
199
199
  const arr = [1, 2, 3];
200
200
 
201
201
  // @ts-expect-error end must be an integer
202
- expect(toRangeFilled(arr, 0, [1, 2.5])).toStrictEqual([1, 0, 3]);
202
+ assert.deepStrictEqual(toRangeFilled(arr, 0, [1, 2.5]), [1, 0, 3]);
203
203
  });
204
204
  });
205
205
 
206
- describe('set', () => {
206
+ describe(set, () => {
207
207
  const result = set([1, 2, 3], 1, 4);
208
208
 
209
209
  expectType<typeof result, readonly [1 | 4, 2 | 4, 3 | 4]>('=');
210
210
 
211
211
  test('case 1', () => {
212
- expect(result).toStrictEqual([1, 4, 3]);
212
+ assert.deepStrictEqual(result, [1, 4, 3]);
213
213
  });
214
214
 
215
215
  test('should work with different value types', () => {
@@ -218,19 +218,22 @@ describe('Arr modifications', () => {
218
218
  expectType<typeof withString, readonly [1 | 'two', 2 | 'two', 3 | 'two']>(
219
219
  '=',
220
220
  );
221
- expect(withString).toStrictEqual([1, 'two', 3]);
221
+
222
+ assert.deepStrictEqual(withString, [1, 'two', 3]);
222
223
  });
223
224
 
224
225
  test('should work at index 0', () => {
225
226
  const tuple = ['a', 'b', 'c'] as const;
226
227
  const updated = set(tuple, 0, 'A');
227
- expect(updated).toStrictEqual(['A', 'b', 'c']);
228
+
229
+ assert.deepStrictEqual(updated, ['A', 'b', 'c']);
228
230
  });
229
231
 
230
232
  test('should work at last index', () => {
231
233
  const tuple = ['a', 'b', 'c'] as const;
232
234
  const updated = set(tuple, 2, 'C');
233
- expect(updated).toStrictEqual(['a', 'b', 'C']);
235
+
236
+ assert.deepStrictEqual(updated, ['a', 'b', 'C']);
234
237
  });
235
238
  });
236
239
  });
@@ -1,3 +1,4 @@
1
+ import { isError } from '@sindresorhus/is';
1
2
  import { IMap } from '../../collections/index.mjs';
2
3
  import { Optional, Result } from '../../functional/index.mjs';
3
4
  import { isString, isUndefined } from '../../guard/index.mjs';
@@ -515,7 +516,7 @@ const joinImpl = <E,>(
515
516
  return Result.ok(result);
516
517
  } catch (error) {
517
518
  return Result.err(
518
- Error.isError(error) ? error : new Error(unknownToString(error)),
519
+ isError(error) ? error : new Error(unknownToString(error)),
519
520
  );
520
521
  }
521
522
  };