ts-data-forge 11.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/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/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 +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
|
@@ -1,119 +1,121 @@
|
|
|
1
1
|
import { type Uint8 as TtfImported_Uint8 } from 'ts-type-forge';
|
|
2
2
|
export type Uint8 = TtfImported_Uint8;
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Type guard that checks if a value is an non-negative integer less than 256.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Returns `true` for an non-negative integer less than 256 — a value with no
|
|
7
|
+
* fractional component.
|
|
8
|
+
*
|
|
9
|
+
* @param value - The value to check
|
|
10
|
+
* @returns `true` if the value is an non-negative integer less than 256, `false` otherwise
|
|
8
11
|
*/
|
|
9
12
|
export declare const isUint8: (x: number) => x is Uint8;
|
|
10
13
|
/**
|
|
11
|
-
* Casts a number to
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
+
* Casts a `number` to the `Uint8` branded type.
|
|
15
|
+
*
|
|
16
|
+
* Validates that the value is an non-negative integer less than 256 and returns
|
|
17
|
+
* it with the `Uint8` brand. Throws a `TypeError` otherwise.
|
|
14
18
|
*
|
|
15
|
-
* @param value The value to cast
|
|
16
|
-
* @returns The value as
|
|
17
|
-
* @throws {TypeError} If the value is not
|
|
19
|
+
* @param value - The value to cast
|
|
20
|
+
* @returns The value as an `Uint8`
|
|
21
|
+
* @throws {TypeError} If the value is not an non-negative integer less than 256
|
|
18
22
|
*/
|
|
19
23
|
export declare const asUint8: (x: number) => Uint8;
|
|
20
24
|
/**
|
|
21
|
-
* Namespace providing type-safe
|
|
22
|
-
* integers.
|
|
25
|
+
* Namespace providing type-safe operations for the `Uint8` branded type.
|
|
23
26
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* constraint, with negative results clamped to 0 and overflow results clamped
|
|
27
|
-
* to MAX_VALUE.
|
|
27
|
+
* The `Uint8` type represents an non-negative integer less than 256. Division
|
|
28
|
+
* (`div`) uses floor division.
|
|
28
29
|
*/
|
|
29
30
|
export declare const Uint8: {
|
|
30
31
|
/**
|
|
31
|
-
* Type guard that checks if a value is an
|
|
32
|
+
* Type guard that checks if a value is an non-negative integer less than 256.
|
|
32
33
|
*
|
|
33
|
-
* @param value The value to check
|
|
34
|
-
* @returns `true` if the value is an
|
|
35
|
-
*
|
|
34
|
+
* @param value - The value to check
|
|
35
|
+
* @returns `true` if the value is an non-negative integer less than 256, `false` otherwise
|
|
36
|
+
* @see {@link isUint8} for usage examples
|
|
36
37
|
*/
|
|
37
38
|
readonly is: (x: number) => x is Uint8;
|
|
38
39
|
/**
|
|
39
|
-
* The
|
|
40
|
-
*
|
|
41
|
-
* @readonly
|
|
40
|
+
* The smallest value representable as `Uint8`.
|
|
42
41
|
*/
|
|
43
42
|
readonly MIN_VALUE: 0;
|
|
44
43
|
/**
|
|
45
|
-
* The
|
|
46
|
-
*
|
|
47
|
-
* @readonly
|
|
44
|
+
* The largest value representable as `Uint8`.
|
|
48
45
|
*/
|
|
49
46
|
readonly MAX_VALUE: 255;
|
|
50
47
|
/**
|
|
51
|
-
* Returns the
|
|
48
|
+
* Returns the largest of the given non-negative integers.
|
|
52
49
|
*
|
|
53
|
-
* @param values The
|
|
54
|
-
* @returns The
|
|
50
|
+
* @param values - The non-negative integers to compare (at least one required)
|
|
51
|
+
* @returns The largest value as an `Uint8`
|
|
55
52
|
*/
|
|
56
53
|
readonly max: (...values: readonly Uint8[]) => Uint8;
|
|
57
54
|
/**
|
|
58
|
-
* Returns the
|
|
55
|
+
* Returns the smallest of the given non-negative integers.
|
|
59
56
|
*
|
|
60
|
-
* @param values The
|
|
61
|
-
* @returns The
|
|
57
|
+
* @param values - The non-negative integers to compare (at least one required)
|
|
58
|
+
* @returns The smallest value as an `Uint8`
|
|
62
59
|
*/
|
|
63
60
|
readonly min: (...values: readonly Uint8[]) => Uint8;
|
|
64
61
|
/**
|
|
65
|
-
* Clamps a number
|
|
62
|
+
* Clamps a `number` into the `Uint8` range, rounding to the nearest integer
|
|
63
|
+
* and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
|
|
66
64
|
*
|
|
67
|
-
* @param value The
|
|
68
|
-
* @returns The
|
|
65
|
+
* @param value - The value to clamp
|
|
66
|
+
* @returns The clamped value as an `Uint8`
|
|
69
67
|
*/
|
|
70
68
|
readonly clamp: (a: number) => Uint8;
|
|
71
69
|
/**
|
|
72
|
-
* Generates a random Uint8
|
|
70
|
+
* Generates a random `Uint8` within the given range.
|
|
71
|
+
*
|
|
72
|
+
* The range is inclusive on both ends.
|
|
73
73
|
*
|
|
74
|
-
* @param min The minimum value (inclusive)
|
|
75
|
-
* @param max The maximum value (inclusive)
|
|
76
|
-
* @returns A random Uint8
|
|
74
|
+
* @param min - The minimum value (inclusive)
|
|
75
|
+
* @param max - The maximum value (inclusive)
|
|
76
|
+
* @returns A random `Uint8` in `[min, max]`
|
|
77
77
|
*/
|
|
78
78
|
readonly random: (min: Uint8, max: Uint8) => Uint8;
|
|
79
79
|
/**
|
|
80
|
-
* Raises
|
|
80
|
+
* Raises `a` to the power `b`, returning `a ** b` as an `Uint8` (floored to
|
|
81
|
+
* an integer).
|
|
81
82
|
*
|
|
82
|
-
* @param
|
|
83
|
-
* @param
|
|
84
|
-
* @returns `
|
|
83
|
+
* @param a - The base non-negative integer
|
|
84
|
+
* @param b - The exponent non-negative integer
|
|
85
|
+
* @returns `a ** b` as an `Uint8`
|
|
85
86
|
*/
|
|
86
87
|
readonly pow: (x: Uint8, y: Uint8) => Uint8;
|
|
87
88
|
/**
|
|
88
|
-
* Adds two
|
|
89
|
+
* Adds two non-negative integers, returning `a + b` as an `Uint8`.
|
|
89
90
|
*
|
|
90
|
-
* @param
|
|
91
|
-
* @param
|
|
92
|
-
* @returns `
|
|
91
|
+
* @param a - The first non-negative integer
|
|
92
|
+
* @param b - The second non-negative integer
|
|
93
|
+
* @returns The sum of `a` and `b` as an `Uint8`
|
|
93
94
|
*/
|
|
94
95
|
readonly add: (x: Uint8, y: Uint8) => Uint8;
|
|
95
96
|
/**
|
|
96
|
-
* Subtracts two
|
|
97
|
+
* Subtracts two non-negative integers, returning `a - b` as an `Uint8`.
|
|
97
98
|
*
|
|
98
|
-
* @param
|
|
99
|
-
* @param
|
|
100
|
-
* @returns `
|
|
99
|
+
* @param a - The first non-negative integer
|
|
100
|
+
* @param b - The second non-negative integer
|
|
101
|
+
* @returns The difference of `a` and `b` as an `Uint8`
|
|
101
102
|
*/
|
|
102
103
|
readonly sub: (x: Uint8, y: Uint8) => Uint8;
|
|
103
104
|
/**
|
|
104
|
-
* Multiplies two
|
|
105
|
+
* Multiplies two non-negative integers, returning `a * b` as an `Uint8`.
|
|
105
106
|
*
|
|
106
|
-
* @param
|
|
107
|
-
* @param
|
|
108
|
-
* @returns `
|
|
107
|
+
* @param a - The first non-negative integer
|
|
108
|
+
* @param b - The second non-negative integer
|
|
109
|
+
* @returns The product of `a` and `b` as an `Uint8`
|
|
109
110
|
*/
|
|
110
111
|
readonly mul: (x: Uint8, y: Uint8) => Uint8;
|
|
111
112
|
/**
|
|
112
|
-
* Divides two
|
|
113
|
+
* Divides two non-negative integers using floor division (`⌊a / b⌋`): the
|
|
114
|
+
* result is `a / b` rounded toward negative infinity, as an `Uint8`.
|
|
113
115
|
*
|
|
114
|
-
* @param
|
|
115
|
-
* @param
|
|
116
|
-
* @returns
|
|
116
|
+
* @param a - The dividend
|
|
117
|
+
* @param b - The divisor (must be non-zero)
|
|
118
|
+
* @returns The floored quotient as an `Uint8`
|
|
117
119
|
*/
|
|
118
120
|
readonly div: (x: Uint8, y: Exclude<Uint8, 0>) => Uint8;
|
|
119
121
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint8.d.mts","sourceRoot":"","sources":["../../../src/number/enum/uint8.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,IAAI,iBAAiB,EAAe,MAAM,eAAe,CAAC;AAI7E,MAAM,MAAM,KAAK,GAAG,iBAAiB,CAAC;AA+CtC
|
|
1
|
+
{"version":3,"file":"uint8.d.mts","sourceRoot":"","sources":["../../../src/number/enum/uint8.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,IAAI,iBAAiB,EAAe,MAAM,eAAe,CAAC;AAI7E,MAAM,MAAM,KAAK,GAAG,iBAAiB,CAAC;AA+CtC;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,MApCL,MAAM,KAAG,CAAC,IAAI,KAoCJ,CAAC;AAE1B;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,MA9CC,MAAM,KAAG,KA8CC,CAAC;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,KAAK;IAChB;;;;;;OAMG;qBA/DU,MAAM,KAAG,CAAC,IAAI,KAAK;IAkEhC;;OAEG;;IAGH;;OAEG;;IAGH;;;;;OAKG;8BAtEoB,SAAS,KAAK,EAAE,KAAG,KAAK;IAyE/C;;;;;OAKG;8BAjFoB,SAAS,KAAK,EAAE,KAAG,KAAK;IAoF/C;;;;;;OAMG;wBA5Fa,MAAM,KAAG,KAAK;IA+F9B;;;;;;;;OAQG;2BArFgB,KAAK,OAAO,KAAK,KAAG,KAAK;IAwF5C;;;;;;;OAOG;sBAzGW,KAAK,KAAK,KAAK,KAAG,KAAK;IA4GrC;;;;;;OAMG;sBAhHW,KAAK,KAAK,KAAK,KAAG,KAAK;IAmHrC;;;;;;OAMG;sBAvHW,KAAK,KAAK,KAAK,KAAG,KAAK;IA0HrC;;;;;;OAMG;sBA9HW,KAAK,KAAK,KAAK,KAAG,KAAK;IAiIrC;;;;;;;OAOG;sBAtIW,KAAK,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,KAAG,KAAK;CAwIzC,CAAC"}
|
|
@@ -34,92 +34,93 @@ const isUint8 = is;
|
|
|
34
34
|
const asUint8 = castType;
|
|
35
35
|
const Uint8 = {
|
|
36
36
|
/**
|
|
37
|
-
* Type guard that checks if a value is an
|
|
37
|
+
* Type guard that checks if a value is an non-negative integer less than 256.
|
|
38
38
|
*
|
|
39
|
-
* @param value The value to check
|
|
40
|
-
* @returns `true` if the value is an
|
|
41
|
-
*
|
|
39
|
+
* @param value - The value to check
|
|
40
|
+
* @returns `true` if the value is an non-negative integer less than 256, `false` otherwise
|
|
41
|
+
* @see {@link isUint8} for usage examples
|
|
42
42
|
*/
|
|
43
43
|
is,
|
|
44
44
|
/**
|
|
45
|
-
* The
|
|
46
|
-
*
|
|
47
|
-
* @readonly
|
|
45
|
+
* The smallest value representable as `Uint8`.
|
|
48
46
|
*/
|
|
49
47
|
MIN_VALUE,
|
|
50
48
|
/**
|
|
51
|
-
* The
|
|
52
|
-
*
|
|
53
|
-
* @readonly
|
|
49
|
+
* The largest value representable as `Uint8`.
|
|
54
50
|
*/
|
|
55
51
|
MAX_VALUE,
|
|
56
52
|
/**
|
|
57
|
-
* Returns the
|
|
53
|
+
* Returns the largest of the given non-negative integers.
|
|
58
54
|
*
|
|
59
|
-
* @param values The
|
|
60
|
-
* @returns The
|
|
55
|
+
* @param values - The non-negative integers to compare (at least one required)
|
|
56
|
+
* @returns The largest value as an `Uint8`
|
|
61
57
|
*/
|
|
62
58
|
max: max_,
|
|
63
59
|
/**
|
|
64
|
-
* Returns the
|
|
60
|
+
* Returns the smallest of the given non-negative integers.
|
|
65
61
|
*
|
|
66
|
-
* @param values The
|
|
67
|
-
* @returns The
|
|
62
|
+
* @param values - The non-negative integers to compare (at least one required)
|
|
63
|
+
* @returns The smallest value as an `Uint8`
|
|
68
64
|
*/
|
|
69
65
|
min: min_,
|
|
70
66
|
/**
|
|
71
|
-
* Clamps a number
|
|
67
|
+
* Clamps a `number` into the `Uint8` range, rounding to the nearest integer
|
|
68
|
+
* and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
|
|
72
69
|
*
|
|
73
|
-
* @param value The
|
|
74
|
-
* @returns The
|
|
70
|
+
* @param value - The value to clamp
|
|
71
|
+
* @returns The clamped value as an `Uint8`
|
|
75
72
|
*/
|
|
76
73
|
clamp,
|
|
77
74
|
/**
|
|
78
|
-
* Generates a random Uint8
|
|
75
|
+
* Generates a random `Uint8` within the given range.
|
|
76
|
+
*
|
|
77
|
+
* The range is inclusive on both ends.
|
|
79
78
|
*
|
|
80
|
-
* @param min The minimum value (inclusive)
|
|
81
|
-
* @param max The maximum value (inclusive)
|
|
82
|
-
* @returns A random Uint8
|
|
79
|
+
* @param min - The minimum value (inclusive)
|
|
80
|
+
* @param max - The maximum value (inclusive)
|
|
81
|
+
* @returns A random `Uint8` in `[min, max]`
|
|
83
82
|
*/
|
|
84
83
|
random,
|
|
85
84
|
/**
|
|
86
|
-
* Raises
|
|
85
|
+
* Raises `a` to the power `b`, returning `a ** b` as an `Uint8` (floored to
|
|
86
|
+
* an integer).
|
|
87
87
|
*
|
|
88
|
-
* @param
|
|
89
|
-
* @param
|
|
90
|
-
* @returns `
|
|
88
|
+
* @param a - The base non-negative integer
|
|
89
|
+
* @param b - The exponent non-negative integer
|
|
90
|
+
* @returns `a ** b` as an `Uint8`
|
|
91
91
|
*/
|
|
92
92
|
pow,
|
|
93
93
|
/**
|
|
94
|
-
* Adds two
|
|
94
|
+
* Adds two non-negative integers, returning `a + b` as an `Uint8`.
|
|
95
95
|
*
|
|
96
|
-
* @param
|
|
97
|
-
* @param
|
|
98
|
-
* @returns `
|
|
96
|
+
* @param a - The first non-negative integer
|
|
97
|
+
* @param b - The second non-negative integer
|
|
98
|
+
* @returns The sum of `a` and `b` as an `Uint8`
|
|
99
99
|
*/
|
|
100
100
|
add,
|
|
101
101
|
/**
|
|
102
|
-
* Subtracts two
|
|
102
|
+
* Subtracts two non-negative integers, returning `a - b` as an `Uint8`.
|
|
103
103
|
*
|
|
104
|
-
* @param
|
|
105
|
-
* @param
|
|
106
|
-
* @returns `
|
|
104
|
+
* @param a - The first non-negative integer
|
|
105
|
+
* @param b - The second non-negative integer
|
|
106
|
+
* @returns The difference of `a` and `b` as an `Uint8`
|
|
107
107
|
*/
|
|
108
108
|
sub,
|
|
109
109
|
/**
|
|
110
|
-
* Multiplies two
|
|
110
|
+
* Multiplies two non-negative integers, returning `a * b` as an `Uint8`.
|
|
111
111
|
*
|
|
112
|
-
* @param
|
|
113
|
-
* @param
|
|
114
|
-
* @returns `
|
|
112
|
+
* @param a - The first non-negative integer
|
|
113
|
+
* @param b - The second non-negative integer
|
|
114
|
+
* @returns The product of `a` and `b` as an `Uint8`
|
|
115
115
|
*/
|
|
116
116
|
mul,
|
|
117
117
|
/**
|
|
118
|
-
* Divides two
|
|
118
|
+
* Divides two non-negative integers using floor division (`⌊a / b⌋`): the
|
|
119
|
+
* result is `a / b` rounded toward negative infinity, as an `Uint8`.
|
|
119
120
|
*
|
|
120
|
-
* @param
|
|
121
|
-
* @param
|
|
122
|
-
* @returns
|
|
121
|
+
* @param a - The dividend
|
|
122
|
+
* @param b - The divisor (must be non-zero)
|
|
123
|
+
* @returns The floored quotient as an `Uint8`
|
|
123
124
|
*/
|
|
124
125
|
div
|
|
125
126
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint8.mjs","sources":["../../../src/number/enum/uint8.mts"],"sourcesContent":["import { type Uint8 as TtfImported_Uint8, type Uint16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type Uint8 = TtfImported_Uint8;\n\nconst typeNameInMessage = 'an non-negative integer less than 256';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n castType: castTypeImpl,\n clamp: clampImpl,\n is: isImpl,\n random: randomImpl,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<Uint16, 0, 255>(\n {\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 0,\n MAX_VALUE: 255,\n typeNameInMessage,\n } as const,\n);\n\nconst is = (x: number): x is Uint8 => isImpl(x);\n\nconst castType = (x: number): Uint8 =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n castTypeImpl(x) as Uint8;\n\nconst clamp = (a: number): Uint8 => castType(clampImpl(a));\n\nconst min_ = (...values: readonly Uint8[]): Uint8 =>\n castType(Math.min(...values));\n\nconst max_ = (...values: readonly Uint8[]): Uint8 =>\n castType(Math.max(...values));\n\nconst pow = (x: Uint8, y: Uint8): Uint8 => clamp(x ** y);\n\nconst add = (x: Uint8, y: Uint8): Uint8 => clamp(x + y);\n\nconst sub = (x: Uint8, y: Uint8): Uint8 => clamp(x - y);\n\nconst mul = (x: Uint8, y: Uint8): Uint8 => clamp(x * y);\n\nconst div = (x: Uint8, y: Exclude<Uint8, 0>): Uint8 => clamp(Math.floor(x / y));\n\nconst random = (min: Uint8, max: Uint8): Uint8 =>\n castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"uint8.mjs","sources":["../../../src/number/enum/uint8.mts"],"sourcesContent":["import { type Uint8 as TtfImported_Uint8, type Uint16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type Uint8 = TtfImported_Uint8;\n\nconst typeNameInMessage = 'an non-negative integer less than 256';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n castType: castTypeImpl,\n clamp: clampImpl,\n is: isImpl,\n random: randomImpl,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<Uint16, 0, 255>(\n {\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 0,\n MAX_VALUE: 255,\n typeNameInMessage,\n } as const,\n);\n\nconst is = (x: number): x is Uint8 => isImpl(x);\n\nconst castType = (x: number): Uint8 =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n castTypeImpl(x) as Uint8;\n\nconst clamp = (a: number): Uint8 => castType(clampImpl(a));\n\nconst min_ = (...values: readonly Uint8[]): Uint8 =>\n castType(Math.min(...values));\n\nconst max_ = (...values: readonly Uint8[]): Uint8 =>\n castType(Math.max(...values));\n\nconst pow = (x: Uint8, y: Uint8): Uint8 => clamp(x ** y);\n\nconst add = (x: Uint8, y: Uint8): Uint8 => clamp(x + y);\n\nconst sub = (x: Uint8, y: Uint8): Uint8 => clamp(x - y);\n\nconst mul = (x: Uint8, y: Uint8): Uint8 => clamp(x * y);\n\nconst div = (x: Uint8, y: Exclude<Uint8, 0>): Uint8 => clamp(Math.floor(x / y));\n\nconst random = (min: Uint8, max: Uint8): Uint8 =>\n castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));\n\n/**\n * Type guard that checks if a value is an non-negative integer less than 256.\n *\n * Returns `true` for an non-negative integer less than 256 — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is an non-negative integer less than 256, `false` otherwise\n */\nexport const isUint8 = is;\n\n/**\n * Casts a `number` to the `Uint8` branded type.\n *\n * Validates that the value is an non-negative integer less than 256 and returns\n * it with the `Uint8` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as an `Uint8`\n * @throws {TypeError} If the value is not an non-negative integer less than 256\n */\nexport const asUint8 = castType;\n\n/**\n * Namespace providing type-safe operations for the `Uint8` branded type.\n *\n * The `Uint8` type represents an non-negative integer less than 256. Division\n * (`div`) uses floor division.\n */\nexport const Uint8 = {\n /**\n * Type guard that checks if a value is an non-negative integer less than 256.\n *\n * @param value - The value to check\n * @returns `true` if the value is an non-negative integer less than 256, `false` otherwise\n * @see {@link isUint8} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `Uint8`.\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `Uint8`.\n */\n MAX_VALUE,\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 `Uint8`\n */\n max: max_,\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 `Uint8`\n */\n min: min_,\n\n /**\n * Clamps a `number` into the `Uint8` 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 `Uint8`\n */\n clamp,\n\n /**\n * Generates a random `Uint8` 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 `Uint8` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as an `Uint8` (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 `Uint8`\n */\n pow,\n\n /**\n * Adds two non-negative integers, returning `a + b` as an `Uint8`.\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 `Uint8`\n */\n add,\n\n /**\n * Subtracts two non-negative integers, returning `a - b` as an `Uint8`.\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 `Uint8`\n */\n sub,\n\n /**\n * Multiplies two non-negative integers, returning `a * b` as an `Uint8`.\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 `Uint8`\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 `Uint8`.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as an `Uint8`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof Uint8,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n Uint16,\n 'int' | 'non-negative' | 'range'\n >\n>('=');\n"],"names":[],"mappings":";;AAMA,MAAM,iBAAA,GAAoB,uCAAA;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,qBAAqB,kBAAA,CAAmB,mBAAA;AAAA,EAC1C;AAAA,IACE,oBAAA,EAAsB,aAAA;AAAA,IACtB,SAAA,EAAW,CAAA;AAAA,IACX,SAAA,EAAW,GAAA;AAAA,IACX;AAAA;AAEJ,CAAA;AAEA,MAAM,EAAA,GAAK,CAAC,CAAA,KAA0B,MAAA,CAAO,CAAC,CAAA;AAE9C,MAAM,WAAW,CAAC,CAAA;AAAA;AAAA,EAEhB,aAAa,CAAC;AAAA,CAAA;AAEhB,MAAM,QAAQ,CAAC,CAAA,KAAqB,QAAA,CAAS,SAAA,CAAU,CAAC,CAAC,CAAA;AAEzD,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,EAAU,CAAA,KAAoB,KAAA,CAAM,KAAK,CAAC,CAAA;AAEvD,MAAM,MAAM,CAAC,CAAA,EAAU,CAAA,KAAoB,KAAA,CAAM,IAAI,CAAC,CAAA;AAEtD,MAAM,MAAM,CAAC,CAAA,EAAU,CAAA,KAAoB,KAAA,CAAM,IAAI,CAAC,CAAA;AAEtD,MAAM,MAAM,CAAC,CAAA,EAAU,CAAA,KAAoB,KAAA,CAAM,IAAI,CAAC,CAAA;AAEtD,MAAM,GAAA,GAAM,CAAC,CAAA,EAAU,CAAA,KAAgC,MAAM,IAAA,CAAK,KAAA,CAAM,CAAA,GAAI,CAAC,CAAC,CAAA;AAE9E,MAAM,MAAA,GAAS,CAAC,GAAA,EAAY,GAAA,KAC1B,QAAA,CAAS,UAAA,CAAW,YAAA,CAAa,GAAG,CAAA,EAAG,YAAA,CAAa,GAAG,CAAC,CAAC,CAAA;AAWpD,MAAM,OAAA,GAAU;AAYhB,MAAM,OAAA,GAAU;AAQhB,MAAM,KAAA,GAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQnB,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;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-data-forge",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"fmt": "format-uncommitted --cwd .",
|
|
68
68
|
"fmt:diff": "format-diff-from origin/main --cwd .",
|
|
69
69
|
"fmt:full": "pnpm run z:prettier .",
|
|
70
|
+
"gen:branded-number": "tsx ./scripts/gen-branded-number/generate.mts && pnpm run doc:embed:jsdoc && pnpm run z:prettier 'src/number/branded-types/*.mts' 'src/number/enum/*.mts'",
|
|
70
71
|
"gi": "run-s gi:src fmt",
|
|
71
72
|
"gi:src": "tsx scripts/cmd/gen-index.mts",
|
|
72
73
|
"lint": "eslint .",
|
|
@@ -59,47 +59,37 @@ expectType<TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>, Int>(
|
|
|
59
59
|
/**
|
|
60
60
|
* Type guard that checks if a value is a finite number.
|
|
61
61
|
*
|
|
62
|
-
* Returns `true`
|
|
63
|
-
*
|
|
64
|
-
* these special values.
|
|
62
|
+
* Returns `true` only for a finite value — never `NaN`, `Infinity`, or
|
|
63
|
+
* `-Infinity`.
|
|
65
64
|
*
|
|
66
65
|
* @param value - The value to check
|
|
67
|
-
* @returns `true` if the value is finite, `false` otherwise
|
|
66
|
+
* @returns `true` if the value is a finite number, `false` otherwise
|
|
68
67
|
*/
|
|
69
68
|
export const isFiniteNumber = is;
|
|
70
69
|
|
|
71
70
|
/**
|
|
72
|
-
* Casts a number to
|
|
71
|
+
* Casts a `number` to the `FiniteNumber` branded type.
|
|
73
72
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* safety for operations that require finite numeric values.
|
|
73
|
+
* Validates that the value is a finite number and returns it with the
|
|
74
|
+
* `FiniteNumber` brand. Throws a `TypeError` otherwise.
|
|
77
75
|
*
|
|
78
76
|
* @param value - The value to cast
|
|
79
|
-
* @returns The value as a FiniteNumber
|
|
80
|
-
* @throws {TypeError} If the value is
|
|
77
|
+
* @returns The value as a `FiniteNumber`
|
|
78
|
+
* @throws {TypeError} If the value is not a finite number
|
|
81
79
|
*/
|
|
82
80
|
export const asFiniteNumber = castType;
|
|
83
81
|
|
|
84
82
|
/**
|
|
85
|
-
* Namespace providing type-safe operations for FiniteNumber branded
|
|
83
|
+
* Namespace providing type-safe operations for the `FiniteNumber` branded type.
|
|
86
84
|
*
|
|
87
|
-
* The FiniteNumber type represents
|
|
88
|
-
* special values NaN, Infinity, and -Infinity. All operations are guaranteed to
|
|
89
|
-
* maintain the finite constraint when given finite inputs.
|
|
90
|
-
*
|
|
91
|
-
* This type is essential for:
|
|
92
|
-
*
|
|
93
|
-
* - Mathematical operations that require real numbers
|
|
94
|
-
* - Preventing NaN/Infinity propagation in calculations
|
|
95
|
-
* - Ensuring numeric stability in algorithms
|
|
85
|
+
* The `FiniteNumber` type represents a finite number.
|
|
96
86
|
*/
|
|
97
87
|
export const FiniteNumber = {
|
|
98
88
|
/**
|
|
99
89
|
* Type guard that checks if a value is a finite number.
|
|
100
90
|
*
|
|
101
91
|
* @param value - The value to check
|
|
102
|
-
* @returns `true` if the value is finite, `false` otherwise
|
|
92
|
+
* @returns `true` if the value is a finite number, `false` otherwise
|
|
103
93
|
* @see {@link isFiniteNumber} for usage examples
|
|
104
94
|
*/
|
|
105
95
|
is,
|
|
@@ -107,110 +97,106 @@ export const FiniteNumber = {
|
|
|
107
97
|
/**
|
|
108
98
|
* Returns the absolute value of a finite number.
|
|
109
99
|
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
100
|
+
* The result is non-negative and keeps the `FiniteNumber` brand.
|
|
101
|
+
*
|
|
102
|
+
* @param a - The finite number value
|
|
103
|
+
* @returns The absolute value as a non-negative `FiniteNumber`
|
|
112
104
|
*/
|
|
113
105
|
abs,
|
|
114
106
|
|
|
115
107
|
/**
|
|
116
|
-
* Returns the
|
|
108
|
+
* Returns the smallest of the given finite numbers.
|
|
117
109
|
*
|
|
118
110
|
* @param values - The finite numbers to compare (at least one required)
|
|
119
|
-
* @returns The smallest value as a FiniteNumber
|
|
111
|
+
* @returns The smallest value as a `FiniteNumber`
|
|
120
112
|
*/
|
|
121
113
|
min: min_,
|
|
122
114
|
|
|
123
115
|
/**
|
|
124
|
-
* Returns the
|
|
116
|
+
* Returns the largest of the given finite numbers.
|
|
125
117
|
*
|
|
126
118
|
* @param values - The finite numbers to compare (at least one required)
|
|
127
|
-
* @returns The largest value as a FiniteNumber
|
|
119
|
+
* @returns The largest value as a `FiniteNumber`
|
|
128
120
|
*/
|
|
129
121
|
max: max_,
|
|
130
122
|
|
|
131
123
|
/**
|
|
132
|
-
* Returns the
|
|
124
|
+
* Returns the greatest integer less than or equal to a finite number.
|
|
133
125
|
*
|
|
134
|
-
* @param
|
|
135
|
-
* @returns The
|
|
126
|
+
* @param a - The finite number value
|
|
127
|
+
* @returns The floored value as an integer
|
|
136
128
|
*/
|
|
137
129
|
floor,
|
|
138
130
|
|
|
139
131
|
/**
|
|
140
|
-
* Returns the smallest integer greater than or equal to
|
|
141
|
-
* number.
|
|
132
|
+
* Returns the smallest integer greater than or equal to a finite number.
|
|
142
133
|
*
|
|
143
|
-
* @param
|
|
144
|
-
* @returns The
|
|
134
|
+
* @param a - The finite number value
|
|
135
|
+
* @returns The ceiled value as an integer
|
|
145
136
|
*/
|
|
146
137
|
ceil,
|
|
147
138
|
|
|
148
139
|
/**
|
|
149
|
-
*
|
|
140
|
+
* Returns the value of a finite number rounded to the nearest integer.
|
|
150
141
|
*
|
|
151
|
-
* @param
|
|
152
|
-
* @returns The rounded value as an
|
|
142
|
+
* @param a - The finite number value
|
|
143
|
+
* @returns The rounded value as an integer
|
|
153
144
|
*/
|
|
154
145
|
round,
|
|
155
146
|
|
|
156
147
|
/**
|
|
157
|
-
* Generates a random
|
|
148
|
+
* Generates a random `FiniteNumber` within the given range.
|
|
158
149
|
*
|
|
159
|
-
* The
|
|
160
|
-
* bounds are inclusive.
|
|
150
|
+
* The range is inclusive on both ends.
|
|
161
151
|
*
|
|
162
152
|
* @param min - The minimum value (inclusive)
|
|
163
153
|
* @param max - The maximum value (inclusive)
|
|
164
|
-
* @returns A random FiniteNumber in
|
|
154
|
+
* @returns A random `FiniteNumber` in `[min, max]`
|
|
165
155
|
*/
|
|
166
156
|
random,
|
|
167
157
|
|
|
168
158
|
/**
|
|
169
|
-
* Raises a
|
|
159
|
+
* Raises `a` to the power `b`, returning `a ** b` as a `FiniteNumber`.
|
|
170
160
|
*
|
|
171
161
|
* @param a - The base finite number
|
|
172
162
|
* @param b - The exponent finite number
|
|
173
|
-
* @returns `a ** b` as a FiniteNumber
|
|
163
|
+
* @returns `a ** b` as a `FiniteNumber`
|
|
174
164
|
*/
|
|
175
165
|
pow,
|
|
176
166
|
|
|
177
167
|
/**
|
|
178
|
-
* Adds two finite numbers
|
|
168
|
+
* Adds two finite numbers, returning `a + b` as a `FiniteNumber`.
|
|
179
169
|
*
|
|
180
|
-
* @param a -
|
|
181
|
-
* @param b -
|
|
182
|
-
* @returns `a
|
|
170
|
+
* @param a - The first finite number
|
|
171
|
+
* @param b - The second finite number
|
|
172
|
+
* @returns The sum of `a` and `b` as a `FiniteNumber`
|
|
183
173
|
*/
|
|
184
174
|
add,
|
|
185
175
|
|
|
186
176
|
/**
|
|
187
|
-
* Subtracts two finite numbers
|
|
177
|
+
* Subtracts two finite numbers, returning `a - b` as a `FiniteNumber`.
|
|
188
178
|
*
|
|
189
|
-
* @param a -
|
|
190
|
-
* @param b -
|
|
191
|
-
* @returns `a
|
|
179
|
+
* @param a - The first finite number
|
|
180
|
+
* @param b - The second finite number
|
|
181
|
+
* @returns The difference of `a` and `b` as a `FiniteNumber`
|
|
192
182
|
*/
|
|
193
183
|
sub,
|
|
194
184
|
|
|
195
185
|
/**
|
|
196
|
-
* Multiplies two finite numbers
|
|
186
|
+
* Multiplies two finite numbers, returning `a * b` as a `FiniteNumber`.
|
|
197
187
|
*
|
|
198
|
-
* @param a -
|
|
199
|
-
* @param b -
|
|
200
|
-
* @returns `a
|
|
188
|
+
* @param a - The first finite number
|
|
189
|
+
* @param b - The second finite number
|
|
190
|
+
* @returns The product of `a` and `b` as a `FiniteNumber`
|
|
201
191
|
*/
|
|
202
192
|
mul,
|
|
203
193
|
|
|
204
194
|
/**
|
|
205
|
-
* Divides two finite numbers
|
|
206
|
-
*
|
|
207
|
-
* The divisor must be non-zero (enforced by type constraints). The result is
|
|
208
|
-
* guaranteed to be finite when both inputs are finite and the divisor is
|
|
209
|
-
* non-zero.
|
|
195
|
+
* Divides two finite numbers, returning `a / b` as a `FiniteNumber`.
|
|
210
196
|
*
|
|
211
197
|
* @param a - The dividend
|
|
212
198
|
* @param b - The divisor (must be non-zero)
|
|
213
|
-
* @returns
|
|
199
|
+
* @returns `a / b` as a `FiniteNumber`
|
|
214
200
|
*/
|
|
215
201
|
div,
|
|
216
202
|
} as const;
|