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
|
@@ -3,19 +3,24 @@ import { PositiveSafeInt } from './positive-safe-int.mjs';
|
|
|
3
3
|
export type NegativeSafeInt = TtfImported_NegativeSafeInt;
|
|
4
4
|
type ElementType = NegativeSafeInt;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* `[Number.MIN_SAFE_INTEGER, -1]`).
|
|
6
|
+
* Type guard that checks if a value is a negative safe integer.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Returns `true` for a negative safe integer — a value with no fractional
|
|
9
|
+
* component.
|
|
10
|
+
*
|
|
11
|
+
* @param value - The value to check
|
|
12
|
+
* @returns `true` if the value is a negative safe integer, `false` otherwise
|
|
11
13
|
*/
|
|
12
14
|
export declare const isNegativeSafeInt: (a: number) => a is TtfImported_NegativeSafeInt;
|
|
13
15
|
/**
|
|
14
|
-
* Casts a number to
|
|
16
|
+
* Casts a `number` to the `NegativeSafeInt` branded type.
|
|
17
|
+
*
|
|
18
|
+
* Validates that the value is a negative safe integer and returns it with the
|
|
19
|
+
* `NegativeSafeInt` brand. Throws a `TypeError` otherwise.
|
|
15
20
|
*
|
|
16
|
-
* @param value The value to cast
|
|
17
|
-
* @returns The value as a NegativeSafeInt
|
|
18
|
-
* @throws {TypeError} If the value is not a negative safe integer
|
|
21
|
+
* @param value - The value to cast
|
|
22
|
+
* @returns The value as a `NegativeSafeInt`
|
|
23
|
+
* @throws {TypeError} If the value is not a negative safe integer
|
|
19
24
|
*/
|
|
20
25
|
export declare const asNegativeSafeInt: <N extends number>(x: N) => number & {
|
|
21
26
|
readonly "!=0": true;
|
|
@@ -33,98 +38,100 @@ export declare const asNegativeSafeInt: <N extends number>(x: N) => number & {
|
|
|
33
38
|
'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
|
|
34
39
|
}> & N;
|
|
35
40
|
/**
|
|
36
|
-
* Namespace providing type-safe
|
|
37
|
-
*
|
|
41
|
+
* Namespace providing type-safe operations for the `NegativeSafeInt` branded
|
|
42
|
+
* type.
|
|
38
43
|
*
|
|
39
|
-
* NegativeSafeInt represents
|
|
40
|
-
* (`
|
|
41
|
-
* safe integers clamp their results to the valid range, while operations whose
|
|
42
|
-
* result leaves the set (`mul`, `div`, `abs`) are typed to reflect the actual
|
|
43
|
-
* sign of the result.
|
|
44
|
+
* The `NegativeSafeInt` type represents a negative safe integer. Division
|
|
45
|
+
* (`div`) uses floor division.
|
|
44
46
|
*/
|
|
45
47
|
export declare const NegativeSafeInt: {
|
|
46
48
|
/**
|
|
47
|
-
* Type guard
|
|
49
|
+
* Type guard that checks if a value is a negative safe integer.
|
|
48
50
|
*
|
|
49
|
-
* @param value The value to check
|
|
50
|
-
* @returns `true` if the value is a negative safe integer, `false` otherwise
|
|
51
|
+
* @param value - The value to check
|
|
52
|
+
* @returns `true` if the value is a negative safe integer, `false` otherwise
|
|
53
|
+
* @see {@link isNegativeSafeInt} for usage examples
|
|
51
54
|
*/
|
|
52
55
|
readonly is: (a: number) => a is TtfImported_NegativeSafeInt;
|
|
53
56
|
/**
|
|
54
|
-
* The
|
|
55
|
-
*
|
|
56
|
-
* @readonly
|
|
57
|
+
* The smallest value representable as `NegativeSafeInt` (the lower saturation
|
|
58
|
+
* target of `fromNumber`).
|
|
57
59
|
*/
|
|
58
60
|
readonly MIN_VALUE: number;
|
|
59
61
|
/**
|
|
60
|
-
* The
|
|
61
|
-
*
|
|
62
|
-
* @readonly
|
|
62
|
+
* The largest value representable as `NegativeSafeInt` (the upper saturation
|
|
63
|
+
* target of `fromNumber`).
|
|
63
64
|
*/
|
|
64
65
|
readonly MAX_VALUE: -1;
|
|
65
66
|
/**
|
|
66
67
|
* Returns the absolute value of a negative safe integer.
|
|
67
68
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
69
|
+
* The result is non-negative and keeps the `NegativeSafeInt` brand.
|
|
70
|
+
*
|
|
71
|
+
* @param a - The negative safe integer value
|
|
72
|
+
* @returns The absolute value as a non-negative `NegativeSafeInt`
|
|
70
73
|
*/
|
|
71
74
|
readonly abs: (x: WithSmallInt<ElementType>) => PositiveSafeInt;
|
|
72
75
|
/**
|
|
73
|
-
* Returns the
|
|
76
|
+
* Returns the smallest of the given negative safe integers.
|
|
74
77
|
*
|
|
75
|
-
* @param
|
|
76
|
-
* @
|
|
77
|
-
* @returns The minimum value as a NegativeSafeInt.
|
|
78
|
+
* @param values - The negative safe integers to compare (at least one required)
|
|
79
|
+
* @returns The smallest value as a `NegativeSafeInt`
|
|
78
80
|
*/
|
|
79
81
|
readonly min: (...values: readonly WithSmallInt<TtfImported_NegativeSafeInt>[]) => TtfImported_NegativeSafeInt;
|
|
80
82
|
/**
|
|
81
|
-
* Returns the
|
|
83
|
+
* Returns the largest of the given negative safe integers.
|
|
82
84
|
*
|
|
83
|
-
* @param
|
|
84
|
-
* @
|
|
85
|
-
* @returns The maximum value as a NegativeSafeInt.
|
|
85
|
+
* @param values - The negative safe integers to compare (at least one required)
|
|
86
|
+
* @returns The largest value as a `NegativeSafeInt`
|
|
86
87
|
*/
|
|
87
88
|
readonly max: (...values: readonly WithSmallInt<TtfImported_NegativeSafeInt>[]) => TtfImported_NegativeSafeInt;
|
|
88
89
|
/**
|
|
89
|
-
*
|
|
90
|
+
* Converts an arbitrary `number` into a `NegativeSafeInt`, rounding to the
|
|
91
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
92
|
+
* MAX_VALUE]`.
|
|
93
|
+
*
|
|
94
|
+
* Unlike `asNegativeSafeInt`, this is total: out-of-range inputs are clamped
|
|
95
|
+
* to the nearest representable `NegativeSafeInt` instead of throwing.
|
|
90
96
|
*
|
|
91
|
-
* @param value The
|
|
92
|
-
* @returns The value
|
|
93
|
-
* NegativeSafeInt.
|
|
97
|
+
* @param value - The value to convert
|
|
98
|
+
* @returns The value as a `NegativeSafeInt`
|
|
94
99
|
*/
|
|
95
|
-
readonly
|
|
100
|
+
readonly fromNumber: (x: number) => TtfImported_NegativeSafeInt;
|
|
96
101
|
/**
|
|
97
|
-
* Generates a random NegativeSafeInt
|
|
102
|
+
* Generates a random `NegativeSafeInt` within the given range.
|
|
98
103
|
*
|
|
99
|
-
*
|
|
104
|
+
* The range is inclusive on both ends.
|
|
105
|
+
*
|
|
106
|
+
* @param min - The minimum value (inclusive)
|
|
107
|
+
* @param max - The maximum value (inclusive)
|
|
108
|
+
* @returns A random `NegativeSafeInt` in `[min, max]`
|
|
100
109
|
*/
|
|
101
110
|
readonly random: (min?: WithSmallInt<TtfImported_NegativeSafeInt> | undefined, max?: WithSmallInt<TtfImported_NegativeSafeInt> | undefined) => TtfImported_NegativeSafeInt;
|
|
102
111
|
/**
|
|
103
|
-
* Raises a
|
|
104
|
-
* integer.
|
|
112
|
+
* Raises `a` to the power `b`, returning `a ** b` as a `NegativeSafeInt`
|
|
113
|
+
* (floored to an integer).
|
|
105
114
|
*
|
|
106
|
-
* @param a The base negative safe integer
|
|
107
|
-
* @param b The exponent negative safe integer
|
|
108
|
-
* @returns `a ** b`
|
|
115
|
+
* @param a - The base negative safe integer
|
|
116
|
+
* @param b - The exponent negative safe integer
|
|
117
|
+
* @returns `a ** b` as a `NegativeSafeInt`
|
|
109
118
|
*/
|
|
110
119
|
readonly pow: (x: WithSmallInt<TtfImported_NegativeSafeInt>, y: WithSmallInt<TtfImported_NegativeSafeInt>) => TtfImported_NegativeSafeInt;
|
|
111
120
|
/**
|
|
112
|
-
* Adds two negative safe integers
|
|
121
|
+
* Adds two negative safe integers, returning `a + b` as a `NegativeSafeInt`.
|
|
113
122
|
*
|
|
114
|
-
* @param a The first negative safe integer
|
|
115
|
-
* @param b The second negative safe integer
|
|
116
|
-
* @returns `a
|
|
123
|
+
* @param a - The first negative safe integer
|
|
124
|
+
* @param b - The second negative safe integer
|
|
125
|
+
* @returns The sum of `a` and `b` as a `NegativeSafeInt`
|
|
117
126
|
*/
|
|
118
127
|
readonly add: (x: WithSmallInt<TtfImported_NegativeSafeInt>, y: WithSmallInt<TtfImported_NegativeSafeInt>) => TtfImported_NegativeSafeInt;
|
|
119
128
|
/**
|
|
120
|
-
* Subtracts
|
|
121
|
-
*
|
|
122
|
-
* The mathematical result can be positive, so it is clamped to the
|
|
123
|
-
* NegativeSafeInt range (maximum `-1`).
|
|
129
|
+
* Subtracts two negative safe integers, returning `a - b` as a
|
|
130
|
+
* `NegativeSafeInt`.
|
|
124
131
|
*
|
|
125
|
-
* @param a The
|
|
126
|
-
* @param b The
|
|
127
|
-
* @returns `a
|
|
132
|
+
* @param a - The first negative safe integer
|
|
133
|
+
* @param b - The second negative safe integer
|
|
134
|
+
* @returns The difference of `a` and `b` as a `NegativeSafeInt`
|
|
128
135
|
*/
|
|
129
136
|
readonly sub: (x: WithSmallInt<TtfImported_NegativeSafeInt>, y: WithSmallInt<TtfImported_NegativeSafeInt>) => TtfImported_NegativeSafeInt;
|
|
130
137
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"negative-safe-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/negative-safe-int.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,IAAI,2BAA2B,EACnD,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAE1D,KAAK,WAAW,GAAG,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"negative-safe-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/negative-safe-int.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,IAAI,2BAA2B,EACnD,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAE1D,KAAK,WAAW,GAAG,eAAe,CAAC;AA+BnC;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,iDAAK,CAAC;AAEpC;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;MAAW,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;IAC1B;;;;;;OAMG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;;;;OAOG;sBA9DW,YAAY,CAAC,WAAW,CAAC,KAAG,eAAe;IAiEzD;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;OAOG;;CAEK,CAAC"}
|
|
@@ -7,7 +7,7 @@ const {
|
|
|
7
7
|
MIN_VALUE,
|
|
8
8
|
add,
|
|
9
9
|
castType,
|
|
10
|
-
|
|
10
|
+
fromNumber,
|
|
11
11
|
is,
|
|
12
12
|
max: max_,
|
|
13
13
|
min: min_,
|
|
@@ -21,92 +21,97 @@ const {
|
|
|
21
21
|
MAX_VALUE: -1,
|
|
22
22
|
typeNameInMessage
|
|
23
23
|
});
|
|
24
|
-
const abs = (x) => PositiveSafeInt.
|
|
24
|
+
const abs = (x) => PositiveSafeInt.fromNumber(Math.abs(x));
|
|
25
25
|
const isNegativeSafeInt = is;
|
|
26
26
|
const asNegativeSafeInt = castType;
|
|
27
27
|
const NegativeSafeInt = {
|
|
28
28
|
/**
|
|
29
|
-
* Type guard
|
|
29
|
+
* Type guard that checks if a value is a negative safe integer.
|
|
30
30
|
*
|
|
31
|
-
* @param value The value to check
|
|
32
|
-
* @returns `true` if the value is a negative safe integer, `false` otherwise
|
|
31
|
+
* @param value - The value to check
|
|
32
|
+
* @returns `true` if the value is a negative safe integer, `false` otherwise
|
|
33
|
+
* @see {@link isNegativeSafeInt} for usage examples
|
|
33
34
|
*/
|
|
34
35
|
is,
|
|
35
36
|
/**
|
|
36
|
-
* The
|
|
37
|
-
*
|
|
38
|
-
* @readonly
|
|
37
|
+
* The smallest value representable as `NegativeSafeInt` (the lower saturation
|
|
38
|
+
* target of `fromNumber`).
|
|
39
39
|
*/
|
|
40
40
|
MIN_VALUE,
|
|
41
41
|
/**
|
|
42
|
-
* The
|
|
43
|
-
*
|
|
44
|
-
* @readonly
|
|
42
|
+
* The largest value representable as `NegativeSafeInt` (the upper saturation
|
|
43
|
+
* target of `fromNumber`).
|
|
45
44
|
*/
|
|
46
45
|
MAX_VALUE,
|
|
47
46
|
/**
|
|
48
47
|
* Returns the absolute value of a negative safe integer.
|
|
49
48
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
49
|
+
* The result is non-negative and keeps the `NegativeSafeInt` brand.
|
|
50
|
+
*
|
|
51
|
+
* @param a - The negative safe integer value
|
|
52
|
+
* @returns The absolute value as a non-negative `NegativeSafeInt`
|
|
52
53
|
*/
|
|
53
54
|
abs,
|
|
54
55
|
/**
|
|
55
|
-
* Returns the
|
|
56
|
+
* Returns the smallest of the given negative safe integers.
|
|
56
57
|
*
|
|
57
|
-
* @param
|
|
58
|
-
* @
|
|
59
|
-
* @returns The minimum value as a NegativeSafeInt.
|
|
58
|
+
* @param values - The negative safe integers to compare (at least one required)
|
|
59
|
+
* @returns The smallest value as a `NegativeSafeInt`
|
|
60
60
|
*/
|
|
61
61
|
min: min_,
|
|
62
62
|
/**
|
|
63
|
-
* Returns the
|
|
63
|
+
* Returns the largest of the given negative safe integers.
|
|
64
64
|
*
|
|
65
|
-
* @param
|
|
66
|
-
* @
|
|
67
|
-
* @returns The maximum value as a NegativeSafeInt.
|
|
65
|
+
* @param values - The negative safe integers to compare (at least one required)
|
|
66
|
+
* @returns The largest value as a `NegativeSafeInt`
|
|
68
67
|
*/
|
|
69
68
|
max: max_,
|
|
70
69
|
/**
|
|
71
|
-
*
|
|
70
|
+
* Converts an arbitrary `number` into a `NegativeSafeInt`, rounding to the
|
|
71
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
72
|
+
* MAX_VALUE]`.
|
|
72
73
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
74
|
+
* Unlike `asNegativeSafeInt`, this is total: out-of-range inputs are clamped
|
|
75
|
+
* to the nearest representable `NegativeSafeInt` instead of throwing.
|
|
76
|
+
*
|
|
77
|
+
* @param value - The value to convert
|
|
78
|
+
* @returns The value as a `NegativeSafeInt`
|
|
76
79
|
*/
|
|
77
|
-
|
|
80
|
+
fromNumber,
|
|
78
81
|
/**
|
|
79
|
-
* Generates a random NegativeSafeInt
|
|
82
|
+
* Generates a random `NegativeSafeInt` within the given range.
|
|
83
|
+
*
|
|
84
|
+
* The range is inclusive on both ends.
|
|
80
85
|
*
|
|
81
|
-
* @
|
|
86
|
+
* @param min - The minimum value (inclusive)
|
|
87
|
+
* @param max - The maximum value (inclusive)
|
|
88
|
+
* @returns A random `NegativeSafeInt` in `[min, max]`
|
|
82
89
|
*/
|
|
83
90
|
random,
|
|
84
91
|
/**
|
|
85
|
-
* Raises a
|
|
86
|
-
* integer.
|
|
92
|
+
* Raises `a` to the power `b`, returning `a ** b` as a `NegativeSafeInt`
|
|
93
|
+
* (floored to an integer).
|
|
87
94
|
*
|
|
88
|
-
* @param a The base negative safe integer
|
|
89
|
-
* @param b The exponent negative safe integer
|
|
90
|
-
* @returns `a ** b`
|
|
95
|
+
* @param a - The base negative safe integer
|
|
96
|
+
* @param b - The exponent negative safe integer
|
|
97
|
+
* @returns `a ** b` as a `NegativeSafeInt`
|
|
91
98
|
*/
|
|
92
99
|
pow,
|
|
93
100
|
/**
|
|
94
|
-
* Adds two negative safe integers
|
|
101
|
+
* Adds two negative safe integers, returning `a + b` as a `NegativeSafeInt`.
|
|
95
102
|
*
|
|
96
|
-
* @param a The first negative safe integer
|
|
97
|
-
* @param b The second negative safe integer
|
|
98
|
-
* @returns `a
|
|
103
|
+
* @param a - The first negative safe integer
|
|
104
|
+
* @param b - The second negative safe integer
|
|
105
|
+
* @returns The sum of `a` and `b` as a `NegativeSafeInt`
|
|
99
106
|
*/
|
|
100
107
|
add,
|
|
101
108
|
/**
|
|
102
|
-
* Subtracts
|
|
103
|
-
*
|
|
104
|
-
* The mathematical result can be positive, so it is clamped to the
|
|
105
|
-
* NegativeSafeInt range (maximum `-1`).
|
|
109
|
+
* Subtracts two negative safe integers, returning `a - b` as a
|
|
110
|
+
* `NegativeSafeInt`.
|
|
106
111
|
*
|
|
107
|
-
* @param a The
|
|
108
|
-
* @param b The
|
|
109
|
-
* @returns `a
|
|
112
|
+
* @param a - The first negative safe integer
|
|
113
|
+
* @param b - The second negative safe integer
|
|
114
|
+
* @returns The difference of `a` and `b` as a `NegativeSafeInt`
|
|
110
115
|
*/
|
|
111
116
|
sub
|
|
112
117
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"negative-safe-int.mjs","sources":["../../../src/number/branded-types/negative-safe-int.mts"],"sourcesContent":["import {\n type NegativeSafeInt as TtfImported_NegativeSafeInt,\n type WithSmallInt,\n} from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\nimport { PositiveSafeInt } from './positive-safe-int.mjs';\n\nexport type NegativeSafeInt = TtfImported_NegativeSafeInt;\n\ntype ElementType = NegativeSafeInt;\n\nconst typeNameInMessage = 'a negative safe integer';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n
|
|
1
|
+
{"version":3,"file":"negative-safe-int.mjs","sources":["../../../src/number/branded-types/negative-safe-int.mts"],"sourcesContent":["import {\n type NegativeSafeInt as TtfImported_NegativeSafeInt,\n type WithSmallInt,\n} from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\nimport { PositiveSafeInt } from './positive-safe-int.mjs';\n\nexport type NegativeSafeInt = TtfImported_NegativeSafeInt;\n\ntype ElementType = NegativeSafeInt;\n\nconst typeNameInMessage = 'a negative safe integer';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n fromNumber,\n is,\n max: max_,\n min: min_,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n number,\n -1\n>({\n integerOrSafeInteger: 'SafeInteger',\n nonZero: true,\n MIN_VALUE: Number.MIN_SAFE_INTEGER,\n MAX_VALUE: -1,\n typeNameInMessage,\n} as const);\n\nconst abs = (x: WithSmallInt<ElementType>): PositiveSafeInt =>\n PositiveSafeInt.fromNumber(Math.abs(x));\n\n/**\n * Type guard that checks if a value is a negative safe integer.\n *\n * Returns `true` for a negative safe integer — a value with no fractional\n * component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a negative safe integer, `false` otherwise\n */\nexport const isNegativeSafeInt = is;\n\n/**\n * Casts a `number` to the `NegativeSafeInt` branded type.\n *\n * Validates that the value is a negative safe integer and returns it with the\n * `NegativeSafeInt` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NegativeSafeInt`\n * @throws {TypeError} If the value is not a negative safe integer\n */\nexport const asNegativeSafeInt = castType;\n\n/**\n * Namespace providing type-safe operations for the `NegativeSafeInt` branded\n * type.\n *\n * The `NegativeSafeInt` type represents a negative safe integer. Division\n * (`div`) uses floor division.\n */\nexport const NegativeSafeInt = {\n /**\n * Type guard that checks if a value is a negative safe integer.\n *\n * @param value - The value to check\n * @returns `true` if the value is a negative safe integer, `false` otherwise\n * @see {@link isNegativeSafeInt} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `NegativeSafeInt` (the lower saturation\n * target of `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `NegativeSafeInt` (the upper saturation\n * target of `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the absolute value of a negative safe integer.\n *\n * The result is non-negative and keeps the `NegativeSafeInt` brand.\n *\n * @param a - The negative safe integer value\n * @returns The absolute value as a non-negative `NegativeSafeInt`\n */\n abs,\n\n /**\n * Returns the smallest of the given negative safe integers.\n *\n * @param values - The negative safe integers to compare (at least one required)\n * @returns The smallest value as a `NegativeSafeInt`\n */\n min: min_,\n\n /**\n * Returns the largest of the given negative safe integers.\n *\n * @param values - The negative safe integers to compare (at least one required)\n * @returns The largest value as a `NegativeSafeInt`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `NegativeSafeInt`, rounding to the\n * nearest integer and saturating the result into the range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * Unlike `asNegativeSafeInt`, this is total: out-of-range inputs are clamped\n * to the nearest representable `NegativeSafeInt` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as a `NegativeSafeInt`\n */\n fromNumber,\n\n /**\n * Generates a random `NegativeSafeInt` 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 `NegativeSafeInt` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NegativeSafeInt`\n * (floored to an integer).\n *\n * @param a - The base negative safe integer\n * @param b - The exponent negative safe integer\n * @returns `a ** b` as a `NegativeSafeInt`\n */\n pow,\n\n /**\n * Adds two negative safe integers, returning `a + b` as a `NegativeSafeInt`.\n *\n * @param a - The first negative safe integer\n * @param b - The second negative safe integer\n * @returns The sum of `a` and `b` as a `NegativeSafeInt`\n */\n add,\n\n /**\n * Subtracts two negative safe integers, returning `a - b` as a\n * `NegativeSafeInt`.\n *\n * @param a - The first negative safe integer\n * @param b - The second negative safe integer\n * @returns The difference of `a` and `b` as a `NegativeSafeInt`\n */\n sub,\n} as const;\n"],"names":[],"mappings":";;;AAWA,MAAM,iBAAA,GAAoB,yBAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA,EACT,WAAW,MAAA,CAAO,gBAAA;AAAA,EAClB,SAAA,EAAW,EAAA;AAAA,EACX;AACF,CAAU,CAAA;AAEV,MAAM,GAAA,GAAM,CAAC,CAAA,KACX,eAAA,CAAgB,WAAW,IAAA,CAAK,GAAA,CAAI,CAAC,CAAC,CAAA;AAWjC,MAAM,iBAAA,GAAoB;AAY1B,MAAM,iBAAA,GAAoB;AAS1B,MAAM,eAAA,GAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;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;AAAA,EAaL,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;AAAA,EAUA;AACF;;;;"}
|
|
@@ -3,18 +3,24 @@ import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
|
3
3
|
export type NonNegativeFiniteNumber = TtfImported_NonNegativeFiniteNumber;
|
|
4
4
|
type ElementType = NonNegativeFiniteNumber;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Type guard that checks if a value is a non-negative finite number.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Returns `true` only for a finite value — never `NaN`, `Infinity`, or
|
|
9
|
+
* `-Infinity`.
|
|
10
|
+
*
|
|
11
|
+
* @param value - The value to check
|
|
12
|
+
* @returns `true` if the value is a non-negative finite number, `false` otherwise
|
|
10
13
|
*/
|
|
11
14
|
export declare const isNonNegativeFiniteNumber: (a: number) => a is TtfImported_NonNegativeFiniteNumber;
|
|
12
15
|
/**
|
|
13
|
-
* Casts a number to
|
|
16
|
+
* Casts a `number` to the `NonNegativeFiniteNumber` branded type.
|
|
17
|
+
*
|
|
18
|
+
* Validates that the value is a non-negative finite number and returns it with
|
|
19
|
+
* the `NonNegativeFiniteNumber` brand. Throws a `TypeError` otherwise.
|
|
14
20
|
*
|
|
15
|
-
* @param value The value to cast
|
|
16
|
-
* @returns The value as a NonNegativeFiniteNumber
|
|
17
|
-
* @throws {TypeError} If the value is not a non-negative finite number
|
|
21
|
+
* @param value - The value to cast
|
|
22
|
+
* @returns The value as a `NonNegativeFiniteNumber`
|
|
23
|
+
* @throws {TypeError} If the value is not a non-negative finite number
|
|
18
24
|
*/
|
|
19
25
|
export declare const asNonNegativeFiniteNumber: <N extends number>(x: N) => number & {
|
|
20
26
|
readonly "> -2^16": true;
|
|
@@ -28,119 +34,128 @@ export declare const asNonNegativeFiniteNumber: <N extends number>(x: N) => numb
|
|
|
28
34
|
'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
|
|
29
35
|
}> & N;
|
|
30
36
|
/**
|
|
31
|
-
* Namespace providing type-safe
|
|
32
|
-
*
|
|
37
|
+
* Namespace providing type-safe operations for the `NonNegativeFiniteNumber`
|
|
38
|
+
* branded type.
|
|
33
39
|
*
|
|
34
|
-
*
|
|
35
|
-
* results to 0, while ensuring results remain finite (excluding NaN and
|
|
36
|
-
* Infinity). This type is useful for representing measurements, distances,
|
|
37
|
-
* weights, and other inherently non-negative values.
|
|
40
|
+
* The `NonNegativeFiniteNumber` type represents a non-negative finite number.
|
|
38
41
|
*/
|
|
39
42
|
export declare const NonNegativeFiniteNumber: {
|
|
40
43
|
/**
|
|
41
|
-
* Type guard
|
|
44
|
+
* Type guard that checks if a value is a non-negative finite number.
|
|
42
45
|
*
|
|
43
|
-
* @param value The value to check
|
|
44
|
-
* @returns `true` if the value is a non-negative finite number, `false`
|
|
45
|
-
*
|
|
46
|
+
* @param value - The value to check
|
|
47
|
+
* @returns `true` if the value is a non-negative finite number, `false` otherwise
|
|
48
|
+
* @see {@link isNonNegativeFiniteNumber} for usage examples
|
|
46
49
|
*/
|
|
47
50
|
readonly is: (a: number) => a is TtfImported_NonNegativeFiniteNumber;
|
|
48
51
|
/**
|
|
49
|
-
* The
|
|
50
|
-
*
|
|
51
|
-
* @readonly
|
|
52
|
+
* The smallest value representable as `NonNegativeFiniteNumber` (the lower
|
|
53
|
+
* saturation target of `fromNumber`).
|
|
52
54
|
*/
|
|
53
55
|
readonly MIN_VALUE: 0;
|
|
54
56
|
/**
|
|
55
|
-
* Returns the
|
|
57
|
+
* Returns the smallest of the given non-negative finite numbers.
|
|
56
58
|
*
|
|
57
|
-
* @param
|
|
58
|
-
* @
|
|
59
|
-
* @returns The minimum value as a NonNegativeFiniteNumber.
|
|
59
|
+
* @param values - The non-negative finite numbers to compare (at least one required)
|
|
60
|
+
* @returns The smallest value as a `NonNegativeFiniteNumber`
|
|
60
61
|
*/
|
|
61
62
|
readonly min: (...values: readonly TtfImported_NonNegativeFiniteNumber[]) => TtfImported_NonNegativeFiniteNumber;
|
|
62
63
|
/**
|
|
63
|
-
* Returns the
|
|
64
|
+
* Returns the largest of the given non-negative finite numbers.
|
|
64
65
|
*
|
|
65
|
-
* @param
|
|
66
|
-
* @
|
|
67
|
-
* @returns The maximum value as a NonNegativeFiniteNumber.
|
|
66
|
+
* @param values - The non-negative finite numbers to compare (at least one required)
|
|
67
|
+
* @returns The largest value as a `NonNegativeFiniteNumber`
|
|
68
68
|
*/
|
|
69
69
|
readonly max: (...values: readonly TtfImported_NonNegativeFiniteNumber[]) => TtfImported_NonNegativeFiniteNumber;
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
71
|
+
* Converts an arbitrary `number` into a `NonNegativeFiniteNumber`, saturating
|
|
72
|
+
* it into the range `[MIN_VALUE, MAX_VALUE]`.
|
|
72
73
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
74
|
+
* Unlike `asNonNegativeFiniteNumber`, this is total: out-of-range inputs are
|
|
75
|
+
* clamped to the nearest representable `NonNegativeFiniteNumber` instead of
|
|
76
|
+
* throwing.
|
|
77
|
+
*
|
|
78
|
+
* @param value - The value to convert
|
|
79
|
+
* @returns The value as a `NonNegativeFiniteNumber`
|
|
75
80
|
*/
|
|
76
|
-
readonly
|
|
81
|
+
readonly fromNumber: (x: number) => TtfImported_NonNegativeFiniteNumber;
|
|
77
82
|
/**
|
|
78
|
-
*
|
|
83
|
+
* Returns the greatest integer less than or equal to a non-negative finite
|
|
84
|
+
* number.
|
|
79
85
|
*
|
|
80
|
-
* @param
|
|
81
|
-
* @returns The
|
|
86
|
+
* @param a - The non-negative finite number value
|
|
87
|
+
* @returns The floored value as an integer
|
|
82
88
|
*/
|
|
83
89
|
readonly floor: (x: ElementType) => TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;
|
|
84
90
|
/**
|
|
85
|
-
*
|
|
91
|
+
* Returns the smallest integer greater than or equal to a non-negative finite
|
|
92
|
+
* number.
|
|
86
93
|
*
|
|
87
|
-
* @param
|
|
88
|
-
* @returns The
|
|
94
|
+
* @param a - The non-negative finite number value
|
|
95
|
+
* @returns The ceiled value as an integer
|
|
89
96
|
*/
|
|
90
97
|
readonly ceil: (x: ElementType) => TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;
|
|
91
98
|
/**
|
|
92
|
-
*
|
|
99
|
+
* Returns the value of a non-negative finite number rounded to the nearest
|
|
100
|
+
* integer.
|
|
93
101
|
*
|
|
94
|
-
* @param
|
|
95
|
-
* @returns The rounded value as
|
|
102
|
+
* @param a - The non-negative finite number value
|
|
103
|
+
* @returns The rounded value as an integer
|
|
96
104
|
*/
|
|
97
105
|
readonly round: (x: ElementType) => TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;
|
|
98
106
|
/**
|
|
99
|
-
* Generates a random NonNegativeFiniteNumber
|
|
107
|
+
* Generates a random `NonNegativeFiniteNumber` within the given range.
|
|
108
|
+
*
|
|
109
|
+
* The range is inclusive on both ends.
|
|
100
110
|
*
|
|
101
|
-
* @
|
|
111
|
+
* @param min - The minimum value (inclusive)
|
|
112
|
+
* @param max - The maximum value (inclusive)
|
|
113
|
+
* @returns A random `NonNegativeFiniteNumber` in `[min, max]`
|
|
102
114
|
*/
|
|
103
115
|
readonly random: (min?: TtfImported_NonNegativeFiniteNumber | undefined, max?: TtfImported_NonNegativeFiniteNumber | undefined) => TtfImported_NonNegativeFiniteNumber;
|
|
104
116
|
/**
|
|
105
|
-
* Raises a
|
|
106
|
-
* NonNegativeFiniteNumber
|
|
117
|
+
* Raises `a` to the power `b`, returning `a ** b` as a
|
|
118
|
+
* `NonNegativeFiniteNumber`.
|
|
107
119
|
*
|
|
108
|
-
* @param a The base
|
|
109
|
-
* @param b The exponent
|
|
110
|
-
* @returns `a ** b`
|
|
120
|
+
* @param a - The base non-negative finite number
|
|
121
|
+
* @param b - The exponent non-negative finite number
|
|
122
|
+
* @returns `a ** b` as a `NonNegativeFiniteNumber`
|
|
111
123
|
*/
|
|
112
124
|
readonly pow: (x: TtfImported_NonNegativeFiniteNumber, y: TtfImported_NonNegativeFiniteNumber) => TtfImported_NonNegativeFiniteNumber;
|
|
113
125
|
/**
|
|
114
|
-
* Adds two
|
|
126
|
+
* Adds two non-negative finite numbers, returning `a + b` as a
|
|
127
|
+
* `NonNegativeFiniteNumber`.
|
|
115
128
|
*
|
|
116
|
-
* @param a The first
|
|
117
|
-
* @param b The second
|
|
118
|
-
* @returns `a
|
|
129
|
+
* @param a - The first non-negative finite number
|
|
130
|
+
* @param b - The second non-negative finite number
|
|
131
|
+
* @returns The sum of `a` and `b` as a `NonNegativeFiniteNumber`
|
|
119
132
|
*/
|
|
120
133
|
readonly add: (x: TtfImported_NonNegativeFiniteNumber, y: TtfImported_NonNegativeFiniteNumber) => TtfImported_NonNegativeFiniteNumber;
|
|
121
134
|
/**
|
|
122
|
-
* Subtracts
|
|
135
|
+
* Subtracts two non-negative finite numbers, returning `a - b` as a
|
|
136
|
+
* `NonNegativeFiniteNumber`.
|
|
123
137
|
*
|
|
124
|
-
* @param a The
|
|
125
|
-
* @param b The
|
|
126
|
-
* @returns `a
|
|
127
|
-
* 0).
|
|
138
|
+
* @param a - The first non-negative finite number
|
|
139
|
+
* @param b - The second non-negative finite number
|
|
140
|
+
* @returns The difference of `a` and `b` as a `NonNegativeFiniteNumber`
|
|
128
141
|
*/
|
|
129
142
|
readonly sub: (x: TtfImported_NonNegativeFiniteNumber, y: TtfImported_NonNegativeFiniteNumber) => TtfImported_NonNegativeFiniteNumber;
|
|
130
143
|
/**
|
|
131
|
-
* Multiplies two
|
|
144
|
+
* Multiplies two non-negative finite numbers, returning `a * b` as a
|
|
145
|
+
* `NonNegativeFiniteNumber`.
|
|
132
146
|
*
|
|
133
|
-
* @param a The first
|
|
134
|
-
* @param b The second
|
|
135
|
-
* @returns `a
|
|
147
|
+
* @param a - The first non-negative finite number
|
|
148
|
+
* @param b - The second non-negative finite number
|
|
149
|
+
* @returns The product of `a` and `b` as a `NonNegativeFiniteNumber`
|
|
136
150
|
*/
|
|
137
151
|
readonly mul: (x: TtfImported_NonNegativeFiniteNumber, y: TtfImported_NonNegativeFiniteNumber) => TtfImported_NonNegativeFiniteNumber;
|
|
138
152
|
/**
|
|
139
|
-
* Divides
|
|
153
|
+
* Divides two non-negative finite numbers, returning `a / b` as a
|
|
154
|
+
* `NonNegativeFiniteNumber`.
|
|
140
155
|
*
|
|
141
|
-
* @param a The dividend
|
|
142
|
-
* @param b The divisor
|
|
143
|
-
* @returns `a / b`
|
|
156
|
+
* @param a - The dividend
|
|
157
|
+
* @param b - The divisor (must be non-zero)
|
|
158
|
+
* @returns `a / b` as a `NonNegativeFiniteNumber`
|
|
144
159
|
*/
|
|
145
160
|
readonly div: (x: TtfImported_NonNegativeFiniteNumber, y: number & {
|
|
146
161
|
readonly "!=0": true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-negative-finite-number.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-negative-finite-number.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,IAAI,mCAAmC,EAEpE,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,MAAM,uBAAuB,GAAG,mCAAmC,CAAC;AAE1E,KAAK,WAAW,GAAG,uBAAuB,CAAC;AAiD3C
|
|
1
|
+
{"version":3,"file":"non-negative-finite-number.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-negative-finite-number.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,IAAI,mCAAmC,EAEpE,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,MAAM,uBAAuB,GAAG,mCAAmC,CAAC;AAE1E,KAAK,WAAW,GAAG,uBAAuB,CAAC;AAiD3C;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,yDAAK,CAAC;AAE5C;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;MAAW,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;IAClC;;;;;;OAMG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;OAMG;wBArGA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC;IAuG3D;;;;;;OAMG;uBAxGA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC;IA0G3D;;;;;;OAMG;wBA3GA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC;IA6G3D;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;;;;;;;;;;;;CAEK,CAAC"}
|