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
@@ -1,4 +1,5 @@
1
1
  import { expectType } from '../expect-type.mjs';
2
+ import { isString } from '../guard/index.mjs';
2
3
  import { ISet } from './iset.mjs';
3
4
 
4
5
  describe('ISet.create', () => {
@@ -6,17 +7,20 @@ describe('ISet.create', () => {
6
7
  const s0 = ISet.create(ISet.create(ISet.create([1, 2, 3] as const)));
7
8
 
8
9
  expectType<typeof s0, ISet<1 | 2 | 3>>('<=');
9
- expect(s0).toStrictEqual(ISet.create([1, 2, 3] as const));
10
+
11
+ assert.deepStrictEqual(s0, ISet.create([1, 2, 3] as const));
10
12
  });
11
13
 
12
14
  test('should create empty set', () => {
13
15
  const set = ISet.create<string>([]);
16
+
14
17
  expect(set.size).toBe(0);
15
18
  expect(set.isEmpty).toBe(true);
16
19
  });
17
20
 
18
21
  test('should create set from array', () => {
19
22
  const set = ISet.create([1, 2, 3, 2, 1]);
23
+
20
24
  expect(set.size).toBe(3);
21
25
  expect(set.has(1)).toBe(true);
22
26
  expect(set.has(2)).toBe(true);
@@ -26,6 +30,7 @@ describe('ISet.create', () => {
26
30
  test('should create set from JavaScript Set', () => {
27
31
  const jsSet = new Set(['a', 'b', 'c']);
28
32
  const set = ISet.create(jsSet);
33
+
29
34
  expect(set.size).toBe(3);
30
35
  expect(set.has('a')).toBe(true);
31
36
  expect(set.has('b')).toBe(true);
@@ -35,6 +40,7 @@ describe('ISet.create', () => {
35
40
  test('should create set from another ISet', () => {
36
41
  const original = ISet.create([1, 2, 3]);
37
42
  const copy = ISet.create(original);
43
+
38
44
  expect(copy.size).toBe(3);
39
45
  expect(copy.has(1)).toBe(true);
40
46
  expect(copy.has(2)).toBe(true);
@@ -47,6 +53,7 @@ describe('ISet.size', () => {
47
53
  const s0 = ISet.create([1, 2, 3] as const);
48
54
 
49
55
  expectType<typeof s0.size, number>('<=');
56
+
50
57
  expect(s0.size).toBe(3);
51
58
  });
52
59
 
@@ -60,11 +67,13 @@ describe('ISet.size', () => {
60
67
  describe('isEmpty property', () => {
61
68
  test('should return true for empty set', () => {
62
69
  const set = ISet.create<string>([]);
70
+
63
71
  expect(set.isEmpty).toBe(true);
64
72
  });
65
73
 
66
74
  test('should return false for non-empty set', () => {
67
75
  const set = ISet.create([1, 2, 3]);
76
+
68
77
  expect(set.isEmpty).toBe(false);
69
78
  });
70
79
  });
@@ -74,6 +83,7 @@ describe('ISet.has', () => {
74
83
  const s0 = ISet.create([1, 2, 3] as const);
75
84
 
76
85
  expectType<typeof s0.has, (value: 1 | 2 | 3) => boolean>('<=');
86
+
77
87
  expect(s0.has(2)).toBe(true);
78
88
  });
79
89
 
@@ -97,12 +107,14 @@ describe('ISet.has', () => {
97
107
 
98
108
  test('should handle boolean values', () => {
99
109
  const set = ISet.create([true, false]);
110
+
100
111
  expect(set.has(true)).toBe(true);
101
112
  expect(set.has(false)).toBe(true);
102
113
  });
103
114
 
104
115
  test('should handle null and undefined', () => {
105
116
  const set = ISet.create([null, undefined]);
117
+
106
118
  expect(set.has(null)).toBe(true);
107
119
  expect(set.has(undefined)).toBe(true);
108
120
  });
@@ -116,6 +128,7 @@ describe('ISet.every', () => {
116
128
  typeof s0.every,
117
129
  (predicate: (value: 2 | 4 | 6) => boolean) => boolean
118
130
  >('<=');
131
+
119
132
  expect(s0.every((x) => x % 2 === 0)).toBe(true);
120
133
  });
121
134
 
@@ -133,16 +146,19 @@ describe('ISet.every', () => {
133
146
 
134
147
  test('should return true when all elements satisfy predicate', () => {
135
148
  const set = ISet.create([2, 4, 6, 8]);
149
+
136
150
  expect(set.every((x) => x % 2 === 0)).toBe(true);
137
151
  });
138
152
 
139
153
  test('should return false when some elements do not satisfy predicate', () => {
140
154
  const set = ISet.create([1, 2, 3, 4]);
155
+
141
156
  expect(set.every((x) => x % 2 === 0)).toBe(false);
142
157
  });
143
158
 
144
159
  test('should return true for empty set', () => {
145
160
  const set = ISet.create<number>([]);
161
+
146
162
  expect(set.every((x) => x > 0)).toBe(true);
147
163
  });
148
164
  });
@@ -154,13 +170,14 @@ describe('every method as type guard', () => {
154
170
  // Type should be narrowed to ISet<string>
155
171
  const values = set.toArray();
156
172
  for (const value of values) {
157
- expect(typeof value).toBe('string');
173
+ expect(isString(value)).toBe(true);
158
174
  }
159
175
  }
160
176
  });
161
177
 
162
178
  test('should work with mixed types that fail guard', () => {
163
179
  const set = ISet.create<string | number>(['hello', 42, 'world']);
180
+
164
181
  expect(
165
182
  set.every((value): value is string => typeof value === 'string'),
166
183
  ).toBe(false);
@@ -175,6 +192,7 @@ describe('ISet.some', () => {
175
192
  typeof s0.some,
176
193
  (predicate: (value: 1 | 3 | 5) => boolean) => boolean
177
194
  >('<=');
195
+
178
196
  expect(s0.some((x) => x % 2 === 0)).toBe(false);
179
197
  });
180
198
 
@@ -192,21 +210,25 @@ describe('ISet.some', () => {
192
210
 
193
211
  test('should return true when at least one element satisfies predicate', () => {
194
212
  const set = ISet.create([1, 3, 5, 6]);
213
+
195
214
  expect(set.some((x) => x % 2 === 0)).toBe(true);
196
215
  });
197
216
 
198
217
  test('should return false when no elements satisfy predicate', () => {
199
218
  const set = ISet.create([1, 3, 5, 7]);
219
+
200
220
  expect(set.some((x) => x % 2 === 0)).toBe(false);
201
221
  });
202
222
 
203
223
  test('should return false for empty set', () => {
204
224
  const set = ISet.create<number>([]);
225
+
205
226
  expect(set.some((x) => x > 0)).toBe(false);
206
227
  });
207
228
 
208
229
  test('should work with complex predicates', () => {
209
230
  const set = ISet.create(['hello', 'world', 'test']);
231
+
210
232
  expect(set.some((str) => str.includes('o'))).toBe(true);
211
233
  expect(set.some((str) => str.includes('z'))).toBe(false);
212
234
  });
@@ -218,22 +240,23 @@ describe('ISet.add', () => {
218
240
 
219
241
  expectType<typeof s0.add, (value: number) => ISet<number>>('<=');
220
242
  const s1 = ISet.create<number>([1, 2, 3, 4]);
221
- expect(s0.add(4)).toStrictEqual(s1);
222
- expect(s0).toStrictEqual(ISet.create<number>([1, 2, 3]));
243
+
244
+ assert.deepStrictEqual(s0.add(4), s1);
245
+ assert.deepStrictEqual(s0, ISet.create<number>([1, 2, 3]));
223
246
  });
224
247
 
225
248
  test('case 2', () => {
226
- const s0 = ISet.create([1, 2, 3]);
249
+ const s0 = ISet.create<number>([1, 2, 3]);
227
250
 
228
- expect(s0.add(2)).toStrictEqual(ISet.create([1, 2, 3]));
229
- expect(s0).toStrictEqual(ISet.create([1, 2, 3]));
251
+ assert.deepStrictEqual(s0.add(2), ISet.create([1, 2, 3]));
252
+ assert.deepStrictEqual(s0, ISet.create([1, 2, 3]));
230
253
  });
231
254
 
232
255
  test('case 3', () => {
233
256
  const s0 = ISet.create<number>([]);
234
257
 
235
- expect(s0.add(1)).toStrictEqual(ISet.create([1]));
236
- expect(s0).toStrictEqual(ISet.create([]));
258
+ assert.deepStrictEqual(s0.add(1), ISet.create([1]));
259
+ assert.deepStrictEqual(s0, ISet.create<number>([]));
237
260
  });
238
261
 
239
262
  test('should add new elements and maintain immutability', () => {
@@ -249,6 +272,7 @@ describe('ISet.add', () => {
249
272
  test('should return same instance when adding existing element', () => {
250
273
  const set = ISet.create([1, 2, 3]);
251
274
  const result = set.add(2);
275
+
252
276
  expect(result).toBe(set);
253
277
  });
254
278
 
@@ -269,22 +293,23 @@ describe('ISet.delete', () => {
269
293
  const s0 = ISet.create<number>([1, 2, 3]);
270
294
 
271
295
  expectType<typeof s0.delete, (value: number) => ISet<number>>('<=');
272
- expect(s0.delete(4)).toStrictEqual(ISet.create<number>([1, 2, 3]));
273
- expect(s0).toStrictEqual(ISet.create<number>([1, 2, 3]));
296
+
297
+ assert.deepStrictEqual(s0.delete(4), ISet.create<number>([1, 2, 3]));
298
+ assert.deepStrictEqual(s0, ISet.create<number>([1, 2, 3]));
274
299
  });
275
300
 
276
301
  test('case 2', () => {
277
302
  const s0 = ISet.create([1, 2, 3]);
278
303
 
279
- expect(s0.delete(2)).toStrictEqual(ISet.create([1, 3]));
280
- expect(s0).toStrictEqual(ISet.create([1, 2, 3]));
304
+ assert.deepStrictEqual(s0.delete(2), ISet.create<1 | 2 | 3>([1, 3]));
305
+ assert.deepStrictEqual(s0, ISet.create([1, 2, 3]));
281
306
  });
282
307
 
283
308
  test('case 3', () => {
284
309
  const s0 = ISet.create<number>([]);
285
310
 
286
- expect(s0.delete(1)).toStrictEqual(ISet.create([]));
287
- expect(s0).toStrictEqual(ISet.create([]));
311
+ assert.deepStrictEqual(s0.delete(1), ISet.create<number>([]));
312
+ assert.deepStrictEqual(s0, ISet.create<number>([]));
288
313
  });
289
314
 
290
315
  test('should delete existing elements and maintain immutability', () => {
@@ -300,6 +325,7 @@ describe('ISet.delete', () => {
300
325
  test('should return same instance when deleting non-existent element', () => {
301
326
  const set = ISet.create<number>([1, 2, 3]);
302
327
  const result = set.delete(4);
328
+
303
329
  expect(result).toBe(set);
304
330
  });
305
331
  });
@@ -312,22 +338,30 @@ describe('ISet.map', () => {
312
338
  typeof s0.map,
313
339
  <U extends MapSetKeyType>(mapper: (value: 1 | 2 | 3) => U) => ISet<U>
314
340
  >('<=');
315
- expect(s0.map((x) => x * 2)).toStrictEqual(ISet.create([2, 4, 6]));
341
+
342
+ assert.deepStrictEqual(
343
+ s0.map((x) => x * 2),
344
+ ISet.create<number>([2, 4, 6]),
345
+ );
316
346
  });
317
347
 
318
348
  test('case 2', () => {
319
349
  const s0 = ISet.create<number>([]);
320
350
 
321
- expect(s0.map((x) => x * 2)).toStrictEqual(ISet.create([]));
351
+ assert.deepStrictEqual(
352
+ s0.map((x) => x * 2),
353
+ ISet.create<number>([]),
354
+ );
322
355
  });
323
356
 
324
357
  test('should transform all elements', () => {
325
358
  const set = ISet.create([1, 2, 3]);
326
359
  const doubled = set.map((x) => x * 2);
327
360
 
328
- expect(doubled.toArray().toSorted((a, b) => a - b)).toStrictEqual([
329
- 2, 4, 6,
330
- ]);
361
+ assert.deepStrictEqual(
362
+ doubled.toArray().toSorted((a, b) => a - b),
363
+ [2, 4, 6],
364
+ );
331
365
  });
332
366
 
333
367
  test('should handle type transformations', () => {
@@ -350,13 +384,20 @@ describe('ISet.filter', () => {
350
384
  predicate: (value: 1 | 2 | 3 | 4 | 5) => boolean,
351
385
  ) => ISet<1 | 2 | 3 | 4 | 5>
352
386
  >('<=');
353
- expect(s0.filter((x) => x % 2 === 0)).toStrictEqual(ISet.create([2, 4]));
387
+
388
+ assert.deepStrictEqual(
389
+ s0.filter((x) => x % 2 === 0),
390
+ ISet.create<1 | 2 | 3 | 4 | 5>([2, 4]),
391
+ );
354
392
  });
355
393
 
356
394
  test('case 2', () => {
357
395
  const s0 = ISet.create<number>([]);
358
396
 
359
- expect(s0.filter((x) => x % 2 === 0)).toStrictEqual(ISet.create([]));
397
+ assert.deepStrictEqual(
398
+ s0.filter((x) => x % 2 === 0),
399
+ ISet.create<number>([]),
400
+ );
360
401
  });
361
402
 
362
403
  test('should filter elements based on predicate', () => {
@@ -403,6 +444,7 @@ describe('ISet.filterNot', () => {
403
444
  test('should return same set when no elements satisfy predicate', () => {
404
445
  const set = ISet.create([1, 3, 5]);
405
446
  const nonEvens = set.filterNot((x) => x % 2 === 0);
447
+
406
448
  expect(nonEvens.size).toBe(3);
407
449
  expect(ISet.equal(set, nonEvens)).toBe(true);
408
450
  });
@@ -410,6 +452,7 @@ describe('ISet.filterNot', () => {
410
452
  test('should return empty set when all elements satisfy predicate', () => {
411
453
  const set = ISet.create([2, 4, 6]);
412
454
  const nonEvens = set.filterNot((x) => x % 2 === 0);
455
+
413
456
  expect(nonEvens.isEmpty).toBe(true);
414
457
  });
415
458
  });
@@ -420,6 +463,7 @@ describe('ISet.isSubsetOf', () => {
420
463
  const s1 = ISet.create<number>([1, 2, 3]);
421
464
 
422
465
  expectType<typeof s0.isSubsetOf, (other: ISet<number>) => boolean>('<=');
466
+
423
467
  expect(s0.isSubsetOf(s1)).toBe(true);
424
468
  });
425
469
 
@@ -440,18 +484,21 @@ describe('ISet.isSubsetOf', () => {
440
484
  test('should return true for subset relationship', () => {
441
485
  const subset = ISet.create<number>([1, 2]);
442
486
  const superset = ISet.create<number>([1, 2, 3, 4]);
487
+
443
488
  expect(subset.isSubsetOf(superset)).toBe(true);
444
489
  });
445
490
 
446
491
  test('should return true for equal sets', () => {
447
492
  const set1 = ISet.create<number>([1, 2, 3]);
448
493
  const set2 = ISet.create<number>([1, 2, 3]);
494
+
449
495
  expect(set1.isSubsetOf(set2)).toBe(true);
450
496
  });
451
497
 
452
498
  test('should return false for non-subset', () => {
453
499
  const set1 = ISet.create<number>([1, 2, 5]);
454
500
  const set2 = ISet.create<number>([1, 2, 3, 4]);
501
+
455
502
  expect(set1.isSubsetOf(set2)).toBe(false);
456
503
  });
457
504
  });
@@ -462,6 +509,7 @@ describe('ISet.isSupersetOf', () => {
462
509
  const s1 = ISet.create<number>([1, 2]);
463
510
 
464
511
  expectType<typeof s0.isSupersetOf, (other: ISet<number>) => boolean>('<=');
512
+
465
513
  expect(s0.isSupersetOf(s1)).toBe(true);
466
514
  });
467
515
 
@@ -482,18 +530,21 @@ describe('ISet.isSupersetOf', () => {
482
530
  test('should return true for superset relationship', () => {
483
531
  const superset = ISet.create<number>([1, 2, 3, 4]);
484
532
  const subset = ISet.create<number>([1, 2]);
533
+
485
534
  expect(superset.isSupersetOf(subset)).toBe(true);
486
535
  });
487
536
 
488
537
  test('should return true for equal sets', () => {
489
538
  const set1 = ISet.create<number>([1, 2, 3]);
490
539
  const set2 = ISet.create<number>([1, 2, 3]);
540
+
491
541
  expect(set1.isSupersetOf(set2)).toBe(true);
492
542
  });
493
543
 
494
544
  test('should return false for non-superset', () => {
495
545
  const set1 = ISet.create<number>([1, 2, 3]);
496
546
  const set2 = ISet.create<number>([1, 2, 3, 4]);
547
+
497
548
  expect(set1.isSupersetOf(set2)).toBe(false);
498
549
  });
499
550
  });
@@ -504,21 +555,22 @@ describe('ISet.subtract', () => {
504
555
  const s1 = ISet.create<number>([2, 4]);
505
556
 
506
557
  expectType<typeof s0.subtract, (other: ISet<number>) => ISet<number>>('<=');
507
- expect(s0.subtract(s1)).toStrictEqual(ISet.create<number>([1, 3]));
558
+
559
+ assert.deepStrictEqual(s0.subtract(s1), ISet.create<number>([1, 3]));
508
560
  });
509
561
 
510
562
  test('case 2', () => {
511
563
  const s0 = ISet.create<number>([1, 2, 3]);
512
564
  const s1 = ISet.create<number>([]);
513
565
 
514
- expect(s0.subtract(s1)).toStrictEqual(ISet.create<number>([1, 2, 3]));
566
+ assert.deepStrictEqual(s0.subtract(s1), ISet.create<number>([1, 2, 3]));
515
567
  });
516
568
 
517
569
  test('case 3', () => {
518
570
  const s0 = ISet.create<number>([]);
519
571
  const s1 = ISet.create<number>([1, 2, 3]);
520
572
 
521
- expect(s0.subtract(s1)).toStrictEqual(ISet.create<number>([]));
573
+ assert.deepStrictEqual(s0.subtract(s1), ISet.create<number>([]));
522
574
  });
523
575
 
524
576
  test('should return elements in first set but not in second', () => {
@@ -549,7 +601,9 @@ describe('ISet.intersection', () => {
549
601
  typeof ISet.intersection,
550
602
  <T extends Primitive>(a: ISet<T>, b: ISet<T>) => ISet<T>
551
603
  >('<=');
552
- expect(ISet.intersection(s0, s1)).toStrictEqual(
604
+
605
+ assert.deepStrictEqual(
606
+ ISet.intersection(s0, s1),
553
607
  ISet.create<number>([2, 3]),
554
608
  );
555
609
  });
@@ -558,14 +612,14 @@ describe('ISet.intersection', () => {
558
612
  const s0 = ISet.create<number>([1, 2, 3]);
559
613
  const s1 = ISet.create<number>([]);
560
614
 
561
- expect(ISet.intersection(s0, s1)).toStrictEqual(ISet.create<number>([]));
615
+ assert.deepStrictEqual(ISet.intersection(s0, s1), ISet.create<number>([]));
562
616
  });
563
617
 
564
618
  test('case 3', () => {
565
619
  const s0 = ISet.create<number>([]);
566
620
  const s1 = ISet.create<number>([1, 2, 3]);
567
621
 
568
- expect(ISet.intersection(s0, s1)).toStrictEqual(ISet.create<number>([]));
622
+ assert.deepStrictEqual(ISet.intersection(s0, s1), ISet.create<number>([]));
569
623
  });
570
624
 
571
625
  test('should return common elements', () => {
@@ -595,21 +649,22 @@ describe('ISet.intersect', () => {
595
649
  expectType<typeof s0.intersect, (other: ISet<number>) => ISet<number>>(
596
650
  '<=',
597
651
  );
598
- expect(s0.intersect(s1)).toStrictEqual(ISet.create<number>([2, 3]));
652
+
653
+ assert.deepStrictEqual(s0.intersect(s1), ISet.create<number>([2, 3]));
599
654
  });
600
655
 
601
656
  test('case 2', () => {
602
657
  const s0 = ISet.create<number>([1, 2, 3]);
603
658
  const s1 = ISet.create<number>([]);
604
659
 
605
- expect(s0.intersect(s1)).toStrictEqual(ISet.create<number>([]));
660
+ assert.deepStrictEqual(s0.intersect(s1), ISet.create<number>([]));
606
661
  });
607
662
 
608
663
  test('case 3', () => {
609
664
  const s0 = ISet.create<number>([]);
610
665
  const s1 = ISet.create<number>([1, 2, 3]);
611
666
 
612
- expect(s0.intersect(s1)).toStrictEqual(ISet.create<number>([]));
667
+ assert.deepStrictEqual(s0.intersect(s1), ISet.create<number>([]));
613
668
  });
614
669
 
615
670
  test('should return common elements using instance method', () => {
@@ -632,7 +687,9 @@ describe('ISet.union', () => {
632
687
  typeof ISet.union,
633
688
  <T extends Primitive>(a: ISet<T>, b: ISet<T>) => ISet<T>
634
689
  >('!=');
635
- expect(ISet.union(s0, s1)).toStrictEqual(
690
+
691
+ assert.deepStrictEqual(
692
+ ISet.union(s0, s1),
636
693
  ISet.create<number>([1, 2, 3, 4, 5]),
637
694
  );
638
695
  });
@@ -641,19 +698,19 @@ describe('ISet.union', () => {
641
698
  const s0 = ISet.create([1, 2, 3]);
642
699
  const s1 = ISet.create<number>([]);
643
700
 
644
- expect(ISet.union(s0, s1)).toStrictEqual(ISet.create([1, 2, 3]));
701
+ assert.deepStrictEqual(ISet.union(s0, s1), ISet.create<number>([1, 2, 3]));
645
702
  });
646
703
 
647
704
  test('case 3', () => {
648
705
  const s0 = ISet.create<number>([]);
649
- const s1 = ISet.create([1, 2, 3]);
706
+ const s1 = ISet.create<number>([1, 2, 3]);
650
707
 
651
- expect(ISet.union(s0, s1)).toStrictEqual(ISet.create([1, 2, 3]));
708
+ assert.deepStrictEqual(ISet.union(s0, s1), ISet.create<number>([1, 2, 3]));
652
709
  });
653
710
 
654
711
  test('should return combined elements using static method', () => {
655
- const set1 = ISet.create([1, 2, 3]);
656
- const set2 = ISet.create([3, 4, 5]);
712
+ const set1 = ISet.create<number>([1, 2, 3]);
713
+ const set2 = ISet.create<number>([3, 4, 5]);
657
714
  const result = ISet.union(set1, set2);
658
715
 
659
716
  expect(result.size).toBe(5);
@@ -670,26 +727,30 @@ describe('ISet.union', () => {
670
727
  const s1 = ISet.create([3, 4, 5] as const);
671
728
 
672
729
  expectType<typeof s0.union, (other: ISet<number>) => ISet<number>>('<=');
673
- expect(s0.union(s1)).toStrictEqual(ISet.create([1, 2, 3, 4, 5]));
730
+
731
+ assert.deepStrictEqual(
732
+ s0.union(s1),
733
+ ISet.create<1 | 2 | 3 | 4 | 5>([1, 2, 3, 4, 5]),
734
+ );
674
735
  });
675
736
 
676
737
  test('case 2', () => {
677
- const s0 = ISet.create([1, 2, 3]);
738
+ const s0 = ISet.create<number>([1, 2, 3]);
678
739
  const s1 = ISet.create<number>([]);
679
740
 
680
- expect(s0.union(s1)).toStrictEqual(ISet.create([1, 2, 3]));
741
+ assert.deepStrictEqual(s0.union(s1), ISet.create<number>([1, 2, 3]));
681
742
  });
682
743
 
683
744
  test('case 3', () => {
684
745
  const s0 = ISet.create<number>([]);
685
- const s1 = ISet.create([1, 2, 3]);
746
+ const s1 = ISet.create<number>([1, 2, 3]);
686
747
 
687
- expect(s0.union(s1)).toStrictEqual(ISet.create([1, 2, 3]));
748
+ assert.deepStrictEqual(s0.union(s1), ISet.create<number>([1, 2, 3]));
688
749
  });
689
750
 
690
751
  test('should return combined elements using instance method', () => {
691
- const set1 = ISet.create([1, 2, 3]);
692
- const set2 = ISet.create([3, 4, 5]);
752
+ const set1 = ISet.create<number>([1, 2, 3]);
753
+ const set2 = ISet.create<number>([3, 4, 5]);
693
754
  const result = set1.union(set2);
694
755
 
695
756
  expect(result.size).toBe(5);
@@ -716,7 +777,10 @@ describe('ISet.forEach', () => {
716
777
  mut_result.push(x);
717
778
  }
718
779
 
719
- expect(mut_result.toSorted((a, b) => a - b)).toStrictEqual([1, 2, 3]);
780
+ assert.deepStrictEqual(
781
+ mut_result.toSorted((a, b) => a - b),
782
+ [1, 2, 3],
783
+ );
720
784
  });
721
785
 
722
786
  test('should execute callback for each element', () => {
@@ -727,7 +791,10 @@ describe('ISet.forEach', () => {
727
791
  mut_collected.push(value);
728
792
  }
729
793
 
730
- expect(mut_collected.toSorted((a, b) => a - b)).toStrictEqual([1, 2, 3]);
794
+ assert.deepStrictEqual(
795
+ mut_collected.toSorted((a, b) => a - b),
796
+ [1, 2, 3],
797
+ );
731
798
  });
732
799
 
733
800
  test('should not call callback for empty set', () => {
@@ -754,7 +821,10 @@ describe('ISet.keys', () => {
754
821
  mut_result.push(x);
755
822
  }
756
823
 
757
- expect(mut_result.toSorted((a, b) => a - b)).toStrictEqual([1, 2, 3]);
824
+ assert.deepStrictEqual(
825
+ mut_result.toSorted((a, b) => a - b),
826
+ [1, 2, 3],
827
+ );
758
828
  });
759
829
  });
760
830
 
@@ -769,7 +839,10 @@ describe('ISet.values', () => {
769
839
  mut_result.push(x);
770
840
  }
771
841
 
772
- expect(mut_result.toSorted((a, b) => a - b)).toStrictEqual([1, 2, 3]);
842
+ assert.deepStrictEqual(
843
+ mut_result.toSorted((a, b) => a - b),
844
+ [1, 2, 3],
845
+ );
773
846
  });
774
847
  });
775
848
 
@@ -787,11 +860,14 @@ describe('ISet.entries', () => {
787
860
  mut_result.push([x[0], x[1]]);
788
861
  }
789
862
 
790
- expect(mut_result.toSorted((a, b) => a[0] - b[0])).toStrictEqual([
791
- [1, 1],
792
- [2, 2],
793
- [3, 3],
794
- ]);
863
+ assert.deepStrictEqual(
864
+ mut_result.toSorted((a, b) => a[0] - b[0]),
865
+ [
866
+ [1, 1],
867
+ [2, 2],
868
+ [3, 3],
869
+ ],
870
+ );
795
871
  });
796
872
  });
797
873
 
@@ -800,15 +876,17 @@ describe('ISet.toArray', () => {
800
876
  const s0 = ISet.create([1, 2, 3] as const);
801
877
 
802
878
  expectType<typeof s0.toArray, () => readonly (1 | 2 | 3)[]>('<=');
803
- expect(Array.from(s0.toArray()).toSorted((a, b) => a - b)).toStrictEqual([
804
- 1, 2, 3,
805
- ]);
879
+
880
+ assert.deepStrictEqual(
881
+ Array.from(s0.toArray()).toSorted((a, b) => a - b),
882
+ [1, 2, 3],
883
+ );
806
884
  });
807
885
 
808
886
  test('case 2', () => {
809
887
  const s0 = ISet.create<number>([]);
810
888
 
811
- expect(s0.toArray()).toStrictEqual([]);
889
+ assert.deepStrictEqual(s0.toArray(), []);
812
890
  });
813
891
 
814
892
  test('should convert set to array', () => {
@@ -816,9 +894,11 @@ describe('ISet.toArray', () => {
816
894
  const array = set.toArray();
817
895
 
818
896
  expect(array).toHaveLength(3);
819
- expect(Array.from(array).toSorted((a, b) => a - b)).toStrictEqual([
820
- 1, 2, 3,
821
- ]);
897
+
898
+ assert.deepStrictEqual(
899
+ Array.from(array).toSorted((a, b) => a - b),
900
+ [1, 2, 3],
901
+ );
822
902
  });
823
903
  });
824
904
 
@@ -845,30 +925,35 @@ describe('ISet.equal', () => {
845
925
  test('should return true for equal sets', () => {
846
926
  const set1 = ISet.create([1, 2, 3]);
847
927
  const set2 = ISet.create([3, 2, 1]); // Different order
928
+
848
929
  expect(ISet.equal(set1, set2)).toBe(true);
849
930
  });
850
931
 
851
932
  test('should return false for sets with different sizes', () => {
852
933
  const set1 = ISet.create<'a' | 'b' | 'c' | 'd'>(['a', 'b']);
853
934
  const set2 = ISet.create<'a' | 'b' | 'c' | 'd'>(['a', 'b', 'c']);
935
+
854
936
  expect(ISet.equal(set1, set2)).toBe(false);
855
937
  });
856
938
 
857
939
  test('should return false for sets with different elements', () => {
858
940
  const set1 = ISet.create<'a' | 'b' | 'c' | 'd'>(['a', 'b', 'c']);
859
941
  const set2 = ISet.create<'a' | 'b' | 'c' | 'd'>(['a', 'b', 'd']);
942
+
860
943
  expect(ISet.equal(set1, set2)).toBe(false);
861
944
  });
862
945
 
863
946
  test('should return true for empty sets', () => {
864
947
  const set1 = ISet.create<string>([]);
865
948
  const set2 = ISet.create<string>([]);
949
+
866
950
  expect(ISet.equal(set1, set2)).toBe(true);
867
951
  });
868
952
 
869
953
  test('should handle sets with special values', () => {
870
954
  const set1 = ISet.create([Number.NaN, null, undefined]);
871
955
  const set2 = ISet.create([undefined, Number.NaN, null]);
956
+
872
957
  expect(ISet.equal(set1, set2)).toBe(true);
873
958
  });
874
959
  });
@@ -917,10 +1002,12 @@ describe('ISet.diff', () => {
917
1002
  const nonEmptySet = ISet.create<string>(['a', 'b']);
918
1003
 
919
1004
  const diff1 = ISet.diff(emptySet, nonEmptySet);
1005
+
920
1006
  expect(diff1.deleted.isEmpty).toBe(true);
921
1007
  expect(diff1.added.size).toBe(2);
922
1008
 
923
1009
  const diff2 = ISet.diff(nonEmptySet, emptySet);
1010
+
924
1011
  expect(diff2.deleted.size).toBe(2);
925
1012
  expect(diff2.added.isEmpty).toBe(true);
926
1013
  });
@@ -946,6 +1033,7 @@ describe('ISet.withMutations', () => {
946
1033
  test('should handle empty mutations array', () => {
947
1034
  const set = ISet.create(['a', 'b', 'c']);
948
1035
  const updated = set.withMutations([]);
1036
+
949
1037
  expect(updated.size).toBe(set.size);
950
1038
  expect(ISet.equal(set, updated)).toBe(true);
951
1039
  });
@@ -957,6 +1045,7 @@ describe('ISet.withMutations', () => {
957
1045
  { type: 'delete', key: 'b' }, // Doesn't exist
958
1046
  { type: 'add', key: 'b' },
959
1047
  ]);
1048
+
960
1049
  expect(updated.size).toBe(2);
961
1050
  expect(updated.has('a')).toBe(true);
962
1051
  expect(updated.has('b')).toBe(true);
@@ -972,44 +1061,54 @@ describe('iterable functionality', () => {
972
1061
  mut_collected.push(value);
973
1062
  }
974
1063
 
975
- expect(mut_collected.toSorted((a, b) => a - b)).toStrictEqual([1, 2, 3]);
1064
+ assert.deepStrictEqual(
1065
+ mut_collected.toSorted((a, b) => a - b),
1066
+ [1, 2, 3],
1067
+ );
976
1068
  });
977
1069
 
978
1070
  test('should work with spread operator', () => {
979
1071
  const set = ISet.create([1, 2, 3]);
980
1072
  const array = Array.from(set);
981
1073
 
982
- expect(Array.from(array).toSorted((a, b) => a - b)).toStrictEqual([
983
- 1, 2, 3,
984
- ]);
1074
+ assert.deepStrictEqual(
1075
+ Array.from(array).toSorted((a, b) => a - b),
1076
+ [1, 2, 3],
1077
+ );
985
1078
  });
986
1079
 
987
1080
  test('should work with Array.from', () => {
988
1081
  const set = ISet.create([1, 2, 3]);
989
1082
  const array = Array.from(set);
990
1083
 
991
- expect(Array.from(array).toSorted((a, b) => a - b)).toStrictEqual([
992
- 1, 2, 3,
993
- ]);
1084
+ assert.deepStrictEqual(
1085
+ Array.from(array).toSorted((a, b) => a - b),
1086
+ [1, 2, 3],
1087
+ );
994
1088
  });
995
1089
 
996
1090
  test('should work with destructuring', () => {
997
1091
  const set = ISet.create([1, 2]);
998
1092
  const values = Array.from(set);
999
1093
 
1000
- expect(values.toSorted((a, b) => a - b)).toStrictEqual([1, 2]);
1094
+ assert.deepStrictEqual(
1095
+ values.toSorted((a, b) => a - b),
1096
+ [1, 2],
1097
+ );
1001
1098
  });
1002
1099
  });
1003
1100
 
1004
1101
  describe('edge cases', () => {
1005
1102
  test('should handle NaN correctly', () => {
1006
1103
  const set = ISet.create([Number.NaN, 1, 2]);
1104
+
1007
1105
  expect(set.has(Number.NaN)).toBe(true);
1008
1106
  expect(set.size).toBe(3);
1009
1107
  });
1010
1108
 
1011
1109
  test('should handle boolean values', () => {
1012
1110
  const set = ISet.create([true, false, true]);
1111
+
1013
1112
  expect(set.size).toBe(2);
1014
1113
  expect(set.has(true)).toBe(true);
1015
1114
  expect(set.has(false)).toBe(true);
@@ -1017,6 +1116,7 @@ describe('edge cases', () => {
1017
1116
 
1018
1117
  test('should handle null and undefined', () => {
1019
1118
  const set = ISet.create([null, undefined, null]);
1119
+
1020
1120
  expect(set.size).toBe(2);
1021
1121
  expect(set.has(null)).toBe(true);
1022
1122
  expect(set.has(undefined)).toBe(true);