ts-data-forge 10.0.0 → 11.0.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/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 +4 -4
- package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
- package/dist/{guard/as-length-bounded-array.d.mts → array/impl/array-utils-length-bounded-array-cast.d.mts} +9 -9
- package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts.map +1 -0
- package/dist/{guard/as-length-bounded-array.mjs → array/impl/array-utils-length-bounded-array-cast.mjs} +2 -2
- package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -0
- package/dist/{guard/is-length-bounded-array.d.mts → array/impl/array-utils-length-bounded-array-guard.d.mts} +13 -13
- package/dist/array/impl/array-utils-length-bounded-array-guard.d.mts.map +1 -0
- package/dist/{guard/is-length-bounded-array.mjs → array/impl/array-utils-length-bounded-array-guard.mjs} +1 -1
- package/dist/array/impl/array-utils-length-bounded-array-guard.mjs.map +1 -0
- package/dist/array/impl/array-utils-modification.d.mts +9 -9
- 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 +9 -9
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-size.d.mts +3 -3
- package/dist/array/impl/array-utils-size.mjs.map +1 -1
- package/dist/array/impl/array-utils-slicing.d.mts +9 -9
- package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
- package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
- package/dist/array/impl/array-utils-transformation.d.mts +16 -10
- package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/array/impl/index.d.mts +2 -0
- package/dist/array/impl/index.d.mts.map +1 -1
- package/dist/array/impl/index.mjs +2 -0
- package/dist/array/impl/index.mjs.map +1 -1
- package/dist/entry-point.mjs +1 -3
- package/dist/entry-point.mjs.map +1 -1
- package/dist/guard/index.d.mts +0 -3
- package/dist/guard/index.d.mts.map +1 -1
- package/dist/guard/index.mjs +0 -3
- package/dist/guard/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -3
- package/dist/index.mjs.map +1 -1
- package/dist/number/branded-types/finite-number.d.mts +47 -61
- package/dist/number/branded-types/finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/finite-number.mjs +37 -41
- package/dist/number/branded-types/finite-number.mjs.map +1 -1
- package/dist/number/branded-types/int.d.mts +40 -46
- package/dist/number/branded-types/int.d.mts.map +1 -1
- package/dist/number/branded-types/int.mjs +29 -31
- package/dist/number/branded-types/int.mjs.map +1 -1
- package/dist/number/branded-types/int16.d.mts +65 -58
- package/dist/number/branded-types/int16.d.mts.map +1 -1
- package/dist/number/branded-types/int16.mjs +49 -45
- package/dist/number/branded-types/int16.mjs.map +1 -1
- package/dist/number/branded-types/int32.d.mts +65 -58
- package/dist/number/branded-types/int32.d.mts.map +1 -1
- package/dist/number/branded-types/int32.mjs +49 -45
- package/dist/number/branded-types/int32.mjs.map +1 -1
- package/dist/number/branded-types/negative-finite-number.d.mts +68 -59
- package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/negative-finite-number.mjs +52 -46
- package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/negative-int.d.mts +60 -48
- package/dist/number/branded-types/negative-int.d.mts.map +1 -1
- package/dist/number/branded-types/negative-int.mjs +40 -36
- package/dist/number/branded-types/negative-int.mjs.map +1 -1
- package/dist/number/branded-types/negative-safe-int.d.mts +57 -56
- package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/negative-safe-int.mjs +40 -41
- package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.d.mts +74 -64
- package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.mjs +58 -51
- package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int16.d.mts +64 -57
- package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-int16.mjs +47 -43
- package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int32.d.mts +64 -58
- package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-int32.mjs +47 -44
- package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-finite-number.d.mts +64 -54
- package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-finite-number.mjs +48 -41
- package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-int.d.mts +41 -146
- package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-int.mjs +27 -107
- package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-safe-int.d.mts +54 -53
- package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-safe-int.mjs +37 -39
- package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.d.mts +62 -49
- package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.mjs +46 -37
- package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int.d.mts +51 -38
- package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int.mjs +31 -27
- package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int16.d.mts +52 -53
- package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int16.mjs +36 -39
- package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int32.d.mts +52 -54
- package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int32.mjs +36 -40
- package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.d.mts +53 -54
- package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs +36 -40
- package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.d.mts +52 -53
- package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.mjs +35 -39
- package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.d.mts +52 -53
- package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.mjs +35 -39
- package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
- package/dist/number/branded-types/positive-finite-number.d.mts +74 -63
- package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/positive-finite-number.mjs +58 -50
- package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/positive-int.d.mts +46 -68
- package/dist/number/branded-types/positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int.mjs +34 -49
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-int16.d.mts +61 -57
- package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int16.mjs +44 -43
- package/dist/number/branded-types/positive-int16.mjs.map +1 -1
- package/dist/number/branded-types/positive-int32.d.mts +61 -57
- package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int32.mjs +44 -43
- package/dist/number/branded-types/positive-int32.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.d.mts +62 -57
- package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs +45 -43
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint16.d.mts +61 -57
- package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint16.mjs +44 -43
- package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint32.d.mts +61 -58
- package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint32.mjs +44 -44
- package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.d.mts +43 -62
- package/dist/number/branded-types/safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/safe-int.mjs +35 -42
- package/dist/number/branded-types/safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-uint.d.mts +62 -57
- package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
- package/dist/number/branded-types/safe-uint.mjs +46 -44
- package/dist/number/branded-types/safe-uint.mjs.map +1 -1
- package/dist/number/branded-types/uint.d.mts +63 -50
- package/dist/number/branded-types/uint.d.mts.map +1 -1
- package/dist/number/branded-types/uint.mjs +42 -39
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/branded-types/uint16.d.mts +60 -58
- package/dist/number/branded-types/uint16.d.mts.map +1 -1
- package/dist/number/branded-types/uint16.mjs +44 -43
- package/dist/number/branded-types/uint16.mjs.map +1 -1
- package/dist/number/branded-types/uint32.d.mts +59 -55
- package/dist/number/branded-types/uint32.d.mts.map +1 -1
- package/dist/number/branded-types/uint32.mjs +42 -42
- package/dist/number/branded-types/uint32.mjs.map +1 -1
- package/dist/number/enum/int8.d.mts +56 -65
- package/dist/number/enum/int8.d.mts.map +1 -1
- package/dist/number/enum/int8.mjs +44 -43
- package/dist/number/enum/int8.mjs.map +1 -1
- package/dist/number/enum/uint8.d.mts +60 -58
- package/dist/number/enum/uint8.d.mts.map +1 -1
- package/dist/number/enum/uint8.mjs +44 -43
- package/dist/number/enum/uint8.mjs.map +1 -1
- package/dist/string/index.d.mts +2 -0
- package/dist/string/index.d.mts.map +1 -0
- package/dist/string/index.mjs +2 -0
- package/dist/string/index.mjs.map +1 -0
- package/dist/string/str.d.mts +273 -0
- package/dist/string/str.d.mts.map +1 -0
- package/dist/string/str.mjs +42 -0
- package/dist/string/str.mjs.map +1 -0
- package/package.json +31 -92
- package/src/array/impl/array-utils-creation.mts +2 -1
- package/src/array/impl/array-utils-element-access.mts +3 -3
- package/src/array/impl/array-utils-element-access.test.mts +3 -3
- package/src/{guard/as-length-bounded-array.mts → array/impl/array-utils-length-bounded-array-cast.mts} +9 -9
- package/src/{guard/as-length-bounded-array.test.mts → array/impl/array-utils-length-bounded-array-cast.test.mts} +2 -2
- package/src/{guard/is-length-bounded-array.mts → array/impl/array-utils-length-bounded-array-guard.mts} +12 -12
- package/src/{guard/is-length-bounded-array.test.mts → array/impl/array-utils-length-bounded-array-guard.test.mts} +2 -2
- package/src/array/impl/array-utils-modification.mts +9 -8
- package/src/array/impl/array-utils-modification.test.mts +6 -1
- package/src/array/impl/array-utils-reducing-value.mts +9 -9
- package/src/array/impl/array-utils-size.mts +2 -2
- package/src/array/impl/array-utils-slicing.mts +24 -13
- package/src/array/impl/array-utils-transformation.mts +18 -12
- package/src/array/impl/array-utils-transformation.test.mts +12 -12
- package/src/array/impl/index.mts +2 -0
- package/src/guard/index.mts +0 -3
- package/src/index.mts +1 -0
- package/src/number/branded-types/finite-number.mts +47 -61
- package/src/number/branded-types/int.mts +40 -46
- package/src/number/branded-types/int16.mts +65 -58
- package/src/number/branded-types/int32.mts +65 -58
- package/src/number/branded-types/negative-finite-number.mts +68 -68
- package/src/number/branded-types/negative-int.mts +60 -57
- package/src/number/branded-types/negative-safe-int.mts +57 -65
- package/src/number/branded-types/non-negative-finite-number.mts +74 -64
- package/src/number/branded-types/non-negative-int16.mts +64 -57
- package/src/number/branded-types/non-negative-int32.mts +64 -58
- package/src/number/branded-types/non-positive-finite-number.mts +64 -54
- package/src/number/branded-types/non-positive-int.mts +41 -146
- package/src/number/branded-types/non-positive-safe-int.mts +54 -53
- package/src/number/branded-types/non-zero-finite-number.mts +62 -51
- package/src/number/branded-types/non-zero-int.mts +51 -38
- package/src/number/branded-types/non-zero-int16.mts +52 -53
- package/src/number/branded-types/non-zero-int32.mts +52 -54
- package/src/number/branded-types/non-zero-safe-int.mts +53 -54
- package/src/number/branded-types/non-zero-uint16.mts +52 -53
- package/src/number/branded-types/non-zero-uint32.mts +52 -53
- package/src/number/branded-types/positive-finite-number.mts +74 -63
- package/src/number/branded-types/positive-int.mts +46 -68
- package/src/number/branded-types/positive-int16.mts +61 -57
- package/src/number/branded-types/positive-int32.mts +61 -57
- package/src/number/branded-types/positive-safe-int.mts +62 -57
- package/src/number/branded-types/positive-uint16.mts +61 -57
- package/src/number/branded-types/positive-uint32.mts +61 -58
- package/src/number/branded-types/safe-int.mts +43 -62
- package/src/number/branded-types/safe-uint.mts +62 -57
- package/src/number/branded-types/uint.mts +63 -50
- package/src/number/branded-types/uint16.mts +60 -58
- package/src/number/branded-types/uint32.mts +59 -55
- package/src/number/enum/int8.mts +56 -65
- package/src/number/enum/uint8.mts +60 -58
- package/src/string/index.mts +1 -0
- package/src/string/str.mts +371 -0
- package/src/string/str.test.mts +215 -0
- package/dist/guard/as-length-bounded-array.d.mts.map +0 -1
- package/dist/guard/as-length-bounded-array.mjs.map +0 -1
- package/dist/guard/is-length-bounded-array.d.mts.map +0 -1
- package/dist/guard/is-length-bounded-array.mjs.map +0 -1
- package/dist/guard/is-length-bounded-string.d.mts +0 -163
- package/dist/guard/is-length-bounded-string.d.mts.map +0 -1
- package/dist/guard/is-length-bounded-string.mjs +0 -7
- package/dist/guard/is-length-bounded-string.mjs.map +0 -1
- package/src/guard/is-length-bounded-string.mts +0 -199
- package/src/guard/is-length-bounded-string.test.mts +0 -170
|
@@ -33,117 +33,116 @@ const {
|
|
|
33
33
|
} as const);
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
* range [-2^15, 2^15) excluding 0).
|
|
36
|
+
* Type guard that checks if a value is a non-zero integer in [-2^15, 2^15).
|
|
38
37
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* Returns `true` for a non-zero integer in [-2^15, 2^15) — a value with no
|
|
39
|
+
* fractional component.
|
|
40
|
+
*
|
|
41
|
+
* @param value - The value to check
|
|
42
|
+
* @returns `true` if the value is a non-zero integer in [-2^15, 2^15), `false` otherwise
|
|
41
43
|
*/
|
|
42
44
|
export const isNonZeroInt16 = is;
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
|
-
* Casts a number to
|
|
47
|
+
* Casts a `number` to the `NonZeroInt16` branded type.
|
|
48
|
+
*
|
|
49
|
+
* Validates that the value is a non-zero integer in [-2^15, 2^15) and returns
|
|
50
|
+
* it with the `NonZeroInt16` brand. Throws a `TypeError` otherwise.
|
|
46
51
|
*
|
|
47
|
-
* @param value The value to cast
|
|
48
|
-
* @returns The value as a NonZeroInt16
|
|
49
|
-
* @throws {TypeError} If the value is not a non-zero integer in [-2^15, 2^15)
|
|
52
|
+
* @param value - The value to cast
|
|
53
|
+
* @returns The value as a `NonZeroInt16`
|
|
54
|
+
* @throws {TypeError} If the value is not a non-zero integer in [-2^15, 2^15)
|
|
50
55
|
*/
|
|
51
56
|
export const asNonZeroInt16 = castType;
|
|
52
57
|
|
|
53
58
|
/**
|
|
54
|
-
* Namespace providing type-safe
|
|
55
|
-
* signed integers.
|
|
59
|
+
* Namespace providing type-safe operations for the `NonZeroInt16` branded type.
|
|
56
60
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* 16-bit non-zero signed integer constraint, preventing zero results and
|
|
60
|
-
* overflow.
|
|
61
|
+
* The `NonZeroInt16` type represents a non-zero integer in [-2^15, 2^15).
|
|
62
|
+
* Division (`div`) uses floor division.
|
|
61
63
|
*/
|
|
62
64
|
export const NonZeroInt16 = {
|
|
63
65
|
/**
|
|
64
|
-
* Type guard
|
|
66
|
+
* Type guard that checks if a value is a non-zero integer in [-2^15, 2^15).
|
|
65
67
|
*
|
|
66
|
-
* @param value The value to check
|
|
67
|
-
* @returns `true` if the value is a
|
|
68
|
-
*
|
|
68
|
+
* @param value - The value to check
|
|
69
|
+
* @returns `true` if the value is a non-zero integer in [-2^15, 2^15), `false` otherwise
|
|
70
|
+
* @see {@link isNonZeroInt16} for usage examples
|
|
69
71
|
*/
|
|
70
72
|
is,
|
|
71
73
|
|
|
72
74
|
/**
|
|
73
|
-
* The
|
|
74
|
-
*
|
|
75
|
-
* @readonly
|
|
75
|
+
* The smallest value representable as `NonZeroInt16`.
|
|
76
76
|
*/
|
|
77
77
|
MIN_VALUE,
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
|
-
* The
|
|
81
|
-
*
|
|
82
|
-
* @readonly
|
|
80
|
+
* The largest value representable as `NonZeroInt16`.
|
|
83
81
|
*/
|
|
84
82
|
MAX_VALUE,
|
|
85
83
|
|
|
86
84
|
/**
|
|
87
|
-
* Returns the absolute value of a
|
|
85
|
+
* Returns the absolute value of a non-zero integer in [-2^15, 2^15).
|
|
88
86
|
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
87
|
+
* The result is non-negative and keeps the `NonZeroInt16` brand.
|
|
88
|
+
*
|
|
89
|
+
* @param a - The non-zero integer value
|
|
90
|
+
* @returns The absolute value as a non-negative `NonZeroInt16`
|
|
91
91
|
*/
|
|
92
92
|
abs,
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
|
-
* Returns the
|
|
95
|
+
* Returns the smallest of the given non-zero integers.
|
|
96
96
|
*
|
|
97
|
-
* @param
|
|
98
|
-
* @
|
|
99
|
-
* @returns The minimum value as a NonZeroInt16.
|
|
97
|
+
* @param values - The non-zero integers to compare (at least one required)
|
|
98
|
+
* @returns The smallest value as a `NonZeroInt16`
|
|
100
99
|
*/
|
|
101
100
|
min: min_,
|
|
102
101
|
|
|
103
102
|
/**
|
|
104
|
-
* Returns the
|
|
103
|
+
* Returns the largest of the given non-zero integers.
|
|
105
104
|
*
|
|
106
|
-
* @param
|
|
107
|
-
* @
|
|
108
|
-
* @returns The maximum value as a NonZeroInt16.
|
|
105
|
+
* @param values - The non-zero integers to compare (at least one required)
|
|
106
|
+
* @returns The largest value as a `NonZeroInt16`
|
|
109
107
|
*/
|
|
110
108
|
max: max_,
|
|
111
109
|
|
|
112
110
|
/**
|
|
113
|
-
* Clamps a number
|
|
111
|
+
* Clamps a `number` into the `NonZeroInt16` range, rounding to the nearest
|
|
112
|
+
* integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
|
|
114
113
|
*
|
|
115
|
-
* @param value The
|
|
116
|
-
* @returns The
|
|
114
|
+
* @param value - The value to clamp
|
|
115
|
+
* @returns The clamped value as a `NonZeroInt16`
|
|
117
116
|
*/
|
|
118
117
|
clamp,
|
|
119
118
|
|
|
120
119
|
/**
|
|
121
|
-
* Generates a random NonZeroInt16
|
|
120
|
+
* Generates a random `NonZeroInt16` within the given range.
|
|
121
|
+
*
|
|
122
|
+
* The range is inclusive on both ends.
|
|
122
123
|
*
|
|
123
|
-
* @
|
|
124
|
-
*
|
|
124
|
+
* @param min - The minimum value (inclusive)
|
|
125
|
+
* @param max - The maximum value (inclusive)
|
|
126
|
+
* @returns A random `NonZeroInt16` in `[min, max]`
|
|
125
127
|
*/
|
|
126
128
|
random,
|
|
127
129
|
|
|
128
130
|
/**
|
|
129
|
-
* Raises a
|
|
131
|
+
* Raises `a` to the power `b`, returning `a ** b` as a `NonZeroInt16`
|
|
132
|
+
* (floored to an integer).
|
|
130
133
|
*
|
|
131
|
-
* @param a The base
|
|
132
|
-
* @param b The exponent
|
|
133
|
-
* @returns `a ** b`
|
|
134
|
+
* @param a - The base non-zero integer
|
|
135
|
+
* @param b - The exponent non-zero integer
|
|
136
|
+
* @returns `a ** b` as a `NonZeroInt16`
|
|
134
137
|
*/
|
|
135
138
|
pow,
|
|
136
139
|
|
|
137
140
|
/**
|
|
138
|
-
* Multiplies two NonZeroInt16
|
|
139
|
-
*
|
|
140
|
-
* The product of two non-zero integers is always non-zero, so this stays
|
|
141
|
-
* closed; for the non-closed operations (`add`/`sub`/`div`, whose result may
|
|
142
|
-
* be `0`) use {@link Num.add}/{@link Num.sub}/{@link Num.divInt}.
|
|
141
|
+
* Multiplies two non-zero integers, returning `a * b` as a `NonZeroInt16`.
|
|
143
142
|
*
|
|
144
|
-
* @param a The first
|
|
145
|
-
* @param b The second
|
|
146
|
-
* @returns `a
|
|
143
|
+
* @param a - The first non-zero integer
|
|
144
|
+
* @param b - The second non-zero integer
|
|
145
|
+
* @returns The product of `a` and `b` as a `NonZeroInt16`
|
|
147
146
|
*/
|
|
148
147
|
mul,
|
|
149
148
|
} as const;
|
|
@@ -33,118 +33,116 @@ const {
|
|
|
33
33
|
} as const);
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
* range [-2^31, 2^31) excluding 0).
|
|
36
|
+
* Type guard that checks if a value is a non-zero integer in [-2^31, 2^31).
|
|
38
37
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* Returns `true` for a non-zero integer in [-2^31, 2^31) — a value with no
|
|
39
|
+
* fractional component.
|
|
40
|
+
*
|
|
41
|
+
* @param value - The value to check
|
|
42
|
+
* @returns `true` if the value is a non-zero integer in [-2^31, 2^31), `false` otherwise
|
|
41
43
|
*/
|
|
42
44
|
export const isNonZeroInt32 = is;
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
|
-
* Casts a number to
|
|
47
|
+
* Casts a `number` to the `NonZeroInt32` branded type.
|
|
48
|
+
*
|
|
49
|
+
* Validates that the value is a non-zero integer in [-2^31, 2^31) and returns
|
|
50
|
+
* it with the `NonZeroInt32` brand. Throws a `TypeError` otherwise.
|
|
46
51
|
*
|
|
47
|
-
* @param value The value to cast
|
|
48
|
-
* @returns The value as a NonZeroInt32
|
|
49
|
-
* @throws {TypeError} If the value is not a non-zero integer in [-2^31, 2^31)
|
|
52
|
+
* @param value - The value to cast
|
|
53
|
+
* @returns The value as a `NonZeroInt32`
|
|
54
|
+
* @throws {TypeError} If the value is not a non-zero integer in [-2^31, 2^31)
|
|
50
55
|
*/
|
|
51
56
|
export const asNonZeroInt32 = castType;
|
|
52
57
|
|
|
53
58
|
/**
|
|
54
|
-
* Namespace providing type-safe
|
|
55
|
-
* signed integers.
|
|
59
|
+
* Namespace providing type-safe operations for the `NonZeroInt32` branded type.
|
|
56
60
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* maintains the 32-bit non-zero signed integer constraint, preventing zero
|
|
60
|
-
* results and overflow.
|
|
61
|
+
* The `NonZeroInt32` type represents a non-zero integer in [-2^31, 2^31).
|
|
62
|
+
* Division (`div`) uses floor division.
|
|
61
63
|
*/
|
|
62
64
|
export const NonZeroInt32 = {
|
|
63
65
|
/**
|
|
64
|
-
* Type guard
|
|
66
|
+
* Type guard that checks if a value is a non-zero integer in [-2^31, 2^31).
|
|
65
67
|
*
|
|
66
|
-
* @param value The value to check
|
|
67
|
-
* @returns `true` if the value is a
|
|
68
|
-
*
|
|
68
|
+
* @param value - The value to check
|
|
69
|
+
* @returns `true` if the value is a non-zero integer in [-2^31, 2^31), `false` otherwise
|
|
70
|
+
* @see {@link isNonZeroInt32} for usage examples
|
|
69
71
|
*/
|
|
70
72
|
is,
|
|
71
73
|
|
|
72
74
|
/**
|
|
73
|
-
* The
|
|
74
|
-
*
|
|
75
|
-
* @readonly
|
|
75
|
+
* The smallest value representable as `NonZeroInt32`.
|
|
76
76
|
*/
|
|
77
77
|
MIN_VALUE,
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
|
-
* The
|
|
81
|
-
*
|
|
82
|
-
* @readonly
|
|
80
|
+
* The largest value representable as `NonZeroInt32`.
|
|
83
81
|
*/
|
|
84
82
|
MAX_VALUE,
|
|
85
83
|
|
|
86
84
|
/**
|
|
87
|
-
* Returns the absolute value of a
|
|
85
|
+
* Returns the absolute value of a non-zero integer in [-2^31, 2^31).
|
|
88
86
|
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
87
|
+
* The result is non-negative and keeps the `NonZeroInt32` brand.
|
|
88
|
+
*
|
|
89
|
+
* @param a - The non-zero integer value
|
|
90
|
+
* @returns The absolute value as a non-negative `NonZeroInt32`
|
|
91
91
|
*/
|
|
92
92
|
abs,
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
|
-
* Returns the
|
|
95
|
+
* Returns the smallest of the given non-zero integers.
|
|
96
96
|
*
|
|
97
|
-
* @param
|
|
98
|
-
* @
|
|
99
|
-
* @returns The minimum value as a NonZeroInt32.
|
|
97
|
+
* @param values - The non-zero integers to compare (at least one required)
|
|
98
|
+
* @returns The smallest value as a `NonZeroInt32`
|
|
100
99
|
*/
|
|
101
100
|
min: min_,
|
|
102
101
|
|
|
103
102
|
/**
|
|
104
|
-
* Returns the
|
|
103
|
+
* Returns the largest of the given non-zero integers.
|
|
105
104
|
*
|
|
106
|
-
* @param
|
|
107
|
-
* @
|
|
108
|
-
* @returns The maximum value as a NonZeroInt32.
|
|
105
|
+
* @param values - The non-zero integers to compare (at least one required)
|
|
106
|
+
* @returns The largest value as a `NonZeroInt32`
|
|
109
107
|
*/
|
|
110
108
|
max: max_,
|
|
111
109
|
|
|
112
110
|
/**
|
|
113
|
-
* Clamps a number
|
|
111
|
+
* Clamps a `number` into the `NonZeroInt32` range, rounding to the nearest
|
|
112
|
+
* integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
|
|
114
113
|
*
|
|
115
|
-
* @param value The
|
|
116
|
-
* @returns The
|
|
117
|
-
* NonZeroInt32.
|
|
114
|
+
* @param value - The value to clamp
|
|
115
|
+
* @returns The clamped value as a `NonZeroInt32`
|
|
118
116
|
*/
|
|
119
117
|
clamp,
|
|
120
118
|
|
|
121
119
|
/**
|
|
122
|
-
* Generates a random NonZeroInt32
|
|
120
|
+
* Generates a random `NonZeroInt32` within the given range.
|
|
121
|
+
*
|
|
122
|
+
* The range is inclusive on both ends.
|
|
123
123
|
*
|
|
124
|
-
* @
|
|
125
|
-
*
|
|
124
|
+
* @param min - The minimum value (inclusive)
|
|
125
|
+
* @param max - The maximum value (inclusive)
|
|
126
|
+
* @returns A random `NonZeroInt32` in `[min, max]`
|
|
126
127
|
*/
|
|
127
128
|
random,
|
|
128
129
|
|
|
129
130
|
/**
|
|
130
|
-
* Raises a
|
|
131
|
+
* Raises `a` to the power `b`, returning `a ** b` as a `NonZeroInt32`
|
|
132
|
+
* (floored to an integer).
|
|
131
133
|
*
|
|
132
|
-
* @param a The base
|
|
133
|
-
* @param b The exponent
|
|
134
|
-
* @returns `a ** b`
|
|
134
|
+
* @param a - The base non-zero integer
|
|
135
|
+
* @param b - The exponent non-zero integer
|
|
136
|
+
* @returns `a ** b` as a `NonZeroInt32`
|
|
135
137
|
*/
|
|
136
138
|
pow,
|
|
137
139
|
|
|
138
140
|
/**
|
|
139
|
-
* Multiplies two NonZeroInt32
|
|
140
|
-
*
|
|
141
|
-
* The product of two non-zero integers is always non-zero, so this stays
|
|
142
|
-
* closed; for the non-closed operations (`add`/`sub`/`div`, whose result may
|
|
143
|
-
* be `0`) use {@link Num.add}/{@link Num.sub}/{@link Num.divInt}.
|
|
141
|
+
* Multiplies two non-zero integers, returning `a * b` as a `NonZeroInt32`.
|
|
144
142
|
*
|
|
145
|
-
* @param a The first
|
|
146
|
-
* @param b The second
|
|
147
|
-
* @returns `a
|
|
143
|
+
* @param a - The first non-zero integer
|
|
144
|
+
* @param b - The second non-zero integer
|
|
145
|
+
* @returns The product of `a` and `b` as a `NonZeroInt32`
|
|
148
146
|
*/
|
|
149
147
|
mul,
|
|
150
148
|
} as const;
|
|
@@ -39,119 +39,118 @@ const {
|
|
|
39
39
|
} as const);
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
* [MIN_SAFE_INTEGER, MAX_SAFE_INTEGER] excluding 0).
|
|
42
|
+
* Type guard that checks if a value is a non-zero safe integer.
|
|
44
43
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
44
|
+
* Returns `true` for a non-zero safe integer — a value with no fractional
|
|
45
|
+
* component.
|
|
46
|
+
*
|
|
47
|
+
* @param value - The value to check
|
|
48
|
+
* @returns `true` if the value is a non-zero safe integer, `false` otherwise
|
|
47
49
|
*/
|
|
48
50
|
export const isNonZeroSafeInt = is;
|
|
49
51
|
|
|
50
52
|
/**
|
|
51
|
-
* Casts a number to
|
|
53
|
+
* Casts a `number` to the `NonZeroSafeInt` branded type.
|
|
54
|
+
*
|
|
55
|
+
* Validates that the value is a non-zero safe integer and returns it with the
|
|
56
|
+
* `NonZeroSafeInt` brand. Throws a `TypeError` otherwise.
|
|
52
57
|
*
|
|
53
|
-
* @param value The value to cast
|
|
54
|
-
* @returns The value as a NonZeroSafeInt
|
|
55
|
-
* @throws {TypeError} If the value is not a non-zero safe integer
|
|
58
|
+
* @param value - The value to cast
|
|
59
|
+
* @returns The value as a `NonZeroSafeInt`
|
|
60
|
+
* @throws {TypeError} If the value is not a non-zero safe integer
|
|
56
61
|
*/
|
|
57
62
|
export const asNonZeroSafeInt = castType;
|
|
58
63
|
|
|
59
64
|
/**
|
|
60
|
-
* Namespace providing type-safe
|
|
61
|
-
*
|
|
65
|
+
* Namespace providing type-safe operations for the `NonZeroSafeInt` branded
|
|
66
|
+
* type.
|
|
62
67
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* non-zero constraint and IEEE 754 precision guarantees, preventing precision
|
|
66
|
-
* loss while ensuring results are never zero.
|
|
68
|
+
* The `NonZeroSafeInt` type represents a non-zero safe integer. Division
|
|
69
|
+
* (`div`) uses floor division.
|
|
67
70
|
*/
|
|
68
71
|
export const NonZeroSafeInt = {
|
|
69
72
|
/**
|
|
70
|
-
* Type guard
|
|
73
|
+
* Type guard that checks if a value is a non-zero safe integer.
|
|
71
74
|
*
|
|
72
|
-
* @param value The value to check
|
|
73
|
-
* @returns `true` if the value is a non-zero safe integer, `false` otherwise
|
|
75
|
+
* @param value - The value to check
|
|
76
|
+
* @returns `true` if the value is a non-zero safe integer, `false` otherwise
|
|
77
|
+
* @see {@link isNonZeroSafeInt} for usage examples
|
|
74
78
|
*/
|
|
75
79
|
is,
|
|
76
80
|
|
|
77
81
|
/**
|
|
78
|
-
* The
|
|
79
|
-
*
|
|
80
|
-
* @readonly
|
|
82
|
+
* The smallest value representable as `NonZeroSafeInt`.
|
|
81
83
|
*/
|
|
82
84
|
MIN_VALUE,
|
|
83
85
|
|
|
84
86
|
/**
|
|
85
|
-
* The
|
|
86
|
-
*
|
|
87
|
-
* @readonly
|
|
87
|
+
* The largest value representable as `NonZeroSafeInt`.
|
|
88
88
|
*/
|
|
89
89
|
MAX_VALUE,
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Returns the absolute value of a non-zero safe integer.
|
|
93
93
|
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
94
|
+
* The result is non-negative and keeps the `NonZeroSafeInt` brand.
|
|
95
|
+
*
|
|
96
|
+
* @param a - The non-zero safe integer value
|
|
97
|
+
* @returns The absolute value as a non-negative `NonZeroSafeInt`
|
|
96
98
|
*/
|
|
97
99
|
abs,
|
|
98
100
|
|
|
99
101
|
/**
|
|
100
|
-
* Returns the
|
|
102
|
+
* Returns the smallest of the given non-zero safe integers.
|
|
101
103
|
*
|
|
102
|
-
* @param
|
|
103
|
-
* @
|
|
104
|
-
* @returns The minimum value as a NonZeroSafeInt.
|
|
104
|
+
* @param values - The non-zero safe integers to compare (at least one required)
|
|
105
|
+
* @returns The smallest value as a `NonZeroSafeInt`
|
|
105
106
|
*/
|
|
106
107
|
min: min_,
|
|
107
108
|
|
|
108
109
|
/**
|
|
109
|
-
* Returns the
|
|
110
|
+
* Returns the largest of the given non-zero safe integers.
|
|
110
111
|
*
|
|
111
|
-
* @param
|
|
112
|
-
* @
|
|
113
|
-
* @returns The maximum value as a NonZeroSafeInt.
|
|
112
|
+
* @param values - The non-zero safe integers to compare (at least one required)
|
|
113
|
+
* @returns The largest value as a `NonZeroSafeInt`
|
|
114
114
|
*/
|
|
115
115
|
max: max_,
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
|
-
* Clamps a number
|
|
118
|
+
* Clamps a `number` into the `NonZeroSafeInt` range, rounding to the nearest
|
|
119
|
+
* integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
|
|
119
120
|
*
|
|
120
|
-
* @param value The
|
|
121
|
-
* @returns The
|
|
122
|
-
* a NonZeroSafeInt.
|
|
121
|
+
* @param value - The value to clamp
|
|
122
|
+
* @returns The clamped value as a `NonZeroSafeInt`
|
|
123
123
|
*/
|
|
124
124
|
clamp,
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
|
-
* Generates a random NonZeroSafeInt
|
|
127
|
+
* Generates a random `NonZeroSafeInt` within the given range.
|
|
128
|
+
*
|
|
129
|
+
* The range is inclusive on both ends.
|
|
128
130
|
*
|
|
129
|
-
* @
|
|
130
|
-
*
|
|
131
|
+
* @param min - The minimum value (inclusive)
|
|
132
|
+
* @param max - The maximum value (inclusive)
|
|
133
|
+
* @returns A random `NonZeroSafeInt` in `[min, max]`
|
|
131
134
|
*/
|
|
132
135
|
random,
|
|
133
136
|
|
|
134
137
|
/**
|
|
135
|
-
* Raises a
|
|
138
|
+
* Raises `a` to the power `b`, returning `a ** b` as a `NonZeroSafeInt`
|
|
139
|
+
* (floored to an integer).
|
|
136
140
|
*
|
|
137
|
-
* @param a The base
|
|
138
|
-
* @param b The exponent
|
|
139
|
-
* @returns `a ** b`
|
|
140
|
-
* NonZeroSafeInt.
|
|
141
|
+
* @param a - The base non-zero safe integer
|
|
142
|
+
* @param b - The exponent non-zero safe integer
|
|
143
|
+
* @returns `a ** b` as a `NonZeroSafeInt`
|
|
141
144
|
*/
|
|
142
145
|
pow,
|
|
143
146
|
|
|
144
147
|
/**
|
|
145
|
-
* Multiplies two
|
|
146
|
-
*
|
|
147
|
-
* The product of two non-zero safe integers is always non-zero, so this stays
|
|
148
|
-
* closed; for the non-closed operations (`add`/`sub`/`div`, whose result may
|
|
149
|
-
* be `0`) use {@link Num.add}/{@link Num.sub}/{@link Num.divInt}.
|
|
148
|
+
* Multiplies two non-zero safe integers, returning `a * b` as a
|
|
149
|
+
* `NonZeroSafeInt`.
|
|
150
150
|
*
|
|
151
|
-
* @param a The first
|
|
152
|
-
* @param b The second
|
|
153
|
-
* @returns `a
|
|
154
|
-
* NonZeroSafeInt.
|
|
151
|
+
* @param a - The first non-zero safe integer
|
|
152
|
+
* @param b - The second non-zero safe integer
|
|
153
|
+
* @returns The product of `a` and `b` as a `NonZeroSafeInt`
|
|
155
154
|
*/
|
|
156
155
|
mul,
|
|
157
156
|
} as const;
|