ts-data-forge 4.1.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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.test.mts +34 -18
- 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
|
@@ -2,13 +2,14 @@ import { expectType } from '../expect-type.mjs';
|
|
|
2
2
|
import { Optional } from './optional/index.mjs';
|
|
3
3
|
import { pipe } from './pipe.mjs';
|
|
4
4
|
|
|
5
|
-
describe(
|
|
5
|
+
describe(pipe, () => {
|
|
6
6
|
test('basic pipe operations', () => {
|
|
7
7
|
const result = pipe(5)
|
|
8
8
|
.map((x) => x * 2)
|
|
9
9
|
.map((x) => x + 1).value;
|
|
10
10
|
|
|
11
11
|
expect(result).toBe(11);
|
|
12
|
+
|
|
12
13
|
expectType<typeof result, number>('=');
|
|
13
14
|
});
|
|
14
15
|
|
|
@@ -18,6 +19,7 @@ describe('pipe', () => {
|
|
|
18
19
|
.map((s) => `${s}!`).value;
|
|
19
20
|
|
|
20
21
|
expect(result).toBe('HELLO!');
|
|
22
|
+
|
|
21
23
|
expectType<typeof result, string>('=');
|
|
22
24
|
});
|
|
23
25
|
|
|
@@ -27,6 +29,7 @@ describe('pipe', () => {
|
|
|
27
29
|
.map((arr) => arr.length).value;
|
|
28
30
|
|
|
29
31
|
expect(result).toBe(3);
|
|
32
|
+
|
|
30
33
|
expectType<typeof result, number>('=');
|
|
31
34
|
});
|
|
32
35
|
|
|
@@ -34,6 +37,7 @@ describe('pipe', () => {
|
|
|
34
37
|
const result = pipe(5 as number | null).mapNullable((x) => x * 2).value;
|
|
35
38
|
|
|
36
39
|
expect(result).toBe(10);
|
|
40
|
+
|
|
37
41
|
expectType<typeof result, number | undefined>('=');
|
|
38
42
|
});
|
|
39
43
|
|
|
@@ -41,6 +45,7 @@ describe('pipe', () => {
|
|
|
41
45
|
const result = pipe(null as number | null).mapNullable((x) => x * 2).value;
|
|
42
46
|
|
|
43
47
|
expect(result).toBeUndefined();
|
|
48
|
+
|
|
44
49
|
expectType<typeof result, number | undefined>('=');
|
|
45
50
|
});
|
|
46
51
|
|
|
@@ -50,6 +55,7 @@ describe('pipe', () => {
|
|
|
50
55
|
).value;
|
|
51
56
|
|
|
52
57
|
expect(result).toBeUndefined();
|
|
58
|
+
|
|
53
59
|
expectType<typeof result, number | undefined>('=');
|
|
54
60
|
});
|
|
55
61
|
|
|
@@ -58,6 +64,7 @@ describe('pipe', () => {
|
|
|
58
64
|
const result = pipe(optional).mapOptional((x) => x * 2).value;
|
|
59
65
|
|
|
60
66
|
expect(Optional.isSome(result)).toBe(true);
|
|
67
|
+
|
|
61
68
|
if (Optional.isSome(result)) {
|
|
62
69
|
expect(result.value).toBe(84);
|
|
63
70
|
}
|
|
@@ -69,6 +76,7 @@ describe('pipe', () => {
|
|
|
69
76
|
const result = pipe(optional).mapOptional((x) => x * 2).value;
|
|
70
77
|
|
|
71
78
|
expect(Optional.isNone(result)).toBe(true);
|
|
79
|
+
|
|
72
80
|
expectType<typeof result, Optional<number>>('=');
|
|
73
81
|
});
|
|
74
82
|
|
|
@@ -80,6 +88,7 @@ describe('pipe', () => {
|
|
|
80
88
|
.map((s) => `${s} items`).value;
|
|
81
89
|
|
|
82
90
|
expect(result).toBe('15 items');
|
|
91
|
+
|
|
83
92
|
expectType<typeof result, string>('=');
|
|
84
93
|
});
|
|
85
94
|
});
|