ts-data-forge 5.1.0 → 6.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/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/is-record.d.mts.map +1 -1
- package/dist/guard/is-record.mjs +1 -1
- package/dist/guard/is-record.mjs.map +1 -1
- 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.mts +1 -2
- package/src/guard/is-record.test.mts +57 -67
- 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
|
@@ -40,18 +40,18 @@ export type Stack<T> = Readonly<{
|
|
|
40
40
|
* ```ts
|
|
41
41
|
* const stack = createStack<string>();
|
|
42
42
|
*
|
|
43
|
-
* assert.
|
|
43
|
+
* assert.isTrue(stack.isEmpty);
|
|
44
44
|
*
|
|
45
|
-
* assert(stack.size === 0);
|
|
45
|
+
* assert.isTrue(stack.size === 0);
|
|
46
46
|
*
|
|
47
47
|
* stack.push('first');
|
|
48
48
|
*
|
|
49
49
|
* // eslint-disable-next-line unicorn/prefer-single-call
|
|
50
50
|
* stack.push('second');
|
|
51
51
|
*
|
|
52
|
-
* assert.
|
|
52
|
+
* assert.isFalse(stack.isEmpty);
|
|
53
53
|
*
|
|
54
|
-
* assert(stack.size === 2);
|
|
54
|
+
* assert.isTrue(stack.size === 2);
|
|
55
55
|
*
|
|
56
56
|
* assert.deepStrictEqual(stack.pop(), Optional.some('second'));
|
|
57
57
|
*
|
|
@@ -61,7 +61,7 @@ export type Stack<T> = Readonly<{
|
|
|
61
61
|
*
|
|
62
62
|
* const seededStack = createStack([10, 20, 30]);
|
|
63
63
|
*
|
|
64
|
-
* assert(seededStack.size === 3);
|
|
64
|
+
* assert.isTrue(seededStack.size === 3);
|
|
65
65
|
*
|
|
66
66
|
* assert.deepStrictEqual(seededStack.pop(), Optional.some(30));
|
|
67
67
|
* ```
|
|
@@ -75,18 +75,18 @@ export type Stack<T> = Readonly<{
|
|
|
75
75
|
* ```ts
|
|
76
76
|
* const stack = createStack<string>();
|
|
77
77
|
*
|
|
78
|
-
* assert.
|
|
78
|
+
* assert.isTrue(stack.isEmpty);
|
|
79
79
|
*
|
|
80
|
-
* assert(stack.size === 0);
|
|
80
|
+
* assert.isTrue(stack.size === 0);
|
|
81
81
|
*
|
|
82
82
|
* stack.push('first');
|
|
83
83
|
*
|
|
84
84
|
* // eslint-disable-next-line unicorn/prefer-single-call
|
|
85
85
|
* stack.push('second');
|
|
86
86
|
*
|
|
87
|
-
* assert.
|
|
87
|
+
* assert.isFalse(stack.isEmpty);
|
|
88
88
|
*
|
|
89
|
-
* assert(stack.size === 2);
|
|
89
|
+
* assert.isTrue(stack.size === 2);
|
|
90
90
|
*
|
|
91
91
|
* assert.deepStrictEqual(stack.pop(), Optional.some('second'));
|
|
92
92
|
*
|
|
@@ -96,7 +96,7 @@ export type Stack<T> = Readonly<{
|
|
|
96
96
|
*
|
|
97
97
|
* const seededStack = createStack([10, 20, 30]);
|
|
98
98
|
*
|
|
99
|
-
* assert(seededStack.size === 3);
|
|
99
|
+
* assert.isTrue(seededStack.size === 3);
|
|
100
100
|
*
|
|
101
101
|
* assert.deepStrictEqual(seededStack.pop(), Optional.some(30));
|
|
102
102
|
* ```
|
|
@@ -110,18 +110,18 @@ export type Stack<T> = Readonly<{
|
|
|
110
110
|
* ```ts
|
|
111
111
|
* const stack = createStack<string>();
|
|
112
112
|
*
|
|
113
|
-
* assert.
|
|
113
|
+
* assert.isTrue(stack.isEmpty);
|
|
114
114
|
*
|
|
115
|
-
* assert(stack.size === 0);
|
|
115
|
+
* assert.isTrue(stack.size === 0);
|
|
116
116
|
*
|
|
117
117
|
* stack.push('first');
|
|
118
118
|
*
|
|
119
119
|
* // eslint-disable-next-line unicorn/prefer-single-call
|
|
120
120
|
* stack.push('second');
|
|
121
121
|
*
|
|
122
|
-
* assert.
|
|
122
|
+
* assert.isFalse(stack.isEmpty);
|
|
123
123
|
*
|
|
124
|
-
* assert(stack.size === 2);
|
|
124
|
+
* assert.isTrue(stack.size === 2);
|
|
125
125
|
*
|
|
126
126
|
* assert.deepStrictEqual(stack.pop(), Optional.some('second'));
|
|
127
127
|
*
|
|
@@ -131,7 +131,7 @@ export type Stack<T> = Readonly<{
|
|
|
131
131
|
*
|
|
132
132
|
* const seededStack = createStack([10, 20, 30]);
|
|
133
133
|
*
|
|
134
|
-
* assert(seededStack.size === 3);
|
|
134
|
+
* assert.isTrue(seededStack.size === 3);
|
|
135
135
|
*
|
|
136
136
|
* assert.deepStrictEqual(seededStack.pop(), Optional.some(30));
|
|
137
137
|
* ```
|
|
@@ -148,18 +148,18 @@ export type Stack<T> = Readonly<{
|
|
|
148
148
|
* ```ts
|
|
149
149
|
* const stack = createStack<string>();
|
|
150
150
|
*
|
|
151
|
-
* assert.
|
|
151
|
+
* assert.isTrue(stack.isEmpty);
|
|
152
152
|
*
|
|
153
|
-
* assert(stack.size === 0);
|
|
153
|
+
* assert.isTrue(stack.size === 0);
|
|
154
154
|
*
|
|
155
155
|
* stack.push('first');
|
|
156
156
|
*
|
|
157
157
|
* // eslint-disable-next-line unicorn/prefer-single-call
|
|
158
158
|
* stack.push('second');
|
|
159
159
|
*
|
|
160
|
-
* assert.
|
|
160
|
+
* assert.isFalse(stack.isEmpty);
|
|
161
161
|
*
|
|
162
|
-
* assert(stack.size === 2);
|
|
162
|
+
* assert.isTrue(stack.size === 2);
|
|
163
163
|
*
|
|
164
164
|
* assert.deepStrictEqual(stack.pop(), Optional.some('second'));
|
|
165
165
|
*
|
|
@@ -169,7 +169,7 @@ export type Stack<T> = Readonly<{
|
|
|
169
169
|
*
|
|
170
170
|
* const seededStack = createStack([10, 20, 30]);
|
|
171
171
|
*
|
|
172
|
-
* assert(seededStack.size === 3);
|
|
172
|
+
* assert.isTrue(seededStack.size === 3);
|
|
173
173
|
*
|
|
174
174
|
* assert.deepStrictEqual(seededStack.pop(), Optional.some(30));
|
|
175
175
|
* ```
|
|
@@ -207,18 +207,18 @@ export type Stack<T> = Readonly<{
|
|
|
207
207
|
* ```ts
|
|
208
208
|
* const stack = createStack<string>();
|
|
209
209
|
*
|
|
210
|
-
* assert.
|
|
210
|
+
* assert.isTrue(stack.isEmpty);
|
|
211
211
|
*
|
|
212
|
-
* assert(stack.size === 0);
|
|
212
|
+
* assert.isTrue(stack.size === 0);
|
|
213
213
|
*
|
|
214
214
|
* stack.push('first');
|
|
215
215
|
*
|
|
216
216
|
* // eslint-disable-next-line unicorn/prefer-single-call
|
|
217
217
|
* stack.push('second');
|
|
218
218
|
*
|
|
219
|
-
* assert.
|
|
219
|
+
* assert.isFalse(stack.isEmpty);
|
|
220
220
|
*
|
|
221
|
-
* assert(stack.size === 2);
|
|
221
|
+
* assert.isTrue(stack.size === 2);
|
|
222
222
|
*
|
|
223
223
|
* assert.deepStrictEqual(stack.pop(), Optional.some('second'));
|
|
224
224
|
*
|
|
@@ -228,7 +228,7 @@ export type Stack<T> = Readonly<{
|
|
|
228
228
|
*
|
|
229
229
|
* const seededStack = createStack([10, 20, 30]);
|
|
230
230
|
*
|
|
231
|
-
* assert(seededStack.size === 3);
|
|
231
|
+
* assert.isTrue(seededStack.size === 3);
|
|
232
232
|
*
|
|
233
233
|
* assert.deepStrictEqual(seededStack.pop(), Optional.some(30));
|
|
234
234
|
* ```
|
|
@@ -171,18 +171,18 @@ class StackClass {
|
|
|
171
171
|
* ```ts
|
|
172
172
|
* const stack = createStack<string>();
|
|
173
173
|
*
|
|
174
|
-
* assert.
|
|
174
|
+
* assert.isTrue(stack.isEmpty);
|
|
175
175
|
*
|
|
176
|
-
* assert(stack.size === 0);
|
|
176
|
+
* assert.isTrue(stack.size === 0);
|
|
177
177
|
*
|
|
178
178
|
* stack.push('first');
|
|
179
179
|
*
|
|
180
180
|
* // eslint-disable-next-line unicorn/prefer-single-call
|
|
181
181
|
* stack.push('second');
|
|
182
182
|
*
|
|
183
|
-
* assert.
|
|
183
|
+
* assert.isFalse(stack.isEmpty);
|
|
184
184
|
*
|
|
185
|
-
* assert(stack.size === 2);
|
|
185
|
+
* assert.isTrue(stack.size === 2);
|
|
186
186
|
*
|
|
187
187
|
* assert.deepStrictEqual(stack.pop(), Optional.some('second'));
|
|
188
188
|
*
|
|
@@ -192,7 +192,7 @@ class StackClass {
|
|
|
192
192
|
*
|
|
193
193
|
* const seededStack = createStack([10, 20, 30]);
|
|
194
194
|
*
|
|
195
|
-
* assert(seededStack.size === 3);
|
|
195
|
+
* assert.isTrue(seededStack.size === 3);
|
|
196
196
|
*
|
|
197
197
|
* assert.deepStrictEqual(seededStack.pop(), Optional.some(30));
|
|
198
198
|
* ```
|
|
@@ -8,13 +8,13 @@ import { type Unwrap } from './types.mjs';
|
|
|
8
8
|
* ```ts
|
|
9
9
|
* const optionalValue = Optional.some('data');
|
|
10
10
|
*
|
|
11
|
-
* assert(Optional.expectToBe(optionalValue, 'value expected') === 'data');
|
|
11
|
+
* assert.isTrue(Optional.expectToBe(optionalValue, 'value expected') === 'data');
|
|
12
12
|
*
|
|
13
13
|
* const expectValue = Optional.expectToBe<string>('missing optional');
|
|
14
14
|
*
|
|
15
15
|
* assert.throws(() => expectValue(Optional.none), /missing optional/u);
|
|
16
16
|
*
|
|
17
|
-
* assert(expectValue(Optional.some('present')) === 'present');
|
|
17
|
+
* assert.isTrue(expectValue(Optional.some('present')) === 'present');
|
|
18
18
|
* ```
|
|
19
19
|
*
|
|
20
20
|
* @template O The `UnknownOptional` type to unwrap.
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
*
|
|
9
9
|
* const notOptional = { $$tag: 'ts-data-forge::Optional.some' };
|
|
10
10
|
*
|
|
11
|
-
* assert.
|
|
11
|
+
* assert.isTrue(Optional.isOptional(maybeOptional));
|
|
12
12
|
*
|
|
13
|
-
* assert.
|
|
13
|
+
* assert.isFalse(Optional.isOptional(notOptional));
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
16
|
* @param maybeOptional The value to check.
|
|
@@ -11,9 +11,9 @@ import { SomeTypeTagName, NoneTypeTagName } from './tag.mjs';
|
|
|
11
11
|
*
|
|
12
12
|
* const notOptional = { $$tag: 'ts-data-forge::Optional.some' };
|
|
13
13
|
*
|
|
14
|
-
* assert.
|
|
14
|
+
* assert.isTrue(Optional.isOptional(maybeOptional));
|
|
15
15
|
*
|
|
16
|
-
* assert.
|
|
16
|
+
* assert.isFalse(Optional.isOptional(notOptional));
|
|
17
17
|
* ```
|
|
18
18
|
*
|
|
19
19
|
* @param maybeOptional The value to check.
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
*
|
|
10
10
|
* const noneValue = Optional.none;
|
|
11
11
|
*
|
|
12
|
-
* assert.
|
|
12
|
+
* assert.isTrue(Optional.isSome(someValue));
|
|
13
13
|
*
|
|
14
|
-
* assert.
|
|
14
|
+
* assert.isTrue(Optional.isNone(noneValue));
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
export declare const none: None;
|
|
@@ -11,9 +11,9 @@ import { NoneTypeTagName } from './tag.mjs';
|
|
|
11
11
|
*
|
|
12
12
|
* const noneValue = Optional.none;
|
|
13
13
|
*
|
|
14
|
-
* assert.
|
|
14
|
+
* assert.isTrue(Optional.isSome(someValue));
|
|
15
15
|
*
|
|
16
|
-
* assert.
|
|
16
|
+
* assert.isTrue(Optional.isNone(noneValue));
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
const none = { $$tag: NoneTypeTagName };
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
*
|
|
9
9
|
* const noneValue = Optional.none;
|
|
10
10
|
*
|
|
11
|
-
* assert.
|
|
11
|
+
* assert.isTrue(Optional.isSome(someValue));
|
|
12
12
|
*
|
|
13
|
-
* assert.
|
|
13
|
+
* assert.isTrue(Optional.isNone(noneValue));
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
16
|
* @template S The type of the value.
|
|
@@ -10,9 +10,9 @@ import { SomeTypeTagName } from './tag.mjs';
|
|
|
10
10
|
*
|
|
11
11
|
* const noneValue = Optional.none;
|
|
12
12
|
*
|
|
13
|
-
* assert.
|
|
13
|
+
* assert.isTrue(Optional.isSome(someValue));
|
|
14
14
|
*
|
|
15
|
-
* assert.
|
|
15
|
+
* assert.isTrue(Optional.isNone(noneValue));
|
|
16
16
|
* ```
|
|
17
17
|
*
|
|
18
18
|
* @template S The type of the value.
|
|
@@ -16,9 +16,9 @@ import { type Unwrap } from './types.mjs';
|
|
|
16
16
|
*
|
|
17
17
|
* const noneNumber = Optional.none as Optional<number>;
|
|
18
18
|
*
|
|
19
|
-
* assert(Optional.toNullable(someNumber) === 42);
|
|
19
|
+
* assert.isTrue(Optional.toNullable(someNumber) === 42);
|
|
20
20
|
*
|
|
21
|
-
* assert(Optional.toNullable(noneNumber) === undefined);
|
|
21
|
+
* assert.isTrue(Optional.toNullable(noneNumber) === undefined);
|
|
22
22
|
* ```
|
|
23
23
|
*
|
|
24
24
|
* @template O The `UnknownOptional` type to convert.
|
|
@@ -18,9 +18,9 @@ import { unwrap } from './optional-unwrap.mjs';
|
|
|
18
18
|
*
|
|
19
19
|
* const noneNumber = Optional.none as Optional<number>;
|
|
20
20
|
*
|
|
21
|
-
* assert(Optional.toNullable(someNumber) === 42);
|
|
21
|
+
* assert.isTrue(Optional.toNullable(someNumber) === 42);
|
|
22
22
|
*
|
|
23
|
-
* assert(Optional.toNullable(noneNumber) === undefined);
|
|
23
|
+
* assert.isTrue(Optional.toNullable(noneNumber) === undefined);
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
26
26
|
* @template O The `UnknownOptional` type to convert.
|
|
@@ -14,15 +14,15 @@ import { type Unwrap } from './types.mjs';
|
|
|
14
14
|
*
|
|
15
15
|
* const withoutValue = Optional.none as Optional<number>;
|
|
16
16
|
*
|
|
17
|
-
* assert(Optional.unwrapOr(withValue, 0) === 5);
|
|
17
|
+
* assert.isTrue(Optional.unwrapOr(withValue, 0) === 5);
|
|
18
18
|
*
|
|
19
|
-
* assert(Optional.unwrapOr(withoutValue, 0) === 0);
|
|
19
|
+
* assert.isTrue(Optional.unwrapOr(withoutValue, 0) === 0);
|
|
20
20
|
*
|
|
21
21
|
* const unwrapWithDefault = Optional.unwrapOr(10);
|
|
22
22
|
*
|
|
23
|
-
* assert(unwrapWithDefault(Optional.some(3)) === 3);
|
|
23
|
+
* assert.isTrue(unwrapWithDefault(Optional.some(3)) === 3);
|
|
24
24
|
*
|
|
25
|
-
* assert(unwrapWithDefault(Optional.none) === 10);
|
|
25
|
+
* assert.isTrue(unwrapWithDefault(Optional.none) === 10);
|
|
26
26
|
* ```
|
|
27
27
|
*
|
|
28
28
|
* @template O The `UnknownOptional` type to unwrap.
|
|
@@ -12,7 +12,7 @@ import { type Unwrap } from './types.mjs';
|
|
|
12
12
|
* ```ts
|
|
13
13
|
* const present = Optional.some('available');
|
|
14
14
|
*
|
|
15
|
-
* assert(Optional.unwrapThrow(present) === 'available');
|
|
15
|
+
* assert.isTrue(Optional.unwrapThrow(present) === 'available');
|
|
16
16
|
*
|
|
17
17
|
* assert.throws(
|
|
18
18
|
* () => Optional.unwrapThrow(Optional.none),
|
|
@@ -13,7 +13,7 @@ import { isSome } from './optional-is-some.mjs';
|
|
|
13
13
|
* ```ts
|
|
14
14
|
* const present = Optional.some('available');
|
|
15
15
|
*
|
|
16
|
-
* assert(Optional.unwrapThrow(present) === 'available');
|
|
16
|
+
* assert.isTrue(Optional.unwrapThrow(present) === 'available');
|
|
17
17
|
*
|
|
18
18
|
* assert.throws(
|
|
19
19
|
* () => Optional.unwrapThrow(Optional.none),
|
|
@@ -16,9 +16,9 @@ import { type Unwrap } from './types.mjs';
|
|
|
16
16
|
*
|
|
17
17
|
* const noneString = Optional.none as Optional<string>;
|
|
18
18
|
*
|
|
19
|
-
* assert(Optional.unwrap(someString) === 'text');
|
|
19
|
+
* assert.isTrue(Optional.unwrap(someString) === 'text');
|
|
20
20
|
*
|
|
21
|
-
* assert(Optional.unwrap(noneString) === undefined);
|
|
21
|
+
* assert.isTrue(Optional.unwrap(noneString) === undefined);
|
|
22
22
|
* ```
|
|
23
23
|
*
|
|
24
24
|
* @template O The `UnknownOptional` type to unwrap.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* ```ts
|
|
8
8
|
* const zipped = Optional.zip(Optional.some('left'), Optional.some(1));
|
|
9
9
|
*
|
|
10
|
-
* assert.
|
|
10
|
+
* assert.isTrue(Optional.isSome(zipped));
|
|
11
11
|
*
|
|
12
12
|
* if (Optional.isSome(zipped)) {
|
|
13
13
|
* const expected: readonly [string, number] = ['left', 1];
|
|
@@ -11,7 +11,7 @@ import { some } from './optional-some.mjs';
|
|
|
11
11
|
* ```ts
|
|
12
12
|
* const zipped = Optional.zip(Optional.some('left'), Optional.some(1));
|
|
13
13
|
*
|
|
14
|
-
* assert.
|
|
14
|
+
* assert.isTrue(Optional.isSome(zipped));
|
|
15
15
|
*
|
|
16
16
|
* if (Optional.isSome(zipped)) {
|
|
17
17
|
* const expected: readonly [string, number] = ['left', 1];
|
|
@@ -65,7 +65,7 @@ type PipeBase<A> = Readonly<{
|
|
|
65
65
|
* value.toUpperCase(),
|
|
66
66
|
* );
|
|
67
67
|
*
|
|
68
|
-
* assert(empty.value === undefined);
|
|
68
|
+
* assert.isTrue(empty.value === undefined);
|
|
69
69
|
* ```
|
|
70
70
|
*
|
|
71
71
|
* @template B The type of the transformed value.
|
|
@@ -100,7 +100,7 @@ type PipeWithMapOptional<A extends UnknownOptional> = MergeIntersection<PipeBase
|
|
|
100
100
|
* (value) => value * 2,
|
|
101
101
|
* );
|
|
102
102
|
*
|
|
103
|
-
* assert.
|
|
103
|
+
* assert.isTrue(Optional.isNone(empty.value));
|
|
104
104
|
* ```
|
|
105
105
|
*
|
|
106
106
|
* @template B The type of the transformed inner value.
|
|
@@ -8,13 +8,13 @@ import { type UnwrapOk } from './types.mjs';
|
|
|
8
8
|
* ```ts
|
|
9
9
|
* const okValue = Result.ok('data');
|
|
10
10
|
*
|
|
11
|
-
* assert(Result.expectToBe(okValue, 'should have value') === 'data');
|
|
11
|
+
* assert.isTrue(Result.expectToBe(okValue, 'should have value') === 'data');
|
|
12
12
|
*
|
|
13
13
|
* const expectResult = Result.expectToBe<string>('missing result');
|
|
14
14
|
*
|
|
15
15
|
* assert.throws(() => expectResult(Result.err('boom')), /missing result/u);
|
|
16
16
|
*
|
|
17
|
-
* assert(expectResult(Result.ok('value')) === 'value');
|
|
17
|
+
* assert.isTrue(expectResult(Result.ok('value')) === 'value');
|
|
18
18
|
* ```
|
|
19
19
|
*
|
|
20
20
|
* @template R The `UnknownResult` type to unwrap.
|
|
@@ -23,7 +23,7 @@ type UnwrapPromise<P extends Promise<unknown>> = P extends Promise<infer V> ? V
|
|
|
23
23
|
*
|
|
24
24
|
* assert.deepStrictEqual(resolved, Result.ok('ok'));
|
|
25
25
|
*
|
|
26
|
-
* assert.
|
|
26
|
+
* assert.isTrue(Result.isErr(rejected));
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
29
|
* @template P The type of the input Promise.
|
|
@@ -12,10 +12,10 @@ import { type NarrowToErr } from './types.mjs';
|
|
|
12
12
|
* if (Result.isOk(operation)) {
|
|
13
13
|
* const value: number = operation.value;
|
|
14
14
|
*
|
|
15
|
-
* assert(value === 3);
|
|
15
|
+
* assert.isTrue(value === 3);
|
|
16
16
|
* }
|
|
17
17
|
*
|
|
18
|
-
* assert.
|
|
18
|
+
* assert.isTrue(Result.isErr(failure));
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
export declare const isErr: <R extends UnknownResult>(result: R) => result is NarrowToErr<R>;
|
|
@@ -13,10 +13,10 @@ import { ErrTypeTagName } from './tag.mjs';
|
|
|
13
13
|
* if (Result.isOk(operation)) {
|
|
14
14
|
* const value: number = operation.value;
|
|
15
15
|
*
|
|
16
|
-
* assert(value === 3);
|
|
16
|
+
* assert.isTrue(value === 3);
|
|
17
17
|
* }
|
|
18
18
|
*
|
|
19
|
-
* assert.
|
|
19
|
+
* assert.isTrue(Result.isErr(failure));
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
const isErr = (result) => result.$$tag === ErrTypeTagName;
|
|
@@ -12,10 +12,10 @@ import { type NarrowToOk } from './types.mjs';
|
|
|
12
12
|
* if (Result.isOk(operation)) {
|
|
13
13
|
* const value: number = operation.value;
|
|
14
14
|
*
|
|
15
|
-
* assert(value === 3);
|
|
15
|
+
* assert.isTrue(value === 3);
|
|
16
16
|
* }
|
|
17
17
|
*
|
|
18
|
-
* assert.
|
|
18
|
+
* assert.isTrue(Result.isErr(failure));
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
export declare const isOk: <R extends UnknownResult>(result: R) => result is NarrowToOk<R>;
|
|
@@ -13,10 +13,10 @@ import { OkTypeTagName } from './tag.mjs';
|
|
|
13
13
|
* if (Result.isOk(operation)) {
|
|
14
14
|
* const value: number = operation.value;
|
|
15
15
|
*
|
|
16
|
-
* assert(value === 3);
|
|
16
|
+
* assert.isTrue(value === 3);
|
|
17
17
|
* }
|
|
18
18
|
*
|
|
19
|
-
* assert.
|
|
19
|
+
* assert.isTrue(Result.isErr(failure));
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
const isOk = (result) => result.$$tag === OkTypeTagName;
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
*
|
|
11
11
|
* const notResult = { $$tag: 'ts-data-forge::Result.ok' };
|
|
12
12
|
*
|
|
13
|
-
* assert.
|
|
13
|
+
* assert.isTrue(Result.isResult(okValue));
|
|
14
14
|
*
|
|
15
|
-
* assert.
|
|
15
|
+
* assert.isTrue(Result.isResult(errValue));
|
|
16
16
|
*
|
|
17
|
-
* assert.
|
|
17
|
+
* assert.isFalse(Result.isResult(notResult));
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
export declare const isResult: (maybeResult: unknown) => maybeResult is UnknownResult;
|
|
@@ -14,11 +14,11 @@ import { ErrTypeTagName, OkTypeTagName } from './tag.mjs';
|
|
|
14
14
|
*
|
|
15
15
|
* const notResult = { $$tag: 'ts-data-forge::Result.ok' };
|
|
16
16
|
*
|
|
17
|
-
* assert.
|
|
17
|
+
* assert.isTrue(Result.isResult(okValue));
|
|
18
18
|
*
|
|
19
|
-
* assert.
|
|
19
|
+
* assert.isTrue(Result.isResult(errValue));
|
|
20
20
|
*
|
|
21
|
-
* assert.
|
|
21
|
+
* assert.isFalse(Result.isResult(notResult));
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
const isResult = (maybeResult) => isRecord(maybeResult) &&
|