ts-data-forge 5.1.0 → 5.1.1
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/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.test.mts +7 -7
- 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
|
@@ -60,35 +60,35 @@ describe('NonZeroInt test', () => {
|
|
|
60
60
|
|
|
61
61
|
describe(isNonZeroInt, () => {
|
|
62
62
|
test('correctly identifies non-zero integers', () => {
|
|
63
|
-
|
|
63
|
+
assert.isTrue(isNonZeroInt(1));
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
assert.isTrue(isNonZeroInt(-1));
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
assert.isTrue(isNonZeroInt(42));
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
assert.isTrue(isNonZeroInt(-42));
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
assert.isTrue(isNonZeroInt(Number.MAX_SAFE_INTEGER));
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
assert.isTrue(isNonZeroInt(Number.MIN_SAFE_INTEGER));
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
test('correctly identifies zero', () => {
|
|
77
|
-
|
|
77
|
+
assert.isFalse(isNonZeroInt(0));
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
assert.isFalse(isNonZeroInt(-0));
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
test('correctly identifies non-integers', () => {
|
|
83
|
-
|
|
83
|
+
assert.isFalse(isNonZeroInt(Number.NaN));
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
assert.isFalse(isNonZeroInt(Number.POSITIVE_INFINITY));
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
assert.isFalse(isNonZeroInt(Number.NEGATIVE_INFINITY));
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
assert.isFalse(isNonZeroInt(1.2));
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
assert.isFalse(isNonZeroInt(-3.4));
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
94
|
|
|
@@ -175,9 +175,9 @@ describe('NonZeroInt test', () => {
|
|
|
175
175
|
|
|
176
176
|
expect(result).toBeLessThanOrEqual(max);
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
assert.isTrue(NonZeroInt.is(result));
|
|
179
179
|
|
|
180
|
-
|
|
180
|
+
assert.isTrue(Number.isInteger(result));
|
|
181
181
|
|
|
182
182
|
expect(result).not.toBe(0);
|
|
183
183
|
}
|
|
@@ -195,9 +195,9 @@ describe('NonZeroInt test', () => {
|
|
|
195
195
|
|
|
196
196
|
expect(result).toBeLessThanOrEqual(max);
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
assert.isTrue(NonZeroInt.is(result));
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
assert.isTrue(Number.isInteger(result));
|
|
201
201
|
|
|
202
202
|
expect(result).not.toBe(0);
|
|
203
203
|
}
|
|
@@ -215,9 +215,9 @@ describe('NonZeroInt test', () => {
|
|
|
215
215
|
|
|
216
216
|
expect(result).toBeLessThanOrEqual(max);
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
assert.isTrue(NonZeroInt.is(result));
|
|
219
219
|
|
|
220
|
-
|
|
220
|
+
assert.isTrue(Number.isInteger(result));
|
|
221
221
|
|
|
222
222
|
expect(result).not.toBe(0);
|
|
223
223
|
}
|
|
@@ -77,39 +77,39 @@ describe('NonZeroInt16 test', () => {
|
|
|
77
77
|
|
|
78
78
|
describe(isNonZeroInt16, () => {
|
|
79
79
|
test('correctly identifies non-zero int16 values', () => {
|
|
80
|
-
|
|
80
|
+
assert.isTrue(isNonZeroInt16(1));
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
assert.isTrue(isNonZeroInt16(-1));
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
assert.isTrue(isNonZeroInt16(32_767));
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
assert.isTrue(isNonZeroInt16(-32_768));
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
test('correctly identifies zero', () => {
|
|
90
|
-
|
|
90
|
+
assert.isFalse(isNonZeroInt16(0));
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
test('correctly identifies values outside int16 range', () => {
|
|
94
|
-
|
|
94
|
+
assert.isFalse(isNonZeroInt16(32_768));
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
assert.isFalse(isNonZeroInt16(-32_769));
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
assert.isFalse(isNonZeroInt16(65_536));
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
assert.isFalse(isNonZeroInt16(-65_536));
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
test('correctly identifies non-integers', () => {
|
|
104
|
-
|
|
104
|
+
assert.isFalse(isNonZeroInt16(Number.NaN));
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
assert.isFalse(isNonZeroInt16(Number.POSITIVE_INFINITY));
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
assert.isFalse(isNonZeroInt16(Number.NEGATIVE_INFINITY));
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
assert.isFalse(isNonZeroInt16(1.2));
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
assert.isFalse(isNonZeroInt16(-3.4));
|
|
113
113
|
});
|
|
114
114
|
});
|
|
115
115
|
|
|
@@ -217,9 +217,9 @@ describe('NonZeroInt16 test', () => {
|
|
|
217
217
|
|
|
218
218
|
expect(result).toBeLessThanOrEqual(max);
|
|
219
219
|
|
|
220
|
-
|
|
220
|
+
assert.isTrue(NonZeroInt16.is(result));
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
assert.isTrue(Number.isInteger(result));
|
|
223
223
|
|
|
224
224
|
expect(result).not.toBe(0);
|
|
225
225
|
}
|
|
@@ -77,39 +77,39 @@ describe('NonZeroInt32 test', () => {
|
|
|
77
77
|
|
|
78
78
|
describe(isNonZeroInt32, () => {
|
|
79
79
|
test('correctly identifies non-zero int32 values', () => {
|
|
80
|
-
|
|
80
|
+
assert.isTrue(isNonZeroInt32(1));
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
assert.isTrue(isNonZeroInt32(-1));
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
assert.isTrue(isNonZeroInt32(2_147_483_647));
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
assert.isTrue(isNonZeroInt32(-2_147_483_648));
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
test('correctly identifies zero', () => {
|
|
90
|
-
|
|
90
|
+
assert.isFalse(isNonZeroInt32(0));
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
test('correctly identifies values outside int32 range', () => {
|
|
94
|
-
|
|
94
|
+
assert.isFalse(isNonZeroInt32(2_147_483_648));
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
assert.isFalse(isNonZeroInt32(-2_147_483_649));
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
assert.isFalse(isNonZeroInt32(4_294_967_296));
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
assert.isFalse(isNonZeroInt32(-4_294_967_296));
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
test('correctly identifies non-integers', () => {
|
|
104
|
-
|
|
104
|
+
assert.isFalse(isNonZeroInt32(Number.NaN));
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
assert.isFalse(isNonZeroInt32(Number.POSITIVE_INFINITY));
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
assert.isFalse(isNonZeroInt32(Number.NEGATIVE_INFINITY));
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
assert.isFalse(isNonZeroInt32(1.2));
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
assert.isFalse(isNonZeroInt32(-3.4));
|
|
113
113
|
});
|
|
114
114
|
});
|
|
115
115
|
|
|
@@ -222,9 +222,9 @@ describe('NonZeroInt32 test', () => {
|
|
|
222
222
|
|
|
223
223
|
expect(result).toBeLessThanOrEqual(max);
|
|
224
224
|
|
|
225
|
-
|
|
225
|
+
assert.isTrue(NonZeroInt32.is(result));
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
assert.isTrue(Number.isInteger(result));
|
|
228
228
|
|
|
229
229
|
expect(result).not.toBe(0);
|
|
230
230
|
}
|
|
@@ -85,45 +85,45 @@ describe('NonZeroSafeInt test', () => {
|
|
|
85
85
|
|
|
86
86
|
describe(isNonZeroSafeInt, () => {
|
|
87
87
|
test('correctly identifies non-zero safe integers', () => {
|
|
88
|
-
|
|
88
|
+
assert.isTrue(isNonZeroSafeInt(1));
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
assert.isTrue(isNonZeroSafeInt(-1));
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
assert.isTrue(isNonZeroSafeInt(42));
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
assert.isTrue(isNonZeroSafeInt(-42));
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
assert.isTrue(isNonZeroSafeInt(Number.MAX_SAFE_INTEGER));
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
assert.isTrue(isNonZeroSafeInt(Number.MIN_SAFE_INTEGER));
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
test('correctly identifies zero', () => {
|
|
102
|
-
|
|
102
|
+
assert.isFalse(isNonZeroSafeInt(0));
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
assert.isFalse(isNonZeroSafeInt(-0));
|
|
105
105
|
});
|
|
106
106
|
|
|
107
107
|
test('correctly identifies values outside safe integer range', () => {
|
|
108
|
-
|
|
108
|
+
assert.isFalse(isNonZeroSafeInt(Number.MAX_SAFE_INTEGER + 1));
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
assert.isFalse(isNonZeroSafeInt(Number.MIN_SAFE_INTEGER - 1));
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
assert.isFalse(isNonZeroSafeInt(Number.MAX_VALUE));
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
assert.isFalse(isNonZeroSafeInt(-Number.MAX_VALUE));
|
|
115
115
|
});
|
|
116
116
|
|
|
117
117
|
test('correctly identifies non-integers', () => {
|
|
118
|
-
|
|
118
|
+
assert.isFalse(isNonZeroSafeInt(Number.NaN));
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
assert.isFalse(isNonZeroSafeInt(Number.POSITIVE_INFINITY));
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
assert.isFalse(isNonZeroSafeInt(Number.NEGATIVE_INFINITY));
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
assert.isFalse(isNonZeroSafeInt(1.2));
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
assert.isFalse(isNonZeroSafeInt(-3.4));
|
|
127
127
|
});
|
|
128
128
|
});
|
|
129
129
|
|
|
@@ -243,9 +243,9 @@ describe('NonZeroSafeInt test', () => {
|
|
|
243
243
|
|
|
244
244
|
expect(result).toBeLessThanOrEqual(max);
|
|
245
245
|
|
|
246
|
-
|
|
246
|
+
assert.isTrue(NonZeroSafeInt.is(result));
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
assert.isTrue(Number.isInteger(result));
|
|
249
249
|
|
|
250
250
|
expect(result).not.toBe(0);
|
|
251
251
|
}
|
|
@@ -263,9 +263,9 @@ describe('NonZeroSafeInt test', () => {
|
|
|
263
263
|
|
|
264
264
|
expect(result).toBeLessThanOrEqual(max);
|
|
265
265
|
|
|
266
|
-
|
|
266
|
+
assert.isTrue(NonZeroSafeInt.is(result));
|
|
267
267
|
|
|
268
|
-
|
|
268
|
+
assert.isTrue(Number.isInteger(result));
|
|
269
269
|
|
|
270
270
|
expect(result).not.toBe(0);
|
|
271
271
|
}
|
|
@@ -283,9 +283,9 @@ describe('NonZeroSafeInt test', () => {
|
|
|
283
283
|
|
|
284
284
|
expect(result).toBeLessThanOrEqual(max);
|
|
285
285
|
|
|
286
|
-
|
|
286
|
+
assert.isTrue(NonZeroSafeInt.is(result));
|
|
287
287
|
|
|
288
|
-
|
|
288
|
+
assert.isTrue(Number.isInteger(result));
|
|
289
289
|
|
|
290
290
|
expect(result).not.toBe(0);
|
|
291
291
|
}
|
|
@@ -81,41 +81,41 @@ describe('NonZeroUint16 test', () => {
|
|
|
81
81
|
|
|
82
82
|
describe(isNonZeroUint16, () => {
|
|
83
83
|
test('correctly identifies non-zero uint16 values', () => {
|
|
84
|
-
|
|
84
|
+
assert.isTrue(isNonZeroUint16(1));
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
assert.isTrue(isNonZeroUint16(1000));
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
assert.isTrue(isNonZeroUint16(65_535));
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
assert.isTrue(isNonZeroUint16(32_768));
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
test('correctly identifies zero', () => {
|
|
94
|
-
|
|
94
|
+
assert.isFalse(isNonZeroUint16(0));
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
test('correctly identifies values outside uint16 range', () => {
|
|
98
|
-
|
|
98
|
+
assert.isFalse(isNonZeroUint16(65_536));
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
assert.isFalse(isNonZeroUint16(100_000));
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
test('correctly identifies negative integers', () => {
|
|
104
|
-
|
|
104
|
+
assert.isFalse(isNonZeroUint16(-1));
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
assert.isFalse(isNonZeroUint16(-42));
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
test('correctly identifies non-integers', () => {
|
|
110
|
-
|
|
110
|
+
assert.isFalse(isNonZeroUint16(Number.NaN));
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
assert.isFalse(isNonZeroUint16(Number.POSITIVE_INFINITY));
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
assert.isFalse(isNonZeroUint16(Number.NEGATIVE_INFINITY));
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
assert.isFalse(isNonZeroUint16(1.2));
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
assert.isFalse(isNonZeroUint16(-3.4));
|
|
119
119
|
});
|
|
120
120
|
});
|
|
121
121
|
|
|
@@ -213,9 +213,9 @@ describe('NonZeroUint16 test', () => {
|
|
|
213
213
|
|
|
214
214
|
expect(result).toBeLessThanOrEqual(max);
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
assert.isTrue(NonZeroUint16.is(result));
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
assert.isTrue(Number.isInteger(result));
|
|
219
219
|
|
|
220
220
|
expect(result).not.toBe(0);
|
|
221
221
|
}
|
|
@@ -81,41 +81,41 @@ describe('NonZeroUint32 test', () => {
|
|
|
81
81
|
|
|
82
82
|
describe(isNonZeroUint32, () => {
|
|
83
83
|
test('correctly identifies non-zero uint32 values', () => {
|
|
84
|
-
|
|
84
|
+
assert.isTrue(isNonZeroUint32(1));
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
assert.isTrue(isNonZeroUint32(1000));
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
assert.isTrue(isNonZeroUint32(4_294_967_295));
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
assert.isTrue(isNonZeroUint32(2_147_483_648));
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
test('correctly identifies zero', () => {
|
|
94
|
-
|
|
94
|
+
assert.isFalse(isNonZeroUint32(0));
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
test('correctly identifies values outside uint32 range', () => {
|
|
98
|
-
|
|
98
|
+
assert.isFalse(isNonZeroUint32(4_294_967_296));
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
assert.isFalse(isNonZeroUint32(10_000_000_000));
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
test('correctly identifies negative integers', () => {
|
|
104
|
-
|
|
104
|
+
assert.isFalse(isNonZeroUint32(-1));
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
assert.isFalse(isNonZeroUint32(-42));
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
test('correctly identifies non-integers', () => {
|
|
110
|
-
|
|
110
|
+
assert.isFalse(isNonZeroUint32(Number.NaN));
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
assert.isFalse(isNonZeroUint32(Number.POSITIVE_INFINITY));
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
assert.isFalse(isNonZeroUint32(Number.NEGATIVE_INFINITY));
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
assert.isFalse(isNonZeroUint32(1.2));
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
assert.isFalse(isNonZeroUint32(-3.4));
|
|
119
119
|
});
|
|
120
120
|
});
|
|
121
121
|
|
|
@@ -213,9 +213,9 @@ describe('NonZeroUint32 test', () => {
|
|
|
213
213
|
|
|
214
214
|
expect(result).toBeLessThanOrEqual(max);
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
assert.isTrue(NonZeroUint32.is(result));
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
assert.isTrue(Number.isInteger(result));
|
|
219
219
|
|
|
220
220
|
expect(result).not.toBe(0);
|
|
221
221
|
}
|
|
@@ -73,37 +73,37 @@ describe('PositiveFiniteNumber test', () => {
|
|
|
73
73
|
|
|
74
74
|
describe(isPositiveFiniteNumber, () => {
|
|
75
75
|
test('correctly identifies positive finite numbers', () => {
|
|
76
|
-
|
|
76
|
+
assert.isTrue(isPositiveFiniteNumber(1));
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
assert.isTrue(isPositiveFiniteNumber(3.14));
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
assert.isTrue(isPositiveFiniteNumber(0.5));
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
assert.isTrue(isPositiveFiniteNumber(Number.MIN_VALUE));
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
assert.isTrue(isPositiveFiniteNumber(Number.MAX_VALUE));
|
|
85
85
|
});
|
|
86
86
|
|
|
87
87
|
test('correctly identifies zero', () => {
|
|
88
|
-
|
|
88
|
+
assert.isFalse(isPositiveFiniteNumber(0));
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
assert.isFalse(isPositiveFiniteNumber(-0));
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
test('correctly identifies negative numbers', () => {
|
|
94
|
-
|
|
94
|
+
assert.isFalse(isPositiveFiniteNumber(-1));
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
assert.isFalse(isPositiveFiniteNumber(-0.1));
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
assert.isFalse(isPositiveFiniteNumber(-Number.MAX_VALUE));
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
test('correctly identifies non-finite numbers', () => {
|
|
102
|
-
|
|
102
|
+
assert.isFalse(isPositiveFiniteNumber(Number.NaN));
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
assert.isFalse(isPositiveFiniteNumber(Number.POSITIVE_INFINITY));
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
assert.isFalse(isPositiveFiniteNumber(Number.NEGATIVE_INFINITY));
|
|
107
107
|
});
|
|
108
108
|
});
|
|
109
109
|
|
|
@@ -219,7 +219,7 @@ describe('PositiveFiniteNumber test', () => {
|
|
|
219
219
|
|
|
220
220
|
expect(result).toBeLessThanOrEqual(max);
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
assert.isTrue(PositiveFiniteNumber.is(result));
|
|
223
223
|
|
|
224
224
|
expect(result).toBeGreaterThan(0);
|
|
225
225
|
}
|
|
@@ -38,11 +38,11 @@ const {
|
|
|
38
38
|
* @example
|
|
39
39
|
*
|
|
40
40
|
* ```ts
|
|
41
|
-
* assert.
|
|
41
|
+
* assert.isTrue(isPositiveInt(5));
|
|
42
42
|
*
|
|
43
|
-
* assert.
|
|
43
|
+
* assert.isFalse(isPositiveInt(0));
|
|
44
44
|
*
|
|
45
|
-
* assert.
|
|
45
|
+
* assert.isTrue(PositiveInt.is(10));
|
|
46
46
|
* ```
|
|
47
47
|
*
|
|
48
48
|
* @param value - The value to check
|
|
@@ -62,9 +62,9 @@ export const isPositiveInt = is;
|
|
|
62
62
|
* ```ts
|
|
63
63
|
* const branded = asPositiveInt(7);
|
|
64
64
|
*
|
|
65
|
-
* assert(branded === 7);
|
|
65
|
+
* assert.isTrue(branded === 7);
|
|
66
66
|
*
|
|
67
|
-
* assert.
|
|
67
|
+
* assert.isTrue(PositiveInt.is(branded));
|
|
68
68
|
* ```
|
|
69
69
|
*
|
|
70
70
|
* @param value - The value to cast
|
|
@@ -96,11 +96,11 @@ export const PositiveInt = {
|
|
|
96
96
|
* @example
|
|
97
97
|
*
|
|
98
98
|
* ```ts
|
|
99
|
-
* assert.
|
|
99
|
+
* assert.isTrue(isPositiveInt(5));
|
|
100
100
|
*
|
|
101
|
-
* assert.
|
|
101
|
+
* assert.isFalse(isPositiveInt(0));
|
|
102
102
|
*
|
|
103
|
-
* assert.
|
|
103
|
+
* assert.isTrue(PositiveInt.is(10));
|
|
104
104
|
* ```
|
|
105
105
|
*
|
|
106
106
|
* @param value - The value to check
|
|
@@ -131,7 +131,7 @@ export const PositiveInt = {
|
|
|
131
131
|
* asPositiveInt(12),
|
|
132
132
|
* );
|
|
133
133
|
*
|
|
134
|
-
* assert(smallest === 3);
|
|
134
|
+
* assert.isTrue(smallest === 3);
|
|
135
135
|
* ```
|
|
136
136
|
*
|
|
137
137
|
* @param values - The positive integers to compare (at least one required)
|
|
@@ -151,7 +151,7 @@ export const PositiveInt = {
|
|
|
151
151
|
* asPositiveInt(12),
|
|
152
152
|
* );
|
|
153
153
|
*
|
|
154
|
-
* assert(largest === 12);
|
|
154
|
+
* assert.isTrue(largest === 12);
|
|
155
155
|
* ```
|
|
156
156
|
*
|
|
157
157
|
* @param values - The positive integers to compare (at least one required)
|
|
@@ -172,9 +172,9 @@ export const PositiveInt = {
|
|
|
172
172
|
*
|
|
173
173
|
* const withinRange = PositiveInt.clamp(10);
|
|
174
174
|
*
|
|
175
|
-
* assert(belowRange === 1);
|
|
175
|
+
* assert.isTrue(belowRange === 1);
|
|
176
176
|
*
|
|
177
|
-
* assert(withinRange === 10);
|
|
177
|
+
* assert.isTrue(withinRange === 10);
|
|
178
178
|
* ```
|
|
179
179
|
*
|
|
180
180
|
* @param value - The number to clamp
|
|
@@ -197,9 +197,9 @@ export const PositiveInt = {
|
|
|
197
197
|
*
|
|
198
198
|
* const randomValue = PositiveInt.random(min, max);
|
|
199
199
|
*
|
|
200
|
-
* assert.
|
|
200
|
+
* assert.isTrue(PositiveInt.is(randomValue));
|
|
201
201
|
*
|
|
202
|
-
* assert.
|
|
202
|
+
* assert.isTrue(randomValue >= 3 && randomValue <= 6);
|
|
203
203
|
* ```
|
|
204
204
|
*
|
|
205
205
|
* @param min - The minimum value (inclusive, must be >= 1)
|
|
@@ -221,7 +221,7 @@ export const PositiveInt = {
|
|
|
221
221
|
*
|
|
222
222
|
* const power = PositiveInt.pow(base, exponent);
|
|
223
223
|
*
|
|
224
|
-
* assert(power === 16);
|
|
224
|
+
* assert.isTrue(power === 16);
|
|
225
225
|
* ```
|
|
226
226
|
*
|
|
227
227
|
* @param a - The base positive integer
|
|
@@ -238,7 +238,7 @@ export const PositiveInt = {
|
|
|
238
238
|
* ```ts
|
|
239
239
|
* const sum = PositiveInt.add(asPositiveInt(4), asPositiveInt(5));
|
|
240
240
|
*
|
|
241
|
-
* assert(sum === 9);
|
|
241
|
+
* assert.isTrue(sum === 9);
|
|
242
242
|
* ```
|
|
243
243
|
*
|
|
244
244
|
* @param a - First positive integer
|
|
@@ -258,7 +258,7 @@ export const PositiveInt = {
|
|
|
258
258
|
* ```ts
|
|
259
259
|
* const difference = PositiveInt.sub(asPositiveInt(5), asPositiveInt(7));
|
|
260
260
|
*
|
|
261
|
-
* assert(difference === 1);
|
|
261
|
+
* assert.isTrue(difference === 1);
|
|
262
262
|
* ```
|
|
263
263
|
*
|
|
264
264
|
* @param a - The minuend (positive integer)
|
|
@@ -275,7 +275,7 @@ export const PositiveInt = {
|
|
|
275
275
|
* ```ts
|
|
276
276
|
* const product = PositiveInt.mul(asPositiveInt(3), asPositiveInt(7));
|
|
277
277
|
*
|
|
278
|
-
* assert(product === 21);
|
|
278
|
+
* assert.isTrue(product === 21);
|
|
279
279
|
* ```
|
|
280
280
|
*
|
|
281
281
|
* @param a - First positive integer
|
|
@@ -299,9 +299,9 @@ export const PositiveInt = {
|
|
|
299
299
|
*
|
|
300
300
|
* const clamped = PositiveInt.div(asPositiveInt(3), asPositiveInt(10));
|
|
301
301
|
*
|
|
302
|
-
* assert(quotient === 4);
|
|
302
|
+
* assert.isTrue(quotient === 4);
|
|
303
303
|
*
|
|
304
|
-
* assert(clamped === 1);
|
|
304
|
+
* assert.isTrue(clamped === 1);
|
|
305
305
|
* ```
|
|
306
306
|
*
|
|
307
307
|
* @param a - The dividend (positive integer)
|