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
|
@@ -25,93 +25,93 @@ const isUint32 = is;
|
|
|
25
25
|
const asUint32 = castType;
|
|
26
26
|
const Uint32 = {
|
|
27
27
|
/**
|
|
28
|
-
* Type guard that checks if a value is a
|
|
28
|
+
* Type guard that checks if a value is a non-negative integer less than 2^32.
|
|
29
29
|
*
|
|
30
30
|
* @param value - The value to check
|
|
31
|
-
* @returns `true` if the value is
|
|
32
|
-
*
|
|
31
|
+
* @returns `true` if the value is a non-negative integer less than 2^32, `false` otherwise
|
|
32
|
+
* @see {@link isUint32} for usage examples
|
|
33
33
|
*/
|
|
34
34
|
is,
|
|
35
35
|
/**
|
|
36
|
-
* The
|
|
37
|
-
*
|
|
38
|
-
* @readonly
|
|
36
|
+
* The smallest value representable as `Uint32`.
|
|
39
37
|
*/
|
|
40
38
|
MIN_VALUE,
|
|
41
39
|
/**
|
|
42
|
-
* The
|
|
43
|
-
*
|
|
44
|
-
* @readonly
|
|
40
|
+
* The largest value representable as `Uint32`.
|
|
45
41
|
*/
|
|
46
42
|
MAX_VALUE,
|
|
47
43
|
/**
|
|
48
|
-
* Returns the
|
|
44
|
+
* Returns the smallest of the given non-negative integers.
|
|
49
45
|
*
|
|
50
|
-
* @param values - The
|
|
51
|
-
* @returns The smallest value as
|
|
46
|
+
* @param values - The non-negative integers to compare (at least one required)
|
|
47
|
+
* @returns The smallest value as an `Uint32`
|
|
52
48
|
*/
|
|
53
49
|
min: min_,
|
|
54
50
|
/**
|
|
55
|
-
* Returns the
|
|
51
|
+
* Returns the largest of the given non-negative integers.
|
|
56
52
|
*
|
|
57
|
-
* @param values - The
|
|
58
|
-
* @returns The largest value as
|
|
53
|
+
* @param values - The non-negative integers to compare (at least one required)
|
|
54
|
+
* @returns The largest value as an `Uint32`
|
|
59
55
|
*/
|
|
60
56
|
max: max_,
|
|
61
57
|
/**
|
|
62
|
-
* Clamps a Uint32
|
|
58
|
+
* Clamps a `number` into the `Uint32` range, rounding to the nearest integer
|
|
59
|
+
* and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
|
|
63
60
|
*
|
|
64
61
|
* @param value - The value to clamp
|
|
65
|
-
* @
|
|
66
|
-
* @param max - The maximum value
|
|
67
|
-
* @returns The clamped value as a Uint32
|
|
62
|
+
* @returns The clamped value as an `Uint32`
|
|
68
63
|
*/
|
|
69
64
|
clamp,
|
|
70
65
|
/**
|
|
71
|
-
* Generates a random Uint32
|
|
66
|
+
* Generates a random `Uint32` within the given range.
|
|
67
|
+
*
|
|
68
|
+
* The range is inclusive on both ends.
|
|
72
69
|
*
|
|
73
|
-
* @
|
|
70
|
+
* @param min - The minimum value (inclusive)
|
|
71
|
+
* @param max - The maximum value (inclusive)
|
|
72
|
+
* @returns A random `Uint32` in `[min, max]`
|
|
74
73
|
*/
|
|
75
74
|
random,
|
|
76
75
|
/**
|
|
77
|
-
* Raises a
|
|
76
|
+
* Raises `a` to the power `b`, returning `a ** b` as an `Uint32` (floored to
|
|
77
|
+
* an integer).
|
|
78
78
|
*
|
|
79
|
-
* @param a - The base
|
|
80
|
-
* @param b - The exponent
|
|
81
|
-
* @returns `a ** b` as
|
|
79
|
+
* @param a - The base non-negative integer
|
|
80
|
+
* @param b - The exponent non-negative integer
|
|
81
|
+
* @returns `a ** b` as an `Uint32`
|
|
82
82
|
*/
|
|
83
83
|
pow,
|
|
84
84
|
/**
|
|
85
|
-
* Adds two
|
|
85
|
+
* Adds two non-negative integers, returning `a + b` as an `Uint32`.
|
|
86
86
|
*
|
|
87
|
-
* @param a -
|
|
88
|
-
* @param b -
|
|
89
|
-
* @returns `a
|
|
87
|
+
* @param a - The first non-negative integer
|
|
88
|
+
* @param b - The second non-negative integer
|
|
89
|
+
* @returns The sum of `a` and `b` as an `Uint32`
|
|
90
90
|
*/
|
|
91
91
|
add,
|
|
92
92
|
/**
|
|
93
|
-
* Subtracts two
|
|
93
|
+
* Subtracts two non-negative integers, returning `a - b` as an `Uint32`.
|
|
94
94
|
*
|
|
95
|
-
* @param a -
|
|
96
|
-
* @param b -
|
|
97
|
-
* @returns `a
|
|
95
|
+
* @param a - The first non-negative integer
|
|
96
|
+
* @param b - The second non-negative integer
|
|
97
|
+
* @returns The difference of `a` and `b` as an `Uint32`
|
|
98
98
|
*/
|
|
99
99
|
sub,
|
|
100
100
|
/**
|
|
101
|
-
* Multiplies two
|
|
101
|
+
* Multiplies two non-negative integers, returning `a * b` as an `Uint32`.
|
|
102
102
|
*
|
|
103
|
-
* @param a -
|
|
104
|
-
* @param b -
|
|
105
|
-
* @returns `a
|
|
103
|
+
* @param a - The first non-negative integer
|
|
104
|
+
* @param b - The second non-negative integer
|
|
105
|
+
* @returns The product of `a` and `b` as an `Uint32`
|
|
106
106
|
*/
|
|
107
107
|
mul,
|
|
108
108
|
/**
|
|
109
|
-
* Divides two
|
|
110
|
-
*
|
|
109
|
+
* Divides two non-negative integers using floor division (`⌊a / b⌋`): the
|
|
110
|
+
* result is `a / b` rounded toward negative infinity, as an `Uint32`.
|
|
111
111
|
*
|
|
112
|
-
* @param a - The dividend
|
|
113
|
-
* @param b - The divisor
|
|
114
|
-
* @returns
|
|
112
|
+
* @param a - The dividend
|
|
113
|
+
* @param b - The divisor (must be non-zero)
|
|
114
|
+
* @returns The floored quotient as an `Uint32`
|
|
115
115
|
*/
|
|
116
116
|
div
|
|
117
117
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint32.mjs","sources":["../../../src/number/branded-types/uint32.mts"],"sourcesContent":["import { type Uint32 as TtfImported_Uint32 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type Uint32 = TtfImported_Uint32;\n\ntype ElementType = Uint32;\n\nconst typeNameInMessage = 'a non-negative integer less than 2^32';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n clamp,\n div,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n 0,\n number\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 0,\n MAX_VALUE: 2 ** 32 - 1,\n typeNameInMessage,\n} as const);\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"uint32.mjs","sources":["../../../src/number/branded-types/uint32.mts"],"sourcesContent":["import { type Uint32 as TtfImported_Uint32 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type Uint32 = TtfImported_Uint32;\n\ntype ElementType = Uint32;\n\nconst typeNameInMessage = 'a non-negative integer less than 2^32';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n clamp,\n div,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n 0,\n number\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 0,\n MAX_VALUE: 2 ** 32 - 1,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a non-negative integer less than 2^32.\n *\n * Returns `true` for a non-negative integer less than 2^32 — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-negative integer less than 2^32, `false` otherwise\n */\nexport const isUint32 = is;\n\n/**\n * Casts a `number` to the `Uint32` branded type.\n *\n * Validates that the value is a non-negative integer less than 2^32 and returns\n * it with the `Uint32` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as an `Uint32`\n * @throws {TypeError} If the value is not a non-negative integer less than 2^32\n */\nexport const asUint32 = castType;\n\n/**\n * Namespace providing type-safe operations for the `Uint32` branded type.\n *\n * The `Uint32` type represents a non-negative integer less than 2^32. Division\n * (`div`) uses floor division.\n */\nexport const Uint32 = {\n /**\n * Type guard that checks if a value is a non-negative integer less than 2^32.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-negative integer less than 2^32, `false` otherwise\n * @see {@link isUint32} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `Uint32`.\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `Uint32`.\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given non-negative integers.\n *\n * @param values - The non-negative integers to compare (at least one required)\n * @returns The smallest value as an `Uint32`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-negative integers.\n *\n * @param values - The non-negative integers to compare (at least one required)\n * @returns The largest value as an `Uint32`\n */\n max: max_,\n\n /**\n * Clamps a `number` into the `Uint32` range, rounding to the nearest integer\n * and constraining the result to `[MIN_VALUE, MAX_VALUE]`.\n *\n * @param value - The value to clamp\n * @returns The clamped value as an `Uint32`\n */\n clamp,\n\n /**\n * Generates a random `Uint32` within the given range.\n *\n * The range is inclusive on both ends.\n *\n * @param min - The minimum value (inclusive)\n * @param max - The maximum value (inclusive)\n * @returns A random `Uint32` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as an `Uint32` (floored to\n * an integer).\n *\n * @param a - The base non-negative integer\n * @param b - The exponent non-negative integer\n * @returns `a ** b` as an `Uint32`\n */\n pow,\n\n /**\n * Adds two non-negative integers, returning `a + b` as an `Uint32`.\n *\n * @param a - The first non-negative integer\n * @param b - The second non-negative integer\n * @returns The sum of `a` and `b` as an `Uint32`\n */\n add,\n\n /**\n * Subtracts two non-negative integers, returning `a - b` as an `Uint32`.\n *\n * @param a - The first non-negative integer\n * @param b - The second non-negative integer\n * @returns The difference of `a` and `b` as an `Uint32`\n */\n sub,\n\n /**\n * Multiplies two non-negative integers, returning `a * b` as an `Uint32`.\n *\n * @param a - The first non-negative integer\n * @param b - The second non-negative integer\n * @returns The product of `a` and `b` as an `Uint32`\n */\n mul,\n\n /**\n * Divides two non-negative integers using floor division (`⌊a / b⌋`): the\n * result is `a / b` rounded toward negative infinity, as an `Uint32`.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as an `Uint32`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof Uint32,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'non-negative' | 'range'\n >\n>('=');\n\nexpectType<\n typeof Uint32,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'non-negative' | 'range'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,uCAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,GAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,SAAA,EAAW,CAAA;AAAA,EACX,SAAA,EAAW,KAAK,EAAA,GAAK,CAAA;AAAA,EACrB;AACF,CAAU,CAAA;AAWH,MAAM,QAAA,GAAW;AAYjB,MAAM,QAAA,GAAW;AAQjB,MAAM,MAAA,GAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpB,EAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AACF;;;;"}
|
|
@@ -1,139 +1,130 @@
|
|
|
1
1
|
import { type AbsoluteValue, type Int8 as TtfImported_Int8 } from 'ts-type-forge';
|
|
2
2
|
export type Int8 = TtfImported_Int8;
|
|
3
3
|
/**
|
|
4
|
-
* Type guard that checks if a value is an
|
|
4
|
+
* Type guard that checks if a value is an integer in [-128, 127].
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Returns `true` for an integer in [-128, 127] — a value with no fractional
|
|
7
|
+
* component.
|
|
8
8
|
*
|
|
9
9
|
* @param value - The value to check
|
|
10
|
-
* @returns `true` if the value is an
|
|
10
|
+
* @returns `true` if the value is an integer in [-128, 127], `false` otherwise
|
|
11
11
|
*/
|
|
12
12
|
export declare const isInt8: (x: number) => x is Int8;
|
|
13
13
|
/**
|
|
14
|
-
* Casts a number to
|
|
14
|
+
* Casts a `number` to the `Int8` branded type.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* Validates that the value is an integer in [-128, 127] and returns it with the
|
|
17
|
+
* `Int8` brand. Throws a `TypeError` otherwise.
|
|
18
18
|
*
|
|
19
19
|
* @param value - The value to cast
|
|
20
|
-
* @returns The value as an Int8
|
|
21
|
-
* @throws {TypeError} If the value is not
|
|
20
|
+
* @returns The value as an `Int8`
|
|
21
|
+
* @throws {TypeError} If the value is not an integer in [-128, 127]
|
|
22
22
|
*/
|
|
23
23
|
export declare const asInt8: (x: number) => Int8;
|
|
24
24
|
/**
|
|
25
|
-
* Namespace providing type-safe operations for Int8
|
|
26
|
-
* branded types.
|
|
25
|
+
* Namespace providing type-safe operations for the `Int8` branded type.
|
|
27
26
|
*
|
|
28
|
-
* Int8 represents
|
|
29
|
-
*
|
|
30
|
-
* results to stay within this range, preventing overflow/underflow issues.
|
|
31
|
-
*
|
|
32
|
-
* This type is useful for:
|
|
33
|
-
*
|
|
34
|
-
* - Binary data processing (signed bytes)
|
|
35
|
-
* - Small integer values with known bounds
|
|
36
|
-
* - Embedded systems programming
|
|
37
|
-
* - Memory-efficient integer storage
|
|
38
|
-
* - Image processing (signed pixel offsets)
|
|
27
|
+
* The `Int8` type represents an integer in [-128, 127]. Division (`div`) uses
|
|
28
|
+
* floor division.
|
|
39
29
|
*/
|
|
40
30
|
export declare const Int8: {
|
|
41
31
|
/**
|
|
42
|
-
* Type guard that checks if a value is an
|
|
32
|
+
* Type guard that checks if a value is an integer in [-128, 127].
|
|
43
33
|
*
|
|
44
34
|
* @param value - The value to check
|
|
45
|
-
* @returns `true` if the value is in
|
|
35
|
+
* @returns `true` if the value is an integer in [-128, 127], `false` otherwise
|
|
46
36
|
* @see {@link isInt8} for usage examples
|
|
47
37
|
*/
|
|
48
38
|
readonly is: (x: number) => x is Int8;
|
|
49
39
|
/**
|
|
50
|
-
* The
|
|
51
|
-
*
|
|
52
|
-
* @readonly
|
|
40
|
+
* The smallest value representable as `Int8`.
|
|
53
41
|
*/
|
|
54
42
|
readonly MIN_VALUE: -128;
|
|
55
43
|
/**
|
|
56
|
-
* The
|
|
57
|
-
*
|
|
58
|
-
* @readonly
|
|
44
|
+
* The largest value representable as `Int8`.
|
|
59
45
|
*/
|
|
60
46
|
readonly MAX_VALUE: 127;
|
|
61
47
|
/**
|
|
62
|
-
* Returns the
|
|
48
|
+
* Returns the smallest of the given integers.
|
|
63
49
|
*
|
|
64
|
-
* @param values - The
|
|
65
|
-
* @returns The smallest value as an Int8
|
|
50
|
+
* @param values - The integers to compare (at least one required)
|
|
51
|
+
* @returns The smallest value as an `Int8`
|
|
66
52
|
*/
|
|
67
53
|
readonly min: (...values: readonly Int8[]) => Int8;
|
|
68
54
|
/**
|
|
69
|
-
* Returns the
|
|
55
|
+
* Returns the largest of the given integers.
|
|
70
56
|
*
|
|
71
|
-
* @param values - The
|
|
72
|
-
* @returns The largest value as an Int8
|
|
57
|
+
* @param values - The integers to compare (at least one required)
|
|
58
|
+
* @returns The largest value as an `Int8`
|
|
73
59
|
*/
|
|
74
60
|
readonly max: (...values: readonly Int8[]) => Int8;
|
|
75
61
|
/**
|
|
76
|
-
* Clamps a number
|
|
62
|
+
* Clamps a `number` into the `Int8` range, rounding to the nearest integer
|
|
63
|
+
* and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
|
|
77
64
|
*
|
|
78
|
-
* @param value The
|
|
79
|
-
* @returns The
|
|
65
|
+
* @param value - The value to clamp
|
|
66
|
+
* @returns The clamped value as an `Int8`
|
|
80
67
|
*/
|
|
81
68
|
readonly clamp: (a: number) => Int8;
|
|
82
69
|
/**
|
|
83
|
-
* Returns the absolute value of an
|
|
70
|
+
* Returns the absolute value of an integer in [-128, 127].
|
|
71
|
+
*
|
|
72
|
+
* The result is non-negative and keeps the `Int8` brand.
|
|
84
73
|
*
|
|
85
|
-
* @param
|
|
86
|
-
* @returns The absolute value as
|
|
74
|
+
* @param a - The integer value
|
|
75
|
+
* @returns The absolute value as a non-negative `Int8`
|
|
87
76
|
*/
|
|
88
77
|
readonly abs: <N extends Int8>(x: N) => AbsoluteValue<N>;
|
|
89
78
|
/**
|
|
90
|
-
* Generates a random Int8
|
|
79
|
+
* Generates a random `Int8` within the given range.
|
|
91
80
|
*
|
|
92
|
-
*
|
|
81
|
+
* The range is inclusive on both ends.
|
|
93
82
|
*
|
|
94
83
|
* @param min - The minimum value (inclusive)
|
|
95
84
|
* @param max - The maximum value (inclusive)
|
|
96
|
-
* @returns A random Int8 in
|
|
85
|
+
* @returns A random `Int8` in `[min, max]`
|
|
97
86
|
*/
|
|
98
87
|
readonly random: (min: Int8, max: Int8) => Int8;
|
|
99
88
|
/**
|
|
100
|
-
* Raises
|
|
89
|
+
* Raises `a` to the power `b`, returning `a ** b` as an `Int8` (floored to an
|
|
90
|
+
* integer).
|
|
101
91
|
*
|
|
102
|
-
* @param
|
|
103
|
-
* @param
|
|
104
|
-
* @returns `
|
|
92
|
+
* @param a - The base integer
|
|
93
|
+
* @param b - The exponent integer
|
|
94
|
+
* @returns `a ** b` as an `Int8`
|
|
105
95
|
*/
|
|
106
96
|
readonly pow: (x: Int8, y: Int8) => Int8;
|
|
107
97
|
/**
|
|
108
|
-
* Adds two
|
|
98
|
+
* Adds two integers, returning `a + b` as an `Int8`.
|
|
109
99
|
*
|
|
110
|
-
* @param
|
|
111
|
-
* @param
|
|
112
|
-
* @returns `
|
|
100
|
+
* @param a - The first integer
|
|
101
|
+
* @param b - The second integer
|
|
102
|
+
* @returns The sum of `a` and `b` as an `Int8`
|
|
113
103
|
*/
|
|
114
104
|
readonly add: (x: Int8, y: Int8) => Int8;
|
|
115
105
|
/**
|
|
116
|
-
* Subtracts two
|
|
106
|
+
* Subtracts two integers, returning `a - b` as an `Int8`.
|
|
117
107
|
*
|
|
118
|
-
* @param
|
|
119
|
-
* @param
|
|
120
|
-
* @returns `
|
|
108
|
+
* @param a - The first integer
|
|
109
|
+
* @param b - The second integer
|
|
110
|
+
* @returns The difference of `a` and `b` as an `Int8`
|
|
121
111
|
*/
|
|
122
112
|
readonly sub: (x: Int8, y: Int8) => Int8;
|
|
123
113
|
/**
|
|
124
|
-
* Multiplies two
|
|
114
|
+
* Multiplies two integers, returning `a * b` as an `Int8`.
|
|
125
115
|
*
|
|
126
|
-
* @param
|
|
127
|
-
* @param
|
|
128
|
-
* @returns `
|
|
116
|
+
* @param a - The first integer
|
|
117
|
+
* @param b - The second integer
|
|
118
|
+
* @returns The product of `a` and `b` as an `Int8`
|
|
129
119
|
*/
|
|
130
120
|
readonly mul: (x: Int8, y: Int8) => Int8;
|
|
131
121
|
/**
|
|
132
|
-
* Divides two
|
|
122
|
+
* Divides two integers using floor division (`⌊a / b⌋`): the result is `a /
|
|
123
|
+
* b` rounded toward negative infinity, as an `Int8`.
|
|
133
124
|
*
|
|
134
|
-
* @param
|
|
135
|
-
* @param
|
|
136
|
-
* @returns
|
|
125
|
+
* @param a - The dividend
|
|
126
|
+
* @param b - The divisor (must be non-zero)
|
|
127
|
+
* @returns The floored quotient as an `Int8`
|
|
137
128
|
*/
|
|
138
129
|
readonly div: (x: Int8, y: Exclude<Int8, 0>) => Int8;
|
|
139
130
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"int8.d.mts","sourceRoot":"","sources":["../../../src/number/enum/int8.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,IAAI,IAAI,gBAAgB,EAC9B,MAAM,eAAe,CAAC;AAIvB,MAAM,MAAM,IAAI,GAAG,gBAAgB,CAAC;AAqDpC;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,MAxCJ,MAAM,KAAG,CAAC,IAAI,IAwCL,CAAC;AAEzB;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,MAlDE,MAAM,KAAG,IAkDA,CAAC;AAE/B
|
|
1
|
+
{"version":3,"file":"int8.d.mts","sourceRoot":"","sources":["../../../src/number/enum/int8.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,IAAI,IAAI,gBAAgB,EAC9B,MAAM,eAAe,CAAC;AAIvB,MAAM,MAAM,IAAI,GAAG,gBAAgB,CAAC;AAqDpC;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,MAxCJ,MAAM,KAAG,CAAC,IAAI,IAwCL,CAAC;AAEzB;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,MAlDE,MAAM,KAAG,IAkDA,CAAC;AAE/B;;;;;GAKG;AACH,eAAO,MAAM,IAAI;IACf;;;;;;OAMG;qBAnEU,MAAM,KAAG,CAAC,IAAI,IAAI;IAsE/B;;OAEG;;IAGH;;OAEG;;IAGH;;;;;OAKG;8BAzEoB,SAAS,IAAI,EAAE,KAAG,IAAI;IA4E7C;;;;;OAKG;8BA9EoB,SAAS,IAAI,EAAE,KAAG,IAAI;IAiF7C;;;;;;OAMG;wBAhGa,MAAM,KAAG,IAAI;IAmG7B;;;;;;;OAOG;mBAxGQ,CAAC,SAAS,IAAI,KAAK,CAAC,KAAG,aAAa,CAAC,CAAC,CAAC;IA2GlD;;;;;;;;OAQG;2BA/FgB,IAAI,OAAO,IAAI,KAAG,IAAI;IAkGzC;;;;;;;OAOG;sBAnHW,IAAI,KAAK,IAAI,KAAG,IAAI;IAsHlC;;;;;;OAMG;sBA1HW,IAAI,KAAK,IAAI,KAAG,IAAI;IA6HlC;;;;;;OAMG;sBAjIW,IAAI,KAAK,IAAI,KAAG,IAAI;IAoIlC;;;;;;OAMG;sBAxIW,IAAI,KAAK,IAAI,KAAG,IAAI;IA2IlC;;;;;;;OAOG;sBAhJW,IAAI,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,KAAG,IAAI;CAkJtC,CAAC"}
|
|
@@ -36,101 +36,102 @@ const isInt8 = is;
|
|
|
36
36
|
const asInt8 = castType;
|
|
37
37
|
const Int8 = {
|
|
38
38
|
/**
|
|
39
|
-
* Type guard that checks if a value is an
|
|
39
|
+
* Type guard that checks if a value is an integer in [-128, 127].
|
|
40
40
|
*
|
|
41
41
|
* @param value - The value to check
|
|
42
|
-
* @returns `true` if the value is in
|
|
42
|
+
* @returns `true` if the value is an integer in [-128, 127], `false` otherwise
|
|
43
43
|
* @see {@link isInt8} for usage examples
|
|
44
44
|
*/
|
|
45
45
|
is,
|
|
46
46
|
/**
|
|
47
|
-
* The
|
|
48
|
-
*
|
|
49
|
-
* @readonly
|
|
47
|
+
* The smallest value representable as `Int8`.
|
|
50
48
|
*/
|
|
51
49
|
MIN_VALUE,
|
|
52
50
|
/**
|
|
53
|
-
* The
|
|
54
|
-
*
|
|
55
|
-
* @readonly
|
|
51
|
+
* The largest value representable as `Int8`.
|
|
56
52
|
*/
|
|
57
53
|
MAX_VALUE,
|
|
58
54
|
/**
|
|
59
|
-
* Returns the
|
|
55
|
+
* Returns the smallest of the given integers.
|
|
60
56
|
*
|
|
61
|
-
* @param values - The
|
|
62
|
-
* @returns The smallest value as an Int8
|
|
57
|
+
* @param values - The integers to compare (at least one required)
|
|
58
|
+
* @returns The smallest value as an `Int8`
|
|
63
59
|
*/
|
|
64
60
|
min: min_,
|
|
65
61
|
/**
|
|
66
|
-
* Returns the
|
|
62
|
+
* Returns the largest of the given integers.
|
|
67
63
|
*
|
|
68
|
-
* @param values - The
|
|
69
|
-
* @returns The largest value as an Int8
|
|
64
|
+
* @param values - The integers to compare (at least one required)
|
|
65
|
+
* @returns The largest value as an `Int8`
|
|
70
66
|
*/
|
|
71
67
|
max: max_,
|
|
72
68
|
/**
|
|
73
|
-
* Clamps a number
|
|
69
|
+
* Clamps a `number` into the `Int8` range, rounding to the nearest integer
|
|
70
|
+
* and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
|
|
74
71
|
*
|
|
75
|
-
* @param value The
|
|
76
|
-
* @returns The
|
|
72
|
+
* @param value - The value to clamp
|
|
73
|
+
* @returns The clamped value as an `Int8`
|
|
77
74
|
*/
|
|
78
75
|
clamp,
|
|
79
76
|
/**
|
|
80
|
-
* Returns the absolute value of an
|
|
77
|
+
* Returns the absolute value of an integer in [-128, 127].
|
|
78
|
+
*
|
|
79
|
+
* The result is non-negative and keeps the `Int8` brand.
|
|
81
80
|
*
|
|
82
|
-
* @param
|
|
83
|
-
* @returns The absolute value as
|
|
81
|
+
* @param a - The integer value
|
|
82
|
+
* @returns The absolute value as a non-negative `Int8`
|
|
84
83
|
*/
|
|
85
84
|
abs,
|
|
86
85
|
/**
|
|
87
|
-
* Generates a random Int8
|
|
86
|
+
* Generates a random `Int8` within the given range.
|
|
88
87
|
*
|
|
89
|
-
*
|
|
88
|
+
* The range is inclusive on both ends.
|
|
90
89
|
*
|
|
91
90
|
* @param min - The minimum value (inclusive)
|
|
92
91
|
* @param max - The maximum value (inclusive)
|
|
93
|
-
* @returns A random Int8 in
|
|
92
|
+
* @returns A random `Int8` in `[min, max]`
|
|
94
93
|
*/
|
|
95
94
|
random,
|
|
96
95
|
/**
|
|
97
|
-
* Raises
|
|
96
|
+
* Raises `a` to the power `b`, returning `a ** b` as an `Int8` (floored to an
|
|
97
|
+
* integer).
|
|
98
98
|
*
|
|
99
|
-
* @param
|
|
100
|
-
* @param
|
|
101
|
-
* @returns `
|
|
99
|
+
* @param a - The base integer
|
|
100
|
+
* @param b - The exponent integer
|
|
101
|
+
* @returns `a ** b` as an `Int8`
|
|
102
102
|
*/
|
|
103
103
|
pow,
|
|
104
104
|
/**
|
|
105
|
-
* Adds two
|
|
105
|
+
* Adds two integers, returning `a + b` as an `Int8`.
|
|
106
106
|
*
|
|
107
|
-
* @param
|
|
108
|
-
* @param
|
|
109
|
-
* @returns `
|
|
107
|
+
* @param a - The first integer
|
|
108
|
+
* @param b - The second integer
|
|
109
|
+
* @returns The sum of `a` and `b` as an `Int8`
|
|
110
110
|
*/
|
|
111
111
|
add,
|
|
112
112
|
/**
|
|
113
|
-
* Subtracts two
|
|
113
|
+
* Subtracts two integers, returning `a - b` as an `Int8`.
|
|
114
114
|
*
|
|
115
|
-
* @param
|
|
116
|
-
* @param
|
|
117
|
-
* @returns `
|
|
115
|
+
* @param a - The first integer
|
|
116
|
+
* @param b - The second integer
|
|
117
|
+
* @returns The difference of `a` and `b` as an `Int8`
|
|
118
118
|
*/
|
|
119
119
|
sub,
|
|
120
120
|
/**
|
|
121
|
-
* Multiplies two
|
|
121
|
+
* Multiplies two integers, returning `a * b` as an `Int8`.
|
|
122
122
|
*
|
|
123
|
-
* @param
|
|
124
|
-
* @param
|
|
125
|
-
* @returns `
|
|
123
|
+
* @param a - The first integer
|
|
124
|
+
* @param b - The second integer
|
|
125
|
+
* @returns The product of `a` and `b` as an `Int8`
|
|
126
126
|
*/
|
|
127
127
|
mul,
|
|
128
128
|
/**
|
|
129
|
-
* Divides two
|
|
129
|
+
* Divides two integers using floor division (`⌊a / b⌋`): the result is `a /
|
|
130
|
+
* b` rounded toward negative infinity, as an `Int8`.
|
|
130
131
|
*
|
|
131
|
-
* @param
|
|
132
|
-
* @param
|
|
133
|
-
* @returns
|
|
132
|
+
* @param a - The dividend
|
|
133
|
+
* @param b - The divisor (must be non-zero)
|
|
134
|
+
* @returns The floored quotient as an `Int8`
|
|
134
135
|
*/
|
|
135
136
|
div
|
|
136
137
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"int8.mjs","sources":["../../../src/number/enum/int8.mts"],"sourcesContent":["import {\n type AbsoluteValue,\n type Int16,\n type Int8 as TtfImported_Int8,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type Int8 = TtfImported_Int8;\n\nconst typeNameInMessage = 'an integer in [-128, 127]';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n castType: castTypeImpl,\n clamp: clampImpl,\n is: isImpl,\n random: randomImpl,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n Int16,\n -128,\n 127\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: -128,\n MAX_VALUE: 127,\n typeNameInMessage,\n} as const);\n\nconst is = (x: number): x is Int8 => isImpl(x);\n\nconst castType = (x: number): Int8 =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n castTypeImpl(x) as Int8;\n\nconst clamp = (a: number): Int8 => castType(clampImpl(a));\n\nconst abs = <N extends Int8>(x: N): AbsoluteValue<N> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.abs(x) as unknown as AbsoluteValue<N>;\n\nconst min_ = (...values: readonly Int8[]): Int8 =>\n castType(Math.min(...values));\n\nconst max_ = (...values: readonly Int8[]): Int8 =>\n castType(Math.max(...values));\n\nconst pow = (x: Int8, y: Int8): Int8 => clamp(x ** y);\n\nconst add = (x: Int8, y: Int8): Int8 => clamp(x + y);\n\nconst sub = (x: Int8, y: Int8): Int8 => clamp(x - y);\n\nconst mul = (x: Int8, y: Int8): Int8 => clamp(x * y);\n\nconst div = (x: Int8, y: Exclude<Int8, 0>): Int8 => clamp(Math.floor(x / y));\n\nconst random = (min: Int8, max: Int8): Int8 =>\n castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));\n\n/**\n * Type guard that checks if a value is an
|
|
1
|
+
{"version":3,"file":"int8.mjs","sources":["../../../src/number/enum/int8.mts"],"sourcesContent":["import {\n type AbsoluteValue,\n type Int16,\n type Int8 as TtfImported_Int8,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type Int8 = TtfImported_Int8;\n\nconst typeNameInMessage = 'an integer in [-128, 127]';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n castType: castTypeImpl,\n clamp: clampImpl,\n is: isImpl,\n random: randomImpl,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n Int16,\n -128,\n 127\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: -128,\n MAX_VALUE: 127,\n typeNameInMessage,\n} as const);\n\nconst is = (x: number): x is Int8 => isImpl(x);\n\nconst castType = (x: number): Int8 =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n castTypeImpl(x) as Int8;\n\nconst clamp = (a: number): Int8 => castType(clampImpl(a));\n\nconst abs = <N extends Int8>(x: N): AbsoluteValue<N> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.abs(x) as unknown as AbsoluteValue<N>;\n\nconst min_ = (...values: readonly Int8[]): Int8 =>\n castType(Math.min(...values));\n\nconst max_ = (...values: readonly Int8[]): Int8 =>\n castType(Math.max(...values));\n\nconst pow = (x: Int8, y: Int8): Int8 => clamp(x ** y);\n\nconst add = (x: Int8, y: Int8): Int8 => clamp(x + y);\n\nconst sub = (x: Int8, y: Int8): Int8 => clamp(x - y);\n\nconst mul = (x: Int8, y: Int8): Int8 => clamp(x * y);\n\nconst div = (x: Int8, y: Exclude<Int8, 0>): Int8 => clamp(Math.floor(x / y));\n\nconst random = (min: Int8, max: Int8): Int8 =>\n castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));\n\n/**\n * Type guard that checks if a value is an integer in [-128, 127].\n *\n * Returns `true` for an integer in [-128, 127] — a value with no fractional\n * component.\n *\n * @param value - The value to check\n * @returns `true` if the value is an integer in [-128, 127], `false` otherwise\n */\nexport const isInt8 = is;\n\n/**\n * Casts a `number` to the `Int8` branded type.\n *\n * Validates that the value is an integer in [-128, 127] and returns it with the\n * `Int8` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as an `Int8`\n * @throws {TypeError} If the value is not an integer in [-128, 127]\n */\nexport const asInt8 = castType;\n\n/**\n * Namespace providing type-safe operations for the `Int8` branded type.\n *\n * The `Int8` type represents an integer in [-128, 127]. Division (`div`) uses\n * floor division.\n */\nexport const Int8 = {\n /**\n * Type guard that checks if a value is an integer in [-128, 127].\n *\n * @param value - The value to check\n * @returns `true` if the value is an integer in [-128, 127], `false` otherwise\n * @see {@link isInt8} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `Int8`.\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `Int8`.\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given integers.\n *\n * @param values - The integers to compare (at least one required)\n * @returns The smallest value as an `Int8`\n */\n min: min_,\n\n /**\n * Returns the largest of the given integers.\n *\n * @param values - The integers to compare (at least one required)\n * @returns The largest value as an `Int8`\n */\n max: max_,\n\n /**\n * Clamps a `number` into the `Int8` range, rounding to the nearest integer\n * and constraining the result to `[MIN_VALUE, MAX_VALUE]`.\n *\n * @param value - The value to clamp\n * @returns The clamped value as an `Int8`\n */\n clamp,\n\n /**\n * Returns the absolute value of an integer in [-128, 127].\n *\n * The result is non-negative and keeps the `Int8` brand.\n *\n * @param a - The integer value\n * @returns The absolute value as a non-negative `Int8`\n */\n abs,\n\n /**\n * Generates a random `Int8` within the given range.\n *\n * The range is inclusive on both ends.\n *\n * @param min - The minimum value (inclusive)\n * @param max - The maximum value (inclusive)\n * @returns A random `Int8` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as an `Int8` (floored to an\n * integer).\n *\n * @param a - The base integer\n * @param b - The exponent integer\n * @returns `a ** b` as an `Int8`\n */\n pow,\n\n /**\n * Adds two integers, returning `a + b` as an `Int8`.\n *\n * @param a - The first integer\n * @param b - The second integer\n * @returns The sum of `a` and `b` as an `Int8`\n */\n add,\n\n /**\n * Subtracts two integers, returning `a - b` as an `Int8`.\n *\n * @param a - The first integer\n * @param b - The second integer\n * @returns The difference of `a` and `b` as an `Int8`\n */\n sub,\n\n /**\n * Multiplies two integers, returning `a * b` as an `Int8`.\n *\n * @param a - The first integer\n * @param b - The second integer\n * @returns The product of `a` and `b` as an `Int8`\n */\n mul,\n\n /**\n * Divides two integers using floor division (`⌊a / b⌋`): the result is `a /\n * b` rounded toward negative infinity, as an `Int8`.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as an `Int8`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof Int8,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n Int16,\n 'int' | 'range'\n >\n>('=');\n"],"names":[],"mappings":";;AAUA,MAAM,iBAAA,GAAoB,2BAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA,EAAU,YAAA;AAAA,EACV,KAAA,EAAO,SAAA;AAAA,EACP,EAAA,EAAI,MAAA;AAAA,EACJ,MAAA,EAAQ;AACV,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,SAAA,EAAW,IAAA;AAAA,EACX,SAAA,EAAW,GAAA;AAAA,EACX;AACF,CAAU,CAAA;AAEV,MAAM,EAAA,GAAK,CAAC,CAAA,KAAyB,MAAA,CAAO,CAAC,CAAA;AAE7C,MAAM,WAAW,CAAC,CAAA;AAAA;AAAA,EAEhB,aAAa,CAAC;AAAA,CAAA;AAEhB,MAAM,QAAQ,CAAC,CAAA,KAAoB,QAAA,CAAS,SAAA,CAAU,CAAC,CAAC,CAAA;AAExD,MAAM,MAAM,CAAiB,CAAA;AAAA;AAAA,EAE3B,IAAA,CAAK,IAAI,CAAC;AAAA,CAAA;AAEZ,MAAM,IAAA,GAAO,IAAI,MAAA,KACf,QAAA,CAAS,KAAK,GAAA,CAAI,GAAG,MAAM,CAAC,CAAA;AAE9B,MAAM,IAAA,GAAO,IAAI,MAAA,KACf,QAAA,CAAS,KAAK,GAAA,CAAI,GAAG,MAAM,CAAC,CAAA;AAE9B,MAAM,MAAM,CAAC,CAAA,EAAS,CAAA,KAAkB,KAAA,CAAM,KAAK,CAAC,CAAA;AAEpD,MAAM,MAAM,CAAC,CAAA,EAAS,CAAA,KAAkB,KAAA,CAAM,IAAI,CAAC,CAAA;AAEnD,MAAM,MAAM,CAAC,CAAA,EAAS,CAAA,KAAkB,KAAA,CAAM,IAAI,CAAC,CAAA;AAEnD,MAAM,MAAM,CAAC,CAAA,EAAS,CAAA,KAAkB,KAAA,CAAM,IAAI,CAAC,CAAA;AAEnD,MAAM,GAAA,GAAM,CAAC,CAAA,EAAS,CAAA,KAA8B,MAAM,IAAA,CAAK,KAAA,CAAM,CAAA,GAAI,CAAC,CAAC,CAAA;AAE3E,MAAM,MAAA,GAAS,CAAC,GAAA,EAAW,GAAA,KACzB,QAAA,CAAS,UAAA,CAAW,YAAA,CAAa,GAAG,CAAA,EAAG,YAAA,CAAa,GAAG,CAAC,CAAC,CAAA;AAWpD,MAAM,MAAA,GAAS;AAYf,MAAM,MAAA,GAAS;AAQf,MAAM,IAAA,GAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlB,EAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AACF;;;;"}
|