ts-data-forge 4.1.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 (76) hide show
  1. package/dist/json/json.d.mts +9 -3
  2. package/dist/json/json.d.mts.map +1 -1
  3. package/dist/json/json.mjs +6 -0
  4. package/dist/json/json.mjs.map +1 -1
  5. package/package.json +13 -13
  6. package/src/array/impl/array-utils-creation.test.mts +187 -74
  7. package/src/array/impl/array-utils-element-access.test.mts +19 -3
  8. package/src/array/impl/array-utils-iterators.test.mts +44 -24
  9. package/src/array/impl/array-utils-modification.test.mts +36 -33
  10. package/src/array/impl/array-utils-reducing-value.test.mts +47 -16
  11. package/src/array/impl/array-utils-search.test.mts +42 -9
  12. package/src/array/impl/array-utils-set-op.test.mts +54 -26
  13. package/src/array/impl/array-utils-size.test.mts +1 -0
  14. package/src/array/impl/array-utils-slice-clamped.test.mts +20 -11
  15. package/src/array/impl/array-utils-slicing.test.mts +27 -21
  16. package/src/array/impl/array-utils-transformation.test.mts +140 -92
  17. package/src/array/impl/array-utils-validation.test.mts +58 -10
  18. package/src/array/impl/array.test.mts +5 -5
  19. package/src/collections/imap-mapped.test.mts +63 -18
  20. package/src/collections/imap.test.mts +74 -26
  21. package/src/collections/iset-mapped.test.mts +81 -30
  22. package/src/collections/iset.test.mts +168 -68
  23. package/src/collections/queue.test.mts +32 -1
  24. package/src/collections/stack.test.mts +22 -8
  25. package/src/functional/match.test.mts +1 -1
  26. package/src/functional/optional.test.mts +61 -4
  27. package/src/functional/pipe.test.mts +10 -1
  28. package/src/functional/result.test.mts +127 -4
  29. package/src/functional/ternary-result.test.mts +34 -18
  30. package/src/guard/is-non-empty-string.test.mts +5 -2
  31. package/src/guard/is-non-null-object.test.mts +3 -5
  32. package/src/guard/is-primitive.test.mts +5 -3
  33. package/src/guard/is-record.test.mts +1 -1
  34. package/src/guard/is-type.test.mts +35 -20
  35. package/src/guard/key-is-in.test.mts +1 -1
  36. package/src/iterator/range.test.mts +22 -16
  37. package/src/json/json.mts +9 -3
  38. package/src/json/json.test.mts +140 -64
  39. package/src/number/branded-types/finite-number.test.mts +3 -2
  40. package/src/number/branded-types/int.test.mts +4 -3
  41. package/src/number/branded-types/int16.test.mts +9 -3
  42. package/src/number/branded-types/int32.test.mts +9 -3
  43. package/src/number/branded-types/non-negative-finite-number.test.mts +6 -4
  44. package/src/number/branded-types/non-negative-int16.test.mts +8 -3
  45. package/src/number/branded-types/non-negative-int32.test.mts +8 -3
  46. package/src/number/branded-types/non-zero-finite-number.test.mts +6 -3
  47. package/src/number/branded-types/non-zero-int.test.mts +6 -3
  48. package/src/number/branded-types/non-zero-int16.test.mts +9 -3
  49. package/src/number/branded-types/non-zero-int32.test.mts +9 -3
  50. package/src/number/branded-types/non-zero-safe-int.test.mts +10 -3
  51. package/src/number/branded-types/non-zero-uint16.test.mts +8 -3
  52. package/src/number/branded-types/non-zero-uint32.test.mts +8 -3
  53. package/src/number/branded-types/positive-finite-number.test.mts +7 -3
  54. package/src/number/branded-types/positive-int.test.mts +5 -3
  55. package/src/number/branded-types/positive-int16.test.mts +8 -3
  56. package/src/number/branded-types/positive-int32.test.mts +8 -3
  57. package/src/number/branded-types/positive-safe-int.test.mts +8 -3
  58. package/src/number/branded-types/positive-uint16.test.mts +8 -3
  59. package/src/number/branded-types/positive-uint32.test.mts +8 -3
  60. package/src/number/branded-types/safe-int.test.mts +8 -2
  61. package/src/number/branded-types/safe-uint.test.mts +8 -3
  62. package/src/number/branded-types/uint.test.mts +5 -3
  63. package/src/number/branded-types/uint16.test.mts +8 -3
  64. package/src/number/branded-types/uint32.test.mts +8 -3
  65. package/src/number/enum/int8.test.mts +8 -3
  66. package/src/number/enum/uint8.test.mts +6 -3
  67. package/src/number/num.test.mts +16 -2
  68. package/src/object/object.test.mts +26 -13
  69. package/src/others/cast-mutable.test.mts +10 -8
  70. package/src/others/cast-readonly.test.mts +9 -5
  71. package/src/others/if-then.test.mts +4 -1
  72. package/src/others/map-nullable.test.mts +28 -1
  73. package/src/others/memoize-function.test.mts +20 -17
  74. package/src/others/tuple.test.mts +3 -2
  75. package/src/others/unknown-to-string.test.mts +15 -2
  76. package/src/promise/promise.test.mts +6 -1
@@ -20,7 +20,8 @@ describe('ISetMapped[Symbol.iterator]', () => {
20
20
  fromKey,
21
21
  );
22
22
 
23
- expect(s0).toStrictEqual(
23
+ assert.deepStrictEqual(
24
+ s0,
24
25
  ISetMapped.create([{ v: 1 }, { v: 2 }, { v: 3 }], toKey, fromKey),
25
26
  );
26
27
  });
@@ -48,6 +49,7 @@ describe('ISetMapped.has', () => {
48
49
 
49
50
  expect(s0.has({ v: 3 })).toBe(true);
50
51
  });
52
+
51
53
  test('case 2', () => {
52
54
  const s0 = ISetMapped.create(
53
55
  [{ v: 1 }, { v: 2 }, { v: 3 }],
@@ -57,6 +59,7 @@ describe('ISetMapped.has', () => {
57
59
 
58
60
  expect(s0.has({ v: 4 })).toBe(false);
59
61
  });
62
+
60
63
  test('case 3', () => {
61
64
  const s0 = ISetMapped.create<Readonly<{ v: number }>, number>(
62
65
  [],
@@ -76,17 +79,20 @@ describe('ISetMapped.add', () => {
76
79
  fromKey,
77
80
  );
78
81
 
79
- expect(s0.add({ v: 5 })).toStrictEqual(
82
+ assert.deepStrictEqual(
83
+ s0.add({ v: 5 }),
80
84
  ISetMapped.create(
81
85
  [{ v: 1 }, { v: 2 }, { v: 3 }, { v: 5 }],
82
86
  toKey,
83
87
  fromKey,
84
88
  ),
85
89
  );
86
- expect(s0).toStrictEqual(
90
+ assert.deepStrictEqual(
91
+ s0,
87
92
  ISetMapped.create([{ v: 1 }, { v: 2 }, { v: 3 }], toKey, fromKey),
88
93
  );
89
94
  });
95
+
90
96
  test('case 2', () => {
91
97
  const s0 = ISetMapped.create(
92
98
  [{ v: 1 }, { v: 2 }, { v: 3 }],
@@ -94,20 +100,24 @@ describe('ISetMapped.add', () => {
94
100
  fromKey,
95
101
  );
96
102
 
97
- expect(s0.add({ v: 3 })).toStrictEqual(
103
+ assert.deepStrictEqual(
104
+ s0.add({ v: 3 }),
98
105
  ISetMapped.create([{ v: 1 }, { v: 2 }, { v: 3 }], toKey, fromKey),
99
106
  );
100
- expect(s0).toStrictEqual(
107
+ assert.deepStrictEqual(
108
+ s0,
101
109
  ISetMapped.create([{ v: 1 }, { v: 2 }, { v: 3 }], toKey, fromKey),
102
110
  );
103
111
  });
112
+
104
113
  test('case 3', () => {
105
114
  const s0 = ISetMapped.create([], toKey, fromKey);
106
115
 
107
- expect(s0.add({ v: 1 })).toStrictEqual(
116
+ assert.deepStrictEqual(
117
+ s0.add({ v: 1 }),
108
118
  ISetMapped.create([{ v: 1 }], toKey, fromKey),
109
119
  );
110
- expect(s0).toStrictEqual(ISetMapped.create([], toKey, fromKey));
120
+ assert.deepStrictEqual(s0, ISetMapped.create([], toKey, fromKey));
111
121
  });
112
122
  });
113
123
 
@@ -119,13 +129,16 @@ describe('ISetMapped.delete', () => {
119
129
  fromKey,
120
130
  );
121
131
 
122
- expect(s0.delete({ v: 10 })).toStrictEqual(
132
+ assert.deepStrictEqual(
133
+ s0.delete({ v: 10 }),
123
134
  ISetMapped.create([{ v: 1 }, { v: 2 }, { v: 3 }], toKey, fromKey),
124
135
  );
125
- expect(s0).toStrictEqual(
136
+ assert.deepStrictEqual(
137
+ s0,
126
138
  ISetMapped.create([{ v: 1 }, { v: 2 }, { v: 3 }], toKey, fromKey),
127
139
  );
128
140
  });
141
+
129
142
  test('case 2', () => {
130
143
  const s0 = ISetMapped.create(
131
144
  [{ v: 1 }, { v: 2 }, { v: 3 }],
@@ -133,20 +146,24 @@ describe('ISetMapped.delete', () => {
133
146
  fromKey,
134
147
  );
135
148
 
136
- expect(s0.delete({ v: 3 })).toStrictEqual(
149
+ assert.deepStrictEqual(
150
+ s0.delete({ v: 3 }),
137
151
  ISetMapped.create([{ v: 1 }, { v: 2 }], toKey, fromKey),
138
152
  );
139
- expect(s0).toStrictEqual(
153
+ assert.deepStrictEqual(
154
+ s0,
140
155
  ISetMapped.create([{ v: 1 }, { v: 2 }, { v: 3 }], toKey, fromKey),
141
156
  );
142
157
  });
158
+
143
159
  test('case 3', () => {
144
160
  const s0 = ISetMapped.create([], toKey, fromKey);
145
161
 
146
- expect(s0.delete({ v: 1 })).toStrictEqual(
162
+ assert.deepStrictEqual(
163
+ s0.delete({ v: 1 }),
147
164
  ISetMapped.create([], toKey, fromKey),
148
165
  );
149
- expect(s0).toStrictEqual(ISetMapped.create([], toKey, fromKey));
166
+ assert.deepStrictEqual(s0, ISetMapped.create([], toKey, fromKey));
150
167
  });
151
168
  });
152
169
 
@@ -207,7 +224,8 @@ describe('ISetMapped.entries', () => {
207
224
  for (const [k, v] of s0.entries()) {
208
225
  expect(elements).toContainEqual(k);
209
226
  expect(elements).toContainEqual(v);
210
- expect(k).toStrictEqual(v);
227
+
228
+ assert.deepStrictEqual(k, v);
211
229
  }
212
230
  });
213
231
  });
@@ -221,10 +239,12 @@ describe('ISetMapped.subtract', () => {
221
239
  );
222
240
  const s1 = ISetMapped.create([{ v: 2 }, { v: 4 }], toKey, fromKey);
223
241
 
224
- expect(s0.subtract(s1)).toStrictEqual(
242
+ assert.deepStrictEqual(
243
+ s0.subtract(s1),
225
244
  ISetMapped.create([{ v: 1 }, { v: 3 }], toKey, fromKey),
226
245
  );
227
246
  });
247
+
228
248
  test('case 2', () => {
229
249
  const s0 = ISetMapped.create(
230
250
  [{ v: 1 }, { v: 2 }, { v: 3 }],
@@ -233,10 +253,12 @@ describe('ISetMapped.subtract', () => {
233
253
  );
234
254
  const s1 = ISetMapped.create([], toKey, fromKey);
235
255
 
236
- expect(s0.subtract(s1)).toStrictEqual(
256
+ assert.deepStrictEqual(
257
+ s0.subtract(s1),
237
258
  ISetMapped.create([{ v: 1 }, { v: 2 }, { v: 3 }], toKey, fromKey),
238
259
  );
239
260
  });
261
+
240
262
  test('case 3', () => {
241
263
  const s0 = ISetMapped.create([], toKey, fromKey);
242
264
  const s1 = ISetMapped.create(
@@ -245,7 +267,8 @@ describe('ISetMapped.subtract', () => {
245
267
  fromKey,
246
268
  );
247
269
 
248
- expect(s0.subtract(s1)).toStrictEqual(
270
+ assert.deepStrictEqual(
271
+ s0.subtract(s1),
249
272
  ISetMapped.create([], toKey, fromKey),
250
273
  );
251
274
  });
@@ -266,13 +289,16 @@ describe('ISetMapped.diff', () => {
266
289
 
267
290
  const diff = ISetMapped.diff(s0, s1);
268
291
 
269
- expect(diff.deleted).toStrictEqual(
292
+ assert.deepStrictEqual(
293
+ diff.deleted,
270
294
  ISetMapped.create([{ v: 1 }], toKey, fromKey),
271
295
  );
272
- expect(diff.added).toStrictEqual(
296
+ assert.deepStrictEqual(
297
+ diff.added,
273
298
  ISetMapped.create([{ v: 4 }], toKey, fromKey),
274
299
  );
275
300
  });
301
+
276
302
  test('case 2', () => {
277
303
  const s0 = ISetMapped.create(
278
304
  [{ v: 1 }, { v: 2 }, { v: 3 }],
@@ -283,11 +309,13 @@ describe('ISetMapped.diff', () => {
283
309
 
284
310
  const diff = ISetMapped.diff(s0, s1);
285
311
 
286
- expect(diff.deleted).toStrictEqual(
312
+ assert.deepStrictEqual(
313
+ diff.deleted,
287
314
  ISetMapped.create([{ v: 1 }, { v: 2 }, { v: 3 }], toKey, fromKey),
288
315
  );
289
- expect(diff.added).toStrictEqual(ISetMapped.create([], toKey, fromKey));
316
+ assert.deepStrictEqual(diff.added, ISetMapped.create([], toKey, fromKey));
290
317
  });
318
+
291
319
  test('case 3', () => {
292
320
  const s0 = ISetMapped.create([], toKey, fromKey);
293
321
  const s1 = ISetMapped.create(
@@ -298,8 +326,9 @@ describe('ISetMapped.diff', () => {
298
326
 
299
327
  const diff = ISetMapped.diff(s0, s1);
300
328
 
301
- expect(diff.deleted).toStrictEqual(ISetMapped.create([], toKey, fromKey));
302
- expect(diff.added).toStrictEqual(
329
+ assert.deepStrictEqual(diff.deleted, ISetMapped.create([], toKey, fromKey));
330
+ assert.deepStrictEqual(
331
+ diff.added,
303
332
  ISetMapped.create([{ v: 1 }, { v: 2 }, { v: 3 }], toKey, fromKey),
304
333
  );
305
334
  });
@@ -318,7 +347,8 @@ describe('ISetMapped.union', () => {
318
347
  fromKey,
319
348
  );
320
349
 
321
- expect(ISetMapped.union(s0, s1)).toStrictEqual(
350
+ assert.deepStrictEqual(
351
+ ISetMapped.union(s0, s1),
322
352
  ISetMapped.create(
323
353
  [{ v: 1 }, { v: 2 }, { v: 3 }, { v: 4 }, { v: 5 }],
324
354
  toKey,
@@ -326,6 +356,7 @@ describe('ISetMapped.union', () => {
326
356
  ),
327
357
  );
328
358
  });
359
+
329
360
  test('case 2', () => {
330
361
  const s0 = ISetMapped.create(
331
362
  [{ v: 1 }, { v: 2 }, { v: 3 }],
@@ -334,10 +365,12 @@ describe('ISetMapped.union', () => {
334
365
  );
335
366
  const s1 = ISetMapped.create([], toKey, fromKey);
336
367
 
337
- expect(ISetMapped.union(s0, s1)).toStrictEqual(
368
+ assert.deepStrictEqual(
369
+ ISetMapped.union(s0, s1),
338
370
  ISetMapped.create([{ v: 1 }, { v: 2 }, { v: 3 }], toKey, fromKey),
339
371
  );
340
372
  });
373
+
341
374
  test('case 3', () => {
342
375
  const s0 = ISetMapped.create([], toKey, fromKey);
343
376
  const s1 = ISetMapped.create(
@@ -346,7 +379,8 @@ describe('ISetMapped.union', () => {
346
379
  fromKey,
347
380
  );
348
381
 
349
- expect(ISetMapped.union(s0, s1)).toStrictEqual(
382
+ assert.deepStrictEqual(
383
+ ISetMapped.union(s0, s1),
350
384
  ISetMapped.create([{ v: 1 }, { v: 2 }, { v: 3 }], toKey, fromKey),
351
385
  );
352
386
  });
@@ -365,10 +399,12 @@ describe('ISetMapped.intersection', () => {
365
399
  fromKey,
366
400
  );
367
401
 
368
- expect(ISetMapped.intersection(s0, s1)).toStrictEqual(
402
+ assert.deepStrictEqual(
403
+ ISetMapped.intersection(s0, s1),
369
404
  ISetMapped.create([{ v: 2 }, { v: 3 }], toKey, fromKey),
370
405
  );
371
406
  });
407
+
372
408
  test('case 2', () => {
373
409
  const s0 = ISetMapped.create(
374
410
  [{ v: 1 }, { v: 2 }, { v: 3 }],
@@ -377,10 +413,12 @@ describe('ISetMapped.intersection', () => {
377
413
  );
378
414
  const s1 = ISetMapped.create([], toKey, fromKey);
379
415
 
380
- expect(ISetMapped.intersection(s0, s1)).toStrictEqual(
416
+ assert.deepStrictEqual(
417
+ ISetMapped.intersection(s0, s1),
381
418
  ISetMapped.create([], toKey, fromKey),
382
419
  );
383
420
  });
421
+
384
422
  test('case 3', () => {
385
423
  const s0 = ISetMapped.create([], toKey, fromKey);
386
424
  const s1 = ISetMapped.create(
@@ -389,7 +427,8 @@ describe('ISetMapped.intersection', () => {
389
427
  fromKey,
390
428
  );
391
429
 
392
- expect(ISetMapped.intersection(s0, s1)).toStrictEqual(
430
+ assert.deepStrictEqual(
431
+ ISetMapped.intersection(s0, s1),
393
432
  ISetMapped.create([], toKey, fromKey),
394
433
  );
395
434
  });
@@ -403,6 +442,7 @@ describe('ISetMapped additional functionality with complex types', () => {
403
442
  testElementToString,
404
443
  stringToTestElement,
405
444
  );
445
+
406
446
  expect(set.size).toBe(0);
407
447
  });
408
448
 
@@ -415,6 +455,7 @@ describe('ISetMapped additional functionality with complex types', () => {
415
455
  testElementToString,
416
456
  stringToTestElement,
417
457
  );
458
+
418
459
  expect(set.size).toBe(2);
419
460
  expect(set.has({ id: 1, type: 'user' })).toBe(true);
420
461
  expect(set.has({ id: 2, type: 'admin' })).toBe(true);
@@ -430,6 +471,7 @@ describe('ISetMapped additional functionality with complex types', () => {
430
471
  testElementToString,
431
472
  stringToTestElement,
432
473
  );
474
+
433
475
  expect(set.size).toBe(2);
434
476
  });
435
477
  });
@@ -452,6 +494,7 @@ describe('ISetMapped additional functionality with complex types', () => {
452
494
  testElementToString,
453
495
  stringToTestElement,
454
496
  );
497
+
455
498
  expect(ISetMapped.equal(set1, set2)).toBe(true);
456
499
  });
457
500
 
@@ -472,6 +515,7 @@ describe('ISetMapped additional functionality with complex types', () => {
472
515
  testElementToString,
473
516
  stringToTestElement,
474
517
  );
518
+
475
519
  expect(ISetMapped.equal(set1, set2)).toBe(false);
476
520
  });
477
521
 
@@ -486,6 +530,7 @@ describe('ISetMapped additional functionality with complex types', () => {
486
530
  testElementToString,
487
531
  stringToTestElement,
488
532
  );
533
+
489
534
  expect(ISetMapped.equal(set1, set2)).toBe(true);
490
535
  });
491
536
  });
@@ -611,6 +656,7 @@ describe('ISetMapped additional functionality with complex types', () => {
611
656
  testElementToString,
612
657
  stringToTestElement,
613
658
  );
659
+
614
660
  expect(set.every((el) => el.type === 'user')).toBe(true);
615
661
  });
616
662
 
@@ -623,6 +669,7 @@ describe('ISetMapped additional functionality with complex types', () => {
623
669
  testElementToString,
624
670
  stringToTestElement,
625
671
  );
672
+
626
673
  expect(set.every((el) => el.type === 'user')).toBe(false);
627
674
  });
628
675
  });
@@ -637,6 +684,7 @@ describe('ISetMapped additional functionality with complex types', () => {
637
684
  testElementToString,
638
685
  stringToTestElement,
639
686
  );
687
+
640
688
  expect(set.some((el) => el.type === 'admin')).toBe(true);
641
689
  });
642
690
 
@@ -649,6 +697,7 @@ describe('ISetMapped additional functionality with complex types', () => {
649
697
  testElementToString,
650
698
  stringToTestElement,
651
699
  );
700
+
652
701
  expect(set.some((el) => el.type === 'admin')).toBe(false);
653
702
  });
654
703
  });
@@ -735,6 +784,7 @@ describe('ISetMapped additional functionality with complex types', () => {
735
784
  stringToTestElement,
736
785
  );
737
786
  const updated = set.withMutations([]);
787
+
738
788
  expect(updated.size).toBe(1);
739
789
  expect(ISetMapped.equal(set, updated)).toBe(true);
740
790
  });
@@ -1035,8 +1085,9 @@ describe('ISetMapped additional functionality with complex types', () => {
1035
1085
  const entries = Array.from(set.entries());
1036
1086
 
1037
1087
  expect(entries).toHaveLength(2);
1088
+
1038
1089
  for (const [key, value] of entries) {
1039
- expect(key).toStrictEqual(value);
1090
+ assert.deepStrictEqual(key, value);
1040
1091
  }
1041
1092
  });
1042
1093