ts-data-forge 5.1.0 → 5.1.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.
- package/README.md +46 -44
- package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
- package/dist/array/impl/array-utils-modification.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.d.mts +8 -8
- package/dist/array/impl/array-utils-search.d.mts +4 -4
- package/dist/array/impl/array-utils-set-op.d.mts +7 -7
- package/dist/array/impl/array-utils-set-op.mjs +7 -7
- package/dist/array/impl/array-utils-size.d.mts +2 -2
- package/dist/array/impl/array-utils-size.mjs +2 -2
- package/dist/array/impl/array-utils-slicing.d.mts +2 -2
- package/dist/array/impl/array-utils-slicing.mjs +2 -2
- package/dist/array/impl/array-utils-validation.d.mts +18 -18
- package/dist/array/impl/array-utils-validation.mjs +14 -14
- package/dist/collections/imap.d.mts +15 -15
- package/dist/collections/imap.mjs +3 -3
- package/dist/collections/iset-mapped.d.mts +19 -19
- package/dist/collections/iset-mapped.mjs +2 -2
- package/dist/collections/iset.d.mts +19 -19
- package/dist/collections/iset.mjs +2 -2
- package/dist/collections/queue.d.mts +25 -25
- package/dist/collections/queue.mjs +5 -5
- package/dist/collections/stack.d.mts +25 -25
- package/dist/collections/stack.mjs +5 -5
- package/dist/functional/match.d.mts +1 -1
- package/dist/functional/optional/impl/optional-expect-to-be.d.mts +2 -2
- package/dist/functional/optional/impl/optional-is-none.d.mts +1 -1
- package/dist/functional/optional/impl/optional-is-none.mjs +1 -1
- package/dist/functional/optional/impl/optional-is-optional.d.mts +2 -2
- package/dist/functional/optional/impl/optional-is-optional.mjs +2 -2
- package/dist/functional/optional/impl/optional-is-some.d.mts +1 -1
- package/dist/functional/optional/impl/optional-is-some.mjs +1 -1
- package/dist/functional/optional/impl/optional-none.d.mts +2 -2
- package/dist/functional/optional/impl/optional-none.mjs +2 -2
- package/dist/functional/optional/impl/optional-some.d.mts +2 -2
- package/dist/functional/optional/impl/optional-some.mjs +2 -2
- package/dist/functional/optional/impl/optional-to-nullable.d.mts +2 -2
- package/dist/functional/optional/impl/optional-to-nullable.mjs +2 -2
- package/dist/functional/optional/impl/optional-unwrap-or.d.mts +4 -4
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts +1 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs +1 -1
- package/dist/functional/optional/impl/optional-unwrap.d.mts +2 -2
- package/dist/functional/optional/impl/optional-zip.d.mts +1 -1
- package/dist/functional/optional/impl/optional-zip.mjs +1 -1
- package/dist/functional/pipe.d.mts +2 -2
- package/dist/functional/result/impl/result-err.d.mts +1 -1
- package/dist/functional/result/impl/result-err.mjs +1 -1
- package/dist/functional/result/impl/result-expect-to-be.d.mts +2 -2
- package/dist/functional/result/impl/result-from-promise.d.mts +1 -1
- package/dist/functional/result/impl/result-from-promise.mjs +1 -1
- package/dist/functional/result/impl/result-from-throwable.d.mts +1 -1
- package/dist/functional/result/impl/result-from-throwable.mjs +1 -1
- package/dist/functional/result/impl/result-is-err.d.mts +2 -2
- package/dist/functional/result/impl/result-is-err.mjs +2 -2
- package/dist/functional/result/impl/result-is-ok.d.mts +2 -2
- package/dist/functional/result/impl/result-is-ok.mjs +2 -2
- package/dist/functional/result/impl/result-is-result.d.mts +3 -3
- package/dist/functional/result/impl/result-is-result.mjs +3 -3
- package/dist/functional/result/impl/result-ok.d.mts +1 -1
- package/dist/functional/result/impl/result-ok.mjs +1 -1
- package/dist/functional/result/impl/result-unwrap-err-or.d.mts +4 -4
- package/dist/functional/result/impl/result-unwrap-err-throw.d.mts +1 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs +1 -1
- package/dist/functional/result/impl/result-unwrap-err.d.mts +2 -2
- package/dist/functional/result/impl/result-unwrap-err.mjs +2 -2
- package/dist/functional/result/impl/result-unwrap-ok-or.d.mts +4 -4
- package/dist/functional/result/impl/result-unwrap-ok.d.mts +2 -2
- package/dist/functional/result/impl/result-unwrap-throw.d.mts +1 -1
- package/dist/functional/result/impl/result-unwrap-throw.mjs +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts +3 -3
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +3 -3
- package/dist/globals.d.mts +2 -1
- package/dist/guard/has-key.d.mts +6 -3
- package/dist/guard/has-key.d.mts.map +1 -1
- package/dist/guard/has-key.mjs +2 -2
- package/dist/guard/key-is-in.d.mts +2 -2
- package/dist/guard/key-is-in.mjs +2 -2
- package/dist/json/json.d.mts +21 -21
- package/dist/json/json.mjs +21 -21
- package/dist/number/branded-types/int.d.mts +19 -19
- package/dist/number/branded-types/int.mjs +19 -19
- package/dist/number/branded-types/positive-int.d.mts +20 -20
- package/dist/number/branded-types/positive-int.mjs +20 -20
- package/dist/number/branded-types/positive-safe-int.d.mts +26 -26
- package/dist/number/branded-types/positive-safe-int.mjs +26 -26
- package/dist/number/branded-types/safe-int.d.mts +27 -27
- package/dist/number/branded-types/safe-int.mjs +27 -27
- package/dist/number/branded-types/uint.d.mts +19 -19
- package/dist/number/branded-types/uint.mjs +19 -19
- package/dist/number/num.d.mts +20 -20
- package/dist/number/num.mjs +16 -16
- package/dist/number/refined-number-utils.d.mts +11 -11
- package/dist/number/refined-number-utils.d.mts.map +1 -1
- package/dist/number/refined-number-utils.mjs +11 -11
- package/dist/object/object.d.mts +3 -3
- package/dist/object/object.d.mts.map +1 -1
- package/dist/object/object.mjs +3 -3
- package/dist/object/object.mjs.map +1 -1
- package/dist/others/tuple.d.mts +3 -3
- package/dist/others/tuple.mjs +3 -3
- package/dist/promise/promise.d.mts +4 -4
- package/dist/promise/promise.mjs +4 -4
- package/package.json +15 -13
- package/src/array/impl/array-utils-creation.test.mts +1 -1
- package/src/array/impl/array-utils-element-access.test.mts +16 -16
- package/src/array/impl/array-utils-modification.mts +38 -19
- package/src/array/impl/array-utils-reducing-value.mts +8 -8
- package/src/array/impl/array-utils-reducing-value.test.mts +23 -31
- package/src/array/impl/array-utils-search.mts +4 -4
- package/src/array/impl/array-utils-search.test.mts +10 -10
- package/src/array/impl/array-utils-set-op.mts +7 -7
- package/src/array/impl/array-utils-set-op.test.mts +13 -13
- package/src/array/impl/array-utils-size.mts +2 -2
- package/src/array/impl/array-utils-slicing.mts +2 -2
- package/src/array/impl/array-utils-transformation.test.mts +2 -2
- package/src/array/impl/array-utils-validation.mts +18 -18
- package/src/array/impl/array-utils-validation.test.mts +80 -78
- package/src/array/impl/array.test.mts +6 -6
- package/src/collections/imap-mapped.test.mts +16 -18
- package/src/collections/imap.mts +15 -15
- package/src/collections/imap.test.mts +31 -31
- package/src/collections/iset-mapped.mts +19 -19
- package/src/collections/iset-mapped.test.mts +52 -52
- package/src/collections/iset.mts +19 -19
- package/src/collections/iset.test.mts +130 -130
- package/src/collections/queue.mts +25 -25
- package/src/collections/queue.test.mts +33 -35
- package/src/collections/stack.mts +25 -25
- package/src/collections/stack.test.mts +15 -15
- package/src/functional/match.mts +1 -1
- package/src/functional/optional/impl/optional-expect-to-be.mts +2 -2
- package/src/functional/optional/impl/optional-is-none.mts +1 -1
- package/src/functional/optional/impl/optional-is-optional.mts +2 -2
- package/src/functional/optional/impl/optional-is-some.mts +1 -1
- package/src/functional/optional/impl/optional-none.mts +2 -2
- package/src/functional/optional/impl/optional-some.mts +2 -2
- package/src/functional/optional/impl/optional-to-nullable.mts +2 -2
- package/src/functional/optional/impl/optional-unwrap-or.mts +4 -4
- package/src/functional/optional/impl/optional-unwrap-throw.mts +1 -1
- package/src/functional/optional/impl/optional-unwrap.mts +2 -2
- package/src/functional/optional/impl/optional-zip.mts +1 -1
- package/src/functional/optional.test.mts +53 -54
- package/src/functional/pipe.mts +2 -2
- package/src/functional/pipe.test.mts +4 -4
- package/src/functional/result/impl/result-err.mts +1 -1
- package/src/functional/result/impl/result-expect-to-be.mts +2 -2
- package/src/functional/result/impl/result-from-promise.mts +1 -1
- package/src/functional/result/impl/result-from-throwable.mts +1 -1
- package/src/functional/result/impl/result-is-err.mts +2 -2
- package/src/functional/result/impl/result-is-ok.mts +2 -2
- package/src/functional/result/impl/result-is-result.mts +3 -3
- package/src/functional/result/impl/result-ok.mts +1 -1
- package/src/functional/result/impl/result-unwrap-err-or.mts +4 -4
- package/src/functional/result/impl/result-unwrap-err-throw.mts +1 -1
- package/src/functional/result/impl/result-unwrap-err.mts +2 -2
- package/src/functional/result/impl/result-unwrap-ok-or.mts +4 -4
- package/src/functional/result/impl/result-unwrap-ok.mts +2 -2
- package/src/functional/result/impl/result-unwrap-throw.mts +1 -1
- package/src/functional/result.test.mts +94 -152
- package/src/functional/ternary-result/impl/ternary-result-err.mts +1 -1
- package/src/functional/ternary-result/impl/ternary-result-from-promise.mts +1 -1
- package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +1 -1
- package/src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts +3 -3
- package/src/functional/ternary-result.test.mts +8 -8
- package/src/globals.d.mts +2 -1
- package/src/guard/has-key.mts +8 -5
- package/src/guard/has-key.test.mts +0 -5
- package/src/guard/is-error.test.mts +143 -0
- package/src/guard/is-non-empty-string.test.mts +24 -24
- package/src/guard/is-non-null-object.test.mts +26 -26
- package/src/guard/is-primitive.test.mts +28 -28
- package/src/guard/is-record.test.mts +7 -7
- package/src/guard/is-type.test.mts +151 -155
- package/src/guard/key-is-in.mts +2 -2
- package/src/guard/key-is-in.test.mts +2 -2
- package/src/json/json.mts +21 -21
- package/src/json/json.test.mts +135 -174
- package/src/number/branded-types/finite-number.test.mts +13 -11
- package/src/number/branded-types/int.mts +19 -19
- package/src/number/branded-types/int.test.mts +14 -14
- package/src/number/branded-types/int16.test.mts +16 -16
- package/src/number/branded-types/int32.test.mts +16 -16
- package/src/number/branded-types/non-negative-finite-number.test.mts +12 -12
- package/src/number/branded-types/non-negative-int16.test.mts +16 -16
- package/src/number/branded-types/non-negative-int32.test.mts +16 -16
- package/src/number/branded-types/non-zero-finite-number.test.mts +14 -14
- package/src/number/branded-types/non-zero-int.test.mts +19 -19
- package/src/number/branded-types/non-zero-int16.test.mts +16 -16
- package/src/number/branded-types/non-zero-int32.test.mts +16 -16
- package/src/number/branded-types/non-zero-safe-int.test.mts +23 -23
- package/src/number/branded-types/non-zero-uint16.test.mts +16 -16
- package/src/number/branded-types/non-zero-uint32.test.mts +16 -16
- package/src/number/branded-types/positive-finite-number.test.mts +14 -14
- package/src/number/branded-types/positive-int.mts +20 -20
- package/src/number/branded-types/positive-int.test.mts +17 -17
- package/src/number/branded-types/positive-int16.test.mts +15 -15
- package/src/number/branded-types/positive-int32.test.mts +15 -15
- package/src/number/branded-types/positive-safe-int.mts +26 -26
- package/src/number/branded-types/positive-safe-int.test.mts +19 -19
- package/src/number/branded-types/positive-uint16.test.mts +16 -16
- package/src/number/branded-types/positive-uint32.test.mts +16 -16
- package/src/number/branded-types/safe-int.mts +27 -27
- package/src/number/branded-types/safe-int.test.mts +18 -18
- package/src/number/branded-types/safe-uint.test.mts +17 -17
- package/src/number/branded-types/uint.mts +19 -19
- package/src/number/branded-types/uint.test.mts +15 -15
- package/src/number/branded-types/uint16.test.mts +15 -15
- package/src/number/branded-types/uint32.test.mts +15 -15
- package/src/number/enum/int8.test.mts +1 -1
- package/src/number/enum/uint8.test.mts +1 -1
- package/src/number/num.mts +20 -20
- package/src/number/num.test.mts +26 -26
- package/src/number/refined-number-utils.mts +13 -13
- package/src/object/object.mts +4 -3
- package/src/object/object.test.mts +6 -6
- package/src/others/cast-mutable.test.mts +1 -1
- package/src/others/cast-readonly.test.mts +4 -4
- package/src/others/if-then.test.mts +24 -24
- package/src/others/tuple.mts +3 -3
- package/src/promise/promise.mts +4 -4
- package/src/promise/promise.test.mts +7 -13
|
@@ -51,7 +51,7 @@ describe('ISetMapped.has', () => {
|
|
|
51
51
|
fromKey,
|
|
52
52
|
);
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
assert.isTrue(s0.has({ v: 3 }));
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
test('case 2', () => {
|
|
@@ -61,7 +61,7 @@ describe('ISetMapped.has', () => {
|
|
|
61
61
|
fromKey,
|
|
62
62
|
);
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
assert.isFalse(s0.has({ v: 4 }));
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
test('case 3', () => {
|
|
@@ -71,7 +71,7 @@ describe('ISetMapped.has', () => {
|
|
|
71
71
|
fromKey,
|
|
72
72
|
);
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
assert.isFalse(s0.has({ v: 3 }));
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
|
|
@@ -488,9 +488,9 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
488
488
|
|
|
489
489
|
expect(set.size).toBe(2);
|
|
490
490
|
|
|
491
|
-
|
|
491
|
+
assert.isTrue(set.has({ id: 1, type: 'user' }));
|
|
492
492
|
|
|
493
|
-
|
|
493
|
+
assert.isTrue(set.has({ id: 2, type: 'admin' }));
|
|
494
494
|
});
|
|
495
495
|
|
|
496
496
|
test('should handle duplicate elements based on mapping', () => {
|
|
@@ -528,7 +528,7 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
528
528
|
stringToTestElement,
|
|
529
529
|
);
|
|
530
530
|
|
|
531
|
-
|
|
531
|
+
assert.isTrue(ISetMapped.equal(set1, set2));
|
|
532
532
|
});
|
|
533
533
|
|
|
534
534
|
test('should return false for sets with different elements', () => {
|
|
@@ -550,7 +550,7 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
550
550
|
stringToTestElement,
|
|
551
551
|
);
|
|
552
552
|
|
|
553
|
-
|
|
553
|
+
assert.isFalse(ISetMapped.equal(set1, set2));
|
|
554
554
|
});
|
|
555
555
|
|
|
556
556
|
test('should return true for empty sets', () => {
|
|
@@ -566,7 +566,7 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
566
566
|
stringToTestElement,
|
|
567
567
|
);
|
|
568
568
|
|
|
569
|
-
|
|
569
|
+
assert.isTrue(ISetMapped.equal(set1, set2));
|
|
570
570
|
});
|
|
571
571
|
});
|
|
572
572
|
|
|
@@ -596,11 +596,11 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
596
596
|
|
|
597
597
|
expect(diff.deleted.size).toBe(1);
|
|
598
598
|
|
|
599
|
-
|
|
599
|
+
assert.isTrue(diff.deleted.has({ id: 1, type: 'user' }));
|
|
600
600
|
|
|
601
601
|
expect(diff.added.size).toBe(1);
|
|
602
602
|
|
|
603
|
-
|
|
603
|
+
assert.isTrue(diff.added.has({ id: 4, type: 'user' }));
|
|
604
604
|
});
|
|
605
605
|
|
|
606
606
|
test('should handle no changes', () => {
|
|
@@ -656,9 +656,9 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
656
656
|
|
|
657
657
|
expect(intersection.size).toBe(2);
|
|
658
658
|
|
|
659
|
-
|
|
659
|
+
assert.isTrue(intersection.has({ id: 2, type: 'admin' }));
|
|
660
660
|
|
|
661
|
-
|
|
661
|
+
assert.isTrue(intersection.has({ id: 3, type: 'guest' }));
|
|
662
662
|
});
|
|
663
663
|
|
|
664
664
|
test('should compute union correctly', () => {
|
|
@@ -684,13 +684,13 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
684
684
|
|
|
685
685
|
expect(union.size).toBe(4);
|
|
686
686
|
|
|
687
|
-
|
|
687
|
+
assert.isTrue(union.has({ id: 1, type: 'user' }));
|
|
688
688
|
|
|
689
|
-
|
|
689
|
+
assert.isTrue(union.has({ id: 2, type: 'admin' }));
|
|
690
690
|
|
|
691
|
-
|
|
691
|
+
assert.isTrue(union.has({ id: 3, type: 'guest' }));
|
|
692
692
|
|
|
693
|
-
|
|
693
|
+
assert.isTrue(union.has({ id: 4, type: 'user' }));
|
|
694
694
|
});
|
|
695
695
|
});
|
|
696
696
|
|
|
@@ -705,7 +705,7 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
705
705
|
stringToTestElement,
|
|
706
706
|
);
|
|
707
707
|
|
|
708
|
-
|
|
708
|
+
assert.isTrue(set.every((el) => el.type === 'user'));
|
|
709
709
|
});
|
|
710
710
|
|
|
711
711
|
test('should return false when some elements do not satisfy predicate', () => {
|
|
@@ -718,7 +718,7 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
718
718
|
stringToTestElement,
|
|
719
719
|
);
|
|
720
720
|
|
|
721
|
-
|
|
721
|
+
assert.isFalse(set.every((el) => el.type === 'user'));
|
|
722
722
|
});
|
|
723
723
|
});
|
|
724
724
|
|
|
@@ -733,7 +733,7 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
733
733
|
stringToTestElement,
|
|
734
734
|
);
|
|
735
735
|
|
|
736
|
-
|
|
736
|
+
assert.isTrue(set.some((el) => el.type === 'admin'));
|
|
737
737
|
});
|
|
738
738
|
|
|
739
739
|
test('should return false when no elements satisfy predicate', () => {
|
|
@@ -746,7 +746,7 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
746
746
|
stringToTestElement,
|
|
747
747
|
);
|
|
748
748
|
|
|
749
|
-
|
|
749
|
+
assert.isFalse(set.some((el) => el.type === 'admin'));
|
|
750
750
|
});
|
|
751
751
|
});
|
|
752
752
|
|
|
@@ -762,9 +762,9 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
762
762
|
|
|
763
763
|
expect(updated.size).toBe(2);
|
|
764
764
|
|
|
765
|
-
|
|
765
|
+
assert.isTrue(updated.has({ id: 1, type: 'user' }));
|
|
766
766
|
|
|
767
|
-
|
|
767
|
+
assert.isTrue(updated.has({ id: 2, type: 'admin' }));
|
|
768
768
|
});
|
|
769
769
|
|
|
770
770
|
test('should return same instance when adding existing element', () => {
|
|
@@ -795,9 +795,9 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
795
795
|
|
|
796
796
|
expect(updated.size).toBe(1);
|
|
797
797
|
|
|
798
|
-
|
|
798
|
+
assert.isFalse(updated.has({ id: 1, type: 'user' }));
|
|
799
799
|
|
|
800
|
-
|
|
800
|
+
assert.isTrue(updated.has({ id: 2, type: 'admin' }));
|
|
801
801
|
});
|
|
802
802
|
|
|
803
803
|
test('should return same instance when deleting non-existent element', () => {
|
|
@@ -829,11 +829,11 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
829
829
|
|
|
830
830
|
expect(updated.size).toBe(2);
|
|
831
831
|
|
|
832
|
-
|
|
832
|
+
assert.isFalse(updated.has({ id: 1, type: 'user' }));
|
|
833
833
|
|
|
834
|
-
|
|
834
|
+
assert.isTrue(updated.has({ id: 2, type: 'admin' }));
|
|
835
835
|
|
|
836
|
-
|
|
836
|
+
assert.isTrue(updated.has({ id: 3, type: 'guest' }));
|
|
837
837
|
});
|
|
838
838
|
|
|
839
839
|
test('should handle empty mutations array', () => {
|
|
@@ -847,7 +847,7 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
847
847
|
|
|
848
848
|
expect(updated.size).toBe(1);
|
|
849
849
|
|
|
850
|
-
|
|
850
|
+
assert.isTrue(ISetMapped.equal(set, updated));
|
|
851
851
|
});
|
|
852
852
|
});
|
|
853
853
|
|
|
@@ -869,9 +869,9 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
869
869
|
|
|
870
870
|
expect(transformed.size).toBe(2);
|
|
871
871
|
|
|
872
|
-
|
|
872
|
+
assert.isTrue(transformed.has({ id: 1, type: 'USER' }));
|
|
873
873
|
|
|
874
|
-
|
|
874
|
+
assert.isTrue(transformed.has({ id: 2, type: 'ADMIN' }));
|
|
875
875
|
});
|
|
876
876
|
});
|
|
877
877
|
|
|
@@ -891,11 +891,11 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
891
891
|
|
|
892
892
|
expect(filtered.size).toBe(2);
|
|
893
893
|
|
|
894
|
-
|
|
894
|
+
assert.isTrue(filtered.has({ id: 1, type: 'user' }));
|
|
895
895
|
|
|
896
|
-
|
|
896
|
+
assert.isTrue(filtered.has({ id: 3, type: 'user' }));
|
|
897
897
|
|
|
898
|
-
|
|
898
|
+
assert.isFalse(filtered.has({ id: 2, type: 'admin' }));
|
|
899
899
|
});
|
|
900
900
|
});
|
|
901
901
|
|
|
@@ -915,11 +915,11 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
915
915
|
|
|
916
916
|
expect(filtered.size).toBe(1);
|
|
917
917
|
|
|
918
|
-
|
|
918
|
+
assert.isTrue(filtered.has({ id: 2, type: 'admin' }));
|
|
919
919
|
|
|
920
|
-
|
|
920
|
+
assert.isFalse(filtered.has({ id: 1, type: 'user' }));
|
|
921
921
|
|
|
922
|
-
|
|
922
|
+
assert.isFalse(filtered.has({ id: 3, type: 'user' }));
|
|
923
923
|
});
|
|
924
924
|
});
|
|
925
925
|
|
|
@@ -965,7 +965,7 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
965
965
|
stringToTestElement,
|
|
966
966
|
);
|
|
967
967
|
|
|
968
|
-
|
|
968
|
+
assert.isTrue(subset.isSubsetOf(superset));
|
|
969
969
|
});
|
|
970
970
|
|
|
971
971
|
test('should return false for non-subset', () => {
|
|
@@ -987,7 +987,7 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
987
987
|
stringToTestElement,
|
|
988
988
|
);
|
|
989
989
|
|
|
990
|
-
|
|
990
|
+
assert.isFalse(set1.isSubsetOf(set2));
|
|
991
991
|
});
|
|
992
992
|
});
|
|
993
993
|
|
|
@@ -1008,7 +1008,7 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
1008
1008
|
stringToTestElement,
|
|
1009
1009
|
);
|
|
1010
1010
|
|
|
1011
|
-
|
|
1011
|
+
assert.isTrue(superset.isSupersetOf(subset));
|
|
1012
1012
|
});
|
|
1013
1013
|
|
|
1014
1014
|
test('should return false for non-superset', () => {
|
|
@@ -1030,7 +1030,7 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
1030
1030
|
stringToTestElement,
|
|
1031
1031
|
);
|
|
1032
1032
|
|
|
1033
|
-
|
|
1033
|
+
assert.isFalse(set1.isSupersetOf(set2));
|
|
1034
1034
|
});
|
|
1035
1035
|
});
|
|
1036
1036
|
|
|
@@ -1059,11 +1059,11 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
1059
1059
|
|
|
1060
1060
|
expect(result.size).toBe(2);
|
|
1061
1061
|
|
|
1062
|
-
|
|
1062
|
+
assert.isTrue(result.has({ id: 1, type: 'user' }));
|
|
1063
1063
|
|
|
1064
|
-
|
|
1064
|
+
assert.isTrue(result.has({ id: 3, type: 'guest' }));
|
|
1065
1065
|
|
|
1066
|
-
|
|
1066
|
+
assert.isFalse(result.has({ id: 2, type: 'admin' }));
|
|
1067
1067
|
});
|
|
1068
1068
|
});
|
|
1069
1069
|
|
|
@@ -1093,11 +1093,11 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
1093
1093
|
|
|
1094
1094
|
expect(result.size).toBe(2);
|
|
1095
1095
|
|
|
1096
|
-
|
|
1096
|
+
assert.isTrue(result.has({ id: 2, type: 'admin' }));
|
|
1097
1097
|
|
|
1098
|
-
|
|
1098
|
+
assert.isTrue(result.has({ id: 3, type: 'guest' }));
|
|
1099
1099
|
|
|
1100
|
-
|
|
1100
|
+
assert.isFalse(result.has({ id: 1, type: 'user' }));
|
|
1101
1101
|
});
|
|
1102
1102
|
});
|
|
1103
1103
|
|
|
@@ -1125,13 +1125,13 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
1125
1125
|
|
|
1126
1126
|
expect(result.size).toBe(4);
|
|
1127
1127
|
|
|
1128
|
-
|
|
1128
|
+
assert.isTrue(result.has({ id: 1, type: 'user' }));
|
|
1129
1129
|
|
|
1130
|
-
|
|
1130
|
+
assert.isTrue(result.has({ id: 2, type: 'admin' }));
|
|
1131
1131
|
|
|
1132
|
-
|
|
1132
|
+
assert.isTrue(result.has({ id: 3, type: 'guest' }));
|
|
1133
1133
|
|
|
1134
|
-
|
|
1134
|
+
assert.isTrue(result.has({ id: 4, type: 'user' }));
|
|
1135
1135
|
});
|
|
1136
1136
|
});
|
|
1137
1137
|
|
|
@@ -1251,9 +1251,9 @@ describe('ISetMapped additional functionality with complex types', () => {
|
|
|
1251
1251
|
|
|
1252
1252
|
expect(rawSet.size).toBe(2);
|
|
1253
1253
|
|
|
1254
|
-
|
|
1254
|
+
assert.isTrue(rawSet.has('user_1'));
|
|
1255
1255
|
|
|
1256
|
-
|
|
1256
|
+
assert.isTrue(rawSet.has('admin_2'));
|
|
1257
1257
|
});
|
|
1258
1258
|
});
|
|
1259
1259
|
});
|
package/src/collections/iset.mts
CHANGED
|
@@ -39,7 +39,7 @@ type ISetInterface<K extends MapSetKeyType> = Readonly<{
|
|
|
39
39
|
* ```ts
|
|
40
40
|
* const set = ISet.create([1, 2, 3]);
|
|
41
41
|
*
|
|
42
|
-
* assert(set.size === 3);
|
|
42
|
+
* assert.isTrue(set.size === 3);
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
45
|
size: SizeType.Arr;
|
|
@@ -54,9 +54,9 @@ type ISetInterface<K extends MapSetKeyType> = Readonly<{
|
|
|
54
54
|
*
|
|
55
55
|
* const filledSet = ISet.create([1, 2]);
|
|
56
56
|
*
|
|
57
|
-
* assert.
|
|
57
|
+
* assert.isTrue(emptySet.isEmpty);
|
|
58
58
|
*
|
|
59
|
-
* assert.
|
|
59
|
+
* assert.isFalse(filledSet.isEmpty);
|
|
60
60
|
* ```
|
|
61
61
|
*/
|
|
62
62
|
isEmpty: boolean;
|
|
@@ -70,9 +70,9 @@ type ISetInterface<K extends MapSetKeyType> = Readonly<{
|
|
|
70
70
|
* ```ts
|
|
71
71
|
* const set = ISet.create(['apple', 'banana']);
|
|
72
72
|
*
|
|
73
|
-
* assert.
|
|
73
|
+
* assert.isTrue(set.has('apple'));
|
|
74
74
|
*
|
|
75
|
-
* assert.
|
|
75
|
+
* assert.isFalse(set.has('cherry'));
|
|
76
76
|
* ```
|
|
77
77
|
*
|
|
78
78
|
* @param key The element to check.
|
|
@@ -94,9 +94,9 @@ type ISetInterface<K extends MapSetKeyType> = Readonly<{
|
|
|
94
94
|
*
|
|
95
95
|
* const narrowed = numbers.every((value): value is 2 | 4 | 6 => value % 2 === 0);
|
|
96
96
|
*
|
|
97
|
-
* assert.
|
|
97
|
+
* assert.isTrue(allEven);
|
|
98
98
|
*
|
|
99
|
-
* assert.
|
|
99
|
+
* assert.isTrue(narrowed);
|
|
100
100
|
* ```
|
|
101
101
|
*
|
|
102
102
|
* @param predicate A function to test each element.
|
|
@@ -122,9 +122,9 @@ type ISetInterface<K extends MapSetKeyType> = Readonly<{
|
|
|
122
122
|
* ```ts
|
|
123
123
|
* const numbers = ISet.create([1, 3, 5]);
|
|
124
124
|
*
|
|
125
|
-
* assert.
|
|
125
|
+
* assert.isTrue(numbers.some((value) => value > 4));
|
|
126
126
|
*
|
|
127
|
-
* assert.
|
|
127
|
+
* assert.isFalse(numbers.some((value) => value > 10));
|
|
128
128
|
* ```
|
|
129
129
|
*
|
|
130
130
|
* @param predicate A function to test each element.
|
|
@@ -149,7 +149,7 @@ type ISetInterface<K extends MapSetKeyType> = Readonly<{
|
|
|
149
149
|
*
|
|
150
150
|
* assert.deepStrictEqual(Array.from(withThree), [1, 2, 3]);
|
|
151
151
|
*
|
|
152
|
-
* assert(unchanged === base);
|
|
152
|
+
* assert.isTrue(unchanged === base);
|
|
153
153
|
* ```
|
|
154
154
|
*
|
|
155
155
|
* @param key The element to add.
|
|
@@ -171,7 +171,7 @@ type ISetInterface<K extends MapSetKeyType> = Readonly<{
|
|
|
171
171
|
*
|
|
172
172
|
* assert.deepStrictEqual(Array.from(withoutTwo), [1, 3]);
|
|
173
173
|
*
|
|
174
|
-
* assert(unchanged === base);
|
|
174
|
+
* assert.isTrue(unchanged === base);
|
|
175
175
|
* ```
|
|
176
176
|
*
|
|
177
177
|
* @param key The element to delete.
|
|
@@ -296,9 +296,9 @@ type ISetInterface<K extends MapSetKeyType> = Readonly<{
|
|
|
296
296
|
*
|
|
297
297
|
* const superset = ISet.create<number>([1, 2, 3]);
|
|
298
298
|
*
|
|
299
|
-
* assert.
|
|
299
|
+
* assert.isTrue(subset.isSubsetOf(superset));
|
|
300
300
|
*
|
|
301
|
-
* assert.
|
|
301
|
+
* assert.isFalse(superset.isSubsetOf(subset));
|
|
302
302
|
* ```
|
|
303
303
|
*
|
|
304
304
|
* @param set The other set.
|
|
@@ -317,9 +317,9 @@ type ISetInterface<K extends MapSetKeyType> = Readonly<{
|
|
|
317
317
|
*
|
|
318
318
|
* const subset = ISet.create<string>(['a', 'c']);
|
|
319
319
|
*
|
|
320
|
-
* assert.
|
|
320
|
+
* assert.isTrue(superset.isSupersetOf(subset));
|
|
321
321
|
*
|
|
322
|
-
* assert.
|
|
322
|
+
* assert.isFalse(subset.isSupersetOf(superset));
|
|
323
323
|
* ```
|
|
324
324
|
*
|
|
325
325
|
* @param set The other set.
|
|
@@ -497,9 +497,9 @@ type ISetInterface<K extends MapSetKeyType> = Readonly<{
|
|
|
497
497
|
*
|
|
498
498
|
* const raw = set.toRawSet();
|
|
499
499
|
*
|
|
500
|
-
* assert.
|
|
500
|
+
* assert.isTrue(is.set(raw));
|
|
501
501
|
*
|
|
502
|
-
* assert.
|
|
502
|
+
* assert.isTrue(raw.has('alpha'));
|
|
503
503
|
* ```
|
|
504
504
|
*
|
|
505
505
|
* @returns The raw ReadonlySet instance.
|
|
@@ -584,9 +584,9 @@ export namespace ISet {
|
|
|
584
584
|
*
|
|
585
585
|
* const third = ISet.create<number>([1, 3]);
|
|
586
586
|
*
|
|
587
|
-
* assert.
|
|
587
|
+
* assert.isTrue(ISet.equal(first, second));
|
|
588
588
|
*
|
|
589
|
-
* assert.
|
|
589
|
+
* assert.isFalse(ISet.equal(first, third));
|
|
590
590
|
* ```
|
|
591
591
|
*
|
|
592
592
|
* @template K The type of the elements.
|