ts-data-forge 14.7.1 → 14.8.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 +21 -34
- package/dist/array/impl/array-utils-creation.d.mts +3 -3
- package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-creation.mjs.map +1 -1
- package/dist/array/impl/array-utils-element-access.d.mts +2 -2
- package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
- package/dist/array/impl/array-utils-element-access.mjs +1 -1
- package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
- package/dist/array/impl/array-utils-iterators.d.mts +1 -1
- package/dist/array/impl/array-utils-iterators.d.mts.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts +1 -1
- package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-array-guard.d.mts +9 -9
- package/dist/array/impl/array-utils-length-bounded-array-guard.d.mts.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-array-guard.mjs +1 -1
- package/dist/array/impl/array-utils-length-bounded-array-guard.mjs.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-tuple-cast.d.mts +2 -2
- package/dist/array/impl/array-utils-length-bounded-tuple-cast.d.mts.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-tuple-guard.d.mts +3 -3
- package/dist/array/impl/array-utils-length-bounded-tuple-guard.d.mts.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs +1 -1
- package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs.map +1 -1
- package/dist/array/impl/array-utils-modification.d.mts +2 -2
- package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.d.mts +2 -2
- package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.mjs +3 -4
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-search.d.mts +1 -1
- package/dist/array/impl/array-utils-search.d.mts.map +1 -1
- package/dist/array/impl/array-utils-set-op.d.mts +1 -1
- package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
- package/dist/array/impl/array-utils-size.d.mts +2 -2
- package/dist/array/impl/array-utils-size.d.mts.map +1 -1
- package/dist/array/impl/array-utils-slice-clamped.d.mts +1 -1
- package/dist/array/impl/array-utils-slice-clamped.d.mts.map +1 -1
- package/dist/array/impl/array-utils-slicing.d.mts +2 -2
- package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
- package/dist/array/impl/array-utils-transformation.d.mts +2 -2
- package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs +6 -3
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/array/impl/array-utils-validation.d.mts +2 -2
- package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
- package/dist/collections/imap-mapped.d.mts +2 -2
- package/dist/collections/imap-mapped.d.mts.map +1 -1
- package/dist/collections/imap-mapped.mjs +10 -7
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.d.mts +2 -2
- package/dist/collections/imap.d.mts.map +1 -1
- package/dist/collections/imap.mjs +10 -7
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/iset-mapped.d.mts +2 -2
- package/dist/collections/iset-mapped.d.mts.map +1 -1
- package/dist/collections/iset-mapped.mjs +6 -3
- package/dist/collections/iset-mapped.mjs.map +1 -1
- package/dist/collections/iset.d.mts +2 -2
- package/dist/collections/iset.d.mts.map +1 -1
- package/dist/collections/iset.mjs +5 -5
- package/dist/collections/iset.mjs.map +1 -1
- package/dist/collections/queue.d.mts +1 -1
- package/dist/collections/queue.d.mts.map +1 -1
- package/dist/collections/stack.d.mts +1 -1
- package/dist/collections/stack.d.mts.map +1 -1
- package/dist/guard/is-non-empty-string.d.mts +1 -1
- package/dist/guard/is-non-empty-string.d.mts.map +1 -1
- package/dist/guard/is-primitive.d.mts +1 -1
- package/dist/guard/is-primitive.d.mts.map +1 -1
- package/dist/guard/is-type.d.mts +1 -1
- package/dist/guard/is-type.d.mts.map +1 -1
- package/dist/iterator/range.d.mts +5 -4
- package/dist/iterator/range.d.mts.map +1 -1
- package/dist/iterator/range.mjs.map +1 -1
- package/dist/json/json.d.mts +29 -32
- package/dist/json/json.d.mts.map +1 -1
- package/dist/json/json.mjs +1 -4
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/branded-types/finite-number.d.mts +1 -1
- package/dist/number/branded-types/finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/int.d.mts +2 -2
- package/dist/number/branded-types/int.d.mts.map +1 -1
- package/dist/number/branded-types/int16.d.mts +1 -1
- package/dist/number/branded-types/int16.d.mts.map +1 -1
- package/dist/number/branded-types/int32.d.mts +1 -1
- package/dist/number/branded-types/int32.d.mts.map +1 -1
- package/dist/number/branded-types/negative-finite-number.d.mts +1 -1
- package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/negative-int.d.mts +1 -1
- package/dist/number/branded-types/negative-int.d.mts.map +1 -1
- package/dist/number/branded-types/negative-safe-int.d.mts +1 -1
- package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.d.mts +1 -1
- package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-int16.d.mts +1 -1
- package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-int32.d.mts +1 -1
- package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-finite-number.d.mts +1 -1
- package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-int.d.mts +1 -1
- package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-safe-int.d.mts +1 -1
- package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.d.mts +1 -1
- package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int.d.mts +1 -1
- package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int16.d.mts +1 -1
- package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int32.d.mts +1 -1
- package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.d.mts +1 -1
- package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.d.mts +1 -1
- package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.d.mts +1 -1
- package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-finite-number.d.mts +1 -1
- package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int.d.mts +2 -2
- package/dist/number/branded-types/positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int16.d.mts +1 -1
- package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int32.d.mts +1 -1
- package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-safe-int.d.mts +2 -2
- package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint16.d.mts +1 -1
- package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint32.d.mts +1 -1
- package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/safe-int.d.mts +2 -2
- package/dist/number/branded-types/safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-uint.d.mts +1 -1
- package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
- package/dist/number/branded-types/uint.d.mts +2 -2
- package/dist/number/branded-types/uint.d.mts.map +1 -1
- package/dist/number/branded-types/uint16.d.mts +1 -1
- package/dist/number/branded-types/uint16.d.mts.map +1 -1
- package/dist/number/branded-types/uint32.d.mts +1 -1
- package/dist/number/branded-types/uint32.d.mts.map +1 -1
- package/dist/number/enum/int8.d.mts +1 -1
- package/dist/number/enum/int8.d.mts.map +1 -1
- package/dist/number/enum/uint8.d.mts +1 -1
- package/dist/number/enum/uint8.d.mts.map +1 -1
- package/dist/number/num-arithmetic-types.d.mts +1 -1
- package/dist/number/num-arithmetic-types.d.mts.map +1 -1
- package/dist/number/num.d.mts +3 -3
- package/dist/number/num.d.mts.map +1 -1
- package/dist/number/refined-number-utils.d.mts +2 -2
- package/dist/number/refined-number-utils.d.mts.map +1 -1
- package/dist/number/refined-number-utils.mjs +6 -4
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/dist/object/object.d.mts +5 -8
- package/dist/object/object.d.mts.map +1 -1
- package/dist/object/object.mjs +16 -13
- package/dist/object/object.mjs.map +1 -1
- package/dist/others/cast-mutable.d.mts +1 -1
- package/dist/others/cast-mutable.d.mts.map +1 -1
- package/dist/others/cast-readonly.d.mts +1 -1
- package/dist/others/cast-readonly.d.mts.map +1 -1
- package/dist/others/debounce-function.d.mts.map +1 -1
- package/dist/others/debounce-function.mjs +1 -5
- package/dist/others/debounce-function.mjs.map +1 -1
- package/dist/others/memoize-function.d.mts +1 -1
- package/dist/others/memoize-function.d.mts.map +1 -1
- package/dist/string/str.d.mts +26 -18
- package/dist/string/str.d.mts.map +1 -1
- package/dist/string/str.mjs +9 -1
- package/dist/string/str.mjs.map +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.d.mts.map +1 -1
- package/package.json +31 -30
- package/src/array/impl/array-utils-creation.mts +24 -22
- package/src/array/impl/array-utils-creation.test.mts +25 -22
- package/src/array/impl/array-utils-element-access.mts +7 -7
- package/src/array/impl/array-utils-element-access.test.mts +2 -2
- package/src/array/impl/array-utils-iterators.mts +1 -1
- package/src/array/impl/array-utils-iterators.test.mts +1 -1
- package/src/array/impl/array-utils-length-bounded-array-cast.mts +7 -7
- package/src/array/impl/array-utils-length-bounded-array-cast.test.mts +6 -6
- package/src/array/impl/array-utils-length-bounded-array-guard.mts +15 -15
- package/src/array/impl/array-utils-length-bounded-array-guard.test.mts +66 -54
- package/src/array/impl/array-utils-length-bounded-tuple-cast.mts +6 -6
- package/src/array/impl/array-utils-length-bounded-tuple-cast.test.mts +10 -10
- package/src/array/impl/array-utils-length-bounded-tuple-guard.mts +8 -8
- package/src/array/impl/array-utils-length-bounded-tuple-guard.test.mts +38 -28
- package/src/array/impl/array-utils-length-constraint-preservation.test.mts +14 -14
- package/src/array/impl/array-utils-modification.mts +12 -12
- package/src/array/impl/array-utils-modification.test.mts +7 -7
- package/src/array/impl/array-utils-overload-type-error.test.mts +1 -1
- package/src/array/impl/array-utils-reducing-value.mts +9 -11
- package/src/array/impl/array-utils-reducing-value.test.mts +2 -2
- package/src/array/impl/array-utils-search.mts +4 -4
- package/src/array/impl/array-utils-search.test.mts +25 -17
- package/src/array/impl/array-utils-set-op.mts +1 -1
- package/src/array/impl/array-utils-shape-invariants.test.mts +8 -8
- package/src/array/impl/array-utils-size.mts +5 -5
- package/src/array/impl/array-utils-slice-clamped.mts +2 -2
- package/src/array/impl/array-utils-slicing.mts +8 -8
- package/src/array/impl/array-utils-slicing.test.mts +1 -1
- package/src/array/impl/array-utils-transformation.mts +26 -24
- package/src/array/impl/array-utils-transformation.test.mts +12 -10
- package/src/array/impl/array-utils-validation.mts +7 -7
- package/src/array/impl/array-utils-validation.test.mts +39 -39
- package/src/array/impl/array.test.mts +1 -1
- package/src/collections/imap-mapped.mts +15 -9
- package/src/collections/imap-mapped.test.mts +1 -1
- package/src/collections/imap.mts +15 -9
- package/src/collections/imap.test.mts +7 -5
- package/src/collections/iset-mapped.mts +14 -8
- package/src/collections/iset.mts +12 -10
- package/src/collections/iset.test.mts +14 -12
- package/src/collections/queue.mts +1 -1
- package/src/collections/stack.mts +1 -1
- package/src/collections/stack.test.mts +8 -6
- package/src/guard/is-error.test.mts +6 -4
- package/src/guard/is-non-empty-string.mts +1 -1
- package/src/guard/is-non-empty-string.test.mts +15 -11
- package/src/guard/is-primitive.mts +1 -1
- package/src/guard/is-type.mts +1 -1
- package/src/guard/is-type.test.mts +87 -59
- package/src/iterator/range.mts +5 -9
- package/src/iterator/range.test.mts +29 -0
- package/src/json/json.mts +32 -35
- package/src/json/json.test.mts +106 -89
- package/src/number/branded-types/finite-number.mts +4 -4
- package/src/number/branded-types/int.mts +2 -2
- package/src/number/branded-types/int16.mts +1 -1
- package/src/number/branded-types/int32.mts +1 -1
- package/src/number/branded-types/negative-finite-number.mts +1 -1
- package/src/number/branded-types/negative-finite-number.test.mts +4 -4
- package/src/number/branded-types/negative-int.mts +3 -3
- package/src/number/branded-types/negative-int.test.mts +1 -1
- package/src/number/branded-types/negative-safe-int.mts +3 -3
- package/src/number/branded-types/negative-safe-int.test.mts +1 -1
- package/src/number/branded-types/non-negative-finite-number.mts +3 -3
- package/src/number/branded-types/non-negative-int16.mts +1 -1
- package/src/number/branded-types/non-negative-int32.mts +1 -1
- package/src/number/branded-types/non-positive-finite-number.mts +1 -1
- package/src/number/branded-types/non-positive-int.mts +1 -1
- package/src/number/branded-types/non-positive-safe-int.mts +1 -1
- package/src/number/branded-types/non-zero-finite-number.mts +5 -5
- package/src/number/branded-types/non-zero-int.mts +1 -1
- package/src/number/branded-types/non-zero-int16.mts +1 -1
- package/src/number/branded-types/non-zero-int32.mts +1 -1
- package/src/number/branded-types/non-zero-safe-int.mts +4 -4
- package/src/number/branded-types/non-zero-uint16.mts +1 -1
- package/src/number/branded-types/non-zero-uint32.mts +1 -1
- package/src/number/branded-types/positive-finite-number.mts +4 -4
- package/src/number/branded-types/positive-int.mts +2 -2
- package/src/number/branded-types/positive-int16.mts +1 -1
- package/src/number/branded-types/positive-int32.mts +1 -1
- package/src/number/branded-types/positive-safe-int.mts +4 -4
- package/src/number/branded-types/positive-uint16.mts +1 -1
- package/src/number/branded-types/positive-uint32.mts +1 -1
- package/src/number/branded-types/safe-int.mts +2 -5
- package/src/number/branded-types/safe-uint.mts +1 -1
- package/src/number/branded-types/uint.mts +2 -2
- package/src/number/branded-types/uint16.mts +1 -1
- package/src/number/branded-types/uint32.mts +1 -1
- package/src/number/enum/int8.mts +5 -5
- package/src/number/enum/uint8.mts +4 -4
- package/src/number/num-arithmetic-types.mts +27 -27
- package/src/number/num-arithmetic-types.test.mts +21 -21
- package/src/number/num-arithmetic.test.mts +6 -6
- package/src/number/num.mts +24 -24
- package/src/number/num.test.mts +1 -1
- package/src/number/refined-number-utils.mts +25 -21
- package/src/object/object.mts +46 -34
- package/src/object/object.test.mts +5 -5
- package/src/others/cast-mutable.mts +1 -1
- package/src/others/cast-readonly.mts +1 -1
- package/src/others/debounce-function.mts +1 -5
- package/src/others/fast-deep-equal.test.mts +1 -1
- package/src/others/map-nullable.test.mts +1 -1
- package/src/others/memoize-function.mts +1 -1
- package/src/string/str.mts +33 -25
- package/src/string/str.test.mts +48 -38
- package/src/types.mts +14 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type {
|
|
2
|
+
SafeUint,
|
|
3
|
+
PositiveSafeInt as TtfImported_PositiveSafeInt,
|
|
4
4
|
} from 'ts-type-forge';
|
|
5
5
|
import { expectType } from '../../expect-type.mjs';
|
|
6
6
|
import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
@@ -206,7 +206,7 @@ export const PositiveSafeInt = {
|
|
|
206
206
|
*
|
|
207
207
|
* assert.isTrue(PositiveSafeInt.is(randomValue));
|
|
208
208
|
*
|
|
209
|
-
* assert.isTrue(
|
|
209
|
+
* assert.isTrue(1 <= randomValue && randomValue <= 6);
|
|
210
210
|
* ```
|
|
211
211
|
*
|
|
212
212
|
* @param min - The minimum value (inclusive)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PositiveUint16 as TtfImported_PositiveUint16 } from 'ts-type-forge';
|
|
2
2
|
import { expectType } from '../../expect-type.mjs';
|
|
3
3
|
import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PositiveUint32 as TtfImported_PositiveUint32 } from 'ts-type-forge';
|
|
2
2
|
import { expectType } from '../../expect-type.mjs';
|
|
3
3
|
import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
4
4
|
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type SafeUint,
|
|
3
|
-
type SafeInt as TtfImported_SafeInt,
|
|
4
|
-
} from 'ts-type-forge';
|
|
1
|
+
import type { SafeUint, SafeInt as TtfImported_SafeInt } from 'ts-type-forge';
|
|
5
2
|
import { expectType } from '../../expect-type.mjs';
|
|
6
3
|
import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
7
4
|
|
|
@@ -217,7 +214,7 @@ export const SafeInt = {
|
|
|
217
214
|
*
|
|
218
215
|
* assert.isTrue(SafeInt.is(randomValue));
|
|
219
216
|
*
|
|
220
|
-
* assert.isTrue(
|
|
217
|
+
* assert.isTrue(-10 <= randomValue && randomValue <= 10);
|
|
221
218
|
* ```
|
|
222
219
|
*
|
|
223
220
|
* @param min - The minimum value (inclusive)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Uint as TtfImported_Uint } from 'ts-type-forge';
|
|
2
2
|
import { expectType } from '../../expect-type.mjs';
|
|
3
3
|
import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
4
4
|
|
|
@@ -184,7 +184,7 @@ export const Uint = {
|
|
|
184
184
|
*
|
|
185
185
|
* assert.isTrue(Uint.is(randomValue));
|
|
186
186
|
*
|
|
187
|
-
* assert.isTrue(
|
|
187
|
+
* assert.isTrue(0 <= randomValue && randomValue <= 3);
|
|
188
188
|
* ```
|
|
189
189
|
*
|
|
190
190
|
* @param min - The minimum value (inclusive)
|
package/src/number/enum/int8.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type {
|
|
2
|
+
AbsoluteValue,
|
|
3
|
+
Int16,
|
|
4
|
+
StrictExclude,
|
|
5
|
+
Int8 as TtfImported_Int8,
|
|
6
6
|
} from 'ts-type-forge';
|
|
7
7
|
import { expectType } from '../../expect-type.mjs';
|
|
8
8
|
import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type {
|
|
2
|
+
StrictExclude,
|
|
3
|
+
Uint8 as TtfImported_Uint8,
|
|
4
|
+
Uint16,
|
|
5
5
|
} from 'ts-type-forge';
|
|
6
6
|
import { expectType } from '../../expect-type.mjs';
|
|
7
7
|
import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import type {
|
|
2
|
+
BoolAnd,
|
|
3
|
+
BoolOr,
|
|
4
|
+
FiniteNumber,
|
|
5
|
+
Int,
|
|
6
|
+
NegativeFiniteNumber,
|
|
7
|
+
NegativeInt,
|
|
8
|
+
NegativeNumber,
|
|
9
|
+
NegativeSafeInt,
|
|
10
|
+
NonNegativeFiniteNumber,
|
|
11
|
+
NonNegativeInt,
|
|
12
|
+
NonNegativeNumber,
|
|
13
|
+
NonPositiveFiniteNumber,
|
|
14
|
+
NonPositiveInt,
|
|
15
|
+
NonPositiveNumber,
|
|
16
|
+
NonPositiveSafeInt,
|
|
17
|
+
NonZeroFiniteNumber,
|
|
18
|
+
NonZeroInt,
|
|
19
|
+
NonZeroNumber,
|
|
20
|
+
NonZeroSafeInt,
|
|
21
|
+
PositiveFiniteNumber,
|
|
22
|
+
PositiveInt,
|
|
23
|
+
PositiveNumber,
|
|
24
|
+
PositiveSafeInt,
|
|
25
|
+
SafeInt,
|
|
26
|
+
SafeUint,
|
|
27
|
+
Uint,
|
|
28
28
|
} from 'ts-type-forge';
|
|
29
29
|
import { expectType } from '../expect-type.mjs';
|
|
30
30
|
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import type {
|
|
2
|
+
FiniteNumber,
|
|
3
|
+
Int,
|
|
4
|
+
NegativeFiniteNumber,
|
|
5
|
+
NegativeInt,
|
|
6
|
+
NonNegativeFiniteNumber,
|
|
7
|
+
NonPositiveInt,
|
|
8
|
+
NonZeroInt,
|
|
9
|
+
PositiveFiniteNumber,
|
|
10
|
+
PositiveInt,
|
|
11
|
+
PositiveSafeInt,
|
|
12
|
+
SafeUint,
|
|
13
|
+
Uint,
|
|
14
14
|
} from 'ts-type-forge';
|
|
15
15
|
import { expectType } from '../expect-type.mjs';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
import type {
|
|
17
|
+
AddResult,
|
|
18
|
+
DivIntResult,
|
|
19
|
+
DivResult,
|
|
20
|
+
LevelOf,
|
|
21
|
+
MulResult,
|
|
22
|
+
SignOf,
|
|
23
|
+
SubResult,
|
|
24
24
|
} from './num-arithmetic-types.mjs';
|
|
25
25
|
|
|
26
26
|
describe('NumericArithmetic type-level', () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type {
|
|
2
|
+
Int,
|
|
3
|
+
NegativeInt,
|
|
4
|
+
PositiveFiniteNumber,
|
|
5
|
+
PositiveInt,
|
|
6
|
+
Uint,
|
|
7
7
|
} from 'ts-type-forge';
|
|
8
8
|
import { expectType } from '../expect-type.mjs';
|
|
9
9
|
import {
|
package/src/number/num.mts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { SafeNumber } from 'ts-std-forge';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
import type {
|
|
3
|
+
Decrement,
|
|
4
|
+
FiniteNumber,
|
|
5
|
+
Increment,
|
|
6
|
+
Index,
|
|
7
|
+
Int,
|
|
8
|
+
Min,
|
|
9
|
+
NaNType,
|
|
10
|
+
NegativeIndex,
|
|
11
|
+
NonNegativeNumber,
|
|
12
|
+
NonZeroNumber,
|
|
13
|
+
PositiveNumber,
|
|
14
|
+
PositiveSafeIntWithSmallInt,
|
|
15
|
+
RelaxedExclude,
|
|
16
|
+
SmallInt,
|
|
17
|
+
SmallUint,
|
|
18
|
+
UnknownBrand,
|
|
19
19
|
} from 'ts-type-forge';
|
|
20
20
|
import { expectType } from '../expect-type.mjs';
|
|
21
21
|
import { Result } from '../functional/index.mjs';
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
import type { SmallPositiveInt } from '../types.mjs';
|
|
23
|
+
import type {
|
|
24
|
+
AddResult,
|
|
25
|
+
DivIntResult,
|
|
26
|
+
DivResult,
|
|
27
|
+
MulResult,
|
|
28
|
+
SubResult,
|
|
29
29
|
} from './num-arithmetic-types.mjs';
|
|
30
30
|
|
|
31
31
|
/**
|
package/src/number/num.test.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FixedLengthTuple, NonZeroNumber } from 'ts-type-forge';
|
|
2
2
|
import { expectType } from '../expect-type.mjs';
|
|
3
3
|
import { pipe, Result } from '../functional/index.mjs';
|
|
4
4
|
import { asNonZeroFiniteNumber } from './branded-types/index.mjs';
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import type {
|
|
2
|
+
Brand,
|
|
3
|
+
ChangeBaseBrand,
|
|
4
|
+
GetBrandValuePart,
|
|
5
|
+
Int,
|
|
6
|
+
IntersectBrand,
|
|
7
|
+
NonNegativeNumber,
|
|
8
|
+
NonZeroNumber,
|
|
9
|
+
PositiveNumber,
|
|
10
|
+
RelaxedExclude,
|
|
11
|
+
StrictPick,
|
|
12
|
+
TypeEq,
|
|
13
|
+
UnknownBrand,
|
|
14
|
+
UnwrapBrandFalseKeys,
|
|
15
|
+
UnwrapBrandTrueKeys,
|
|
16
|
+
WithSmallInt,
|
|
17
17
|
} from 'ts-type-forge';
|
|
18
18
|
import { expectType } from '../expect-type.mjs';
|
|
19
19
|
import { pipe } from '../functional/index.mjs';
|
|
@@ -392,7 +392,7 @@ export namespace TsDataForgeInternals {
|
|
|
392
392
|
(integerOrSafeInteger === 'Integer'
|
|
393
393
|
? Number.isInteger(a)
|
|
394
394
|
: Number.isSafeInteger(a)) &&
|
|
395
|
-
(nonZero
|
|
395
|
+
(nonZero !== true || a !== 0) &&
|
|
396
396
|
(isFnOrUndefined(MIN_VALUE, MAX_VALUE)?.(a) ?? true);
|
|
397
397
|
|
|
398
398
|
const castType = castTypeImpl<ElementType>(is, typeNameInMessage);
|
|
@@ -469,7 +469,9 @@ export namespace TsDataForgeInternals {
|
|
|
469
469
|
while (true) {
|
|
470
470
|
const r = randomImpl(min, max);
|
|
471
471
|
|
|
472
|
-
if (Num.isNonZero(r))
|
|
472
|
+
if (Num.isNonZero(r)) {
|
|
473
|
+
return clampOrCastFn(r);
|
|
474
|
+
}
|
|
473
475
|
}
|
|
474
476
|
};
|
|
475
477
|
|
|
@@ -576,7 +578,7 @@ export namespace TsDataForgeInternals {
|
|
|
576
578
|
*
|
|
577
579
|
* assert.isTrue(coerced >= Number.MIN_VALUE);
|
|
578
580
|
*
|
|
579
|
-
* assert.isTrue(
|
|
581
|
+
* assert.isTrue(10 <= boundedRandom && boundedRandom <= 20);
|
|
580
582
|
*
|
|
581
583
|
* assert.isTrue(nonZeroRandom > 0);
|
|
582
584
|
* ```
|
|
@@ -611,7 +613,7 @@ export namespace TsDataForgeInternals {
|
|
|
611
613
|
}>): OperatorsForFloat<ElementType, MIN_VALUE, MAX_VALUE> => {
|
|
612
614
|
const is = (a: number): a is ElementType =>
|
|
613
615
|
Number.isFinite(a) &&
|
|
614
|
-
(nonZero
|
|
616
|
+
(nonZero !== true || a !== 0) &&
|
|
615
617
|
(isFnOrUndefined(MIN_VALUE, MAX_VALUE)?.(a) ?? true);
|
|
616
618
|
|
|
617
619
|
const castType = castTypeImpl<ElementType>(is, typeNameInMessage);
|
|
@@ -667,7 +669,9 @@ export namespace TsDataForgeInternals {
|
|
|
667
669
|
while (true) {
|
|
668
670
|
const r = random(min, max);
|
|
669
671
|
|
|
670
|
-
if (isNonZero(r))
|
|
672
|
+
if (isNonZero(r)) {
|
|
673
|
+
return r;
|
|
674
|
+
}
|
|
671
675
|
}
|
|
672
676
|
};
|
|
673
677
|
|
package/src/object/object.mts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import type {
|
|
2
|
+
ArrayElement,
|
|
3
|
+
Decrement,
|
|
4
|
+
DeepOmit,
|
|
5
|
+
DeepPick,
|
|
6
|
+
IsFixedLengthList,
|
|
7
|
+
IsUnion,
|
|
8
|
+
List,
|
|
9
|
+
ReadonlyRecord,
|
|
10
|
+
RelaxedExclude,
|
|
11
|
+
RelaxedOmit,
|
|
12
|
+
RelaxedPick,
|
|
13
|
+
StrictOmit,
|
|
14
|
+
StrictPick,
|
|
15
|
+
ToString,
|
|
16
|
+
TypeEq,
|
|
17
|
+
UnknownRecord,
|
|
18
18
|
} from 'ts-type-forge';
|
|
19
19
|
import { Arr } from '../array/index.mjs';
|
|
20
20
|
import { Optional } from '../functional/index.mjs';
|
|
@@ -53,13 +53,10 @@ export namespace Obj {
|
|
|
53
53
|
*
|
|
54
54
|
* const obj5 = { value: 1.00001 } as const;
|
|
55
55
|
*
|
|
56
|
-
* const closeEnough = (a: unknown, b: unknown): boolean =>
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* return Object.is(a, b);
|
|
62
|
-
* };
|
|
56
|
+
* const closeEnough = (a: unknown, b: unknown): boolean =>
|
|
57
|
+
* typeof a === 'number' && typeof b === 'number'
|
|
58
|
+
* ? Math.abs(a - b) < 0.001
|
|
59
|
+
* : Object.is(a, b);
|
|
63
60
|
*
|
|
64
61
|
* assert.isTrue(Obj.shallowEq(obj4, obj5, closeEnough));
|
|
65
62
|
* ```
|
|
@@ -80,9 +77,10 @@ export namespace Obj {
|
|
|
80
77
|
|
|
81
78
|
const bEntries = Object.entries(b);
|
|
82
79
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
return (
|
|
81
|
+
aEntries.length === bEntries.length &&
|
|
82
|
+
aEntries.every(([k, v]) => eq(b[k], v))
|
|
83
|
+
);
|
|
86
84
|
};
|
|
87
85
|
|
|
88
86
|
/**
|
|
@@ -721,19 +719,27 @@ const deepPickImpl = (
|
|
|
721
719
|
record: UnknownRecord,
|
|
722
720
|
path: readonly (string | number)[],
|
|
723
721
|
): UnknownRecord => {
|
|
724
|
-
if (!Arr.isNonEmpty(path))
|
|
722
|
+
if (!Arr.isNonEmpty(path)) {
|
|
723
|
+
return record;
|
|
724
|
+
}
|
|
725
725
|
|
|
726
726
|
const head = path[0];
|
|
727
727
|
|
|
728
|
-
if (!hasKey(record, head))
|
|
728
|
+
if (!hasKey(record, head)) {
|
|
729
|
+
return {};
|
|
730
|
+
}
|
|
729
731
|
|
|
730
732
|
const value = record[head];
|
|
731
733
|
|
|
732
734
|
const tail = path.slice(1);
|
|
733
735
|
|
|
734
|
-
if (!Arr.isNonEmpty(tail))
|
|
736
|
+
if (!Arr.isNonEmpty(tail)) {
|
|
737
|
+
return { [head]: value };
|
|
738
|
+
}
|
|
735
739
|
|
|
736
|
-
if (!isRecord(value))
|
|
740
|
+
if (!isRecord(value)) {
|
|
741
|
+
return { [head]: {} };
|
|
742
|
+
}
|
|
737
743
|
|
|
738
744
|
return {
|
|
739
745
|
[head]: deepPickImpl(value, tail),
|
|
@@ -744,11 +750,15 @@ const deepOmitImpl = (
|
|
|
744
750
|
record: UnknownRecord,
|
|
745
751
|
path: readonly (string | number)[],
|
|
746
752
|
): UnknownRecord => {
|
|
747
|
-
if (!Arr.isNonEmpty(path))
|
|
753
|
+
if (!Arr.isNonEmpty(path)) {
|
|
754
|
+
return record;
|
|
755
|
+
}
|
|
748
756
|
|
|
749
757
|
const head = path[0];
|
|
750
758
|
|
|
751
|
-
if (!hasKey(record, head))
|
|
759
|
+
if (!hasKey(record, head)) {
|
|
760
|
+
return record;
|
|
761
|
+
}
|
|
752
762
|
|
|
753
763
|
const tail = path.slice(1);
|
|
754
764
|
|
|
@@ -760,7 +770,9 @@ const deepOmitImpl = (
|
|
|
760
770
|
|
|
761
771
|
const value = record[head];
|
|
762
772
|
|
|
763
|
-
if (!isRecord(value))
|
|
773
|
+
if (!isRecord(value)) {
|
|
774
|
+
return record;
|
|
775
|
+
}
|
|
764
776
|
|
|
765
777
|
return {
|
|
766
778
|
...record,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type {
|
|
2
|
+
DeepReadonly,
|
|
3
|
+
FixedLengthTuple,
|
|
4
|
+
ReadonlyRecord,
|
|
5
|
+
UnknownRecord,
|
|
6
6
|
} from 'ts-type-forge';
|
|
7
7
|
import { expectType } from '../expect-type.mjs';
|
|
8
8
|
import { Optional, pipe } from '../functional/index.mjs';
|
|
@@ -11,11 +11,7 @@ export const debounce = <Args extends readonly unknown[]>(
|
|
|
11
11
|
func: (...args: Args) => void,
|
|
12
12
|
waitMilliseconds: number,
|
|
13
13
|
): ((...args: Args) => void) => {
|
|
14
|
-
|
|
15
|
-
// declarations in scope that resolves to `unknown`, which `clearTimeout`
|
|
16
|
-
// will not take. Naming what `clearTimeout` accepts says the same thing and
|
|
17
|
-
// stays true in either environment.
|
|
18
|
-
let mut_timeoutId: Parameters<typeof clearTimeout>[0];
|
|
14
|
+
let mut_timeoutId: ReturnType<typeof setTimeout> | undefined = undefined;
|
|
19
15
|
|
|
20
16
|
return (...args: Args): void => {
|
|
21
17
|
clearTimeout(mut_timeoutId);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/* eslint-disable no-restricted-globals */
|
|
5
5
|
/* eslint-disable functional/no-class-inheritance */
|
|
6
6
|
import * as React from 'react';
|
|
7
|
-
import {
|
|
7
|
+
import type { ReadonlyRecord } from 'ts-type-forge';
|
|
8
8
|
import { fastDeepEqual } from './fast-deep-equal.mjs';
|
|
9
9
|
|
|
10
10
|
const fastDeepEqualUntyped = (a: any, b: any): boolean => fastDeepEqual(a, b);
|