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
package/src/collections/imap.mts
CHANGED
|
@@ -44,7 +44,7 @@ type IMapInterface<K extends MapSetKeyType, V> = Readonly<{
|
|
|
44
44
|
*
|
|
45
45
|
* const map = IMap.create(entries);
|
|
46
46
|
*
|
|
47
|
-
* assert(map.size === 2);
|
|
47
|
+
* assert.isTrue(map.size === 2);
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
50
|
size: SizeType.Arr;
|
|
@@ -61,9 +61,9 @@ type IMapInterface<K extends MapSetKeyType, V> = Readonly<{
|
|
|
61
61
|
* ['enabled', true],
|
|
62
62
|
* ]);
|
|
63
63
|
*
|
|
64
|
-
* assert.
|
|
64
|
+
* assert.isTrue(map.has('id'));
|
|
65
65
|
*
|
|
66
|
-
* assert.
|
|
66
|
+
* assert.isFalse(map.has('missing'));
|
|
67
67
|
* ```
|
|
68
68
|
*
|
|
69
69
|
* @param key The key to check.
|
|
@@ -107,9 +107,9 @@ type IMapInterface<K extends MapSetKeyType, V> = Readonly<{
|
|
|
107
107
|
*
|
|
108
108
|
* const isNarrowed = map.every((value): value is 2 | 4 => value % 2 === 0);
|
|
109
109
|
*
|
|
110
|
-
* assert.
|
|
110
|
+
* assert.isTrue(allEven);
|
|
111
111
|
*
|
|
112
|
-
* assert.
|
|
112
|
+
* assert.isTrue(isNarrowed);
|
|
113
113
|
* ```
|
|
114
114
|
*
|
|
115
115
|
* @param predicate A function to test each key-value pair.
|
|
@@ -142,9 +142,9 @@ type IMapInterface<K extends MapSetKeyType, V> = Readonly<{
|
|
|
142
142
|
*
|
|
143
143
|
* const map = IMap.create(entries);
|
|
144
144
|
*
|
|
145
|
-
* assert.
|
|
145
|
+
* assert.isTrue(map.some((value) => value > 4));
|
|
146
146
|
*
|
|
147
|
-
* assert.
|
|
147
|
+
* assert.isFalse(map.some((value) => value > 10));
|
|
148
148
|
* ```
|
|
149
149
|
*
|
|
150
150
|
* @param predicate A function to test each key-value pair.
|
|
@@ -172,9 +172,9 @@ type IMapInterface<K extends MapSetKeyType, V> = Readonly<{
|
|
|
172
172
|
*
|
|
173
173
|
* assert.deepStrictEqual(withoutB.get('b'), Optional.none);
|
|
174
174
|
*
|
|
175
|
-
* assert(original.size === 2);
|
|
175
|
+
* assert.isTrue(original.size === 2);
|
|
176
176
|
*
|
|
177
|
-
* assert(withoutB.size === 1);
|
|
177
|
+
* assert.isTrue(withoutB.size === 1);
|
|
178
178
|
* ```
|
|
179
179
|
*
|
|
180
180
|
* @param key The key to delete.
|
|
@@ -233,7 +233,7 @@ type IMapInterface<K extends MapSetKeyType, V> = Readonly<{
|
|
|
233
233
|
*
|
|
234
234
|
* assert.deepStrictEqual(scores.get('alice'), Optional.some(10));
|
|
235
235
|
*
|
|
236
|
-
* assert(unchanged === scores);
|
|
236
|
+
* assert.isTrue(unchanged === scores);
|
|
237
237
|
* ```
|
|
238
238
|
*
|
|
239
239
|
* @param key The key whose value to update.
|
|
@@ -575,9 +575,9 @@ type IMapInterface<K extends MapSetKeyType, V> = Readonly<{
|
|
|
575
575
|
*
|
|
576
576
|
* const raw = map.toRawMap();
|
|
577
577
|
*
|
|
578
|
-
* assert.
|
|
578
|
+
* assert.isTrue(is.map(raw));
|
|
579
579
|
*
|
|
580
|
-
* assert(raw.get('key') === 1);
|
|
580
|
+
* assert.isTrue(raw.get('key') === 1);
|
|
581
581
|
* ```
|
|
582
582
|
*
|
|
583
583
|
* @returns The raw ReadonlyMap instance.
|
|
@@ -633,7 +633,7 @@ export namespace IMap {
|
|
|
633
633
|
* ['status', 'active'],
|
|
634
634
|
* ]);
|
|
635
635
|
*
|
|
636
|
-
* assert(map.size === 2);
|
|
636
|
+
* assert.isTrue(map.size === 2);
|
|
637
637
|
*
|
|
638
638
|
* assert.deepStrictEqual(map.get('status'), Optional.some('active'));
|
|
639
639
|
* ```
|
|
@@ -676,9 +676,9 @@ export namespace IMap {
|
|
|
676
676
|
* ['b', 3],
|
|
677
677
|
* ]);
|
|
678
678
|
*
|
|
679
|
-
* assert.
|
|
679
|
+
* assert.isTrue(IMap.equal(first, second));
|
|
680
680
|
*
|
|
681
|
-
* assert.
|
|
681
|
+
* assert.isFalse(IMap.equal(first, third));
|
|
682
682
|
* ```
|
|
683
683
|
*
|
|
684
684
|
* @template K The type of the keys.
|
|
@@ -122,7 +122,7 @@ describe('IMap.equal', () => {
|
|
|
122
122
|
['b', 2],
|
|
123
123
|
]);
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
assert.isTrue(IMap.equal(map1, map2));
|
|
126
126
|
});
|
|
127
127
|
|
|
128
128
|
test('should return true for different creation order', () => {
|
|
@@ -136,7 +136,7 @@ describe('IMap.equal', () => {
|
|
|
136
136
|
['a', 1],
|
|
137
137
|
]);
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
assert.isTrue(IMap.equal(map1, map2));
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
test('should return false for maps with different sizes', () => {
|
|
@@ -147,7 +147,7 @@ describe('IMap.equal', () => {
|
|
|
147
147
|
['b', 2],
|
|
148
148
|
]);
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
assert.isFalse(IMap.equal(map1, map2));
|
|
151
151
|
});
|
|
152
152
|
|
|
153
153
|
test('should return false for maps with different values', () => {
|
|
@@ -161,7 +161,7 @@ describe('IMap.equal', () => {
|
|
|
161
161
|
['b', 3],
|
|
162
162
|
]);
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
assert.isFalse(IMap.equal(map1, map2));
|
|
165
165
|
});
|
|
166
166
|
|
|
167
167
|
test('should return false for maps with different keys', () => {
|
|
@@ -175,7 +175,7 @@ describe('IMap.equal', () => {
|
|
|
175
175
|
['c', 2],
|
|
176
176
|
]);
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
assert.isFalse(IMap.equal(map1, map2));
|
|
179
179
|
});
|
|
180
180
|
|
|
181
181
|
test('should return true for empty maps', () => {
|
|
@@ -183,7 +183,7 @@ describe('IMap.equal', () => {
|
|
|
183
183
|
|
|
184
184
|
const map2 = IMap.create<string, number>([]);
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
assert.isTrue(IMap.equal(map1, map2));
|
|
187
187
|
});
|
|
188
188
|
});
|
|
189
189
|
|
|
@@ -209,7 +209,7 @@ describe('IMap.has', () => {
|
|
|
209
209
|
[7, 70],
|
|
210
210
|
] as const);
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
assert.isTrue(m0.has(6));
|
|
213
213
|
});
|
|
214
214
|
|
|
215
215
|
test('case 2', () => {
|
|
@@ -221,13 +221,13 @@ describe('IMap.has', () => {
|
|
|
221
221
|
[7, 70],
|
|
222
222
|
]);
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
assert.isFalse(m0.has(8));
|
|
225
225
|
});
|
|
226
226
|
|
|
227
227
|
test('case 3', () => {
|
|
228
228
|
const m0 = IMap.create<number, number>([]);
|
|
229
229
|
|
|
230
|
-
|
|
230
|
+
assert.isFalse(m0.has(0));
|
|
231
231
|
});
|
|
232
232
|
|
|
233
233
|
test('case 4', () => {
|
|
@@ -240,7 +240,7 @@ describe('IMap.has', () => {
|
|
|
240
240
|
[Number.NaN, 0],
|
|
241
241
|
] as const);
|
|
242
242
|
|
|
243
|
-
|
|
243
|
+
assert.isTrue(m0.has(Number.NaN));
|
|
244
244
|
});
|
|
245
245
|
|
|
246
246
|
test('should handle boolean keys', () => {
|
|
@@ -249,9 +249,9 @@ describe('IMap.has', () => {
|
|
|
249
249
|
[false, 'no'],
|
|
250
250
|
]);
|
|
251
251
|
|
|
252
|
-
|
|
252
|
+
assert.isTrue(map.has(true));
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
assert.isTrue(map.has(false));
|
|
255
255
|
});
|
|
256
256
|
|
|
257
257
|
test('should handle string number keys', () => {
|
|
@@ -260,9 +260,9 @@ describe('IMap.has', () => {
|
|
|
260
260
|
['2', 'two'],
|
|
261
261
|
]);
|
|
262
262
|
|
|
263
|
-
|
|
263
|
+
assert.isTrue(map.has('1'));
|
|
264
264
|
|
|
265
|
-
|
|
265
|
+
assert.isTrue(map.has(String(1)));
|
|
266
266
|
});
|
|
267
267
|
});
|
|
268
268
|
|
|
@@ -411,7 +411,7 @@ describe('IMap.set', () => {
|
|
|
411
411
|
|
|
412
412
|
const curr = map.get('a');
|
|
413
413
|
|
|
414
|
-
assert(Optional.isSome(curr));
|
|
414
|
+
assert.isTrue(Optional.isSome(curr));
|
|
415
415
|
|
|
416
416
|
const updated = map.set('a', curr.value);
|
|
417
417
|
|
|
@@ -429,9 +429,9 @@ describe('IMap.set', () => {
|
|
|
429
429
|
|
|
430
430
|
expect(modified.size).toBe(2);
|
|
431
431
|
|
|
432
|
-
|
|
432
|
+
assert.isFalse(original.has('b'));
|
|
433
433
|
|
|
434
|
-
|
|
434
|
+
assert.isTrue(modified.has('b'));
|
|
435
435
|
});
|
|
436
436
|
});
|
|
437
437
|
|
|
@@ -606,9 +606,9 @@ describe('IMap.delete', () => {
|
|
|
606
606
|
|
|
607
607
|
expect(modified.size).toBe(1);
|
|
608
608
|
|
|
609
|
-
|
|
609
|
+
assert.isTrue(original.has('a'));
|
|
610
610
|
|
|
611
|
-
|
|
611
|
+
assert.isFalse(modified.has('a'));
|
|
612
612
|
});
|
|
613
613
|
});
|
|
614
614
|
|
|
@@ -620,7 +620,7 @@ describe('IMap.every', () => {
|
|
|
620
620
|
['c', 6],
|
|
621
621
|
]);
|
|
622
622
|
|
|
623
|
-
|
|
623
|
+
assert.isTrue(map.every((value) => value % 2 === 0));
|
|
624
624
|
});
|
|
625
625
|
|
|
626
626
|
test('should return false when some elements do not satisfy predicate', () => {
|
|
@@ -630,13 +630,13 @@ describe('IMap.every', () => {
|
|
|
630
630
|
['c', 4],
|
|
631
631
|
]);
|
|
632
632
|
|
|
633
|
-
|
|
633
|
+
assert.isFalse(map.every((value) => value % 2 === 0));
|
|
634
634
|
});
|
|
635
635
|
|
|
636
636
|
test('should return true for empty map', () => {
|
|
637
637
|
const map = IMap.create<string, number>([]);
|
|
638
638
|
|
|
639
|
-
|
|
639
|
+
assert.isTrue(map.every((value) => value > 0));
|
|
640
640
|
});
|
|
641
641
|
|
|
642
642
|
test('should work with key parameter', () => {
|
|
@@ -646,7 +646,7 @@ describe('IMap.every', () => {
|
|
|
646
646
|
['cc', 3],
|
|
647
647
|
]);
|
|
648
648
|
|
|
649
|
-
|
|
649
|
+
assert.isTrue(map.every((_value, key) => key.length === 2));
|
|
650
650
|
});
|
|
651
651
|
|
|
652
652
|
test('should work as type guard', () => {
|
|
@@ -659,7 +659,7 @@ describe('IMap.every', () => {
|
|
|
659
659
|
// Type should be narrowed to IMap<string, string>
|
|
660
660
|
const firstValue = Optional.unwrap(map.get('a'));
|
|
661
661
|
|
|
662
|
-
|
|
662
|
+
assert.isTrue(isString(firstValue));
|
|
663
663
|
}
|
|
664
664
|
});
|
|
665
665
|
});
|
|
@@ -672,7 +672,7 @@ describe('IMap.some', () => {
|
|
|
672
672
|
['c', 3],
|
|
673
673
|
]);
|
|
674
674
|
|
|
675
|
-
|
|
675
|
+
assert.isTrue(map.some((value) => value % 2 === 0));
|
|
676
676
|
});
|
|
677
677
|
|
|
678
678
|
test('should return false when no elements satisfy predicate', () => {
|
|
@@ -682,13 +682,13 @@ describe('IMap.some', () => {
|
|
|
682
682
|
['c', 5],
|
|
683
683
|
]);
|
|
684
684
|
|
|
685
|
-
|
|
685
|
+
assert.isFalse(map.some((value) => value % 2 === 0));
|
|
686
686
|
});
|
|
687
687
|
|
|
688
688
|
test('should return false for empty map', () => {
|
|
689
689
|
const map = IMap.create<string, number>([]);
|
|
690
690
|
|
|
691
|
-
|
|
691
|
+
assert.isFalse(map.some((value) => value > 0));
|
|
692
692
|
});
|
|
693
693
|
|
|
694
694
|
test('should work with key parameter', () => {
|
|
@@ -698,7 +698,7 @@ describe('IMap.some', () => {
|
|
|
698
698
|
['c', 3],
|
|
699
699
|
]);
|
|
700
700
|
|
|
701
|
-
|
|
701
|
+
assert.isTrue(map.some((_value, key) => key.length > 1));
|
|
702
702
|
});
|
|
703
703
|
});
|
|
704
704
|
|
|
@@ -721,7 +721,7 @@ describe('IMap.withMutations', () => {
|
|
|
721
721
|
|
|
722
722
|
expect(Optional.unwrap(updated.get('c'))).toBe(3);
|
|
723
723
|
|
|
724
|
-
|
|
724
|
+
assert.isTrue(Optional.isNone(updated.get('b')));
|
|
725
725
|
});
|
|
726
726
|
|
|
727
727
|
test('should handle empty mutations array', () => {
|
|
@@ -748,7 +748,7 @@ describe('IMap.withMutations', () => {
|
|
|
748
748
|
|
|
749
749
|
expect(updated.size).toBe(map.size);
|
|
750
750
|
|
|
751
|
-
|
|
751
|
+
assert.isTrue(Optional.isNone(updated.get('nonexistent')));
|
|
752
752
|
});
|
|
753
753
|
|
|
754
754
|
test('should handle mixed operations', () => {
|
|
@@ -816,7 +816,7 @@ describe('IMap.mapKeys', () => {
|
|
|
816
816
|
|
|
817
817
|
const mapped = map.mapKeys((key) => key.toUpperCase());
|
|
818
818
|
|
|
819
|
-
|
|
819
|
+
assert.isTrue(Optional.isNone(mapped.get('a')));
|
|
820
820
|
|
|
821
821
|
expect(Optional.unwrap(mapped.get('A'))).toBe(1);
|
|
822
822
|
|
|
@@ -64,7 +64,7 @@ type ISetMappedInterface<K, KM extends MapSetKeyType> = Readonly<{
|
|
|
64
64
|
*
|
|
65
65
|
* const set = ISetMapped.create<Point, string>(points, toKey, fromKey);
|
|
66
66
|
*
|
|
67
|
-
* assert(set.size === 2);
|
|
67
|
+
* assert.isTrue(set.size === 2);
|
|
68
68
|
* ```
|
|
69
69
|
*/
|
|
70
70
|
size: SizeType.Arr;
|
|
@@ -90,9 +90,9 @@ type ISetMappedInterface<K, KM extends MapSetKeyType> = Readonly<{
|
|
|
90
90
|
* fromKey,
|
|
91
91
|
* );
|
|
92
92
|
*
|
|
93
|
-
* assert.
|
|
93
|
+
* assert.isTrue(empty.isEmpty);
|
|
94
94
|
*
|
|
95
|
-
* assert.
|
|
95
|
+
* assert.isFalse(points.isEmpty);
|
|
96
96
|
* ```
|
|
97
97
|
*/
|
|
98
98
|
isEmpty: boolean;
|
|
@@ -116,9 +116,9 @@ type ISetMappedInterface<K, KM extends MapSetKeyType> = Readonly<{
|
|
|
116
116
|
* fromKey,
|
|
117
117
|
* );
|
|
118
118
|
*
|
|
119
|
-
* assert.
|
|
119
|
+
* assert.isTrue(set.has({ x: 1, tag: 'a' }));
|
|
120
120
|
*
|
|
121
|
-
* assert.
|
|
121
|
+
* assert.isFalse(set.has({ x: 2, tag: 'b' }));
|
|
122
122
|
* ```
|
|
123
123
|
*
|
|
124
124
|
* @param key The element to check.
|
|
@@ -156,9 +156,9 @@ type ISetMappedInterface<K, KM extends MapSetKeyType> = Readonly<{
|
|
|
156
156
|
* (point): point is Readonly<{ x: 2 | 4; tag: 'even' }> => point.x % 2 === 0,
|
|
157
157
|
* );
|
|
158
158
|
*
|
|
159
|
-
* assert.
|
|
159
|
+
* assert.isTrue(allEven);
|
|
160
160
|
*
|
|
161
|
-
* assert.
|
|
161
|
+
* assert.isTrue(narrowed);
|
|
162
162
|
* ```
|
|
163
163
|
*
|
|
164
164
|
* @param predicate A function to test each element.
|
|
@@ -200,9 +200,9 @@ type ISetMappedInterface<K, KM extends MapSetKeyType> = Readonly<{
|
|
|
200
200
|
* fromKey,
|
|
201
201
|
* );
|
|
202
202
|
*
|
|
203
|
-
* assert.
|
|
203
|
+
* assert.isTrue(set.some((point) => point.x > 4));
|
|
204
204
|
*
|
|
205
|
-
* assert.
|
|
205
|
+
* assert.isFalse(set.some((point) => point.x > 10));
|
|
206
206
|
* ```
|
|
207
207
|
*
|
|
208
208
|
* @param predicate A function to test each element.
|
|
@@ -241,7 +241,7 @@ type ISetMappedInterface<K, KM extends MapSetKeyType> = Readonly<{
|
|
|
241
241
|
* { x: 2, tag: 'b' },
|
|
242
242
|
* ]);
|
|
243
243
|
*
|
|
244
|
-
* assert(unchanged === base);
|
|
244
|
+
* assert.isTrue(unchanged === base);
|
|
245
245
|
* ```
|
|
246
246
|
*
|
|
247
247
|
* @param key The element to add.
|
|
@@ -277,7 +277,7 @@ type ISetMappedInterface<K, KM extends MapSetKeyType> = Readonly<{
|
|
|
277
277
|
*
|
|
278
278
|
* assert.deepStrictEqual(Array.from(withoutSecond), [{ x: 1, tag: 'a' }]);
|
|
279
279
|
*
|
|
280
|
-
* assert(unchanged === base);
|
|
280
|
+
* assert.isTrue(unchanged === base);
|
|
281
281
|
* ```
|
|
282
282
|
*
|
|
283
283
|
* @param key The element to delete.
|
|
@@ -517,9 +517,9 @@ type ISetMappedInterface<K, KM extends MapSetKeyType> = Readonly<{
|
|
|
517
517
|
* fromKey,
|
|
518
518
|
* );
|
|
519
519
|
*
|
|
520
|
-
* assert.
|
|
520
|
+
* assert.isTrue(subset.isSubsetOf(superset));
|
|
521
521
|
*
|
|
522
|
-
* assert.
|
|
522
|
+
* assert.isFalse(superset.isSubsetOf(subset));
|
|
523
523
|
* ```
|
|
524
524
|
*
|
|
525
525
|
* @param set The other set.
|
|
@@ -556,9 +556,9 @@ type ISetMappedInterface<K, KM extends MapSetKeyType> = Readonly<{
|
|
|
556
556
|
* fromKey,
|
|
557
557
|
* );
|
|
558
558
|
*
|
|
559
|
-
* assert.
|
|
559
|
+
* assert.isTrue(superset.isSupersetOf(subset));
|
|
560
560
|
*
|
|
561
|
-
* assert.
|
|
561
|
+
* assert.isFalse(subset.isSupersetOf(superset));
|
|
562
562
|
* ```
|
|
563
563
|
*
|
|
564
564
|
* @param set The other set.
|
|
@@ -846,9 +846,9 @@ type ISetMappedInterface<K, KM extends MapSetKeyType> = Readonly<{
|
|
|
846
846
|
*
|
|
847
847
|
* const raw = set.toRawSet();
|
|
848
848
|
*
|
|
849
|
-
* assert.
|
|
849
|
+
* assert.isTrue(is.set(raw));
|
|
850
850
|
*
|
|
851
|
-
* assert.
|
|
851
|
+
* assert.isTrue(raw.has(toKey({ x: 1, tag: 'a' })));
|
|
852
852
|
* ```
|
|
853
853
|
*
|
|
854
854
|
* @returns The raw ReadonlySet instance.
|
|
@@ -991,9 +991,9 @@ export namespace ISetMapped {
|
|
|
991
991
|
* fromKey,
|
|
992
992
|
* );
|
|
993
993
|
*
|
|
994
|
-
* assert.
|
|
994
|
+
* assert.isTrue(ISetMapped.equal(first, second));
|
|
995
995
|
*
|
|
996
|
-
* assert.
|
|
996
|
+
* assert.isFalse(ISetMapped.equal(first, third));
|
|
997
997
|
* ```
|
|
998
998
|
*
|
|
999
999
|
* @template K The type of the custom elements.
|