ts-data-forge 4.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entry-point.mjs +2 -0
- package/dist/entry-point.mjs.map +1 -1
- package/dist/functional/index.d.mts +1 -0
- package/dist/functional/index.d.mts.map +1 -1
- package/dist/functional/index.mjs +2 -0
- package/dist/functional/index.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/index.d.mts +29 -0
- package/dist/functional/ternary-result/impl/index.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/index.mjs +28 -0
- package/dist/functional/ternary-result/impl/index.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/tag.d.mts +7 -0
- package/dist/functional/ternary-result/impl/tag.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/tag.mjs +9 -0
- package/dist/functional/ternary-result/impl/tag.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts +14 -0
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs +21 -0
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts +18 -0
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +24 -0
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts +29 -0
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +41 -0
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts +27 -0
- package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +36 -0
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts +20 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +24 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +33 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts +20 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +23 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts +21 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +24 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +28 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts +21 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +24 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts +23 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +26 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts +21 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +29 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map.d.mts +29 -0
- package/dist/functional/ternary-result/impl/ternary-result-map.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs +35 -0
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts +16 -0
- package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +23 -0
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts +26 -0
- package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +19 -0
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts +16 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +25 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts +22 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts +18 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +36 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +22 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts +22 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +13 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts +18 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +36 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts +19 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts +18 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +32 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +22 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts +18 -0
- package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +26 -0
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts +26 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +48 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/types.d.mts +25 -0
- package/dist/functional/ternary-result/impl/types.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/types.mjs +2 -0
- package/dist/functional/ternary-result/impl/types.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/variant-name.d.mts +3 -0
- package/dist/functional/ternary-result/impl/variant-name.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/variant-name.mjs +16 -0
- package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -0
- package/dist/functional/ternary-result/index.d.mts +2 -0
- package/dist/functional/ternary-result/index.d.mts.map +1 -0
- package/dist/functional/ternary-result/index.mjs +3 -0
- package/dist/functional/ternary-result/index.mjs.map +1 -0
- package/dist/globals.d.mts +55 -2
- package/dist/json/json.d.mts +9 -3
- package/dist/json/json.d.mts.map +1 -1
- package/dist/json/json.mjs +6 -0
- package/dist/json/json.mjs.map +1 -1
- package/package.json +13 -13
- package/src/array/impl/array-utils-creation.test.mts +187 -74
- package/src/array/impl/array-utils-element-access.test.mts +19 -3
- package/src/array/impl/array-utils-iterators.test.mts +44 -24
- package/src/array/impl/array-utils-modification.test.mts +36 -33
- package/src/array/impl/array-utils-reducing-value.test.mts +47 -16
- package/src/array/impl/array-utils-search.test.mts +42 -9
- package/src/array/impl/array-utils-set-op.test.mts +54 -26
- package/src/array/impl/array-utils-size.test.mts +1 -0
- package/src/array/impl/array-utils-slice-clamped.test.mts +20 -11
- package/src/array/impl/array-utils-slicing.test.mts +27 -21
- package/src/array/impl/array-utils-transformation.test.mts +140 -92
- package/src/array/impl/array-utils-validation.test.mts +58 -10
- package/src/array/impl/array.test.mts +5 -5
- package/src/collections/imap-mapped.test.mts +63 -18
- package/src/collections/imap.test.mts +74 -26
- package/src/collections/iset-mapped.test.mts +81 -30
- package/src/collections/iset.test.mts +168 -68
- package/src/collections/queue.test.mts +32 -1
- package/src/collections/stack.test.mts +22 -8
- package/src/functional/index.mts +1 -0
- package/src/functional/match.test.mts +1 -1
- package/src/functional/optional.test.mts +61 -4
- package/src/functional/pipe.test.mts +10 -1
- package/src/functional/result.test.mts +127 -4
- package/src/functional/ternary-result/impl/index.mts +28 -0
- package/src/functional/ternary-result/impl/tag.mts +11 -0
- package/src/functional/ternary-result/impl/ternary-result-err.mts +18 -0
- package/src/functional/ternary-result/impl/ternary-result-expect-to-be.mts +53 -0
- package/src/functional/ternary-result/impl/ternary-result-flat-map.mts +95 -0
- package/src/functional/ternary-result/impl/ternary-result-fold.mts +93 -0
- package/src/functional/ternary-result/impl/ternary-result-from-promise.mts +27 -0
- package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +31 -0
- package/src/functional/ternary-result/impl/ternary-result-is-err.mts +23 -0
- package/src/functional/ternary-result/impl/ternary-result-is-ok.mts +24 -0
- package/src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts +27 -0
- package/src/functional/ternary-result/impl/ternary-result-is-warn.mts +24 -0
- package/src/functional/ternary-result/impl/ternary-result-map-err.mts +64 -0
- package/src/functional/ternary-result/impl/ternary-result-map-warn.mts +66 -0
- package/src/functional/ternary-result/impl/ternary-result-map.mts +81 -0
- package/src/functional/ternary-result/impl/ternary-result-ok.mts +20 -0
- package/src/functional/ternary-result/impl/ternary-result-or-else.mts +66 -0
- package/src/functional/ternary-result/impl/ternary-result-to-optional.mts +25 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err-or.mts +45 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mts +40 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err.mts +22 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mts +45 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-ok.mts +32 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts +45 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mts +42 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mts +38 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn.mts +22 -0
- package/src/functional/ternary-result/impl/ternary-result-warn.mts +23 -0
- package/src/functional/ternary-result/impl/ternary-result-zip.mts +53 -0
- package/src/functional/ternary-result/impl/types.mts +39 -0
- package/src/functional/ternary-result/impl/variant-name.mts +17 -0
- package/src/functional/ternary-result/index.mts +1 -0
- package/src/functional/ternary-result.test.mts +214 -0
- package/src/globals.d.mts +55 -2
- package/src/guard/is-non-empty-string.test.mts +5 -2
- package/src/guard/is-non-null-object.test.mts +3 -5
- package/src/guard/is-primitive.test.mts +5 -3
- package/src/guard/is-record.test.mts +1 -1
- package/src/guard/is-type.test.mts +35 -20
- package/src/guard/key-is-in.test.mts +1 -1
- package/src/iterator/range.test.mts +22 -16
- package/src/json/json.mts +9 -3
- package/src/json/json.test.mts +140 -64
- package/src/number/branded-types/finite-number.test.mts +3 -2
- package/src/number/branded-types/int.test.mts +4 -3
- package/src/number/branded-types/int16.test.mts +9 -3
- package/src/number/branded-types/int32.test.mts +9 -3
- package/src/number/branded-types/non-negative-finite-number.test.mts +6 -4
- package/src/number/branded-types/non-negative-int16.test.mts +8 -3
- package/src/number/branded-types/non-negative-int32.test.mts +8 -3
- package/src/number/branded-types/non-zero-finite-number.test.mts +6 -3
- package/src/number/branded-types/non-zero-int.test.mts +6 -3
- package/src/number/branded-types/non-zero-int16.test.mts +9 -3
- package/src/number/branded-types/non-zero-int32.test.mts +9 -3
- package/src/number/branded-types/non-zero-safe-int.test.mts +10 -3
- package/src/number/branded-types/non-zero-uint16.test.mts +8 -3
- package/src/number/branded-types/non-zero-uint32.test.mts +8 -3
- package/src/number/branded-types/positive-finite-number.test.mts +7 -3
- package/src/number/branded-types/positive-int.test.mts +5 -3
- package/src/number/branded-types/positive-int16.test.mts +8 -3
- package/src/number/branded-types/positive-int32.test.mts +8 -3
- package/src/number/branded-types/positive-safe-int.test.mts +8 -3
- package/src/number/branded-types/positive-uint16.test.mts +8 -3
- package/src/number/branded-types/positive-uint32.test.mts +8 -3
- package/src/number/branded-types/safe-int.test.mts +8 -2
- package/src/number/branded-types/safe-uint.test.mts +8 -3
- package/src/number/branded-types/uint.test.mts +5 -3
- package/src/number/branded-types/uint16.test.mts +8 -3
- package/src/number/branded-types/uint32.test.mts +8 -3
- package/src/number/enum/int8.test.mts +8 -3
- package/src/number/enum/uint8.test.mts +6 -3
- package/src/number/num.test.mts +16 -2
- package/src/object/object.test.mts +26 -13
- package/src/others/cast-mutable.test.mts +10 -8
- package/src/others/cast-readonly.test.mts +9 -5
- package/src/others/if-then.test.mts +4 -1
- package/src/others/map-nullable.test.mts +28 -1
- package/src/others/memoize-function.test.mts +20 -17
- package/src/others/tuple.test.mts +3 -2
- package/src/others/unknown-to-string.test.mts +15 -2
- package/src/promise/promise.test.mts +6 -1
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { expectType } from '../../expect-type.mjs';
|
|
2
2
|
import { range as rangeIterator } from '../../iterator/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
asNonZeroSafeInt,
|
|
5
|
+
asSafeInt,
|
|
6
|
+
asSafeUint,
|
|
7
|
+
asUint32,
|
|
8
|
+
} from '../../number/index.mjs';
|
|
4
9
|
import {
|
|
5
10
|
copy,
|
|
6
11
|
create,
|
|
@@ -13,34 +18,40 @@ import {
|
|
|
13
18
|
} from './array-utils-creation.mjs';
|
|
14
19
|
|
|
15
20
|
describe('Arr creations', () => {
|
|
16
|
-
describe(
|
|
21
|
+
describe(zeros, () => {
|
|
17
22
|
test('fixed length', () => {
|
|
18
23
|
const result = zeros(3);
|
|
19
24
|
expectType<typeof result, readonly [0, 0, 0]>('=');
|
|
20
|
-
|
|
25
|
+
|
|
26
|
+
assert.deepStrictEqual(result, [0, 0, 0]);
|
|
21
27
|
});
|
|
22
28
|
|
|
23
29
|
test('fixed length (empty)', () => {
|
|
24
30
|
const result = zeros(0);
|
|
25
31
|
expectType<typeof result, readonly []>('=');
|
|
26
|
-
|
|
32
|
+
|
|
33
|
+
assert.deepStrictEqual(result, []);
|
|
27
34
|
});
|
|
28
35
|
|
|
29
36
|
test('unknown length', () => {
|
|
30
37
|
const n: number = 3;
|
|
31
38
|
const result = zeros(asUint32(n));
|
|
32
39
|
expectType<typeof result, readonly 0[]>('=');
|
|
33
|
-
|
|
40
|
+
|
|
41
|
+
assert.deepStrictEqual(result, [0, 0, 0]);
|
|
34
42
|
});
|
|
35
43
|
|
|
36
44
|
test('should create array with zero length', () => {
|
|
37
45
|
const result = zeros(0);
|
|
38
|
-
|
|
46
|
+
|
|
47
|
+
assert.deepStrictEqual(result, []);
|
|
48
|
+
|
|
39
49
|
expect(result).toHaveLength(0);
|
|
40
50
|
});
|
|
41
51
|
|
|
42
52
|
test('should create large arrays', () => {
|
|
43
53
|
const result = zeros(asUint32(1000));
|
|
54
|
+
|
|
44
55
|
expect(result).toHaveLength(1000);
|
|
45
56
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
46
57
|
expect(result.every((x) => x === 0)).toBe(true);
|
|
@@ -48,37 +59,43 @@ describe('Arr creations', () => {
|
|
|
48
59
|
|
|
49
60
|
test('should work with curried version', () => {
|
|
50
61
|
const createTenZeros = zeros(10);
|
|
51
|
-
|
|
62
|
+
|
|
63
|
+
assert.deepStrictEqual(createTenZeros, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
|
52
64
|
});
|
|
53
65
|
});
|
|
54
66
|
|
|
55
|
-
describe(
|
|
67
|
+
describe(seq, () => {
|
|
56
68
|
test('fixed length', () => {
|
|
57
69
|
const result = seq(5);
|
|
58
70
|
expectType<typeof result, readonly [0, 1, 2, 3, 4]>('=');
|
|
59
|
-
|
|
71
|
+
|
|
72
|
+
assert.deepStrictEqual(result, [0, 1, 2, 3, 4]);
|
|
60
73
|
});
|
|
61
74
|
|
|
62
75
|
test('fixed length (empty)', () => {
|
|
63
76
|
const result = seq(0);
|
|
64
77
|
expectType<typeof result, readonly []>('=');
|
|
65
|
-
|
|
78
|
+
|
|
79
|
+
assert.deepStrictEqual(result, []);
|
|
66
80
|
});
|
|
67
81
|
|
|
68
82
|
test('unknown length', () => {
|
|
69
83
|
const n: number = 3;
|
|
70
84
|
const result = seq(asUint32(n));
|
|
71
85
|
expectType<typeof result, readonly SizeType.Arr[]>('=');
|
|
72
|
-
|
|
86
|
+
|
|
87
|
+
assert.deepStrictEqual(result, [asUint32(0), asUint32(1), asUint32(2)]);
|
|
73
88
|
});
|
|
74
89
|
|
|
75
90
|
test('should create sequence with zero length', () => {
|
|
76
91
|
const result = seq(0);
|
|
77
|
-
|
|
92
|
+
|
|
93
|
+
assert.deepStrictEqual(result, []);
|
|
78
94
|
});
|
|
79
95
|
|
|
80
96
|
test('should create sequence with large length', () => {
|
|
81
97
|
const result = seq(asUint32(100));
|
|
98
|
+
|
|
82
99
|
expect(result).toHaveLength(100);
|
|
83
100
|
expect(result[0]).toBe(0);
|
|
84
101
|
expect(result[99]).toBe(99);
|
|
@@ -86,21 +103,24 @@ describe('Arr creations', () => {
|
|
|
86
103
|
|
|
87
104
|
test('should work with curried version', () => {
|
|
88
105
|
const createFiveSeq = seq(5);
|
|
89
|
-
|
|
106
|
+
|
|
107
|
+
assert.deepStrictEqual(createFiveSeq, [0, 1, 2, 3, 4]);
|
|
90
108
|
});
|
|
91
109
|
});
|
|
92
110
|
|
|
93
|
-
describe(
|
|
111
|
+
describe(create, () => {
|
|
94
112
|
test('fixed length with primitive value', () => {
|
|
95
113
|
const result = create(3, 'a');
|
|
96
114
|
expectType<typeof result, readonly ['a', 'a', 'a']>('=');
|
|
97
|
-
|
|
115
|
+
|
|
116
|
+
assert.deepStrictEqual(result, ['a', 'a', 'a']);
|
|
98
117
|
});
|
|
99
118
|
|
|
100
119
|
test('fixed length with null', () => {
|
|
101
120
|
const result = create(2, null);
|
|
102
121
|
expectType<typeof result, readonly [null, null]>('=');
|
|
103
|
-
|
|
122
|
+
|
|
123
|
+
assert.deepStrictEqual(result, [null, null]);
|
|
104
124
|
});
|
|
105
125
|
|
|
106
126
|
test('fixed length with object (shallow copy)', () => {
|
|
@@ -109,7 +129,9 @@ describe('Arr creations', () => {
|
|
|
109
129
|
expectType<typeof result, readonly [{ id: number }, { id: number }]>(
|
|
110
130
|
'~=',
|
|
111
131
|
);
|
|
112
|
-
|
|
132
|
+
|
|
133
|
+
assert.deepStrictEqual(result, [obj, obj]);
|
|
134
|
+
|
|
113
135
|
expect(result[0]).toBe(obj);
|
|
114
136
|
expect(result[1]).toBe(obj);
|
|
115
137
|
});
|
|
@@ -117,49 +139,59 @@ describe('Arr creations', () => {
|
|
|
117
139
|
test('fixed length (empty)', () => {
|
|
118
140
|
const result = create(0, 123);
|
|
119
141
|
expectType<typeof result, readonly []>('=');
|
|
120
|
-
|
|
142
|
+
|
|
143
|
+
assert.deepStrictEqual(result, []);
|
|
121
144
|
});
|
|
122
145
|
|
|
123
146
|
test('unknown length', () => {
|
|
124
147
|
const n: number = 2;
|
|
125
148
|
const result = create(asUint32(n), true);
|
|
126
149
|
expectType<typeof result, readonly true[]>('=');
|
|
127
|
-
|
|
150
|
+
|
|
151
|
+
assert.deepStrictEqual(result, [true, true]);
|
|
128
152
|
});
|
|
129
153
|
|
|
130
154
|
test('should create array with function values', () => {
|
|
131
155
|
const fn = (): string => 'test';
|
|
132
156
|
const result = create(3, fn);
|
|
133
|
-
|
|
157
|
+
|
|
158
|
+
assert.deepStrictEqual(result, [fn, fn, fn]);
|
|
159
|
+
|
|
134
160
|
expect(result[0]).toBe(fn);
|
|
135
161
|
});
|
|
136
162
|
|
|
137
163
|
test('should create array with object values', () => {
|
|
138
164
|
const obj = { a: 1 };
|
|
139
165
|
const result = create(2, obj);
|
|
140
|
-
|
|
166
|
+
|
|
167
|
+
assert.deepStrictEqual(result, [obj, obj]);
|
|
168
|
+
|
|
141
169
|
expect(result[0]).toBe(obj); // Same reference
|
|
142
170
|
});
|
|
143
171
|
|
|
144
172
|
test('should create empty array when length is 0', () => {
|
|
145
173
|
const result = create(0, 'value');
|
|
146
|
-
|
|
174
|
+
|
|
175
|
+
assert.deepStrictEqual(result, []);
|
|
147
176
|
});
|
|
148
177
|
|
|
149
178
|
test('newArray is alias for create', () => {
|
|
150
179
|
const created1 = create(3, 'test');
|
|
151
180
|
const created2 = newArray(3, 'test');
|
|
152
|
-
|
|
153
|
-
|
|
181
|
+
|
|
182
|
+
assert.deepStrictEqual(created1, created2);
|
|
183
|
+
assert.deepStrictEqual(created1, ['test', 'test', 'test']);
|
|
154
184
|
});
|
|
155
185
|
});
|
|
156
186
|
|
|
157
|
-
describe(
|
|
187
|
+
describe(copy, () => {
|
|
158
188
|
test('should create a shallow copy of an array of primitives', () => {
|
|
159
189
|
const original = [1, 2, 3] as const;
|
|
160
190
|
const copied = copy(original);
|
|
161
191
|
expectType<typeof copied, readonly [1, 2, 3]>('=');
|
|
162
|
-
|
|
192
|
+
|
|
193
|
+
assert.deepStrictEqual(copied, original);
|
|
194
|
+
|
|
163
195
|
expect(copied).not.toBe(original);
|
|
164
196
|
});
|
|
165
197
|
|
|
@@ -170,7 +202,9 @@ describe('Arr creations', () => {
|
|
|
170
202
|
const copied = copy(original);
|
|
171
203
|
|
|
172
204
|
expectType<typeof copied, readonly [{ id: number }, { id: number }]>('=');
|
|
173
|
-
|
|
205
|
+
|
|
206
|
+
assert.deepStrictEqual(copied, original);
|
|
207
|
+
|
|
174
208
|
expect(copied).not.toBe(original);
|
|
175
209
|
expect(copied[0]).toBe(original[0]); // Object references are the same
|
|
176
210
|
expect(copied[1]).toBe(original[1]);
|
|
@@ -180,7 +214,9 @@ describe('Arr creations', () => {
|
|
|
180
214
|
const original = [] as const;
|
|
181
215
|
const copied = copy(original);
|
|
182
216
|
expectType<typeof copied, readonly []>('=');
|
|
183
|
-
|
|
217
|
+
|
|
218
|
+
assert.deepStrictEqual(copied, original);
|
|
219
|
+
|
|
184
220
|
expect(copied).not.toBe(original);
|
|
185
221
|
});
|
|
186
222
|
|
|
@@ -190,7 +226,9 @@ describe('Arr creations', () => {
|
|
|
190
226
|
expectType<typeof copied, readonly [1, 'hello', true, null, undefined]>(
|
|
191
227
|
'=',
|
|
192
228
|
);
|
|
193
|
-
|
|
229
|
+
|
|
230
|
+
assert.deepStrictEqual(copied, original);
|
|
231
|
+
|
|
194
232
|
expect(copied).not.toBe(original);
|
|
195
233
|
});
|
|
196
234
|
|
|
@@ -198,26 +236,34 @@ describe('Arr creations', () => {
|
|
|
198
236
|
const mut_original: number[] = [1, 2, 3];
|
|
199
237
|
const copied = copy(mut_original);
|
|
200
238
|
expectType<typeof copied, number[]>('=');
|
|
201
|
-
|
|
239
|
+
|
|
240
|
+
assert.deepStrictEqual(copied, mut_original);
|
|
241
|
+
|
|
202
242
|
expect(copied).not.toBe(mut_original);
|
|
243
|
+
|
|
203
244
|
// Modify original to ensure copy is shallow
|
|
204
245
|
mut_original.push(4);
|
|
205
|
-
|
|
206
|
-
|
|
246
|
+
|
|
247
|
+
assert.deepStrictEqual(mut_original, [1, 2, 3, 4]);
|
|
248
|
+
assert.deepStrictEqual(copied, [1, 2, 3]);
|
|
207
249
|
});
|
|
208
250
|
|
|
209
251
|
test('should create shallow copy of array', () => {
|
|
210
252
|
const original = [1, 2, 3] as const;
|
|
211
253
|
const copied = copy(original);
|
|
212
254
|
expectType<typeof copied, readonly [1, 2, 3]>('=');
|
|
213
|
-
|
|
255
|
+
|
|
256
|
+
assert.deepStrictEqual(copied, original);
|
|
257
|
+
|
|
214
258
|
expect(copied).not.toBe(original);
|
|
215
259
|
});
|
|
216
260
|
|
|
217
261
|
test('should work with empty array', () => {
|
|
218
262
|
const empty = [] as const;
|
|
219
263
|
const copied = copy(empty);
|
|
220
|
-
|
|
264
|
+
|
|
265
|
+
assert.deepStrictEqual(copied, []);
|
|
266
|
+
|
|
221
267
|
expect(copied).not.toBe(empty);
|
|
222
268
|
});
|
|
223
269
|
|
|
@@ -225,58 +271,82 @@ describe('Arr creations', () => {
|
|
|
225
271
|
const mixed = [1, 'hello', true] as const;
|
|
226
272
|
const copied = copy(mixed);
|
|
227
273
|
expectType<typeof copied, readonly [1, 'hello', true]>('=');
|
|
228
|
-
|
|
274
|
+
|
|
275
|
+
assert.deepStrictEqual(copied, [1, 'hello', true]);
|
|
229
276
|
});
|
|
230
277
|
});
|
|
231
278
|
|
|
232
|
-
describe(
|
|
279
|
+
describe(range, () => {
|
|
233
280
|
test('start < end, step = 1 (default)', () => {
|
|
234
281
|
const result = range(1, 5);
|
|
235
282
|
expectType<typeof result, readonly [1, 2, 3, 4]>('=');
|
|
236
|
-
|
|
283
|
+
|
|
284
|
+
assert.deepStrictEqual(result, [1, 2, 3, 4]);
|
|
237
285
|
});
|
|
238
286
|
|
|
239
287
|
test('start === end, step = 1 (default)', () => {
|
|
240
288
|
const result = range(3, 3);
|
|
241
289
|
expectType<typeof result, readonly []>('=');
|
|
242
|
-
|
|
290
|
+
|
|
291
|
+
assert.deepStrictEqual(result, []);
|
|
243
292
|
});
|
|
244
293
|
|
|
245
294
|
test('start > end, step = 1 (default)', () => {
|
|
246
295
|
const result = range(5, 1);
|
|
247
296
|
expectType<typeof result, readonly []>('=');
|
|
248
|
-
|
|
297
|
+
|
|
298
|
+
assert.deepStrictEqual(result, []);
|
|
249
299
|
});
|
|
250
300
|
|
|
251
301
|
test('start < end, step > 1', () => {
|
|
252
302
|
const result = range(0, 6, 2);
|
|
253
303
|
expectType<typeof result, readonly SafeUint[]>('='); // Type is less specific with explicit step
|
|
254
|
-
|
|
304
|
+
|
|
305
|
+
assert.deepStrictEqual(result, [
|
|
306
|
+
asSafeUint(0),
|
|
307
|
+
asSafeUint(2),
|
|
308
|
+
asSafeUint(4),
|
|
309
|
+
]);
|
|
255
310
|
});
|
|
256
311
|
|
|
257
312
|
test('start < end, step > 1, not reaching end', () => {
|
|
258
313
|
const result = range(0, 5, 2);
|
|
259
|
-
|
|
314
|
+
|
|
315
|
+
assert.deepStrictEqual(result, [
|
|
316
|
+
asSafeUint(0),
|
|
317
|
+
asSafeUint(2),
|
|
318
|
+
asSafeUint(4),
|
|
319
|
+
]);
|
|
260
320
|
});
|
|
261
321
|
|
|
262
322
|
test('start > end, step < 0', () => {
|
|
263
323
|
const result = range(5, 0, -1);
|
|
264
|
-
|
|
324
|
+
|
|
325
|
+
assert.deepStrictEqual(result, [
|
|
326
|
+
asSafeInt(5),
|
|
327
|
+
asSafeInt(4),
|
|
328
|
+
asSafeInt(3),
|
|
329
|
+
asSafeInt(2),
|
|
330
|
+
asSafeInt(1),
|
|
331
|
+
]);
|
|
265
332
|
});
|
|
266
333
|
|
|
267
334
|
test('start > end, step < 0, not reaching end', () => {
|
|
268
335
|
const result = range(5, 1, -2);
|
|
269
|
-
|
|
336
|
+
|
|
337
|
+
assert.deepStrictEqual(result, [asSafeInt(5), asSafeInt(3)]);
|
|
270
338
|
});
|
|
271
339
|
|
|
272
340
|
test('start < end, step < 0 (empty result)', () => {
|
|
273
341
|
const result = range(1, 5, -1);
|
|
274
|
-
|
|
342
|
+
|
|
343
|
+
assert.deepStrictEqual(result, []);
|
|
275
344
|
});
|
|
276
345
|
|
|
277
346
|
test('start > end, step > 0 (empty result)', () => {
|
|
278
347
|
const result = range(5, 1, 1);
|
|
279
|
-
|
|
348
|
+
|
|
349
|
+
assert.deepStrictEqual(result, []);
|
|
280
350
|
});
|
|
281
351
|
|
|
282
352
|
test('unknown start/end/step', () => {
|
|
@@ -289,7 +359,12 @@ describe('Arr creations', () => {
|
|
|
289
359
|
asNonZeroSafeInt(step),
|
|
290
360
|
);
|
|
291
361
|
expectType<typeof result, readonly SafeInt[]>('=');
|
|
292
|
-
|
|
362
|
+
|
|
363
|
+
assert.deepStrictEqual(result, [
|
|
364
|
+
asSafeInt(1),
|
|
365
|
+
asSafeInt(2),
|
|
366
|
+
asSafeInt(3),
|
|
367
|
+
]);
|
|
293
368
|
});
|
|
294
369
|
|
|
295
370
|
test('range(1, 3)', () => {
|
|
@@ -297,7 +372,7 @@ describe('Arr creations', () => {
|
|
|
297
372
|
|
|
298
373
|
expectType<typeof result, readonly [1, 2]>('=');
|
|
299
374
|
|
|
300
|
-
|
|
375
|
+
assert.deepStrictEqual(result, [1, 2]);
|
|
301
376
|
});
|
|
302
377
|
|
|
303
378
|
test('range(1, 3, 1)', () => {
|
|
@@ -305,7 +380,7 @@ describe('Arr creations', () => {
|
|
|
305
380
|
|
|
306
381
|
expectType<typeof result, readonly [1, 2]>('=');
|
|
307
382
|
|
|
308
|
-
|
|
383
|
+
assert.deepStrictEqual(result, [1, 2]);
|
|
309
384
|
});
|
|
310
385
|
|
|
311
386
|
test('range(0, 0)', () => {
|
|
@@ -313,7 +388,7 @@ describe('Arr creations', () => {
|
|
|
313
388
|
|
|
314
389
|
expectType<typeof result, readonly []>('=');
|
|
315
390
|
|
|
316
|
-
|
|
391
|
+
assert.deepStrictEqual(result, []);
|
|
317
392
|
});
|
|
318
393
|
|
|
319
394
|
test('range(0, 1)', () => {
|
|
@@ -321,7 +396,7 @@ describe('Arr creations', () => {
|
|
|
321
396
|
|
|
322
397
|
expectType<typeof result, readonly [0]>('=');
|
|
323
398
|
|
|
324
|
-
|
|
399
|
+
assert.deepStrictEqual(result, [asSafeUint(0)]);
|
|
325
400
|
});
|
|
326
401
|
|
|
327
402
|
test('range(0, -1)', () => {
|
|
@@ -329,7 +404,7 @@ describe('Arr creations', () => {
|
|
|
329
404
|
|
|
330
405
|
expectType<typeof result, readonly SafeInt[]>('=');
|
|
331
406
|
|
|
332
|
-
|
|
407
|
+
assert.deepStrictEqual(result, []);
|
|
333
408
|
});
|
|
334
409
|
|
|
335
410
|
test('range(SmallUint, SmallUint)', () => {
|
|
@@ -380,7 +455,7 @@ describe('Arr creations', () => {
|
|
|
380
455
|
)[]
|
|
381
456
|
>('=');
|
|
382
457
|
|
|
383
|
-
|
|
458
|
+
assert.deepStrictEqual(result, [asSafeUint(0)]);
|
|
384
459
|
});
|
|
385
460
|
|
|
386
461
|
test('range(0 | 1 | 2, 1 | 2 | 3)', () => {
|
|
@@ -388,7 +463,7 @@ describe('Arr creations', () => {
|
|
|
388
463
|
|
|
389
464
|
expectType<typeof result, readonly (0 | 1 | 2)[]>('=');
|
|
390
465
|
|
|
391
|
-
|
|
466
|
+
assert.deepStrictEqual(result, [0]);
|
|
392
467
|
});
|
|
393
468
|
|
|
394
469
|
test('range(2|3, 5|6|7)', () => {
|
|
@@ -396,7 +471,7 @@ describe('Arr creations', () => {
|
|
|
396
471
|
|
|
397
472
|
expectType<typeof result, readonly (2 | 3 | 4 | 5 | 6)[]>('=');
|
|
398
473
|
|
|
399
|
-
|
|
474
|
+
assert.deepStrictEqual(result, [2, 3, 4]);
|
|
400
475
|
});
|
|
401
476
|
|
|
402
477
|
test('range(0, 10, 2)', () => {
|
|
@@ -404,7 +479,13 @@ describe('Arr creations', () => {
|
|
|
404
479
|
|
|
405
480
|
expectType<typeof result, readonly SafeUint[]>('=');
|
|
406
481
|
|
|
407
|
-
|
|
482
|
+
assert.deepStrictEqual(result, [
|
|
483
|
+
asSafeUint(0),
|
|
484
|
+
asSafeUint(2),
|
|
485
|
+
asSafeUint(4),
|
|
486
|
+
asSafeUint(6),
|
|
487
|
+
asSafeUint(8),
|
|
488
|
+
]);
|
|
408
489
|
});
|
|
409
490
|
|
|
410
491
|
test('range(0, 11, 2)', () => {
|
|
@@ -412,7 +493,14 @@ describe('Arr creations', () => {
|
|
|
412
493
|
|
|
413
494
|
expectType<typeof result, readonly SafeUint[]>('=');
|
|
414
495
|
|
|
415
|
-
|
|
496
|
+
assert.deepStrictEqual(result, [
|
|
497
|
+
asSafeUint(0),
|
|
498
|
+
asSafeUint(2),
|
|
499
|
+
asSafeUint(4),
|
|
500
|
+
asSafeUint(6),
|
|
501
|
+
asSafeUint(8),
|
|
502
|
+
asSafeUint(10),
|
|
503
|
+
]);
|
|
416
504
|
});
|
|
417
505
|
|
|
418
506
|
test('range(1, 12, 2)', () => {
|
|
@@ -420,7 +508,14 @@ describe('Arr creations', () => {
|
|
|
420
508
|
|
|
421
509
|
expectType<typeof result, readonly SafeUint[]>('=');
|
|
422
510
|
|
|
423
|
-
|
|
511
|
+
assert.deepStrictEqual(result, [
|
|
512
|
+
asSafeUint(1),
|
|
513
|
+
asSafeUint(3),
|
|
514
|
+
asSafeUint(5),
|
|
515
|
+
asSafeUint(7),
|
|
516
|
+
asSafeUint(9),
|
|
517
|
+
asSafeUint(11),
|
|
518
|
+
]);
|
|
424
519
|
});
|
|
425
520
|
|
|
426
521
|
// Note: These tests were removed as the range function doesn't return Result type
|
|
@@ -428,22 +523,31 @@ describe('Arr creations', () => {
|
|
|
428
523
|
|
|
429
524
|
test('should handle range with step larger than difference', () => {
|
|
430
525
|
const result = range(0, 5, 10);
|
|
431
|
-
|
|
526
|
+
|
|
527
|
+
assert.deepStrictEqual(result, [asSafeUint(0)]);
|
|
432
528
|
});
|
|
433
529
|
|
|
434
530
|
test('should handle negative step with increasing range', () => {
|
|
435
531
|
const result = range(0, 5, -1);
|
|
436
|
-
|
|
532
|
+
|
|
533
|
+
assert.deepStrictEqual(result, []); // Should be empty when step direction conflicts
|
|
437
534
|
});
|
|
438
535
|
|
|
439
536
|
test('should work with basic range functionality', () => {
|
|
440
537
|
// Test basic range functionality without currying assumptions
|
|
441
538
|
const result = range(0, 5, 1);
|
|
442
|
-
|
|
539
|
+
|
|
540
|
+
assert.deepStrictEqual(result, [
|
|
541
|
+
asSafeUint(0),
|
|
542
|
+
asSafeUint(1),
|
|
543
|
+
asSafeUint(2),
|
|
544
|
+
asSafeUint(3),
|
|
545
|
+
asSafeUint(4),
|
|
546
|
+
]);
|
|
443
547
|
});
|
|
444
548
|
});
|
|
445
549
|
|
|
446
|
-
describe(
|
|
550
|
+
describe(generate, () => {
|
|
447
551
|
test('basic generator usage', () => {
|
|
448
552
|
const result = generate<number>(function* () {
|
|
449
553
|
yield 1;
|
|
@@ -452,7 +556,8 @@ describe('Arr creations', () => {
|
|
|
452
556
|
});
|
|
453
557
|
|
|
454
558
|
expectType<typeof result, readonly number[]>('=');
|
|
455
|
-
|
|
559
|
+
|
|
560
|
+
assert.deepStrictEqual(result, [1, 2, 3]);
|
|
456
561
|
});
|
|
457
562
|
|
|
458
563
|
test('generator with yield*', () => {
|
|
@@ -463,7 +568,8 @@ describe('Arr creations', () => {
|
|
|
463
568
|
});
|
|
464
569
|
|
|
465
570
|
expectType<typeof result, readonly number[]>('=');
|
|
466
|
-
|
|
571
|
+
|
|
572
|
+
assert.deepStrictEqual(result, [1, 2, 3, 4]);
|
|
467
573
|
});
|
|
468
574
|
|
|
469
575
|
test('empty generator', () => {
|
|
@@ -472,7 +578,8 @@ describe('Arr creations', () => {
|
|
|
472
578
|
});
|
|
473
579
|
|
|
474
580
|
expectType<typeof result, readonly string[]>('=');
|
|
475
|
-
|
|
581
|
+
|
|
582
|
+
assert.deepStrictEqual(result, []);
|
|
476
583
|
});
|
|
477
584
|
|
|
478
585
|
test('generator with conditional logic', () => {
|
|
@@ -486,7 +593,8 @@ describe('Arr creations', () => {
|
|
|
486
593
|
});
|
|
487
594
|
|
|
488
595
|
expectType<typeof result, readonly number[]>('=');
|
|
489
|
-
|
|
596
|
+
|
|
597
|
+
assert.deepStrictEqual(result, [1, 2, 3]);
|
|
490
598
|
});
|
|
491
599
|
|
|
492
600
|
test('generator with early return', () => {
|
|
@@ -500,7 +608,8 @@ describe('Arr creations', () => {
|
|
|
500
608
|
});
|
|
501
609
|
|
|
502
610
|
expectType<typeof result, readonly number[]>('=');
|
|
503
|
-
|
|
611
|
+
|
|
612
|
+
assert.deepStrictEqual(result, [1]);
|
|
504
613
|
});
|
|
505
614
|
|
|
506
615
|
test('generator with complex data types', () => {
|
|
@@ -510,7 +619,8 @@ describe('Arr creations', () => {
|
|
|
510
619
|
});
|
|
511
620
|
|
|
512
621
|
expectType<typeof result, readonly { id: number; name: string }[]>('=');
|
|
513
|
-
|
|
622
|
+
|
|
623
|
+
assert.deepStrictEqual(result, [
|
|
514
624
|
{ id: 1, name: 'Alice' },
|
|
515
625
|
{ id: 2, name: 'Bob' },
|
|
516
626
|
]);
|
|
@@ -524,7 +634,8 @@ describe('Arr creations', () => {
|
|
|
524
634
|
});
|
|
525
635
|
|
|
526
636
|
expectType<typeof result, readonly (string | number)[]>('=');
|
|
527
|
-
|
|
637
|
+
|
|
638
|
+
assert.deepStrictEqual(result, ['hello', 42, 'world']);
|
|
528
639
|
});
|
|
529
640
|
|
|
530
641
|
test('generator with loops', () => {
|
|
@@ -535,11 +646,12 @@ describe('Arr creations', () => {
|
|
|
535
646
|
});
|
|
536
647
|
|
|
537
648
|
expectType<typeof result, readonly number[]>('=');
|
|
538
|
-
|
|
649
|
+
|
|
650
|
+
assert.deepStrictEqual(result, [0, 1, 2]);
|
|
539
651
|
});
|
|
540
652
|
});
|
|
541
653
|
|
|
542
|
-
describe(
|
|
654
|
+
describe(generateAsync, () => {
|
|
543
655
|
test('should generate array from async generator', async () => {
|
|
544
656
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
545
657
|
const result = await generateAsync<number>(async function* () {
|
|
@@ -549,7 +661,8 @@ describe('Arr creations', () => {
|
|
|
549
661
|
});
|
|
550
662
|
|
|
551
663
|
expectType<typeof result, readonly number[]>('=');
|
|
552
|
-
|
|
664
|
+
|
|
665
|
+
assert.deepStrictEqual(result, [1, 2, 3]);
|
|
553
666
|
});
|
|
554
667
|
|
|
555
668
|
test('should handle async operations in generator', async () => {
|
|
@@ -562,7 +675,7 @@ describe('Arr creations', () => {
|
|
|
562
675
|
yield 'c';
|
|
563
676
|
});
|
|
564
677
|
|
|
565
|
-
|
|
678
|
+
assert.deepStrictEqual(result, ['a', 'b', 'c']);
|
|
566
679
|
});
|
|
567
680
|
|
|
568
681
|
test('should generate empty array from empty async generator', async () => {
|
|
@@ -570,7 +683,7 @@ describe('Arr creations', () => {
|
|
|
570
683
|
// Empty generator
|
|
571
684
|
});
|
|
572
685
|
|
|
573
|
-
|
|
686
|
+
assert.deepStrictEqual(result, []);
|
|
574
687
|
});
|
|
575
688
|
|
|
576
689
|
test('should handle async generator with delays', async () => {
|
|
@@ -583,7 +696,7 @@ describe('Arr creations', () => {
|
|
|
583
696
|
}
|
|
584
697
|
});
|
|
585
698
|
|
|
586
|
-
|
|
699
|
+
assert.deepStrictEqual(result, [0, 1, 2]);
|
|
587
700
|
});
|
|
588
701
|
});
|
|
589
702
|
});
|