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
|
@@ -53,27 +53,29 @@ describe('FiniteNumber test', () => {
|
|
|
53
53
|
|
|
54
54
|
describe('FiniteNumber.is', () => {
|
|
55
55
|
test('correctly identifies finite numbers', () => {
|
|
56
|
-
|
|
56
|
+
assert.isTrue(FiniteNumber.is(0));
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
assert.isTrue(FiniteNumber.is(1));
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
assert.isTrue(FiniteNumber.is(-1));
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
assert.isTrue(FiniteNumber.is(3.14));
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
assert.isTrue(FiniteNumber.is(-2.5));
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
assert.isTrue(FiniteNumber.is(-Number.MAX_VALUE));
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
assert.isTrue(FiniteNumber.is(Number.MAX_VALUE));
|
|
69
|
+
|
|
70
|
+
expectType<FiniteNumber, typeof Number.MAX_VALUE>('=');
|
|
69
71
|
});
|
|
70
72
|
|
|
71
73
|
test('correctly identifies non-finite numbers', () => {
|
|
72
|
-
|
|
74
|
+
assert.isFalse(FiniteNumber.is(Number.NaN));
|
|
73
75
|
|
|
74
|
-
|
|
76
|
+
assert.isFalse(FiniteNumber.is(Number.POSITIVE_INFINITY));
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
assert.isFalse(FiniteNumber.is(Number.NEGATIVE_INFINITY));
|
|
77
79
|
});
|
|
78
80
|
});
|
|
79
81
|
|
|
@@ -160,7 +162,7 @@ describe('FiniteNumber test', () => {
|
|
|
160
162
|
|
|
161
163
|
expect(result).toBeLessThanOrEqual(max);
|
|
162
164
|
|
|
163
|
-
|
|
165
|
+
assert.isTrue(FiniteNumber.is(result));
|
|
164
166
|
}
|
|
165
167
|
});
|
|
166
168
|
});
|
|
@@ -38,11 +38,11 @@ const {
|
|
|
38
38
|
* @example
|
|
39
39
|
*
|
|
40
40
|
* ```ts
|
|
41
|
-
* assert.
|
|
41
|
+
* assert.isTrue(isInt(5));
|
|
42
42
|
*
|
|
43
|
-
* assert.
|
|
43
|
+
* assert.isFalse(isInt(5.25));
|
|
44
44
|
*
|
|
45
|
-
* assert.
|
|
45
|
+
* assert.isTrue(Int.is(-10));
|
|
46
46
|
* ```
|
|
47
47
|
*
|
|
48
48
|
* @param value - The value to check
|
|
@@ -62,9 +62,9 @@ export const isInt = is;
|
|
|
62
62
|
* ```ts
|
|
63
63
|
* const branded = asInt(42);
|
|
64
64
|
*
|
|
65
|
-
* assert(branded === 42);
|
|
65
|
+
* assert.isTrue(branded === 42);
|
|
66
66
|
*
|
|
67
|
-
* assert.
|
|
67
|
+
* assert.isTrue(Int.is(branded));
|
|
68
68
|
* ```
|
|
69
69
|
*
|
|
70
70
|
* @param value - The value to cast
|
|
@@ -91,11 +91,11 @@ export const Int = {
|
|
|
91
91
|
* @example
|
|
92
92
|
*
|
|
93
93
|
* ```ts
|
|
94
|
-
* assert.
|
|
94
|
+
* assert.isTrue(isInt(5));
|
|
95
95
|
*
|
|
96
|
-
* assert.
|
|
96
|
+
* assert.isFalse(isInt(5.25));
|
|
97
97
|
*
|
|
98
|
-
* assert.
|
|
98
|
+
* assert.isTrue(Int.is(-10));
|
|
99
99
|
* ```
|
|
100
100
|
*
|
|
101
101
|
* @param value - The value to check
|
|
@@ -118,9 +118,9 @@ export const Int = {
|
|
|
118
118
|
*
|
|
119
119
|
* const absolute = Int.abs(negative);
|
|
120
120
|
*
|
|
121
|
-
* assert(absolute === 12);
|
|
121
|
+
* assert.isTrue(absolute === 12);
|
|
122
122
|
*
|
|
123
|
-
* assert.
|
|
123
|
+
* assert.isTrue(Int.is(absolute));
|
|
124
124
|
* ```
|
|
125
125
|
*
|
|
126
126
|
* @param a - The integer value
|
|
@@ -136,7 +136,7 @@ export const Int = {
|
|
|
136
136
|
* ```ts
|
|
137
137
|
* const smallest = Int.min(asInt(7), asInt(-3), asInt(2));
|
|
138
138
|
*
|
|
139
|
-
* assert(smallest === -3);
|
|
139
|
+
* assert.isTrue(smallest === -3);
|
|
140
140
|
* ```
|
|
141
141
|
*
|
|
142
142
|
* @param values - The integers to compare (at least one required)
|
|
@@ -152,7 +152,7 @@ export const Int = {
|
|
|
152
152
|
* ```ts
|
|
153
153
|
* const largest = Int.max(asInt(7), asInt(-3), asInt(2));
|
|
154
154
|
*
|
|
155
|
-
* assert(largest === 7);
|
|
155
|
+
* assert.isTrue(largest === 7);
|
|
156
156
|
* ```
|
|
157
157
|
*
|
|
158
158
|
* @param values - The integers to compare (at least one required)
|
|
@@ -175,9 +175,9 @@ export const Int = {
|
|
|
175
175
|
*
|
|
176
176
|
* const randomValue = Int.random(min, max);
|
|
177
177
|
*
|
|
178
|
-
* assert.
|
|
178
|
+
* assert.isTrue(Int.is(randomValue));
|
|
179
179
|
*
|
|
180
|
-
* assert.
|
|
180
|
+
* assert.isTrue(randomValue >= 1 && randomValue <= 6);
|
|
181
181
|
* ```
|
|
182
182
|
*
|
|
183
183
|
* @param min - The minimum value (inclusive)
|
|
@@ -198,7 +198,7 @@ export const Int = {
|
|
|
198
198
|
*
|
|
199
199
|
* const power = Int.pow(base, exponent);
|
|
200
200
|
*
|
|
201
|
-
* assert(power === 32);
|
|
201
|
+
* assert.isTrue(power === 32);
|
|
202
202
|
* ```
|
|
203
203
|
*
|
|
204
204
|
* @param a - The base integer
|
|
@@ -215,7 +215,7 @@ export const Int = {
|
|
|
215
215
|
* ```ts
|
|
216
216
|
* const sum = Int.add(asInt(12), asInt(8));
|
|
217
217
|
*
|
|
218
|
-
* assert(sum === 20);
|
|
218
|
+
* assert.isTrue(sum === 20);
|
|
219
219
|
* ```
|
|
220
220
|
*
|
|
221
221
|
* @param a - First integer
|
|
@@ -232,7 +232,7 @@ export const Int = {
|
|
|
232
232
|
* ```ts
|
|
233
233
|
* const difference = Int.sub(asInt(12), asInt(8));
|
|
234
234
|
*
|
|
235
|
-
* assert(difference === 4);
|
|
235
|
+
* assert.isTrue(difference === 4);
|
|
236
236
|
* ```
|
|
237
237
|
*
|
|
238
238
|
* @param a - First integer
|
|
@@ -249,7 +249,7 @@ export const Int = {
|
|
|
249
249
|
* ```ts
|
|
250
250
|
* const product = Int.mul(asInt(-4), asInt(6));
|
|
251
251
|
*
|
|
252
|
-
* assert(product === -24);
|
|
252
|
+
* assert.isTrue(product === -24);
|
|
253
253
|
* ```
|
|
254
254
|
*
|
|
255
255
|
* @param a - First integer
|
|
@@ -273,7 +273,7 @@ export const Int = {
|
|
|
273
273
|
*
|
|
274
274
|
* const quotient = Int.div(dividend, divisor);
|
|
275
275
|
*
|
|
276
|
-
* assert(quotient === 3);
|
|
276
|
+
* assert.isTrue(quotient === 3);
|
|
277
277
|
* ```
|
|
278
278
|
*
|
|
279
279
|
* @param a - The dividend
|
|
@@ -56,31 +56,31 @@ describe('Int test', () => {
|
|
|
56
56
|
|
|
57
57
|
describe(isInt, () => {
|
|
58
58
|
test('correctly identifies integers', () => {
|
|
59
|
-
|
|
59
|
+
assert.isTrue(isInt(0));
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
assert.isTrue(isInt(1));
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
assert.isTrue(isInt(-1));
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
assert.isTrue(isInt(42));
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
assert.isTrue(isInt(-42));
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
assert.isTrue(isInt(Number.MAX_SAFE_INTEGER));
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
assert.isTrue(isInt(Number.MIN_SAFE_INTEGER));
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
test('correctly identifies non-integers', () => {
|
|
75
|
-
|
|
75
|
+
assert.isFalse(isInt(Number.NaN));
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
assert.isFalse(isInt(Number.POSITIVE_INFINITY));
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
assert.isFalse(isInt(Number.NEGATIVE_INFINITY));
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
assert.isFalse(isInt(1.2));
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
assert.isFalse(isInt(-3.4));
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
86
|
|
|
@@ -167,9 +167,9 @@ describe('Int test', () => {
|
|
|
167
167
|
|
|
168
168
|
expect(result).toBeLessThanOrEqual(max);
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
assert.isTrue(Int.is(result));
|
|
171
171
|
|
|
172
|
-
|
|
172
|
+
assert.isTrue(Number.isInteger(result));
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
175
|
});
|
|
@@ -66,37 +66,37 @@ describe('Int16 test', () => {
|
|
|
66
66
|
|
|
67
67
|
describe(isInt16, () => {
|
|
68
68
|
test('correctly identifies int16 values', () => {
|
|
69
|
-
|
|
69
|
+
assert.isTrue(isInt16(0));
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
assert.isTrue(isInt16(1));
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
assert.isTrue(isInt16(-1));
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
assert.isTrue(isInt16(32_767));
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
assert.isTrue(isInt16(-32_768));
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
test('correctly identifies values outside int16 range', () => {
|
|
81
|
-
|
|
81
|
+
assert.isFalse(isInt16(32_768));
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
assert.isFalse(isInt16(-32_769));
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
assert.isFalse(isInt16(65_536));
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
assert.isFalse(isInt16(-65_536));
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
test('correctly identifies non-integers', () => {
|
|
91
|
-
|
|
91
|
+
assert.isFalse(isInt16(Number.NaN));
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
assert.isFalse(isInt16(Number.POSITIVE_INFINITY));
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
assert.isFalse(isInt16(Number.NEGATIVE_INFINITY));
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
assert.isFalse(isInt16(1.2));
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
assert.isFalse(isInt16(-3.4));
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
102
|
|
|
@@ -197,9 +197,9 @@ describe('Int16 test', () => {
|
|
|
197
197
|
|
|
198
198
|
expect(result).toBeLessThanOrEqual(max);
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
assert.isTrue(Int16.is(result));
|
|
201
201
|
|
|
202
|
-
|
|
202
|
+
assert.isTrue(Number.isInteger(result));
|
|
203
203
|
}
|
|
204
204
|
});
|
|
205
205
|
|
|
@@ -66,37 +66,37 @@ describe('Int32 test', () => {
|
|
|
66
66
|
|
|
67
67
|
describe(isInt32, () => {
|
|
68
68
|
test('correctly identifies int32 values', () => {
|
|
69
|
-
|
|
69
|
+
assert.isTrue(isInt32(0));
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
assert.isTrue(isInt32(1));
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
assert.isTrue(isInt32(-1));
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
assert.isTrue(isInt32(2_147_483_647));
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
assert.isTrue(isInt32(-2_147_483_648));
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
test('correctly identifies values outside int32 range', () => {
|
|
81
|
-
|
|
81
|
+
assert.isFalse(isInt32(2_147_483_648));
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
assert.isFalse(isInt32(-2_147_483_649));
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
assert.isFalse(isInt32(4_294_967_296));
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
assert.isFalse(isInt32(-4_294_967_296));
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
test('correctly identifies non-integers', () => {
|
|
91
|
-
|
|
91
|
+
assert.isFalse(isInt32(Number.NaN));
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
assert.isFalse(isInt32(Number.POSITIVE_INFINITY));
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
assert.isFalse(isInt32(Number.NEGATIVE_INFINITY));
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
assert.isFalse(isInt32(1.2));
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
assert.isFalse(isInt32(-3.4));
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
102
|
|
|
@@ -197,9 +197,9 @@ describe('Int32 test', () => {
|
|
|
197
197
|
|
|
198
198
|
expect(result).toBeLessThanOrEqual(max);
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
assert.isTrue(Int32.is(result));
|
|
201
201
|
|
|
202
|
-
|
|
202
|
+
assert.isTrue(Number.isInteger(result));
|
|
203
203
|
}
|
|
204
204
|
});
|
|
205
205
|
|
|
@@ -67,31 +67,31 @@ describe('NonNegativeFiniteNumber test', () => {
|
|
|
67
67
|
|
|
68
68
|
describe(isNonNegativeFiniteNumber, () => {
|
|
69
69
|
test('correctly identifies non-negative finite numbers', () => {
|
|
70
|
-
|
|
70
|
+
assert.isTrue(isNonNegativeFiniteNumber(0));
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
assert.isTrue(isNonNegativeFiniteNumber(1));
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
assert.isTrue(isNonNegativeFiniteNumber(3.14));
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
assert.isTrue(isNonNegativeFiniteNumber(0.5));
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
assert.isTrue(isNonNegativeFiniteNumber(Number.MAX_VALUE));
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
test('correctly identifies negative numbers', () => {
|
|
82
|
-
|
|
82
|
+
assert.isFalse(isNonNegativeFiniteNumber(-1));
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
assert.isFalse(isNonNegativeFiniteNumber(-0.1));
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
assert.isFalse(isNonNegativeFiniteNumber(-Number.MAX_VALUE));
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
test('correctly identifies non-finite numbers', () => {
|
|
90
|
-
|
|
90
|
+
assert.isFalse(isNonNegativeFiniteNumber(Number.NaN));
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
assert.isFalse(isNonNegativeFiniteNumber(Number.POSITIVE_INFINITY));
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
assert.isFalse(isNonNegativeFiniteNumber(Number.NEGATIVE_INFINITY));
|
|
95
95
|
});
|
|
96
96
|
});
|
|
97
97
|
|
|
@@ -198,7 +198,7 @@ describe('NonNegativeFiniteNumber test', () => {
|
|
|
198
198
|
|
|
199
199
|
expect(result).toBeLessThanOrEqual(max);
|
|
200
200
|
|
|
201
|
-
|
|
201
|
+
assert.isTrue(NonNegativeFiniteNumber.is(result));
|
|
202
202
|
|
|
203
203
|
expect(result).toBeGreaterThanOrEqual(0);
|
|
204
204
|
}
|
|
@@ -79,39 +79,39 @@ describe('NonNegativeInt16 test', () => {
|
|
|
79
79
|
|
|
80
80
|
describe(isNonNegativeInt16, () => {
|
|
81
81
|
test('correctly identifies non-negative int16 values', () => {
|
|
82
|
-
|
|
82
|
+
assert.isTrue(isNonNegativeInt16(0));
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
assert.isTrue(isNonNegativeInt16(1));
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
assert.isTrue(isNonNegativeInt16(1000));
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
assert.isTrue(isNonNegativeInt16(32_767));
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
test('correctly identifies negative integers', () => {
|
|
92
|
-
|
|
92
|
+
assert.isFalse(isNonNegativeInt16(-1));
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
assert.isFalse(isNonNegativeInt16(-42));
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
assert.isFalse(isNonNegativeInt16(-32_768));
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
test('correctly identifies values outside int16 range', () => {
|
|
100
|
-
|
|
100
|
+
assert.isFalse(isNonNegativeInt16(32_768));
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
assert.isFalse(isNonNegativeInt16(65_536));
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
test('correctly identifies non-integers', () => {
|
|
106
|
-
|
|
106
|
+
assert.isFalse(isNonNegativeInt16(Number.NaN));
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
assert.isFalse(isNonNegativeInt16(Number.POSITIVE_INFINITY));
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
assert.isFalse(isNonNegativeInt16(Number.NEGATIVE_INFINITY));
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
assert.isFalse(isNonNegativeInt16(1.2));
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
assert.isFalse(isNonNegativeInt16(-3.4));
|
|
115
115
|
});
|
|
116
116
|
});
|
|
117
117
|
|
|
@@ -221,9 +221,9 @@ describe('NonNegativeInt16 test', () => {
|
|
|
221
221
|
|
|
222
222
|
expect(result).toBeLessThanOrEqual(max);
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
assert.isTrue(NonNegativeInt16.is(result));
|
|
225
225
|
|
|
226
|
-
|
|
226
|
+
assert.isTrue(Number.isInteger(result));
|
|
227
227
|
|
|
228
228
|
expect(result).toBeGreaterThanOrEqual(0);
|
|
229
229
|
}
|
|
@@ -79,39 +79,39 @@ describe('NonNegativeInt32 test', () => {
|
|
|
79
79
|
|
|
80
80
|
describe(isNonNegativeInt32, () => {
|
|
81
81
|
test('correctly identifies non-negative int32 values', () => {
|
|
82
|
-
|
|
82
|
+
assert.isTrue(isNonNegativeInt32(0));
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
assert.isTrue(isNonNegativeInt32(1));
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
assert.isTrue(isNonNegativeInt32(1000));
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
assert.isTrue(isNonNegativeInt32(2_147_483_647));
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
test('correctly identifies negative integers', () => {
|
|
92
|
-
|
|
92
|
+
assert.isFalse(isNonNegativeInt32(-1));
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
assert.isFalse(isNonNegativeInt32(-42));
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
assert.isFalse(isNonNegativeInt32(-2_147_483_648));
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
test('correctly identifies values outside int32 range', () => {
|
|
100
|
-
|
|
100
|
+
assert.isFalse(isNonNegativeInt32(2_147_483_648));
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
assert.isFalse(isNonNegativeInt32(4_294_967_296));
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
test('correctly identifies non-integers', () => {
|
|
106
|
-
|
|
106
|
+
assert.isFalse(isNonNegativeInt32(Number.NaN));
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
assert.isFalse(isNonNegativeInt32(Number.POSITIVE_INFINITY));
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
assert.isFalse(isNonNegativeInt32(Number.NEGATIVE_INFINITY));
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
assert.isFalse(isNonNegativeInt32(1.2));
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
assert.isFalse(isNonNegativeInt32(-3.4));
|
|
115
115
|
});
|
|
116
116
|
});
|
|
117
117
|
|
|
@@ -224,9 +224,9 @@ describe('NonNegativeInt32 test', () => {
|
|
|
224
224
|
|
|
225
225
|
expect(result).toBeLessThanOrEqual(max);
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
assert.isTrue(NonNegativeInt32.is(result));
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
assert.isTrue(Number.isInteger(result));
|
|
230
230
|
|
|
231
231
|
expect(result).toBeGreaterThanOrEqual(0);
|
|
232
232
|
}
|
|
@@ -69,31 +69,31 @@ describe('NonZeroFiniteNumber test', () => {
|
|
|
69
69
|
|
|
70
70
|
describe(isNonZeroFiniteNumber, () => {
|
|
71
71
|
test('correctly identifies non-zero finite numbers', () => {
|
|
72
|
-
|
|
72
|
+
assert.isTrue(isNonZeroFiniteNumber(1));
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
assert.isTrue(isNonZeroFiniteNumber(-1));
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
assert.isTrue(isNonZeroFiniteNumber(3.14));
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
assert.isTrue(isNonZeroFiniteNumber(-2.5));
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
assert.isTrue(isNonZeroFiniteNumber(0.001));
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
assert.isTrue(isNonZeroFiniteNumber(-0.001));
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
test('correctly identifies zero', () => {
|
|
86
|
-
|
|
86
|
+
assert.isFalse(isNonZeroFiniteNumber(0));
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
assert.isFalse(isNonZeroFiniteNumber(-0));
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
test('correctly identifies non-finite numbers', () => {
|
|
92
|
-
|
|
92
|
+
assert.isFalse(isNonZeroFiniteNumber(Number.NaN));
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
assert.isFalse(isNonZeroFiniteNumber(Number.POSITIVE_INFINITY));
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
assert.isFalse(isNonZeroFiniteNumber(Number.NEGATIVE_INFINITY));
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
99
|
|
|
@@ -200,7 +200,7 @@ describe('NonZeroFiniteNumber test', () => {
|
|
|
200
200
|
|
|
201
201
|
expect(result).toBeLessThanOrEqual(max);
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
assert.isTrue(NonZeroFiniteNumber.is(result));
|
|
204
204
|
|
|
205
205
|
expect(result).not.toBe(0);
|
|
206
206
|
}
|
|
@@ -218,7 +218,7 @@ describe('NonZeroFiniteNumber test', () => {
|
|
|
218
218
|
|
|
219
219
|
expect(result).toBeLessThanOrEqual(max);
|
|
220
220
|
|
|
221
|
-
|
|
221
|
+
assert.isTrue(NonZeroFiniteNumber.is(result));
|
|
222
222
|
|
|
223
223
|
expect(result).not.toBe(0);
|
|
224
224
|
}
|
|
@@ -236,7 +236,7 @@ describe('NonZeroFiniteNumber test', () => {
|
|
|
236
236
|
|
|
237
237
|
expect(result).toBeLessThanOrEqual(max);
|
|
238
238
|
|
|
239
|
-
|
|
239
|
+
assert.isTrue(NonZeroFiniteNumber.is(result));
|
|
240
240
|
|
|
241
241
|
expect(result).not.toBe(0);
|
|
242
242
|
}
|