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
|
@@ -20,19 +20,19 @@ import {
|
|
|
20
20
|
|
|
21
21
|
describe(isUndefined, () => {
|
|
22
22
|
test('should return true for undefined', () => {
|
|
23
|
-
|
|
23
|
+
assert.isTrue(isUndefined(undefined));
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
test('should return false for non-undefined values', () => {
|
|
27
|
-
|
|
27
|
+
assert.isFalse(isUndefined(null));
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
assert.isFalse(isUndefined(0));
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
assert.isFalse(isUndefined(''));
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
assert.isFalse(isUndefined(false));
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
assert.isFalse(isUndefined({}));
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
test('should act as a type guard', () => {
|
|
@@ -46,17 +46,17 @@ describe(isUndefined, () => {
|
|
|
46
46
|
|
|
47
47
|
describe(isNotUndefined, () => {
|
|
48
48
|
test('should return false for undefined', () => {
|
|
49
|
-
|
|
49
|
+
assert.isFalse(isNotUndefined(undefined));
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
test('should return true for non-undefined values', () => {
|
|
53
|
-
|
|
53
|
+
assert.isTrue(isNotUndefined(null));
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
assert.isTrue(isNotUndefined(0));
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
assert.isTrue(isNotUndefined(''));
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
assert.isTrue(isNotUndefined(false));
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
test('should narrow types correctly', () => {
|
|
@@ -70,19 +70,19 @@ describe(isNotUndefined, () => {
|
|
|
70
70
|
|
|
71
71
|
describe(isNull, () => {
|
|
72
72
|
test('should return true for null', () => {
|
|
73
|
-
|
|
73
|
+
assert.isTrue(isNull(null));
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
test('should return false for non-null values', () => {
|
|
77
|
-
|
|
77
|
+
assert.isFalse(isNull(undefined));
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
assert.isFalse(isNull(0));
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
assert.isFalse(isNull(''));
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
assert.isFalse(isNull(false));
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
assert.isFalse(isNull({}));
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
test('should act as a type guard', () => {
|
|
@@ -96,15 +96,15 @@ describe(isNull, () => {
|
|
|
96
96
|
|
|
97
97
|
describe(isNotNull, () => {
|
|
98
98
|
test('should return false for null', () => {
|
|
99
|
-
|
|
99
|
+
assert.isFalse(isNotNull(null));
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
test('should return true for non-null values', () => {
|
|
103
|
-
|
|
103
|
+
assert.isTrue(isNotNull(undefined));
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
assert.isTrue(isNotNull(0));
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
assert.isTrue(isNotNull(''));
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
test('should narrow types correctly', () => {
|
|
@@ -118,26 +118,26 @@ describe(isNotNull, () => {
|
|
|
118
118
|
|
|
119
119
|
describe(isString, () => {
|
|
120
120
|
test('should return true for strings', () => {
|
|
121
|
-
|
|
121
|
+
assert.isTrue(isString(''));
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
assert.isTrue(isString('hello'));
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
assert.isTrue(isString('123'));
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
assert.isTrue(isString(`template`));
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
test('should return false for non-strings', () => {
|
|
131
|
-
|
|
131
|
+
assert.isFalse(isString(123));
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
assert.isFalse(isString(true));
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
assert.isFalse(isString(null));
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
assert.isFalse(isString(undefined));
|
|
138
138
|
|
|
139
139
|
// eslint-disable-next-line unicorn/new-for-builtins
|
|
140
|
-
|
|
140
|
+
assert.isFalse(isString(new String('hello')));
|
|
141
141
|
});
|
|
142
142
|
|
|
143
143
|
test('should act as a type guard', () => {
|
|
@@ -153,30 +153,30 @@ describe(isString, () => {
|
|
|
153
153
|
|
|
154
154
|
describe(isNumber, () => {
|
|
155
155
|
test('should return true for numbers', () => {
|
|
156
|
-
|
|
156
|
+
assert.isTrue(isNumber(0));
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
assert.isTrue(isNumber(42));
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
assert.isTrue(isNumber(-3.14));
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
assert.isTrue(isNumber(Number.NaN));
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
assert.isTrue(isNumber(Number.POSITIVE_INFINITY));
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
assert.isTrue(isNumber(Number.NEGATIVE_INFINITY));
|
|
167
167
|
});
|
|
168
168
|
|
|
169
169
|
test('should return false for non-numbers', () => {
|
|
170
|
-
|
|
170
|
+
assert.isFalse(isNumber('123'));
|
|
171
171
|
|
|
172
|
-
|
|
172
|
+
assert.isFalse(isNumber(true));
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
assert.isFalse(isNumber(null));
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
assert.isFalse(isNumber(123n));
|
|
177
177
|
|
|
178
178
|
// eslint-disable-next-line unicorn/new-for-builtins
|
|
179
|
-
|
|
179
|
+
assert.isFalse(isNumber(new Number(42)));
|
|
180
180
|
});
|
|
181
181
|
|
|
182
182
|
test('should act as a type guard', () => {
|
|
@@ -192,21 +192,21 @@ describe(isNumber, () => {
|
|
|
192
192
|
|
|
193
193
|
describe(isBigint, () => {
|
|
194
194
|
test('should return true for bigints', () => {
|
|
195
|
-
|
|
195
|
+
assert.isTrue(isBigint(0n));
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
assert.isTrue(isBigint(123n));
|
|
198
198
|
|
|
199
|
-
|
|
199
|
+
assert.isTrue(isBigint(-456n));
|
|
200
200
|
});
|
|
201
201
|
|
|
202
202
|
test('should return false for non-bigints', () => {
|
|
203
|
-
|
|
203
|
+
assert.isFalse(isBigint(123));
|
|
204
204
|
|
|
205
|
-
|
|
205
|
+
assert.isFalse(isBigint('123'));
|
|
206
206
|
|
|
207
|
-
|
|
207
|
+
assert.isFalse(isBigint(true));
|
|
208
208
|
|
|
209
|
-
|
|
209
|
+
assert.isFalse(isBigint(null));
|
|
210
210
|
});
|
|
211
211
|
|
|
212
212
|
test('should act as a type guard', () => {
|
|
@@ -222,22 +222,22 @@ describe(isBigint, () => {
|
|
|
222
222
|
|
|
223
223
|
describe(isBoolean, () => {
|
|
224
224
|
test('should return true for booleans', () => {
|
|
225
|
-
|
|
225
|
+
assert.isTrue(isBoolean(true));
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
assert.isTrue(isBoolean(false));
|
|
228
228
|
});
|
|
229
229
|
|
|
230
230
|
test('should return false for non-booleans', () => {
|
|
231
|
-
|
|
231
|
+
assert.isFalse(isBoolean(1));
|
|
232
232
|
|
|
233
|
-
|
|
233
|
+
assert.isFalse(isBoolean(0));
|
|
234
234
|
|
|
235
|
-
|
|
235
|
+
assert.isFalse(isBoolean('true'));
|
|
236
236
|
|
|
237
|
-
|
|
237
|
+
assert.isFalse(isBoolean(null));
|
|
238
238
|
|
|
239
239
|
// eslint-disable-next-line unicorn/new-for-builtins
|
|
240
|
-
|
|
240
|
+
assert.isFalse(isBoolean(new Boolean(true)));
|
|
241
241
|
});
|
|
242
242
|
|
|
243
243
|
test('should act as a type guard', () => {
|
|
@@ -246,26 +246,26 @@ describe(isBoolean, () => {
|
|
|
246
246
|
if (isBoolean(value)) {
|
|
247
247
|
expectType<typeof value, boolean>('=');
|
|
248
248
|
|
|
249
|
-
|
|
249
|
+
assert.isTrue(value);
|
|
250
250
|
}
|
|
251
251
|
});
|
|
252
252
|
});
|
|
253
253
|
|
|
254
254
|
describe(isSymbol, () => {
|
|
255
255
|
test('should return true for symbols', () => {
|
|
256
|
-
|
|
256
|
+
assert.isTrue(isSymbol(Symbol()));
|
|
257
257
|
|
|
258
|
-
|
|
258
|
+
assert.isTrue(isSymbol(Symbol('test')));
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
assert.isTrue(isSymbol(Symbol.iterator));
|
|
261
261
|
});
|
|
262
262
|
|
|
263
263
|
test('should return false for non-symbols', () => {
|
|
264
|
-
|
|
264
|
+
assert.isFalse(isSymbol('symbol'));
|
|
265
265
|
|
|
266
|
-
|
|
266
|
+
assert.isFalse(isSymbol(123));
|
|
267
267
|
|
|
268
|
-
|
|
268
|
+
assert.isFalse(isSymbol(null));
|
|
269
269
|
});
|
|
270
270
|
|
|
271
271
|
test('should act as a type guard', () => {
|
|
@@ -281,27 +281,27 @@ describe(isSymbol, () => {
|
|
|
281
281
|
|
|
282
282
|
describe(isNotBoolean, () => {
|
|
283
283
|
test('should return false for boolean values', () => {
|
|
284
|
-
|
|
284
|
+
assert.isFalse(isNotBoolean(true));
|
|
285
285
|
|
|
286
|
-
|
|
286
|
+
assert.isFalse(isNotBoolean(false));
|
|
287
287
|
});
|
|
288
288
|
|
|
289
289
|
test('should return true for non-boolean values', () => {
|
|
290
|
-
|
|
290
|
+
assert.isTrue(isNotBoolean(0));
|
|
291
291
|
|
|
292
|
-
|
|
292
|
+
assert.isTrue(isNotBoolean(1));
|
|
293
293
|
|
|
294
|
-
|
|
294
|
+
assert.isTrue(isNotBoolean('true'));
|
|
295
295
|
|
|
296
|
-
|
|
296
|
+
assert.isTrue(isNotBoolean('false'));
|
|
297
297
|
|
|
298
|
-
|
|
298
|
+
assert.isTrue(isNotBoolean(null));
|
|
299
299
|
|
|
300
|
-
|
|
300
|
+
assert.isTrue(isNotBoolean(undefined));
|
|
301
301
|
|
|
302
|
-
|
|
302
|
+
assert.isTrue(isNotBoolean({}));
|
|
303
303
|
|
|
304
|
-
|
|
304
|
+
assert.isTrue(isNotBoolean([]));
|
|
305
305
|
});
|
|
306
306
|
|
|
307
307
|
test('should act as a type guard', () => {
|
|
@@ -311,44 +311,44 @@ describe(isNotBoolean, () => {
|
|
|
311
311
|
expectType<typeof value, string | number>('<=');
|
|
312
312
|
|
|
313
313
|
// Should not have boolean methods
|
|
314
|
-
|
|
314
|
+
assert.isTrue(typeof value === 'string' || typeof value === 'number');
|
|
315
315
|
}
|
|
316
316
|
});
|
|
317
317
|
});
|
|
318
318
|
|
|
319
319
|
describe(isNotNumber, () => {
|
|
320
320
|
test('should return false for number values', () => {
|
|
321
|
-
|
|
321
|
+
assert.isFalse(isNotNumber(0));
|
|
322
322
|
|
|
323
|
-
|
|
323
|
+
assert.isFalse(isNotNumber(42));
|
|
324
324
|
|
|
325
|
-
|
|
325
|
+
assert.isFalse(isNotNumber(-3.14));
|
|
326
326
|
|
|
327
|
-
|
|
327
|
+
assert.isFalse(isNotNumber(Number.NaN));
|
|
328
328
|
|
|
329
|
-
|
|
329
|
+
assert.isFalse(isNotNumber(Number.POSITIVE_INFINITY));
|
|
330
330
|
|
|
331
|
-
|
|
331
|
+
assert.isFalse(isNotNumber(Number.NEGATIVE_INFINITY));
|
|
332
332
|
});
|
|
333
333
|
|
|
334
334
|
test('should return true for non-number values', () => {
|
|
335
|
-
|
|
335
|
+
assert.isTrue(isNotNumber('123'));
|
|
336
336
|
|
|
337
|
-
|
|
337
|
+
assert.isTrue(isNotNumber(true));
|
|
338
338
|
|
|
339
|
-
|
|
339
|
+
assert.isTrue(isNotNumber(false));
|
|
340
340
|
|
|
341
|
-
|
|
341
|
+
assert.isTrue(isNotNumber(null));
|
|
342
342
|
|
|
343
|
-
|
|
343
|
+
assert.isTrue(isNotNumber(undefined));
|
|
344
344
|
|
|
345
|
-
|
|
345
|
+
assert.isTrue(isNotNumber(123n));
|
|
346
346
|
|
|
347
|
-
|
|
347
|
+
assert.isTrue(isNotNumber({}));
|
|
348
348
|
|
|
349
|
-
|
|
349
|
+
assert.isTrue(isNotNumber([]));
|
|
350
350
|
|
|
351
|
-
|
|
351
|
+
assert.isTrue(isNotNumber(Symbol('test')));
|
|
352
352
|
});
|
|
353
353
|
|
|
354
354
|
test('should act as a type guard', () => {
|
|
@@ -357,38 +357,36 @@ describe(isNotNumber, () => {
|
|
|
357
357
|
if (isNotNumber(value)) {
|
|
358
358
|
expectType<typeof value, string | boolean>('<=');
|
|
359
359
|
|
|
360
|
-
|
|
361
|
-
true,
|
|
362
|
-
);
|
|
360
|
+
assert.isTrue(typeof value === 'string' || typeof value === 'boolean');
|
|
363
361
|
}
|
|
364
362
|
});
|
|
365
363
|
});
|
|
366
364
|
|
|
367
365
|
describe(isNotBigint, () => {
|
|
368
366
|
test('should return false for bigint values', () => {
|
|
369
|
-
|
|
367
|
+
assert.isFalse(isNotBigint(0n));
|
|
370
368
|
|
|
371
|
-
|
|
369
|
+
assert.isFalse(isNotBigint(123n));
|
|
372
370
|
|
|
373
|
-
|
|
371
|
+
assert.isFalse(isNotBigint(-456n));
|
|
374
372
|
});
|
|
375
373
|
|
|
376
374
|
test('should return true for non-bigint values', () => {
|
|
377
|
-
|
|
375
|
+
assert.isTrue(isNotBigint(123));
|
|
378
376
|
|
|
379
|
-
|
|
377
|
+
assert.isTrue(isNotBigint('123'));
|
|
380
378
|
|
|
381
|
-
|
|
379
|
+
assert.isTrue(isNotBigint(true));
|
|
382
380
|
|
|
383
|
-
|
|
381
|
+
assert.isTrue(isNotBigint(false));
|
|
384
382
|
|
|
385
|
-
|
|
383
|
+
assert.isTrue(isNotBigint(null));
|
|
386
384
|
|
|
387
|
-
|
|
385
|
+
assert.isTrue(isNotBigint(undefined));
|
|
388
386
|
|
|
389
|
-
|
|
387
|
+
assert.isTrue(isNotBigint({}));
|
|
390
388
|
|
|
391
|
-
|
|
389
|
+
assert.isTrue(isNotBigint(Symbol('test')));
|
|
392
390
|
});
|
|
393
391
|
|
|
394
392
|
test('should act as a type guard', () => {
|
|
@@ -404,33 +402,33 @@ describe(isNotBigint, () => {
|
|
|
404
402
|
|
|
405
403
|
describe(isNotString, () => {
|
|
406
404
|
test('should return false for string values', () => {
|
|
407
|
-
|
|
405
|
+
assert.isFalse(isNotString(''));
|
|
408
406
|
|
|
409
|
-
|
|
407
|
+
assert.isFalse(isNotString('hello'));
|
|
410
408
|
|
|
411
|
-
|
|
409
|
+
assert.isFalse(isNotString('123'));
|
|
412
410
|
|
|
413
|
-
|
|
411
|
+
assert.isFalse(isNotString(`template`));
|
|
414
412
|
});
|
|
415
413
|
|
|
416
414
|
test('should return true for non-string values', () => {
|
|
417
|
-
|
|
415
|
+
assert.isTrue(isNotString(123));
|
|
418
416
|
|
|
419
|
-
|
|
417
|
+
assert.isTrue(isNotString(true));
|
|
420
418
|
|
|
421
|
-
|
|
419
|
+
assert.isTrue(isNotString(false));
|
|
422
420
|
|
|
423
|
-
|
|
421
|
+
assert.isTrue(isNotString(null));
|
|
424
422
|
|
|
425
|
-
|
|
423
|
+
assert.isTrue(isNotString(undefined));
|
|
426
424
|
|
|
427
|
-
|
|
425
|
+
assert.isTrue(isNotString({}));
|
|
428
426
|
|
|
429
|
-
|
|
427
|
+
assert.isTrue(isNotString([]));
|
|
430
428
|
|
|
431
|
-
|
|
429
|
+
assert.isTrue(isNotString(Symbol('test')));
|
|
432
430
|
|
|
433
|
-
|
|
431
|
+
assert.isTrue(isNotString(123n));
|
|
434
432
|
});
|
|
435
433
|
|
|
436
434
|
test('should act as a type guard', () => {
|
|
@@ -439,40 +437,38 @@ describe(isNotString, () => {
|
|
|
439
437
|
if (isNotString(value)) {
|
|
440
438
|
expectType<typeof value, number | boolean>('<=');
|
|
441
439
|
|
|
442
|
-
|
|
443
|
-
true,
|
|
444
|
-
);
|
|
440
|
+
assert.isTrue(typeof value === 'number' || typeof value === 'boolean');
|
|
445
441
|
}
|
|
446
442
|
});
|
|
447
443
|
});
|
|
448
444
|
|
|
449
445
|
describe(isNotSymbol, () => {
|
|
450
446
|
test('should return false for symbol values', () => {
|
|
451
|
-
|
|
447
|
+
assert.isFalse(isNotSymbol(Symbol()));
|
|
452
448
|
|
|
453
|
-
|
|
449
|
+
assert.isFalse(isNotSymbol(Symbol('test')));
|
|
454
450
|
|
|
455
|
-
|
|
451
|
+
assert.isFalse(isNotSymbol(Symbol.iterator));
|
|
456
452
|
});
|
|
457
453
|
|
|
458
454
|
test('should return true for non-symbol values', () => {
|
|
459
|
-
|
|
455
|
+
assert.isTrue(isNotSymbol('symbol'));
|
|
460
456
|
|
|
461
|
-
|
|
457
|
+
assert.isTrue(isNotSymbol(123));
|
|
462
458
|
|
|
463
|
-
|
|
459
|
+
assert.isTrue(isNotSymbol(true));
|
|
464
460
|
|
|
465
|
-
|
|
461
|
+
assert.isTrue(isNotSymbol(false));
|
|
466
462
|
|
|
467
|
-
|
|
463
|
+
assert.isTrue(isNotSymbol(null));
|
|
468
464
|
|
|
469
|
-
|
|
465
|
+
assert.isTrue(isNotSymbol(undefined));
|
|
470
466
|
|
|
471
|
-
|
|
467
|
+
assert.isTrue(isNotSymbol({}));
|
|
472
468
|
|
|
473
|
-
|
|
469
|
+
assert.isTrue(isNotSymbol([]));
|
|
474
470
|
|
|
475
|
-
|
|
471
|
+
assert.isTrue(isNotSymbol(123n));
|
|
476
472
|
});
|
|
477
473
|
|
|
478
474
|
test('should act as a type guard', () => {
|
|
@@ -481,34 +477,34 @@ describe(isNotSymbol, () => {
|
|
|
481
477
|
if (isNotSymbol(value)) {
|
|
482
478
|
expectType<typeof value, string | number>('<=');
|
|
483
479
|
|
|
484
|
-
|
|
480
|
+
assert.isTrue(typeof value === 'string' || typeof value === 'number');
|
|
485
481
|
}
|
|
486
482
|
});
|
|
487
483
|
});
|
|
488
484
|
|
|
489
485
|
describe(isNullish, () => {
|
|
490
486
|
test('should return true for null and undefined', () => {
|
|
491
|
-
|
|
487
|
+
assert.isTrue(isNullish(null));
|
|
492
488
|
|
|
493
|
-
|
|
489
|
+
assert.isTrue(isNullish(undefined));
|
|
494
490
|
});
|
|
495
491
|
|
|
496
492
|
test('should return false for non-nullish values', () => {
|
|
497
|
-
|
|
493
|
+
assert.isFalse(isNullish(0));
|
|
498
494
|
|
|
499
|
-
|
|
495
|
+
assert.isFalse(isNullish(false));
|
|
500
496
|
|
|
501
|
-
|
|
497
|
+
assert.isFalse(isNullish(''));
|
|
502
498
|
|
|
503
|
-
|
|
499
|
+
assert.isFalse(isNullish('null'));
|
|
504
500
|
|
|
505
|
-
|
|
501
|
+
assert.isFalse(isNullish('undefined'));
|
|
506
502
|
|
|
507
|
-
|
|
503
|
+
assert.isFalse(isNullish({}));
|
|
508
504
|
|
|
509
|
-
|
|
505
|
+
assert.isFalse(isNullish([]));
|
|
510
506
|
|
|
511
|
-
|
|
507
|
+
assert.isFalse(isNullish(Number.NaN));
|
|
512
508
|
});
|
|
513
509
|
|
|
514
510
|
test('should act as a type guard', () => {
|
|
@@ -524,39 +520,39 @@ describe(isNullish, () => {
|
|
|
524
520
|
|
|
525
521
|
test('should handle edge cases', () => {
|
|
526
522
|
// Test that it uses loose equality (==)
|
|
527
|
-
|
|
523
|
+
assert.isTrue(isNullish(null));
|
|
528
524
|
|
|
529
|
-
|
|
525
|
+
assert.isTrue(isNullish(undefined));
|
|
530
526
|
});
|
|
531
527
|
});
|
|
532
528
|
|
|
533
529
|
describe(isNonNullish, () => {
|
|
534
530
|
test('should return false for null and undefined', () => {
|
|
535
|
-
|
|
531
|
+
assert.isFalse(isNonNullish(null));
|
|
536
532
|
|
|
537
|
-
|
|
533
|
+
assert.isFalse(isNonNullish(undefined));
|
|
538
534
|
});
|
|
539
535
|
|
|
540
536
|
test('should return true for non-nullish values', () => {
|
|
541
|
-
|
|
537
|
+
assert.isTrue(isNonNullish(0));
|
|
542
538
|
|
|
543
|
-
|
|
539
|
+
assert.isTrue(isNonNullish(false));
|
|
544
540
|
|
|
545
|
-
|
|
541
|
+
assert.isTrue(isNonNullish(''));
|
|
546
542
|
|
|
547
|
-
|
|
543
|
+
assert.isTrue(isNonNullish('null'));
|
|
548
544
|
|
|
549
|
-
|
|
545
|
+
assert.isTrue(isNonNullish('undefined'));
|
|
550
546
|
|
|
551
|
-
|
|
547
|
+
assert.isTrue(isNonNullish({}));
|
|
552
548
|
|
|
553
|
-
|
|
549
|
+
assert.isTrue(isNonNullish([]));
|
|
554
550
|
|
|
555
|
-
|
|
551
|
+
assert.isTrue(isNonNullish(Number.NaN));
|
|
556
552
|
|
|
557
|
-
|
|
553
|
+
assert.isTrue(isNonNullish(Symbol('test')));
|
|
558
554
|
|
|
559
|
-
|
|
555
|
+
assert.isTrue(isNonNullish(123n));
|
|
560
556
|
});
|
|
561
557
|
|
|
562
558
|
test('should act as a type guard', () => {
|
package/src/guard/key-is-in.mts
CHANGED
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
* const maybeKey: string = 'name';
|
|
24
24
|
*
|
|
25
25
|
* if (keyIsIn(maybeKey, user)) {
|
|
26
|
-
* assert(user[maybeKey] === 'Ada');
|
|
26
|
+
* assert.isTrue(user[maybeKey] === 'Ada');
|
|
27
27
|
* } else {
|
|
28
|
-
* assert.fail(
|
|
28
|
+
* assert.fail();
|
|
29
29
|
* }
|
|
30
30
|
* ```
|
|
31
31
|
*
|