ts-data-forge 11.0.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- 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 +71 -59
- package/dist/number/branded-types/int16.d.mts.map +1 -1
- package/dist/number/branded-types/int16.mjs +56 -47
- package/dist/number/branded-types/int16.mjs.map +1 -1
- package/dist/number/branded-types/int32.d.mts +71 -59
- package/dist/number/branded-types/int32.d.mts.map +1 -1
- package/dist/number/branded-types/int32.mjs +56 -47
- package/dist/number/branded-types/int32.mjs.map +1 -1
- package/dist/number/branded-types/negative-finite-number.d.mts +76 -60
- package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/negative-finite-number.mjs +62 -49
- package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/negative-int.d.mts +66 -49
- package/dist/number/branded-types/negative-int.d.mts.map +1 -1
- package/dist/number/branded-types/negative-int.mjs +48 -39
- package/dist/number/branded-types/negative-int.mjs.map +1 -1
- package/dist/number/branded-types/negative-safe-int.d.mts +64 -57
- package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/negative-safe-int.mjs +49 -44
- package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.d.mts +80 -65
- package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.mjs +65 -53
- package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int16.d.mts +71 -58
- package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-int16.mjs +55 -45
- package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int32.d.mts +71 -59
- package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-int32.mjs +55 -46
- package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-finite-number.d.mts +70 -55
- package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-finite-number.mjs +55 -43
- package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-int.d.mts +46 -146
- package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-int.mjs +33 -108
- package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-safe-int.d.mts +62 -54
- package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-safe-int.mjs +46 -41
- 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 +59 -54
- package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int16.mjs +44 -41
- package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int32.d.mts +59 -55
- package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int32.mjs +44 -42
- package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.d.mts +60 -55
- package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs +44 -42
- package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.d.mts +59 -54
- package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.mjs +43 -41
- package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.d.mts +59 -54
- package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.mjs +43 -41
- package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
- package/dist/number/branded-types/positive-finite-number.d.mts +82 -64
- package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/positive-finite-number.mjs +67 -52
- package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/positive-int.d.mts +53 -70
- package/dist/number/branded-types/positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int.mjs +42 -52
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-int16.d.mts +68 -58
- package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int16.mjs +52 -45
- package/dist/number/branded-types/positive-int16.mjs.map +1 -1
- package/dist/number/branded-types/positive-int32.d.mts +68 -58
- package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int32.mjs +52 -45
- package/dist/number/branded-types/positive-int32.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.d.mts +72 -61
- package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs +56 -48
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint16.d.mts +68 -58
- package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint16.mjs +52 -45
- package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint32.d.mts +68 -59
- package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint32.mjs +52 -46
- package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.d.mts +52 -66
- package/dist/number/branded-types/safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/safe-int.mjs +45 -47
- package/dist/number/branded-types/safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-uint.d.mts +68 -58
- package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
- package/dist/number/branded-types/safe-uint.mjs +53 -46
- package/dist/number/branded-types/safe-uint.mjs.map +1 -1
- package/dist/number/branded-types/uint.d.mts +72 -55
- package/dist/number/branded-types/uint.d.mts.map +1 -1
- package/dist/number/branded-types/uint.mjs +52 -45
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/branded-types/uint16.d.mts +66 -59
- package/dist/number/branded-types/uint16.d.mts.map +1 -1
- package/dist/number/branded-types/uint16.mjs +51 -45
- package/dist/number/branded-types/uint16.mjs.map +1 -1
- package/dist/number/branded-types/uint32.d.mts +66 -57
- package/dist/number/branded-types/uint32.d.mts.map +1 -1
- package/dist/number/branded-types/uint32.mjs +50 -45
- package/dist/number/branded-types/uint32.mjs.map +1 -1
- package/dist/number/enum/int8.d.mts +62 -66
- package/dist/number/enum/int8.d.mts.map +1 -1
- package/dist/number/enum/int8.mjs +57 -51
- package/dist/number/enum/int8.mjs.map +1 -1
- package/dist/number/enum/uint8.d.mts +66 -59
- package/dist/number/enum/uint8.d.mts.map +1 -1
- package/dist/number/enum/uint8.mjs +57 -51
- package/dist/number/enum/uint8.mjs.map +1 -1
- package/dist/number/refined-number-utils.d.mts +9 -9
- package/dist/number/refined-number-utils.d.mts.map +1 -1
- package/dist/number/refined-number-utils.mjs +7 -7
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/package.json +2 -1
- 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 +72 -60
- package/src/number/branded-types/int32.mts +72 -60
- package/src/number/branded-types/negative-finite-number.mts +78 -71
- package/src/number/branded-types/negative-finite-number.test.mts +4 -4
- package/src/number/branded-types/negative-int.mts +68 -60
- package/src/number/branded-types/negative-int.test.mts +5 -5
- package/src/number/branded-types/negative-safe-int.mts +66 -68
- package/src/number/branded-types/negative-safe-int.test.mts +4 -4
- package/src/number/branded-types/non-negative-finite-number.mts +81 -66
- package/src/number/branded-types/non-negative-int16.mts +72 -59
- package/src/number/branded-types/non-negative-int32.mts +72 -60
- package/src/number/branded-types/non-positive-finite-number.mts +71 -56
- package/src/number/branded-types/non-positive-finite-number.test.mts +7 -7
- package/src/number/branded-types/non-positive-int.mts +47 -147
- package/src/number/branded-types/non-positive-int.test.mts +7 -7
- package/src/number/branded-types/non-positive-safe-int.mts +63 -55
- package/src/number/branded-types/non-positive-safe-int.test.mts +7 -7
- 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 +60 -55
- package/src/number/branded-types/non-zero-int32.mts +60 -56
- package/src/number/branded-types/non-zero-safe-int.mts +61 -56
- package/src/number/branded-types/non-zero-uint16.mts +60 -55
- package/src/number/branded-types/non-zero-uint32.mts +60 -55
- package/src/number/branded-types/positive-finite-number.mts +83 -65
- package/src/number/branded-types/positive-int.mts +54 -71
- package/src/number/branded-types/positive-int16.mts +69 -59
- package/src/number/branded-types/positive-int32.mts +69 -59
- package/src/number/branded-types/positive-safe-int.mts +73 -62
- package/src/number/branded-types/positive-uint16.mts +69 -59
- package/src/number/branded-types/positive-uint32.mts +69 -60
- package/src/number/branded-types/safe-int.mts +53 -67
- package/src/number/branded-types/safe-uint.mts +69 -59
- package/src/number/branded-types/uint.mts +73 -56
- package/src/number/branded-types/uint16.mts +67 -60
- package/src/number/branded-types/uint32.mts +67 -58
- package/src/number/enum/int8.mts +70 -73
- package/src/number/enum/int8.test.mts +7 -4
- package/src/number/enum/uint8.mts +74 -66
- package/src/number/enum/uint8.test.mts +7 -4
- package/src/number/refined-number-utils.mts +22 -19
|
@@ -6,8 +6,8 @@ const {
|
|
|
6
6
|
MIN_VALUE,
|
|
7
7
|
add,
|
|
8
8
|
castType,
|
|
9
|
-
clamp,
|
|
10
9
|
div,
|
|
10
|
+
fromNumber,
|
|
11
11
|
is,
|
|
12
12
|
max: max_,
|
|
13
13
|
min: min_,
|
|
@@ -25,93 +25,98 @@ 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` (the lower saturation target
|
|
37
|
+
* of `fromNumber`).
|
|
39
38
|
*/
|
|
40
39
|
MIN_VALUE,
|
|
41
40
|
/**
|
|
42
|
-
* The
|
|
43
|
-
*
|
|
44
|
-
* @readonly
|
|
41
|
+
* The largest value representable as `Uint32` (the upper saturation target of
|
|
42
|
+
* `fromNumber`).
|
|
45
43
|
*/
|
|
46
44
|
MAX_VALUE,
|
|
47
45
|
/**
|
|
48
|
-
* Returns the
|
|
46
|
+
* Returns the smallest of the given non-negative integers.
|
|
49
47
|
*
|
|
50
|
-
* @param values - The
|
|
51
|
-
* @returns The smallest value as
|
|
48
|
+
* @param values - The non-negative integers to compare (at least one required)
|
|
49
|
+
* @returns The smallest value as an `Uint32`
|
|
52
50
|
*/
|
|
53
51
|
min: min_,
|
|
54
52
|
/**
|
|
55
|
-
* Returns the
|
|
53
|
+
* Returns the largest of the given non-negative integers.
|
|
56
54
|
*
|
|
57
|
-
* @param values - The
|
|
58
|
-
* @returns The largest value as
|
|
55
|
+
* @param values - The non-negative integers to compare (at least one required)
|
|
56
|
+
* @returns The largest value as an `Uint32`
|
|
59
57
|
*/
|
|
60
58
|
max: max_,
|
|
61
59
|
/**
|
|
62
|
-
*
|
|
60
|
+
* Converts an arbitrary `number` into an `Uint32`, rounding to the nearest
|
|
61
|
+
* integer and saturating the result into the range `[MIN_VALUE, MAX_VALUE]`.
|
|
63
62
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* @
|
|
63
|
+
* Unlike `asUint32`, this is total: out-of-range inputs are clamped to the
|
|
64
|
+
* nearest representable `Uint32` instead of throwing.
|
|
65
|
+
*
|
|
66
|
+
* @param value - The value to convert
|
|
67
|
+
* @returns The value as an `Uint32`
|
|
68
68
|
*/
|
|
69
|
-
|
|
69
|
+
fromNumber,
|
|
70
70
|
/**
|
|
71
|
-
* Generates a random Uint32
|
|
71
|
+
* Generates a random `Uint32` within the given range.
|
|
72
|
+
*
|
|
73
|
+
* The range is inclusive on both ends.
|
|
72
74
|
*
|
|
73
|
-
* @
|
|
75
|
+
* @param min - The minimum value (inclusive)
|
|
76
|
+
* @param max - The maximum value (inclusive)
|
|
77
|
+
* @returns A random `Uint32` in `[min, max]`
|
|
74
78
|
*/
|
|
75
79
|
random,
|
|
76
80
|
/**
|
|
77
|
-
* Raises a
|
|
81
|
+
* Raises `a` to the power `b`, returning `a ** b` as an `Uint32` (floored to
|
|
82
|
+
* an integer).
|
|
78
83
|
*
|
|
79
|
-
* @param a - The base
|
|
80
|
-
* @param b - The exponent
|
|
81
|
-
* @returns `a ** b` as
|
|
84
|
+
* @param a - The base non-negative integer
|
|
85
|
+
* @param b - The exponent non-negative integer
|
|
86
|
+
* @returns `a ** b` as an `Uint32`
|
|
82
87
|
*/
|
|
83
88
|
pow,
|
|
84
89
|
/**
|
|
85
|
-
* Adds two
|
|
90
|
+
* Adds two non-negative integers, returning `a + b` as an `Uint32`.
|
|
86
91
|
*
|
|
87
|
-
* @param a -
|
|
88
|
-
* @param b -
|
|
89
|
-
* @returns `a
|
|
92
|
+
* @param a - The first non-negative integer
|
|
93
|
+
* @param b - The second non-negative integer
|
|
94
|
+
* @returns The sum of `a` and `b` as an `Uint32`
|
|
90
95
|
*/
|
|
91
96
|
add,
|
|
92
97
|
/**
|
|
93
|
-
* Subtracts two
|
|
98
|
+
* Subtracts two non-negative integers, returning `a - b` as an `Uint32`.
|
|
94
99
|
*
|
|
95
|
-
* @param a -
|
|
96
|
-
* @param b -
|
|
97
|
-
* @returns `a
|
|
100
|
+
* @param a - The first non-negative integer
|
|
101
|
+
* @param b - The second non-negative integer
|
|
102
|
+
* @returns The difference of `a` and `b` as an `Uint32`
|
|
98
103
|
*/
|
|
99
104
|
sub,
|
|
100
105
|
/**
|
|
101
|
-
* Multiplies two
|
|
106
|
+
* Multiplies two non-negative integers, returning `a * b` as an `Uint32`.
|
|
102
107
|
*
|
|
103
|
-
* @param a -
|
|
104
|
-
* @param b -
|
|
105
|
-
* @returns `a
|
|
108
|
+
* @param a - The first non-negative integer
|
|
109
|
+
* @param b - The second non-negative integer
|
|
110
|
+
* @returns The product of `a` and `b` as an `Uint32`
|
|
106
111
|
*/
|
|
107
112
|
mul,
|
|
108
113
|
/**
|
|
109
|
-
* Divides two
|
|
110
|
-
*
|
|
114
|
+
* Divides two non-negative integers using floor division (`⌊a / b⌋`): the
|
|
115
|
+
* result is `a / b` rounded toward negative infinity, as an `Uint32`.
|
|
111
116
|
*
|
|
112
|
-
* @param a - The dividend
|
|
113
|
-
* @param b - The divisor
|
|
114
|
-
* @returns
|
|
117
|
+
* @param a - The dividend
|
|
118
|
+
* @param b - The divisor (must be non-zero)
|
|
119
|
+
* @returns The floored quotient as an `Uint32`
|
|
115
120
|
*/
|
|
116
121
|
div
|
|
117
122
|
};
|
|
@@ -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
|
|
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 div,\n fromNumber,\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` (the lower saturation target\n * of `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `Uint32` (the upper saturation target of\n * `fromNumber`).\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 * Converts an arbitrary `number` into an `Uint32`, rounding to the nearest\n * integer and saturating the result into the range `[MIN_VALUE, MAX_VALUE]`.\n *\n * Unlike `asUint32`, this is total: out-of-range inputs are clamped to the\n * nearest representable `Uint32` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as an `Uint32`\n */\n fromNumber,\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,GAAA;AAAA,EACA,UAAA;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;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,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;AAAA;AAAA;AAAA,EAYL,UAAA;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,135 @@
|
|
|
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` (the lower saturation target of
|
|
41
|
+
* `fromNumber`).
|
|
53
42
|
*/
|
|
54
43
|
readonly MIN_VALUE: -128;
|
|
55
44
|
/**
|
|
56
|
-
* The
|
|
57
|
-
*
|
|
58
|
-
* @readonly
|
|
45
|
+
* The largest value representable as `Int8` (the upper saturation target of
|
|
46
|
+
* `fromNumber`).
|
|
59
47
|
*/
|
|
60
48
|
readonly MAX_VALUE: 127;
|
|
61
49
|
/**
|
|
62
|
-
* Returns the
|
|
50
|
+
* Returns the smallest of the given integers.
|
|
63
51
|
*
|
|
64
|
-
* @param values - The
|
|
65
|
-
* @returns The smallest value as an Int8
|
|
52
|
+
* @param values - The integers to compare (at least one required)
|
|
53
|
+
* @returns The smallest value as an `Int8`
|
|
66
54
|
*/
|
|
67
55
|
readonly min: (...values: readonly Int8[]) => Int8;
|
|
68
56
|
/**
|
|
69
|
-
* Returns the
|
|
57
|
+
* Returns the largest of the given integers.
|
|
70
58
|
*
|
|
71
|
-
* @param values - The
|
|
72
|
-
* @returns The largest value as an Int8
|
|
59
|
+
* @param values - The integers to compare (at least one required)
|
|
60
|
+
* @returns The largest value as an `Int8`
|
|
73
61
|
*/
|
|
74
62
|
readonly max: (...values: readonly Int8[]) => Int8;
|
|
75
63
|
/**
|
|
76
|
-
*
|
|
64
|
+
* Converts an arbitrary `number` into an `Int8`, rounding to the nearest
|
|
65
|
+
* integer and saturating the result into the range `[MIN_VALUE, MAX_VALUE]`.
|
|
66
|
+
*
|
|
67
|
+
* Unlike `asInt8`, this is total: out-of-range inputs are clamped to the
|
|
68
|
+
* nearest representable `Int8` instead of throwing.
|
|
77
69
|
*
|
|
78
|
-
* @param value The
|
|
79
|
-
* @returns The value
|
|
70
|
+
* @param value - The value to convert
|
|
71
|
+
* @returns The value as an `Int8`
|
|
80
72
|
*/
|
|
81
|
-
readonly
|
|
73
|
+
readonly fromNumber: (a: number) => Int8;
|
|
82
74
|
/**
|
|
83
|
-
* Returns the absolute value of an
|
|
75
|
+
* Returns the absolute value of an integer in [-128, 127].
|
|
76
|
+
*
|
|
77
|
+
* The result is non-negative and keeps the `Int8` brand.
|
|
84
78
|
*
|
|
85
|
-
* @param
|
|
86
|
-
* @returns The absolute value as
|
|
79
|
+
* @param a - The integer value
|
|
80
|
+
* @returns The absolute value as a non-negative `Int8`
|
|
87
81
|
*/
|
|
88
82
|
readonly abs: <N extends Int8>(x: N) => AbsoluteValue<N>;
|
|
89
83
|
/**
|
|
90
|
-
* Generates a random Int8
|
|
84
|
+
* Generates a random `Int8` within the given range.
|
|
91
85
|
*
|
|
92
|
-
*
|
|
86
|
+
* The range is inclusive on both ends.
|
|
93
87
|
*
|
|
94
88
|
* @param min - The minimum value (inclusive)
|
|
95
89
|
* @param max - The maximum value (inclusive)
|
|
96
|
-
* @returns A random Int8 in
|
|
90
|
+
* @returns A random `Int8` in `[min, max]`
|
|
97
91
|
*/
|
|
98
92
|
readonly random: (min: Int8, max: Int8) => Int8;
|
|
99
93
|
/**
|
|
100
|
-
* Raises
|
|
94
|
+
* Raises `a` to the power `b`, returning `a ** b` as an `Int8` (floored to an
|
|
95
|
+
* integer).
|
|
101
96
|
*
|
|
102
|
-
* @param
|
|
103
|
-
* @param
|
|
104
|
-
* @returns `
|
|
97
|
+
* @param a - The base integer
|
|
98
|
+
* @param b - The exponent integer
|
|
99
|
+
* @returns `a ** b` as an `Int8`
|
|
105
100
|
*/
|
|
106
101
|
readonly pow: (x: Int8, y: Int8) => Int8;
|
|
107
102
|
/**
|
|
108
|
-
* Adds two
|
|
103
|
+
* Adds two integers, returning `a + b` as an `Int8`.
|
|
109
104
|
*
|
|
110
|
-
* @param
|
|
111
|
-
* @param
|
|
112
|
-
* @returns `
|
|
105
|
+
* @param a - The first integer
|
|
106
|
+
* @param b - The second integer
|
|
107
|
+
* @returns The sum of `a` and `b` as an `Int8`
|
|
113
108
|
*/
|
|
114
109
|
readonly add: (x: Int8, y: Int8) => Int8;
|
|
115
110
|
/**
|
|
116
|
-
* Subtracts two
|
|
111
|
+
* Subtracts two integers, returning `a - b` as an `Int8`.
|
|
117
112
|
*
|
|
118
|
-
* @param
|
|
119
|
-
* @param
|
|
120
|
-
* @returns `
|
|
113
|
+
* @param a - The first integer
|
|
114
|
+
* @param b - The second integer
|
|
115
|
+
* @returns The difference of `a` and `b` as an `Int8`
|
|
121
116
|
*/
|
|
122
117
|
readonly sub: (x: Int8, y: Int8) => Int8;
|
|
123
118
|
/**
|
|
124
|
-
* Multiplies two
|
|
119
|
+
* Multiplies two integers, returning `a * b` as an `Int8`.
|
|
125
120
|
*
|
|
126
|
-
* @param
|
|
127
|
-
* @param
|
|
128
|
-
* @returns `
|
|
121
|
+
* @param a - The first integer
|
|
122
|
+
* @param b - The second integer
|
|
123
|
+
* @returns The product of `a` and `b` as an `Int8`
|
|
129
124
|
*/
|
|
130
125
|
readonly mul: (x: Int8, y: Int8) => Int8;
|
|
131
126
|
/**
|
|
132
|
-
* Divides two
|
|
127
|
+
* Divides two integers using floor division (`⌊a / b⌋`): the result is `a /
|
|
128
|
+
* b` rounded toward negative infinity, as an `Int8`.
|
|
133
129
|
*
|
|
134
|
-
* @param
|
|
135
|
-
* @param
|
|
136
|
-
* @returns
|
|
130
|
+
* @param a - The dividend
|
|
131
|
+
* @param b - The divisor (must be non-zero)
|
|
132
|
+
* @returns The floored quotient as an `Int8`
|
|
137
133
|
*/
|
|
138
134
|
readonly div: (x: Int8, y: Exclude<Int8, 0>) => Int8;
|
|
139
135
|
};
|
|
@@ -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;
|
|
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;AAsDpC;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,MAzCJ,MAAM,KAAG,CAAC,IAAI,IAyCL,CAAC;AAEzB;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,MAnDE,MAAM,KAAG,IAmDA,CAAC;AAE/B;;;;;GAKG;AACH,eAAO,MAAM,IAAI;IACf;;;;;;OAMG;qBApEU,MAAM,KAAG,CAAC,IAAI,IAAI;IAuE/B;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;8BA5EoB,SAAS,IAAI,EAAE,KAAG,IAAI;IA+E7C;;;;;OAKG;8BAjFoB,SAAS,IAAI,EAAE,KAAG,IAAI;IAoF7C;;;;;;;;;OASG;6BAtGkB,MAAM,KAAG,IAAI;IAyGlC;;;;;;;OAOG;mBA9GQ,CAAC,SAAS,IAAI,KAAK,CAAC,KAAG,aAAa,CAAC,CAAC,CAAC;IAiHlD;;;;;;;;OAQG;2BApGgB,IAAI,OAAO,IAAI,KAAG,IAAI;IAuGzC;;;;;;;OAOG;sBAzHW,IAAI,KAAK,IAAI,KAAG,IAAI;IA4HlC;;;;;;OAMG;sBAhIW,IAAI,KAAK,IAAI,KAAG,IAAI;IAmIlC;;;;;;OAMG;sBAvIW,IAAI,KAAK,IAAI,KAAG,IAAI;IA0IlC;;;;;;OAMG;sBA9IW,IAAI,KAAK,IAAI,KAAG,IAAI;IAiJlC;;;;;;;OAOG;sBAtJW,IAAI,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,KAAG,IAAI;CAwJtC,CAAC"}
|
|
@@ -5,7 +5,7 @@ const {
|
|
|
5
5
|
MAX_VALUE,
|
|
6
6
|
MIN_VALUE,
|
|
7
7
|
castType: castTypeImpl,
|
|
8
|
-
|
|
8
|
+
fromNumber: fromNumberImpl,
|
|
9
9
|
is: isImpl,
|
|
10
10
|
random: randomImpl
|
|
11
11
|
} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger({
|
|
@@ -19,118 +19,124 @@ const castType = (x) => (
|
|
|
19
19
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
20
20
|
castTypeImpl(x)
|
|
21
21
|
);
|
|
22
|
-
const
|
|
22
|
+
const fromNumber = (a) => castType(fromNumberImpl(a));
|
|
23
23
|
const abs = (x) => (
|
|
24
24
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
25
25
|
Math.abs(x)
|
|
26
26
|
);
|
|
27
27
|
const min_ = (...values) => castType(Math.min(...values));
|
|
28
28
|
const max_ = (...values) => castType(Math.max(...values));
|
|
29
|
-
const pow = (x, y) =>
|
|
30
|
-
const add = (x, y) =>
|
|
31
|
-
const sub = (x, y) =>
|
|
32
|
-
const mul = (x, y) =>
|
|
33
|
-
const div = (x, y) =>
|
|
29
|
+
const pow = (x, y) => fromNumber(x ** y);
|
|
30
|
+
const add = (x, y) => fromNumber(x + y);
|
|
31
|
+
const sub = (x, y) => fromNumber(x - y);
|
|
32
|
+
const mul = (x, y) => fromNumber(x * y);
|
|
33
|
+
const div = (x, y) => fromNumber(Math.floor(x / y));
|
|
34
34
|
const random = (min, max) => castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));
|
|
35
35
|
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` (the lower saturation target of
|
|
48
|
+
* `fromNumber`).
|
|
50
49
|
*/
|
|
51
50
|
MIN_VALUE,
|
|
52
51
|
/**
|
|
53
|
-
* The
|
|
54
|
-
*
|
|
55
|
-
* @readonly
|
|
52
|
+
* The largest value representable as `Int8` (the upper saturation target of
|
|
53
|
+
* `fromNumber`).
|
|
56
54
|
*/
|
|
57
55
|
MAX_VALUE,
|
|
58
56
|
/**
|
|
59
|
-
* Returns the
|
|
57
|
+
* Returns the smallest of the given integers.
|
|
60
58
|
*
|
|
61
|
-
* @param values - The
|
|
62
|
-
* @returns The smallest value as an Int8
|
|
59
|
+
* @param values - The integers to compare (at least one required)
|
|
60
|
+
* @returns The smallest value as an `Int8`
|
|
63
61
|
*/
|
|
64
62
|
min: min_,
|
|
65
63
|
/**
|
|
66
|
-
* Returns the
|
|
64
|
+
* Returns the largest of the given integers.
|
|
67
65
|
*
|
|
68
|
-
* @param values - The
|
|
69
|
-
* @returns The largest value as an Int8
|
|
66
|
+
* @param values - The integers to compare (at least one required)
|
|
67
|
+
* @returns The largest value as an `Int8`
|
|
70
68
|
*/
|
|
71
69
|
max: max_,
|
|
72
70
|
/**
|
|
73
|
-
*
|
|
71
|
+
* Converts an arbitrary `number` into an `Int8`, rounding to the nearest
|
|
72
|
+
* integer and saturating the result into the range `[MIN_VALUE, MAX_VALUE]`.
|
|
74
73
|
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
74
|
+
* Unlike `asInt8`, this is total: out-of-range inputs are clamped to the
|
|
75
|
+
* nearest representable `Int8` instead of throwing.
|
|
76
|
+
*
|
|
77
|
+
* @param value - The value to convert
|
|
78
|
+
* @returns The value as an `Int8`
|
|
77
79
|
*/
|
|
78
|
-
|
|
80
|
+
fromNumber,
|
|
79
81
|
/**
|
|
80
|
-
* Returns the absolute value of an
|
|
82
|
+
* Returns the absolute value of an integer in [-128, 127].
|
|
83
|
+
*
|
|
84
|
+
* The result is non-negative and keeps the `Int8` brand.
|
|
81
85
|
*
|
|
82
|
-
* @param
|
|
83
|
-
* @returns The absolute value as
|
|
86
|
+
* @param a - The integer value
|
|
87
|
+
* @returns The absolute value as a non-negative `Int8`
|
|
84
88
|
*/
|
|
85
89
|
abs,
|
|
86
90
|
/**
|
|
87
|
-
* Generates a random Int8
|
|
91
|
+
* Generates a random `Int8` within the given range.
|
|
88
92
|
*
|
|
89
|
-
*
|
|
93
|
+
* The range is inclusive on both ends.
|
|
90
94
|
*
|
|
91
95
|
* @param min - The minimum value (inclusive)
|
|
92
96
|
* @param max - The maximum value (inclusive)
|
|
93
|
-
* @returns A random Int8 in
|
|
97
|
+
* @returns A random `Int8` in `[min, max]`
|
|
94
98
|
*/
|
|
95
99
|
random,
|
|
96
100
|
/**
|
|
97
|
-
* Raises
|
|
101
|
+
* Raises `a` to the power `b`, returning `a ** b` as an `Int8` (floored to an
|
|
102
|
+
* integer).
|
|
98
103
|
*
|
|
99
|
-
* @param
|
|
100
|
-
* @param
|
|
101
|
-
* @returns `
|
|
104
|
+
* @param a - The base integer
|
|
105
|
+
* @param b - The exponent integer
|
|
106
|
+
* @returns `a ** b` as an `Int8`
|
|
102
107
|
*/
|
|
103
108
|
pow,
|
|
104
109
|
/**
|
|
105
|
-
* Adds two
|
|
110
|
+
* Adds two integers, returning `a + b` as an `Int8`.
|
|
106
111
|
*
|
|
107
|
-
* @param
|
|
108
|
-
* @param
|
|
109
|
-
* @returns `
|
|
112
|
+
* @param a - The first integer
|
|
113
|
+
* @param b - The second integer
|
|
114
|
+
* @returns The sum of `a` and `b` as an `Int8`
|
|
110
115
|
*/
|
|
111
116
|
add,
|
|
112
117
|
/**
|
|
113
|
-
* Subtracts two
|
|
118
|
+
* Subtracts two integers, returning `a - b` as an `Int8`.
|
|
114
119
|
*
|
|
115
|
-
* @param
|
|
116
|
-
* @param
|
|
117
|
-
* @returns `
|
|
120
|
+
* @param a - The first integer
|
|
121
|
+
* @param b - The second integer
|
|
122
|
+
* @returns The difference of `a` and `b` as an `Int8`
|
|
118
123
|
*/
|
|
119
124
|
sub,
|
|
120
125
|
/**
|
|
121
|
-
* Multiplies two
|
|
126
|
+
* Multiplies two integers, returning `a * b` as an `Int8`.
|
|
122
127
|
*
|
|
123
|
-
* @param
|
|
124
|
-
* @param
|
|
125
|
-
* @returns `
|
|
128
|
+
* @param a - The first integer
|
|
129
|
+
* @param b - The second integer
|
|
130
|
+
* @returns The product of `a` and `b` as an `Int8`
|
|
126
131
|
*/
|
|
127
132
|
mul,
|
|
128
133
|
/**
|
|
129
|
-
* Divides two
|
|
134
|
+
* Divides two integers using floor division (`⌊a / b⌋`): the result is `a /
|
|
135
|
+
* b` rounded toward negative infinity, as an `Int8`.
|
|
130
136
|
*
|
|
131
|
-
* @param
|
|
132
|
-
* @param
|
|
133
|
-
* @returns
|
|
137
|
+
* @param a - The dividend
|
|
138
|
+
* @param b - The divisor (must be non-zero)
|
|
139
|
+
* @returns The floored quotient as an `Int8`
|
|
134
140
|
*/
|
|
135
141
|
div
|
|
136
142
|
};
|