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
|
@@ -16,7 +16,7 @@ describe('ISet.create', () => {
|
|
|
16
16
|
|
|
17
17
|
expect(set.size).toBe(0);
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
assert.isTrue(set.isEmpty);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
test('should create set from array', () => {
|
|
@@ -24,11 +24,11 @@ describe('ISet.create', () => {
|
|
|
24
24
|
|
|
25
25
|
expect(set.size).toBe(3);
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
assert.isTrue(set.has(1));
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
assert.isTrue(set.has(2));
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
assert.isTrue(set.has(3));
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
test('should create set from JavaScript Set', () => {
|
|
@@ -38,11 +38,11 @@ describe('ISet.create', () => {
|
|
|
38
38
|
|
|
39
39
|
expect(set.size).toBe(3);
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
assert.isTrue(set.has('a'));
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
assert.isTrue(set.has('b'));
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
assert.isTrue(set.has('c'));
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
test('should create set from another ISet', () => {
|
|
@@ -52,11 +52,11 @@ describe('ISet.create', () => {
|
|
|
52
52
|
|
|
53
53
|
expect(copy.size).toBe(3);
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
assert.isTrue(copy.has(1));
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
assert.isTrue(copy.has(2));
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
assert.isTrue(copy.has(3));
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
62
|
|
|
@@ -80,13 +80,13 @@ describe('isEmpty property', () => {
|
|
|
80
80
|
test('should return true for empty set', () => {
|
|
81
81
|
const set = ISet.create<string>([]);
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
assert.isTrue(set.isEmpty);
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
test('should return false for non-empty set', () => {
|
|
87
87
|
const set = ISet.create([1, 2, 3]);
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
assert.isFalse(set.isEmpty);
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
92
|
|
|
@@ -96,41 +96,41 @@ describe('ISet.has', () => {
|
|
|
96
96
|
|
|
97
97
|
expectType<typeof s0.has, (value: 1 | 2 | 3) => boolean>('<=');
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
assert.isTrue(s0.has(2));
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
test('case 2', () => {
|
|
103
103
|
const s0 = ISet.create<number>([1, 2, 3]);
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
assert.isFalse(s0.has(4));
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
test('case 3', () => {
|
|
109
109
|
const s0 = ISet.create<number>([]);
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
assert.isFalse(s0.has(1));
|
|
112
112
|
});
|
|
113
113
|
|
|
114
114
|
test('case 4', () => {
|
|
115
115
|
const s0 = ISet.create([1, 2, 3, Number.NaN] as const);
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
assert.isTrue(s0.has(Number.NaN));
|
|
118
118
|
});
|
|
119
119
|
|
|
120
120
|
test('should handle boolean values', () => {
|
|
121
121
|
const set = ISet.create([true, false]);
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
assert.isTrue(set.has(true));
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
assert.isTrue(set.has(false));
|
|
126
126
|
});
|
|
127
127
|
|
|
128
128
|
test('should handle null and undefined', () => {
|
|
129
129
|
const set = ISet.create([null, undefined]);
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
assert.isTrue(set.has(null));
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
assert.isTrue(set.has(undefined));
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
136
|
|
|
@@ -143,37 +143,37 @@ describe('ISet.every', () => {
|
|
|
143
143
|
(predicate: (value: 2 | 4 | 6) => boolean) => boolean
|
|
144
144
|
>('<=');
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
assert.isTrue(s0.every((x) => x % 2 === 0));
|
|
147
147
|
});
|
|
148
148
|
|
|
149
149
|
test('case 2', () => {
|
|
150
150
|
const s0 = ISet.create([1, 2, 3] as const);
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
assert.isFalse(s0.every((x) => x % 2 === 0));
|
|
153
153
|
});
|
|
154
154
|
|
|
155
155
|
test('case 3', () => {
|
|
156
156
|
const s0 = ISet.create<number>([]);
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
assert.isTrue(s0.every((x) => x % 2 === 0));
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
test('should return true when all elements satisfy predicate', () => {
|
|
162
162
|
const set = ISet.create([2, 4, 6, 8]);
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
assert.isTrue(set.every((x) => x % 2 === 0));
|
|
165
165
|
});
|
|
166
166
|
|
|
167
167
|
test('should return false when some elements do not satisfy predicate', () => {
|
|
168
168
|
const set = ISet.create([1, 2, 3, 4]);
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
assert.isFalse(set.every((x) => x % 2 === 0));
|
|
171
171
|
});
|
|
172
172
|
|
|
173
173
|
test('should return true for empty set', () => {
|
|
174
174
|
const set = ISet.create<number>([]);
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
assert.isTrue(set.every((x) => x > 0));
|
|
177
177
|
});
|
|
178
178
|
});
|
|
179
179
|
|
|
@@ -186,7 +186,7 @@ describe('every method as type guard', () => {
|
|
|
186
186
|
const values = set.toArray();
|
|
187
187
|
|
|
188
188
|
for (const value of values) {
|
|
189
|
-
|
|
189
|
+
assert.isTrue(isString(value));
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
});
|
|
@@ -194,9 +194,9 @@ describe('every method as type guard', () => {
|
|
|
194
194
|
test('should work with mixed types that fail guard', () => {
|
|
195
195
|
const set = ISet.create<string | number>(['hello', 42, 'world']);
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
assert.isFalse(
|
|
198
198
|
set.every((value): value is string => typeof value === 'string'),
|
|
199
|
-
)
|
|
199
|
+
);
|
|
200
200
|
});
|
|
201
201
|
});
|
|
202
202
|
|
|
@@ -209,45 +209,45 @@ describe('ISet.some', () => {
|
|
|
209
209
|
(predicate: (value: 1 | 3 | 5) => boolean) => boolean
|
|
210
210
|
>('<=');
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
assert.isFalse(s0.some((x) => x % 2 === 0));
|
|
213
213
|
});
|
|
214
214
|
|
|
215
215
|
test('case 2', () => {
|
|
216
216
|
const s0 = ISet.create([1, 2, 3] as const);
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
assert.isTrue(s0.some((x) => x % 2 === 0));
|
|
219
219
|
});
|
|
220
220
|
|
|
221
221
|
test('case 3', () => {
|
|
222
222
|
const s0 = ISet.create<number>([]);
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
assert.isFalse(s0.some((x) => x % 2 === 0));
|
|
225
225
|
});
|
|
226
226
|
|
|
227
227
|
test('should return true when at least one element satisfies predicate', () => {
|
|
228
228
|
const set = ISet.create([1, 3, 5, 6]);
|
|
229
229
|
|
|
230
|
-
|
|
230
|
+
assert.isTrue(set.some((x) => x % 2 === 0));
|
|
231
231
|
});
|
|
232
232
|
|
|
233
233
|
test('should return false when no elements satisfy predicate', () => {
|
|
234
234
|
const set = ISet.create([1, 3, 5, 7]);
|
|
235
235
|
|
|
236
|
-
|
|
236
|
+
assert.isFalse(set.some((x) => x % 2 === 0));
|
|
237
237
|
});
|
|
238
238
|
|
|
239
239
|
test('should return false for empty set', () => {
|
|
240
240
|
const set = ISet.create<number>([]);
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
assert.isFalse(set.some((x) => x > 0));
|
|
243
243
|
});
|
|
244
244
|
|
|
245
245
|
test('should work with complex predicates', () => {
|
|
246
246
|
const set = ISet.create(['hello', 'world', 'test']);
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
assert.isTrue(set.some((str) => str.includes('o')));
|
|
249
249
|
|
|
250
|
-
|
|
250
|
+
assert.isFalse(set.some((str) => str.includes('z')));
|
|
251
251
|
});
|
|
252
252
|
});
|
|
253
253
|
|
|
@@ -289,9 +289,9 @@ describe('ISet.add', () => {
|
|
|
289
289
|
|
|
290
290
|
expect(modified.size).toBe(4);
|
|
291
291
|
|
|
292
|
-
|
|
292
|
+
assert.isFalse(original.has(4));
|
|
293
293
|
|
|
294
|
-
|
|
294
|
+
assert.isTrue(modified.has(4));
|
|
295
295
|
});
|
|
296
296
|
|
|
297
297
|
test('should return same instance when adding existing element', () => {
|
|
@@ -311,11 +311,11 @@ describe('ISet.add', () => {
|
|
|
311
311
|
|
|
312
312
|
const withNaN = withUndefined.add(Number.NaN);
|
|
313
313
|
|
|
314
|
-
|
|
314
|
+
assert.isTrue(withNaN.has(null));
|
|
315
315
|
|
|
316
|
-
|
|
316
|
+
assert.isTrue(withNaN.has(undefined));
|
|
317
317
|
|
|
318
|
-
|
|
318
|
+
assert.isTrue(withNaN.has(Number.NaN));
|
|
319
319
|
});
|
|
320
320
|
});
|
|
321
321
|
|
|
@@ -355,9 +355,9 @@ describe('ISet.delete', () => {
|
|
|
355
355
|
|
|
356
356
|
expect(modified.size).toBe(3);
|
|
357
357
|
|
|
358
|
-
|
|
358
|
+
assert.isTrue(original.has(2));
|
|
359
359
|
|
|
360
|
-
|
|
360
|
+
assert.isFalse(modified.has(2));
|
|
361
361
|
});
|
|
362
362
|
|
|
363
363
|
test('should return same instance when deleting non-existent element', () => {
|
|
@@ -409,11 +409,11 @@ describe('ISet.map', () => {
|
|
|
409
409
|
|
|
410
410
|
const strings = set.map((x) => x.toString());
|
|
411
411
|
|
|
412
|
-
|
|
412
|
+
assert.isTrue(strings.has('1'));
|
|
413
413
|
|
|
414
|
-
|
|
414
|
+
assert.isTrue(strings.has('2'));
|
|
415
415
|
|
|
416
|
-
|
|
416
|
+
assert.isTrue(strings.has('3'));
|
|
417
417
|
});
|
|
418
418
|
});
|
|
419
419
|
|
|
@@ -450,11 +450,11 @@ describe('ISet.filter', () => {
|
|
|
450
450
|
|
|
451
451
|
expect(evens.size).toBe(3);
|
|
452
452
|
|
|
453
|
-
|
|
453
|
+
assert.isTrue(evens.has(2));
|
|
454
454
|
|
|
455
|
-
|
|
455
|
+
assert.isTrue(evens.has(4));
|
|
456
456
|
|
|
457
|
-
|
|
457
|
+
assert.isTrue(evens.has(6));
|
|
458
458
|
});
|
|
459
459
|
|
|
460
460
|
test('should work as type guard', () => {
|
|
@@ -466,9 +466,9 @@ describe('ISet.filter', () => {
|
|
|
466
466
|
|
|
467
467
|
expect(strings.size).toBe(2);
|
|
468
468
|
|
|
469
|
-
|
|
469
|
+
assert.isTrue(strings.has('hello'));
|
|
470
470
|
|
|
471
|
-
|
|
471
|
+
assert.isTrue(strings.has('world'));
|
|
472
472
|
});
|
|
473
473
|
|
|
474
474
|
test('should return empty set when no elements match', () => {
|
|
@@ -478,7 +478,7 @@ describe('ISet.filter', () => {
|
|
|
478
478
|
|
|
479
479
|
expect(evens.size).toBe(0);
|
|
480
480
|
|
|
481
|
-
|
|
481
|
+
assert.isTrue(evens.isEmpty);
|
|
482
482
|
});
|
|
483
483
|
});
|
|
484
484
|
|
|
@@ -490,11 +490,11 @@ describe('ISet.filterNot', () => {
|
|
|
490
490
|
|
|
491
491
|
expect(odds.size).toBe(3);
|
|
492
492
|
|
|
493
|
-
|
|
493
|
+
assert.isTrue(odds.has(1));
|
|
494
494
|
|
|
495
|
-
|
|
495
|
+
assert.isTrue(odds.has(3));
|
|
496
496
|
|
|
497
|
-
|
|
497
|
+
assert.isTrue(odds.has(5));
|
|
498
498
|
});
|
|
499
499
|
|
|
500
500
|
test('should return same set when no elements satisfy predicate', () => {
|
|
@@ -504,7 +504,7 @@ describe('ISet.filterNot', () => {
|
|
|
504
504
|
|
|
505
505
|
expect(nonEvens.size).toBe(3);
|
|
506
506
|
|
|
507
|
-
|
|
507
|
+
assert.isTrue(ISet.equal(set, nonEvens));
|
|
508
508
|
});
|
|
509
509
|
|
|
510
510
|
test('should return empty set when all elements satisfy predicate', () => {
|
|
@@ -512,7 +512,7 @@ describe('ISet.filterNot', () => {
|
|
|
512
512
|
|
|
513
513
|
const nonEvens = set.filterNot((x) => x % 2 === 0);
|
|
514
514
|
|
|
515
|
-
|
|
515
|
+
assert.isTrue(nonEvens.isEmpty);
|
|
516
516
|
});
|
|
517
517
|
});
|
|
518
518
|
|
|
@@ -524,7 +524,7 @@ describe('ISet.isSubsetOf', () => {
|
|
|
524
524
|
|
|
525
525
|
expectType<typeof s0.isSubsetOf, (other: ISet<number>) => boolean>('<=');
|
|
526
526
|
|
|
527
|
-
|
|
527
|
+
assert.isTrue(s0.isSubsetOf(s1));
|
|
528
528
|
});
|
|
529
529
|
|
|
530
530
|
test('case 2', () => {
|
|
@@ -532,7 +532,7 @@ describe('ISet.isSubsetOf', () => {
|
|
|
532
532
|
|
|
533
533
|
const s1 = ISet.create<number>([1, 2]);
|
|
534
534
|
|
|
535
|
-
|
|
535
|
+
assert.isFalse(s0.isSubsetOf(s1));
|
|
536
536
|
});
|
|
537
537
|
|
|
538
538
|
test('case 3', () => {
|
|
@@ -540,7 +540,7 @@ describe('ISet.isSubsetOf', () => {
|
|
|
540
540
|
|
|
541
541
|
const s1 = ISet.create<number>([1, 2, 3]);
|
|
542
542
|
|
|
543
|
-
|
|
543
|
+
assert.isTrue(s0.isSubsetOf(s1));
|
|
544
544
|
});
|
|
545
545
|
|
|
546
546
|
test('should return true for subset relationship', () => {
|
|
@@ -548,7 +548,7 @@ describe('ISet.isSubsetOf', () => {
|
|
|
548
548
|
|
|
549
549
|
const superset = ISet.create<number>([1, 2, 3, 4]);
|
|
550
550
|
|
|
551
|
-
|
|
551
|
+
assert.isTrue(subset.isSubsetOf(superset));
|
|
552
552
|
});
|
|
553
553
|
|
|
554
554
|
test('should return true for equal sets', () => {
|
|
@@ -556,7 +556,7 @@ describe('ISet.isSubsetOf', () => {
|
|
|
556
556
|
|
|
557
557
|
const set2 = ISet.create<number>([1, 2, 3]);
|
|
558
558
|
|
|
559
|
-
|
|
559
|
+
assert.isTrue(set1.isSubsetOf(set2));
|
|
560
560
|
});
|
|
561
561
|
|
|
562
562
|
test('should return false for non-subset', () => {
|
|
@@ -564,7 +564,7 @@ describe('ISet.isSubsetOf', () => {
|
|
|
564
564
|
|
|
565
565
|
const set2 = ISet.create<number>([1, 2, 3, 4]);
|
|
566
566
|
|
|
567
|
-
|
|
567
|
+
assert.isFalse(set1.isSubsetOf(set2));
|
|
568
568
|
});
|
|
569
569
|
});
|
|
570
570
|
|
|
@@ -576,7 +576,7 @@ describe('ISet.isSupersetOf', () => {
|
|
|
576
576
|
|
|
577
577
|
expectType<typeof s0.isSupersetOf, (other: ISet<number>) => boolean>('<=');
|
|
578
578
|
|
|
579
|
-
|
|
579
|
+
assert.isTrue(s0.isSupersetOf(s1));
|
|
580
580
|
});
|
|
581
581
|
|
|
582
582
|
test('case 2', () => {
|
|
@@ -584,7 +584,7 @@ describe('ISet.isSupersetOf', () => {
|
|
|
584
584
|
|
|
585
585
|
const s1 = ISet.create<number>([1, 2, 3]);
|
|
586
586
|
|
|
587
|
-
|
|
587
|
+
assert.isFalse(s0.isSupersetOf(s1));
|
|
588
588
|
});
|
|
589
589
|
|
|
590
590
|
test('case 3', () => {
|
|
@@ -592,7 +592,7 @@ describe('ISet.isSupersetOf', () => {
|
|
|
592
592
|
|
|
593
593
|
const s1 = ISet.create<number>([]);
|
|
594
594
|
|
|
595
|
-
|
|
595
|
+
assert.isTrue(s0.isSupersetOf(s1));
|
|
596
596
|
});
|
|
597
597
|
|
|
598
598
|
test('should return true for superset relationship', () => {
|
|
@@ -600,7 +600,7 @@ describe('ISet.isSupersetOf', () => {
|
|
|
600
600
|
|
|
601
601
|
const subset = ISet.create<number>([1, 2]);
|
|
602
602
|
|
|
603
|
-
|
|
603
|
+
assert.isTrue(superset.isSupersetOf(subset));
|
|
604
604
|
});
|
|
605
605
|
|
|
606
606
|
test('should return true for equal sets', () => {
|
|
@@ -608,7 +608,7 @@ describe('ISet.isSupersetOf', () => {
|
|
|
608
608
|
|
|
609
609
|
const set2 = ISet.create<number>([1, 2, 3]);
|
|
610
610
|
|
|
611
|
-
|
|
611
|
+
assert.isTrue(set1.isSupersetOf(set2));
|
|
612
612
|
});
|
|
613
613
|
|
|
614
614
|
test('should return false for non-superset', () => {
|
|
@@ -616,7 +616,7 @@ describe('ISet.isSupersetOf', () => {
|
|
|
616
616
|
|
|
617
617
|
const set2 = ISet.create<number>([1, 2, 3, 4]);
|
|
618
618
|
|
|
619
|
-
|
|
619
|
+
assert.isFalse(set1.isSupersetOf(set2));
|
|
620
620
|
});
|
|
621
621
|
});
|
|
622
622
|
|
|
@@ -656,9 +656,9 @@ describe('ISet.subtract', () => {
|
|
|
656
656
|
|
|
657
657
|
expect(result.size).toBe(2);
|
|
658
658
|
|
|
659
|
-
|
|
659
|
+
assert.isTrue(result.has(1));
|
|
660
660
|
|
|
661
|
-
|
|
661
|
+
assert.isTrue(result.has(2));
|
|
662
662
|
});
|
|
663
663
|
|
|
664
664
|
test('should return empty set when all elements are removed', () => {
|
|
@@ -668,7 +668,7 @@ describe('ISet.subtract', () => {
|
|
|
668
668
|
|
|
669
669
|
const result = set1.subtract(set2);
|
|
670
670
|
|
|
671
|
-
|
|
671
|
+
assert.isTrue(result.isEmpty);
|
|
672
672
|
});
|
|
673
673
|
});
|
|
674
674
|
|
|
@@ -714,9 +714,9 @@ describe('ISet.intersection', () => {
|
|
|
714
714
|
|
|
715
715
|
expect(result.size).toBe(2);
|
|
716
716
|
|
|
717
|
-
|
|
717
|
+
assert.isTrue(result.has(3));
|
|
718
718
|
|
|
719
|
-
|
|
719
|
+
assert.isTrue(result.has(4));
|
|
720
720
|
});
|
|
721
721
|
|
|
722
722
|
test('should return empty set when no common elements', () => {
|
|
@@ -726,7 +726,7 @@ describe('ISet.intersection', () => {
|
|
|
726
726
|
|
|
727
727
|
const result = ISet.intersection(set1, set2);
|
|
728
728
|
|
|
729
|
-
|
|
729
|
+
assert.isTrue(result.isEmpty);
|
|
730
730
|
});
|
|
731
731
|
});
|
|
732
732
|
|
|
@@ -768,9 +768,9 @@ describe('ISet.intersect', () => {
|
|
|
768
768
|
|
|
769
769
|
expect(result.size).toBe(2);
|
|
770
770
|
|
|
771
|
-
|
|
771
|
+
assert.isTrue(result.has(3));
|
|
772
772
|
|
|
773
|
-
|
|
773
|
+
assert.isTrue(result.has(4));
|
|
774
774
|
});
|
|
775
775
|
});
|
|
776
776
|
|
|
@@ -816,15 +816,15 @@ describe('ISet.union', () => {
|
|
|
816
816
|
|
|
817
817
|
expect(result.size).toBe(5);
|
|
818
818
|
|
|
819
|
-
|
|
819
|
+
assert.isTrue(result.has(1));
|
|
820
820
|
|
|
821
|
-
|
|
821
|
+
assert.isTrue(result.has(2));
|
|
822
822
|
|
|
823
|
-
|
|
823
|
+
assert.isTrue(result.has(3));
|
|
824
824
|
|
|
825
|
-
|
|
825
|
+
assert.isTrue(result.has(4));
|
|
826
826
|
|
|
827
|
-
|
|
827
|
+
assert.isTrue(result.has(5));
|
|
828
828
|
});
|
|
829
829
|
|
|
830
830
|
describe('instance method', () => {
|
|
@@ -866,15 +866,15 @@ describe('ISet.union', () => {
|
|
|
866
866
|
|
|
867
867
|
expect(result.size).toBe(5);
|
|
868
868
|
|
|
869
|
-
|
|
869
|
+
assert.isTrue(result.has(1));
|
|
870
870
|
|
|
871
|
-
|
|
871
|
+
assert.isTrue(result.has(2));
|
|
872
872
|
|
|
873
|
-
|
|
873
|
+
assert.isTrue(result.has(3));
|
|
874
874
|
|
|
875
|
-
|
|
875
|
+
assert.isTrue(result.has(4));
|
|
876
876
|
|
|
877
|
-
|
|
877
|
+
assert.isTrue(result.has(5));
|
|
878
878
|
});
|
|
879
879
|
});
|
|
880
880
|
});
|
|
@@ -1033,11 +1033,11 @@ describe('ISet.toRawSet', () => {
|
|
|
1033
1033
|
|
|
1034
1034
|
expect(rawSet.size).toBe(3);
|
|
1035
1035
|
|
|
1036
|
-
|
|
1036
|
+
assert.isTrue(rawSet.has(1));
|
|
1037
1037
|
|
|
1038
|
-
|
|
1038
|
+
assert.isTrue(rawSet.has(2));
|
|
1039
1039
|
|
|
1040
|
-
|
|
1040
|
+
assert.isTrue(rawSet.has(3));
|
|
1041
1041
|
});
|
|
1042
1042
|
|
|
1043
1043
|
test('should return empty ReadonlySet for empty ISet', () => {
|
|
@@ -1055,7 +1055,7 @@ describe('ISet.equal', () => {
|
|
|
1055
1055
|
|
|
1056
1056
|
const set2 = ISet.create([3, 2, 1]); // Different order
|
|
1057
1057
|
|
|
1058
|
-
|
|
1058
|
+
assert.isTrue(ISet.equal(set1, set2));
|
|
1059
1059
|
});
|
|
1060
1060
|
|
|
1061
1061
|
test('should return false for sets with different sizes', () => {
|
|
@@ -1063,7 +1063,7 @@ describe('ISet.equal', () => {
|
|
|
1063
1063
|
|
|
1064
1064
|
const set2 = ISet.create<'a' | 'b' | 'c' | 'd'>(['a', 'b', 'c']);
|
|
1065
1065
|
|
|
1066
|
-
|
|
1066
|
+
assert.isFalse(ISet.equal(set1, set2));
|
|
1067
1067
|
});
|
|
1068
1068
|
|
|
1069
1069
|
test('should return false for sets with different elements', () => {
|
|
@@ -1071,7 +1071,7 @@ describe('ISet.equal', () => {
|
|
|
1071
1071
|
|
|
1072
1072
|
const set2 = ISet.create<'a' | 'b' | 'c' | 'd'>(['a', 'b', 'd']);
|
|
1073
1073
|
|
|
1074
|
-
|
|
1074
|
+
assert.isFalse(ISet.equal(set1, set2));
|
|
1075
1075
|
});
|
|
1076
1076
|
|
|
1077
1077
|
test('should return true for empty sets', () => {
|
|
@@ -1079,7 +1079,7 @@ describe('ISet.equal', () => {
|
|
|
1079
1079
|
|
|
1080
1080
|
const set2 = ISet.create<string>([]);
|
|
1081
1081
|
|
|
1082
|
-
|
|
1082
|
+
assert.isTrue(ISet.equal(set1, set2));
|
|
1083
1083
|
});
|
|
1084
1084
|
|
|
1085
1085
|
test('should handle sets with special values', () => {
|
|
@@ -1087,7 +1087,7 @@ describe('ISet.equal', () => {
|
|
|
1087
1087
|
|
|
1088
1088
|
const set2 = ISet.create([undefined, Number.NaN, null]);
|
|
1089
1089
|
|
|
1090
|
-
|
|
1090
|
+
assert.isTrue(ISet.equal(set1, set2));
|
|
1091
1091
|
});
|
|
1092
1092
|
});
|
|
1093
1093
|
|
|
@@ -1101,11 +1101,11 @@ describe('ISet.diff', () => {
|
|
|
1101
1101
|
|
|
1102
1102
|
expect(diff.deleted.size).toBe(1);
|
|
1103
1103
|
|
|
1104
|
-
|
|
1104
|
+
assert.isTrue(diff.deleted.has('a'));
|
|
1105
1105
|
|
|
1106
1106
|
expect(diff.added.size).toBe(1);
|
|
1107
1107
|
|
|
1108
|
-
|
|
1108
|
+
assert.isTrue(diff.added.has('d'));
|
|
1109
1109
|
});
|
|
1110
1110
|
|
|
1111
1111
|
test('should handle no changes', () => {
|
|
@@ -1115,9 +1115,9 @@ describe('ISet.diff', () => {
|
|
|
1115
1115
|
|
|
1116
1116
|
const diff = ISet.diff(set1, set2);
|
|
1117
1117
|
|
|
1118
|
-
|
|
1118
|
+
assert.isTrue(diff.deleted.isEmpty);
|
|
1119
1119
|
|
|
1120
|
-
|
|
1120
|
+
assert.isTrue(diff.added.isEmpty);
|
|
1121
1121
|
});
|
|
1122
1122
|
|
|
1123
1123
|
test('should handle complete replacement', () => {
|
|
@@ -1129,15 +1129,15 @@ describe('ISet.diff', () => {
|
|
|
1129
1129
|
|
|
1130
1130
|
expect(diff.deleted.size).toBe(2);
|
|
1131
1131
|
|
|
1132
|
-
|
|
1132
|
+
assert.isTrue(diff.deleted.has('a'));
|
|
1133
1133
|
|
|
1134
|
-
|
|
1134
|
+
assert.isTrue(diff.deleted.has('b'));
|
|
1135
1135
|
|
|
1136
1136
|
expect(diff.added.size).toBe(2);
|
|
1137
1137
|
|
|
1138
|
-
|
|
1138
|
+
assert.isTrue(diff.added.has('c'));
|
|
1139
1139
|
|
|
1140
|
-
|
|
1140
|
+
assert.isTrue(diff.added.has('d'));
|
|
1141
1141
|
});
|
|
1142
1142
|
|
|
1143
1143
|
test('should handle empty sets', () => {
|
|
@@ -1147,7 +1147,7 @@ describe('ISet.diff', () => {
|
|
|
1147
1147
|
|
|
1148
1148
|
const diff1 = ISet.diff(emptySet, nonEmptySet);
|
|
1149
1149
|
|
|
1150
|
-
|
|
1150
|
+
assert.isTrue(diff1.deleted.isEmpty);
|
|
1151
1151
|
|
|
1152
1152
|
expect(diff1.added.size).toBe(2);
|
|
1153
1153
|
|
|
@@ -1155,7 +1155,7 @@ describe('ISet.diff', () => {
|
|
|
1155
1155
|
|
|
1156
1156
|
expect(diff2.deleted.size).toBe(2);
|
|
1157
1157
|
|
|
1158
|
-
|
|
1158
|
+
assert.isTrue(diff2.added.isEmpty);
|
|
1159
1159
|
});
|
|
1160
1160
|
});
|
|
1161
1161
|
|
|
@@ -1171,13 +1171,13 @@ describe('ISet.withMutations', () => {
|
|
|
1171
1171
|
|
|
1172
1172
|
expect(updated.size).toBe(3);
|
|
1173
1173
|
|
|
1174
|
-
|
|
1174
|
+
assert.isTrue(updated.has('b'));
|
|
1175
1175
|
|
|
1176
|
-
|
|
1176
|
+
assert.isTrue(updated.has('c'));
|
|
1177
1177
|
|
|
1178
|
-
|
|
1178
|
+
assert.isTrue(updated.has('d'));
|
|
1179
1179
|
|
|
1180
|
-
|
|
1180
|
+
assert.isFalse(updated.has('a'));
|
|
1181
1181
|
});
|
|
1182
1182
|
|
|
1183
1183
|
test('should handle empty mutations array', () => {
|
|
@@ -1187,7 +1187,7 @@ describe('ISet.withMutations', () => {
|
|
|
1187
1187
|
|
|
1188
1188
|
expect(updated.size).toBe(set.size);
|
|
1189
1189
|
|
|
1190
|
-
|
|
1190
|
+
assert.isTrue(ISet.equal(set, updated));
|
|
1191
1191
|
});
|
|
1192
1192
|
|
|
1193
1193
|
test('should handle duplicate operations', () => {
|
|
@@ -1201,9 +1201,9 @@ describe('ISet.withMutations', () => {
|
|
|
1201
1201
|
|
|
1202
1202
|
expect(updated.size).toBe(2);
|
|
1203
1203
|
|
|
1204
|
-
|
|
1204
|
+
assert.isTrue(updated.has('a'));
|
|
1205
1205
|
|
|
1206
|
-
|
|
1206
|
+
assert.isTrue(updated.has('b'));
|
|
1207
1207
|
});
|
|
1208
1208
|
});
|
|
1209
1209
|
|
|
@@ -1261,7 +1261,7 @@ describe('edge cases', () => {
|
|
|
1261
1261
|
test('should handle NaN correctly', () => {
|
|
1262
1262
|
const set = ISet.create([Number.NaN, 1, 2]);
|
|
1263
1263
|
|
|
1264
|
-
|
|
1264
|
+
assert.isTrue(set.has(Number.NaN));
|
|
1265
1265
|
|
|
1266
1266
|
expect(set.size).toBe(3);
|
|
1267
1267
|
});
|
|
@@ -1271,9 +1271,9 @@ describe('edge cases', () => {
|
|
|
1271
1271
|
|
|
1272
1272
|
expect(set.size).toBe(2);
|
|
1273
1273
|
|
|
1274
|
-
|
|
1274
|
+
assert.isTrue(set.has(true));
|
|
1275
1275
|
|
|
1276
|
-
|
|
1276
|
+
assert.isTrue(set.has(false));
|
|
1277
1277
|
});
|
|
1278
1278
|
|
|
1279
1279
|
test('should handle null and undefined', () => {
|
|
@@ -1281,9 +1281,9 @@ describe('edge cases', () => {
|
|
|
1281
1281
|
|
|
1282
1282
|
expect(set.size).toBe(2);
|
|
1283
1283
|
|
|
1284
|
-
|
|
1284
|
+
assert.isTrue(set.has(null));
|
|
1285
1285
|
|
|
1286
|
-
|
|
1286
|
+
assert.isTrue(set.has(undefined));
|
|
1287
1287
|
});
|
|
1288
1288
|
|
|
1289
1289
|
test('should handle symbols by reference', () => {
|
|
@@ -1295,11 +1295,11 @@ describe('edge cases', () => {
|
|
|
1295
1295
|
|
|
1296
1296
|
expect(set.size).toBe(2);
|
|
1297
1297
|
|
|
1298
|
-
|
|
1298
|
+
assert.isTrue(set.has(sym1));
|
|
1299
1299
|
|
|
1300
|
-
|
|
1300
|
+
assert.isTrue(set.has(sym2));
|
|
1301
1301
|
|
|
1302
|
-
|
|
1302
|
+
assert.isFalse(set.has(Symbol('test'))); // Different symbol
|
|
1303
1303
|
});
|
|
1304
1304
|
});
|
|
1305
1305
|
|
|
@@ -1313,9 +1313,9 @@ describe('immutability', () => {
|
|
|
1313
1313
|
|
|
1314
1314
|
expect(modified.size).toBe(4);
|
|
1315
1315
|
|
|
1316
|
-
|
|
1316
|
+
assert.isFalse(original.has(4));
|
|
1317
1317
|
|
|
1318
|
-
|
|
1318
|
+
assert.isTrue(modified.has(4));
|
|
1319
1319
|
});
|
|
1320
1320
|
|
|
1321
1321
|
test('should not modify original set when deleting', () => {
|
|
@@ -1327,9 +1327,9 @@ describe('immutability', () => {
|
|
|
1327
1327
|
|
|
1328
1328
|
expect(modified.size).toBe(2);
|
|
1329
1329
|
|
|
1330
|
-
|
|
1330
|
+
assert.isTrue(original.has(2));
|
|
1331
1331
|
|
|
1332
|
-
|
|
1332
|
+
assert.isFalse(modified.has(2));
|
|
1333
1333
|
});
|
|
1334
1334
|
|
|
1335
1335
|
test('should not modify original set when filtering', () => {
|
|
@@ -1341,9 +1341,9 @@ describe('immutability', () => {
|
|
|
1341
1341
|
|
|
1342
1342
|
expect(filtered.size).toBe(2);
|
|
1343
1343
|
|
|
1344
|
-
|
|
1344
|
+
assert.isTrue(original.has(1));
|
|
1345
1345
|
|
|
1346
|
-
|
|
1346
|
+
assert.isFalse(filtered.has(1));
|
|
1347
1347
|
});
|
|
1348
1348
|
|
|
1349
1349
|
test('should not modify original set when mapping', () => {
|
|
@@ -1355,11 +1355,11 @@ describe('immutability', () => {
|
|
|
1355
1355
|
|
|
1356
1356
|
expect(mapped.size).toBe(3);
|
|
1357
1357
|
|
|
1358
|
-
|
|
1358
|
+
assert.isTrue(original.has(1));
|
|
1359
1359
|
|
|
1360
|
-
|
|
1360
|
+
assert.isFalse(mapped.has(1));
|
|
1361
1361
|
|
|
1362
|
-
|
|
1362
|
+
assert.isTrue(mapped.has(2));
|
|
1363
1363
|
});
|
|
1364
1364
|
|
|
1365
1365
|
test('should not modify original sets during set operations', () => {
|