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
|
@@ -70,41 +70,41 @@ describe('PositiveInt test', () => {
|
|
|
70
70
|
|
|
71
71
|
describe(isPositiveInt, () => {
|
|
72
72
|
test('correctly identifies positive integers', () => {
|
|
73
|
-
|
|
73
|
+
assert.isTrue(isPositiveInt(1));
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
assert.isTrue(isPositiveInt(2));
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
assert.isTrue(isPositiveInt(42));
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
assert.isTrue(isPositiveInt(100));
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
assert.isTrue(isPositiveInt(Number.MAX_SAFE_INTEGER));
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
test('correctly identifies zero', () => {
|
|
85
|
-
|
|
85
|
+
assert.isFalse(isPositiveInt(0));
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
assert.isFalse(isPositiveInt(-0));
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
test('correctly identifies negative integers', () => {
|
|
91
|
-
|
|
91
|
+
assert.isFalse(isPositiveInt(-1));
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
assert.isFalse(isPositiveInt(-42));
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
assert.isFalse(isPositiveInt(Number.MIN_SAFE_INTEGER));
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
test('correctly identifies non-integers', () => {
|
|
99
|
-
|
|
99
|
+
assert.isFalse(isPositiveInt(Number.NaN));
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
assert.isFalse(isPositiveInt(Number.POSITIVE_INFINITY));
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
assert.isFalse(isPositiveInt(Number.NEGATIVE_INFINITY));
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
assert.isFalse(isPositiveInt(1.2));
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
assert.isFalse(isPositiveInt(-3.4));
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
|
|
@@ -191,9 +191,9 @@ describe('PositiveInt test', () => {
|
|
|
191
191
|
|
|
192
192
|
expect(result).toBeLessThanOrEqual(max);
|
|
193
193
|
|
|
194
|
-
|
|
194
|
+
assert.isTrue(PositiveInt.is(result));
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
assert.isTrue(Number.isInteger(result));
|
|
197
197
|
|
|
198
198
|
expect(result).toBeGreaterThan(0);
|
|
199
199
|
}
|
|
@@ -79,39 +79,39 @@ describe('PositiveInt16 test', () => {
|
|
|
79
79
|
|
|
80
80
|
describe(isPositiveInt16, () => {
|
|
81
81
|
test('correctly identifies positive int16 values', () => {
|
|
82
|
-
|
|
82
|
+
assert.isTrue(isPositiveInt16(1));
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
assert.isTrue(isPositiveInt16(1000));
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
assert.isTrue(isPositiveInt16(32_767));
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
test('correctly identifies zero', () => {
|
|
90
|
-
|
|
90
|
+
assert.isFalse(isPositiveInt16(0));
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
test('correctly identifies values outside int16 range', () => {
|
|
94
|
-
|
|
94
|
+
assert.isFalse(isPositiveInt16(32_768));
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
assert.isFalse(isPositiveInt16(65_536));
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
test('correctly identifies negative integers', () => {
|
|
100
|
-
|
|
100
|
+
assert.isFalse(isPositiveInt16(-1));
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
assert.isFalse(isPositiveInt16(-42));
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
test('correctly identifies non-integers', () => {
|
|
106
|
-
|
|
106
|
+
assert.isFalse(isPositiveInt16(Number.NaN));
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
assert.isFalse(isPositiveInt16(Number.POSITIVE_INFINITY));
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
assert.isFalse(isPositiveInt16(Number.NEGATIVE_INFINITY));
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
assert.isFalse(isPositiveInt16(1.2));
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
assert.isFalse(isPositiveInt16(-3.4));
|
|
115
115
|
});
|
|
116
116
|
});
|
|
117
117
|
|
|
@@ -209,9 +209,9 @@ describe('PositiveInt16 test', () => {
|
|
|
209
209
|
|
|
210
210
|
expect(result).toBeLessThanOrEqual(max);
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
assert.isTrue(PositiveInt16.is(result));
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
assert.isTrue(Number.isInteger(result));
|
|
215
215
|
|
|
216
216
|
expect(result).toBeGreaterThan(0);
|
|
217
217
|
}
|
|
@@ -79,39 +79,39 @@ describe('PositiveInt32 test', () => {
|
|
|
79
79
|
|
|
80
80
|
describe(isPositiveInt32, () => {
|
|
81
81
|
test('correctly identifies positive int32 values', () => {
|
|
82
|
-
|
|
82
|
+
assert.isTrue(isPositiveInt32(1));
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
assert.isTrue(isPositiveInt32(1000));
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
assert.isTrue(isPositiveInt32(2_147_483_647));
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
test('correctly identifies zero', () => {
|
|
90
|
-
|
|
90
|
+
assert.isFalse(isPositiveInt32(0));
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
test('correctly identifies values outside int32 range', () => {
|
|
94
|
-
|
|
94
|
+
assert.isFalse(isPositiveInt32(2_147_483_648));
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
assert.isFalse(isPositiveInt32(4_294_967_296));
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
test('correctly identifies negative integers', () => {
|
|
100
|
-
|
|
100
|
+
assert.isFalse(isPositiveInt32(-1));
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
assert.isFalse(isPositiveInt32(-42));
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
test('correctly identifies non-integers', () => {
|
|
106
|
-
|
|
106
|
+
assert.isFalse(isPositiveInt32(Number.NaN));
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
assert.isFalse(isPositiveInt32(Number.POSITIVE_INFINITY));
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
assert.isFalse(isPositiveInt32(Number.NEGATIVE_INFINITY));
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
assert.isFalse(isPositiveInt32(1.2));
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
assert.isFalse(isPositiveInt32(-3.4));
|
|
115
115
|
});
|
|
116
116
|
});
|
|
117
117
|
|
|
@@ -209,9 +209,9 @@ describe('PositiveInt32 test', () => {
|
|
|
209
209
|
|
|
210
210
|
expect(result).toBeLessThanOrEqual(max);
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
assert.isTrue(PositiveInt32.is(result));
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
assert.isTrue(Number.isInteger(result));
|
|
215
215
|
|
|
216
216
|
expect(result).toBeGreaterThan(0);
|
|
217
217
|
}
|
|
@@ -38,13 +38,13 @@ const {
|
|
|
38
38
|
* @example
|
|
39
39
|
*
|
|
40
40
|
* ```ts
|
|
41
|
-
* assert.
|
|
41
|
+
* assert.isTrue(isPositiveSafeInt(1));
|
|
42
42
|
*
|
|
43
|
-
* assert.
|
|
43
|
+
* assert.isTrue(isPositiveSafeInt(Number.MAX_SAFE_INTEGER));
|
|
44
44
|
*
|
|
45
|
-
* assert.
|
|
45
|
+
* assert.isFalse(isPositiveSafeInt(0));
|
|
46
46
|
*
|
|
47
|
-
* assert.
|
|
47
|
+
* assert.isTrue(PositiveSafeInt.is(42));
|
|
48
48
|
* ```
|
|
49
49
|
*
|
|
50
50
|
* @param value The value to check.
|
|
@@ -60,9 +60,9 @@ export const isPositiveSafeInt = is;
|
|
|
60
60
|
* ```ts
|
|
61
61
|
* const branded = asPositiveSafeInt(128);
|
|
62
62
|
*
|
|
63
|
-
* assert(branded === 128);
|
|
63
|
+
* assert.isTrue(branded === 128);
|
|
64
64
|
*
|
|
65
|
-
* assert.
|
|
65
|
+
* assert.isTrue(PositiveSafeInt.is(branded));
|
|
66
66
|
* ```
|
|
67
67
|
*
|
|
68
68
|
* @param value The value to cast.
|
|
@@ -87,13 +87,13 @@ export const PositiveSafeInt = {
|
|
|
87
87
|
* @example
|
|
88
88
|
*
|
|
89
89
|
* ```ts
|
|
90
|
-
* assert.
|
|
90
|
+
* assert.isTrue(isPositiveSafeInt(1));
|
|
91
91
|
*
|
|
92
|
-
* assert.
|
|
92
|
+
* assert.isTrue(isPositiveSafeInt(Number.MAX_SAFE_INTEGER));
|
|
93
93
|
*
|
|
94
|
-
* assert.
|
|
94
|
+
* assert.isFalse(isPositiveSafeInt(0));
|
|
95
95
|
*
|
|
96
|
-
* assert.
|
|
96
|
+
* assert.isTrue(PositiveSafeInt.is(42));
|
|
97
97
|
* ```
|
|
98
98
|
*
|
|
99
99
|
* @param value The value to check.
|
|
@@ -127,7 +127,7 @@ export const PositiveSafeInt = {
|
|
|
127
127
|
* asPositiveSafeInt(5),
|
|
128
128
|
* );
|
|
129
129
|
*
|
|
130
|
-
* assert(smallest === 5);
|
|
130
|
+
* assert.isTrue(smallest === 5);
|
|
131
131
|
* ```
|
|
132
132
|
*
|
|
133
133
|
* @param a The first PositiveSafeInt.
|
|
@@ -147,7 +147,7 @@ export const PositiveSafeInt = {
|
|
|
147
147
|
* asPositiveSafeInt(5),
|
|
148
148
|
* );
|
|
149
149
|
*
|
|
150
|
-
* assert(largest === 10);
|
|
150
|
+
* assert.isTrue(largest === 10);
|
|
151
151
|
* ```
|
|
152
152
|
*
|
|
153
153
|
* @param a The first PositiveSafeInt.
|
|
@@ -168,11 +168,11 @@ export const PositiveSafeInt = {
|
|
|
168
168
|
*
|
|
169
169
|
* const aboveRange = PositiveSafeInt.clamp(Number.MAX_SAFE_INTEGER + 10);
|
|
170
170
|
*
|
|
171
|
-
* assert(belowRange === 1);
|
|
171
|
+
* assert.isTrue(belowRange === 1);
|
|
172
172
|
*
|
|
173
|
-
* assert(withinRange === 123);
|
|
173
|
+
* assert.isTrue(withinRange === 123);
|
|
174
174
|
*
|
|
175
|
-
* assert(aboveRange === Number.MAX_SAFE_INTEGER);
|
|
175
|
+
* assert.isTrue(aboveRange === Number.MAX_SAFE_INTEGER);
|
|
176
176
|
* ```
|
|
177
177
|
*
|
|
178
178
|
* @param value The number to clamp.
|
|
@@ -192,9 +192,9 @@ export const PositiveSafeInt = {
|
|
|
192
192
|
*
|
|
193
193
|
* const randomValue = PositiveSafeInt.random(min, max);
|
|
194
194
|
*
|
|
195
|
-
* assert.
|
|
195
|
+
* assert.isTrue(PositiveSafeInt.is(randomValue));
|
|
196
196
|
*
|
|
197
|
-
* assert.
|
|
197
|
+
* assert.isTrue(randomValue >= 1 && randomValue <= 6);
|
|
198
198
|
* ```
|
|
199
199
|
*
|
|
200
200
|
* @returns A random PositiveSafeInt between 1 and MAX_SAFE_INTEGER.
|
|
@@ -213,7 +213,7 @@ export const PositiveSafeInt = {
|
|
|
213
213
|
*
|
|
214
214
|
* const power = PositiveSafeInt.pow(base, exponent);
|
|
215
215
|
*
|
|
216
|
-
* assert(power === 27);
|
|
216
|
+
* assert.isTrue(power === 27);
|
|
217
217
|
* ```
|
|
218
218
|
*
|
|
219
219
|
* @param a The base PositiveSafeInt.
|
|
@@ -233,9 +233,9 @@ export const PositiveSafeInt = {
|
|
|
233
233
|
* asPositiveSafeInt(2048),
|
|
234
234
|
* );
|
|
235
235
|
*
|
|
236
|
-
* assert(sum === 3048);
|
|
236
|
+
* assert.isTrue(sum === 3048);
|
|
237
237
|
*
|
|
238
|
-
* assert.
|
|
238
|
+
* assert.isTrue(PositiveSafeInt.is(sum));
|
|
239
239
|
* ```
|
|
240
240
|
*
|
|
241
241
|
* @param a The first PositiveSafeInt.
|
|
@@ -255,9 +255,9 @@ export const PositiveSafeInt = {
|
|
|
255
255
|
* asPositiveSafeInt(20),
|
|
256
256
|
* );
|
|
257
257
|
*
|
|
258
|
-
* assert(difference === 1);
|
|
258
|
+
* assert.isTrue(difference === 1);
|
|
259
259
|
*
|
|
260
|
-
* assert.
|
|
260
|
+
* assert.isTrue(PositiveSafeInt.is(difference));
|
|
261
261
|
* ```
|
|
262
262
|
*
|
|
263
263
|
* @param a The minuend PositiveSafeInt.
|
|
@@ -278,9 +278,9 @@ export const PositiveSafeInt = {
|
|
|
278
278
|
* asPositiveSafeInt(20),
|
|
279
279
|
* );
|
|
280
280
|
*
|
|
281
|
-
* assert(product === 1000);
|
|
281
|
+
* assert.isTrue(product === 1000);
|
|
282
282
|
*
|
|
283
|
-
* assert.
|
|
283
|
+
* assert.isTrue(PositiveSafeInt.is(product));
|
|
284
284
|
* ```
|
|
285
285
|
*
|
|
286
286
|
* @param a The first PositiveSafeInt.
|
|
@@ -305,9 +305,9 @@ export const PositiveSafeInt = {
|
|
|
305
305
|
* asPositiveSafeInt(50),
|
|
306
306
|
* );
|
|
307
307
|
*
|
|
308
|
-
* assert(quotient === 6);
|
|
308
|
+
* assert.isTrue(quotient === 6);
|
|
309
309
|
*
|
|
310
|
-
* assert(clamped === 1);
|
|
310
|
+
* assert.isTrue(clamped === 1);
|
|
311
311
|
* ```
|
|
312
312
|
*
|
|
313
313
|
* @param a The dividend PositiveSafeInt.
|
|
@@ -88,47 +88,47 @@ describe('PositiveSafeInt test', () => {
|
|
|
88
88
|
|
|
89
89
|
describe(isPositiveSafeInt, () => {
|
|
90
90
|
test('correctly identifies positive safe integers', () => {
|
|
91
|
-
|
|
91
|
+
assert.isTrue(isPositiveSafeInt(1));
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
assert.isTrue(isPositiveSafeInt(2));
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
assert.isTrue(isPositiveSafeInt(42));
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
assert.isTrue(isPositiveSafeInt(100));
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
assert.isTrue(isPositiveSafeInt(Number.MAX_SAFE_INTEGER));
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
test('correctly identifies zero', () => {
|
|
103
|
-
|
|
103
|
+
assert.isFalse(isPositiveSafeInt(0));
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
assert.isFalse(isPositiveSafeInt(-0));
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
test('correctly identifies negative integers', () => {
|
|
109
|
-
|
|
109
|
+
assert.isFalse(isPositiveSafeInt(-1));
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
assert.isFalse(isPositiveSafeInt(-42));
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
assert.isFalse(isPositiveSafeInt(Number.MIN_SAFE_INTEGER));
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
test('correctly identifies values outside safe integer range', () => {
|
|
117
|
-
|
|
117
|
+
assert.isFalse(isPositiveSafeInt(Number.MAX_SAFE_INTEGER + 1));
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
assert.isFalse(isPositiveSafeInt(Number.MAX_VALUE));
|
|
120
120
|
});
|
|
121
121
|
|
|
122
122
|
test('correctly identifies non-integers', () => {
|
|
123
|
-
|
|
123
|
+
assert.isFalse(isPositiveSafeInt(Number.NaN));
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
assert.isFalse(isPositiveSafeInt(Number.POSITIVE_INFINITY));
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
assert.isFalse(isPositiveSafeInt(Number.NEGATIVE_INFINITY));
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
assert.isFalse(isPositiveSafeInt(1.2));
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
assert.isFalse(isPositiveSafeInt(-3.4));
|
|
132
132
|
});
|
|
133
133
|
});
|
|
134
134
|
|
|
@@ -236,9 +236,9 @@ describe('PositiveSafeInt test', () => {
|
|
|
236
236
|
|
|
237
237
|
expect(result).toBeLessThanOrEqual(max);
|
|
238
238
|
|
|
239
|
-
|
|
239
|
+
assert.isTrue(PositiveSafeInt.is(result));
|
|
240
240
|
|
|
241
|
-
|
|
241
|
+
assert.isTrue(Number.isInteger(result));
|
|
242
242
|
|
|
243
243
|
expect(result).toBeGreaterThan(0);
|
|
244
244
|
}
|
|
@@ -81,41 +81,41 @@ describe('PositiveUint16 test', () => {
|
|
|
81
81
|
|
|
82
82
|
describe(isPositiveUint16, () => {
|
|
83
83
|
test('correctly identifies positive uint16 values', () => {
|
|
84
|
-
|
|
84
|
+
assert.isTrue(isPositiveUint16(1));
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
assert.isTrue(isPositiveUint16(1000));
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
assert.isTrue(isPositiveUint16(65_535));
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
assert.isTrue(isPositiveUint16(32_768));
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
test('correctly identifies zero', () => {
|
|
94
|
-
|
|
94
|
+
assert.isFalse(isPositiveUint16(0));
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
test('correctly identifies values outside uint16 range', () => {
|
|
98
|
-
|
|
98
|
+
assert.isFalse(isPositiveUint16(65_536));
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
assert.isFalse(isPositiveUint16(100_000));
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
test('correctly identifies negative integers', () => {
|
|
104
|
-
|
|
104
|
+
assert.isFalse(isPositiveUint16(-1));
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
assert.isFalse(isPositiveUint16(-42));
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
test('correctly identifies non-integers', () => {
|
|
110
|
-
|
|
110
|
+
assert.isFalse(isPositiveUint16(Number.NaN));
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
assert.isFalse(isPositiveUint16(Number.POSITIVE_INFINITY));
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
assert.isFalse(isPositiveUint16(Number.NEGATIVE_INFINITY));
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
assert.isFalse(isPositiveUint16(1.2));
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
assert.isFalse(isPositiveUint16(-3.4));
|
|
119
119
|
});
|
|
120
120
|
});
|
|
121
121
|
|
|
@@ -217,9 +217,9 @@ describe('PositiveUint16 test', () => {
|
|
|
217
217
|
|
|
218
218
|
expect(result).toBeLessThanOrEqual(max);
|
|
219
219
|
|
|
220
|
-
|
|
220
|
+
assert.isTrue(PositiveUint16.is(result));
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
assert.isTrue(Number.isInteger(result));
|
|
223
223
|
|
|
224
224
|
expect(result).toBeGreaterThan(0);
|
|
225
225
|
}
|
|
@@ -81,41 +81,41 @@ describe('PositiveUint32 test', () => {
|
|
|
81
81
|
|
|
82
82
|
describe(isPositiveUint32, () => {
|
|
83
83
|
test('correctly identifies positive uint32 values', () => {
|
|
84
|
-
|
|
84
|
+
assert.isTrue(isPositiveUint32(1));
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
assert.isTrue(isPositiveUint32(1000));
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
assert.isTrue(isPositiveUint32(4_294_967_295));
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
assert.isTrue(isPositiveUint32(2_147_483_648));
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
test('correctly identifies zero', () => {
|
|
94
|
-
|
|
94
|
+
assert.isFalse(isPositiveUint32(0));
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
test('correctly identifies values outside uint32 range', () => {
|
|
98
|
-
|
|
98
|
+
assert.isFalse(isPositiveUint32(4_294_967_296));
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
assert.isFalse(isPositiveUint32(10_000_000_000));
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
test('correctly identifies negative integers', () => {
|
|
104
|
-
|
|
104
|
+
assert.isFalse(isPositiveUint32(-1));
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
assert.isFalse(isPositiveUint32(-42));
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
test('correctly identifies non-integers', () => {
|
|
110
|
-
|
|
110
|
+
assert.isFalse(isPositiveUint32(Number.NaN));
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
assert.isFalse(isPositiveUint32(Number.POSITIVE_INFINITY));
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
assert.isFalse(isPositiveUint32(Number.NEGATIVE_INFINITY));
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
assert.isFalse(isPositiveUint32(1.2));
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
assert.isFalse(isPositiveUint32(-3.4));
|
|
119
119
|
});
|
|
120
120
|
});
|
|
121
121
|
|
|
@@ -220,9 +220,9 @@ describe('PositiveUint32 test', () => {
|
|
|
220
220
|
|
|
221
221
|
expect(result).toBeLessThanOrEqual(max);
|
|
222
222
|
|
|
223
|
-
|
|
223
|
+
assert.isTrue(PositiveUint32.is(result));
|
|
224
224
|
|
|
225
|
-
|
|
225
|
+
assert.isTrue(Number.isInteger(result));
|
|
226
226
|
|
|
227
227
|
expect(result).toBeGreaterThan(0);
|
|
228
228
|
}
|