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
|
@@ -37,91 +37,98 @@ const isNonPositiveFiniteNumber = is;
|
|
|
37
37
|
const asNonPositiveFiniteNumber = castType;
|
|
38
38
|
const NonPositiveFiniteNumber = {
|
|
39
39
|
/**
|
|
40
|
-
* Type guard
|
|
40
|
+
* Type guard that checks if a value is a non-positive finite number.
|
|
41
41
|
*
|
|
42
|
-
* @param value The value to check
|
|
43
|
-
* @returns `true` if the value is a non-positive finite number, `false`
|
|
44
|
-
*
|
|
42
|
+
* @param value - The value to check
|
|
43
|
+
* @returns `true` if the value is a non-positive finite number, `false` otherwise
|
|
44
|
+
* @see {@link isNonPositiveFiniteNumber} for usage examples
|
|
45
45
|
*/
|
|
46
46
|
is,
|
|
47
47
|
/**
|
|
48
|
-
* The
|
|
49
|
-
*
|
|
50
|
-
* @readonly
|
|
48
|
+
* The largest value representable as `NonPositiveFiniteNumber`.
|
|
51
49
|
*/
|
|
52
50
|
MAX_VALUE,
|
|
53
51
|
/**
|
|
54
|
-
* Returns the
|
|
52
|
+
* Returns the smallest of the given non-positive finite numbers.
|
|
55
53
|
*
|
|
56
|
-
* @param
|
|
57
|
-
* @
|
|
58
|
-
* @returns The minimum value as a NonPositiveFiniteNumber.
|
|
54
|
+
* @param values - The non-positive finite numbers to compare (at least one required)
|
|
55
|
+
* @returns The smallest value as a `NonPositiveFiniteNumber`
|
|
59
56
|
*/
|
|
60
57
|
min: min_,
|
|
61
58
|
/**
|
|
62
|
-
* Returns the
|
|
59
|
+
* Returns the largest of the given non-positive finite numbers.
|
|
63
60
|
*
|
|
64
|
-
* @param
|
|
65
|
-
* @
|
|
66
|
-
* @returns The maximum value as a NonPositiveFiniteNumber.
|
|
61
|
+
* @param values - The non-positive finite numbers to compare (at least one required)
|
|
62
|
+
* @returns The largest value as a `NonPositiveFiniteNumber`
|
|
67
63
|
*/
|
|
68
64
|
max: max_,
|
|
69
65
|
/**
|
|
70
|
-
* Clamps a number
|
|
66
|
+
* Clamps a `number` into the `NonPositiveFiniteNumber` range `[MIN_VALUE,
|
|
67
|
+
* MAX_VALUE]`.
|
|
71
68
|
*
|
|
72
|
-
* @param value The
|
|
73
|
-
* @returns The
|
|
69
|
+
* @param value - The value to clamp
|
|
70
|
+
* @returns The clamped value as a `NonPositiveFiniteNumber`
|
|
74
71
|
*/
|
|
75
72
|
clamp,
|
|
76
73
|
/**
|
|
77
|
-
*
|
|
74
|
+
* Returns the greatest integer less than or equal to a non-positive finite
|
|
75
|
+
* number.
|
|
78
76
|
*
|
|
79
|
-
* @param
|
|
80
|
-
* @returns The
|
|
77
|
+
* @param a - The non-positive finite number value
|
|
78
|
+
* @returns The floored value as an integer
|
|
81
79
|
*/
|
|
82
80
|
floor,
|
|
83
81
|
/**
|
|
84
|
-
*
|
|
82
|
+
* Returns the smallest integer greater than or equal to a non-positive finite
|
|
83
|
+
* number.
|
|
85
84
|
*
|
|
86
|
-
* @param
|
|
87
|
-
* @returns The
|
|
85
|
+
* @param a - The non-positive finite number value
|
|
86
|
+
* @returns The ceiled value as an integer
|
|
88
87
|
*/
|
|
89
88
|
ceil,
|
|
90
89
|
/**
|
|
91
|
-
*
|
|
90
|
+
* Returns the value of a non-positive finite number rounded to the nearest
|
|
91
|
+
* integer.
|
|
92
92
|
*
|
|
93
|
-
* @param
|
|
94
|
-
* @returns The rounded value as
|
|
93
|
+
* @param a - The non-positive finite number value
|
|
94
|
+
* @returns The rounded value as an integer
|
|
95
95
|
*/
|
|
96
96
|
round,
|
|
97
97
|
/**
|
|
98
|
-
* Generates a random NonPositiveFiniteNumber
|
|
98
|
+
* Generates a random `NonPositiveFiniteNumber` within the given range.
|
|
99
|
+
*
|
|
100
|
+
* The range is inclusive on both ends.
|
|
99
101
|
*
|
|
100
|
-
* @
|
|
102
|
+
* @param min - The minimum value (inclusive)
|
|
103
|
+
* @param max - The maximum value (inclusive)
|
|
104
|
+
* @returns A random `NonPositiveFiniteNumber` in `[min, max]`
|
|
101
105
|
*/
|
|
102
106
|
random,
|
|
103
107
|
/**
|
|
104
|
-
* Raises a
|
|
108
|
+
* Raises `a` to the power `b`, returning `a ** b` as a
|
|
109
|
+
* `NonPositiveFiniteNumber`.
|
|
105
110
|
*
|
|
106
|
-
* @param a The base
|
|
107
|
-
* @param b The exponent
|
|
108
|
-
* @returns `a ** b`
|
|
111
|
+
* @param a - The base non-positive finite number
|
|
112
|
+
* @param b - The exponent non-positive finite number
|
|
113
|
+
* @returns `a ** b` as a `NonPositiveFiniteNumber`
|
|
109
114
|
*/
|
|
110
115
|
pow,
|
|
111
116
|
/**
|
|
112
|
-
* Adds two
|
|
117
|
+
* Adds two non-positive finite numbers, returning `a + b` as a
|
|
118
|
+
* `NonPositiveFiniteNumber`.
|
|
113
119
|
*
|
|
114
|
-
* @param a The first
|
|
115
|
-
* @param b The second
|
|
116
|
-
* @returns `a
|
|
120
|
+
* @param a - The first non-positive finite number
|
|
121
|
+
* @param b - The second non-positive finite number
|
|
122
|
+
* @returns The sum of `a` and `b` as a `NonPositiveFiniteNumber`
|
|
117
123
|
*/
|
|
118
124
|
add,
|
|
119
125
|
/**
|
|
120
|
-
* Subtracts
|
|
126
|
+
* Subtracts two non-positive finite numbers, returning `a - b` as a
|
|
127
|
+
* `NonPositiveFiniteNumber`.
|
|
121
128
|
*
|
|
122
|
-
* @param a The
|
|
123
|
-
* @param b The
|
|
124
|
-
* @returns `a
|
|
129
|
+
* @param a - The first non-positive finite number
|
|
130
|
+
* @param b - The second non-positive finite number
|
|
131
|
+
* @returns The difference of `a` and `b` as a `NonPositiveFiniteNumber`
|
|
125
132
|
*/
|
|
126
133
|
sub
|
|
127
134
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-positive-finite-number.mjs","sources":["../../../src/number/branded-types/non-positive-finite-number.mts"],"sourcesContent":["import { type NonPositiveFiniteNumber as TtfImported_NonPositiveFiniteNumber } from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonPositiveFiniteNumber = TtfImported_NonPositiveFiniteNumber;\n\ntype ElementType = NonPositiveFiniteNumber;\n\nconst typeNameInMessage = 'a non-positive finite number';\n\nconst {\n MAX_VALUE,\n add,\n castType,\n clamp,\n is,\n max: max_,\n min: min_,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForFloat<\n ElementType,\n number,\n 0\n>({\n MIN_VALUE: Number.MAX_VALUE * -1,\n MAX_VALUE: 0,\n typeNameInMessage,\n} as const);\n\nconst floor = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.floor(\n x,\n ) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\nconst ceil = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.ceil(x) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\nconst round = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.round(\n x,\n ) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"non-positive-finite-number.mjs","sources":["../../../src/number/branded-types/non-positive-finite-number.mts"],"sourcesContent":["import { type NonPositiveFiniteNumber as TtfImported_NonPositiveFiniteNumber } from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonPositiveFiniteNumber = TtfImported_NonPositiveFiniteNumber;\n\ntype ElementType = NonPositiveFiniteNumber;\n\nconst typeNameInMessage = 'a non-positive finite number';\n\nconst {\n MAX_VALUE,\n add,\n castType,\n clamp,\n is,\n max: max_,\n min: min_,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForFloat<\n ElementType,\n number,\n 0\n>({\n MIN_VALUE: Number.MAX_VALUE * -1,\n MAX_VALUE: 0,\n typeNameInMessage,\n} as const);\n\nconst floor = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.floor(\n x,\n ) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\nconst ceil = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.ceil(x) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\nconst round = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.round(\n x,\n ) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\n/**\n * Type guard that checks if a value is a non-positive finite number.\n *\n * Returns `true` only for a finite value — never `NaN`, `Infinity`, or\n * `-Infinity`.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-positive finite number, `false` otherwise\n */\nexport const isNonPositiveFiniteNumber = is;\n\n/**\n * Casts a `number` to the `NonPositiveFiniteNumber` branded type.\n *\n * Validates that the value is a non-positive finite number and returns it with\n * the `NonPositiveFiniteNumber` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonPositiveFiniteNumber`\n * @throws {TypeError} If the value is not a non-positive finite number\n */\nexport const asNonPositiveFiniteNumber = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonPositiveFiniteNumber`\n * branded type.\n *\n * The `NonPositiveFiniteNumber` type represents a non-positive finite number.\n */\nexport const NonPositiveFiniteNumber = {\n /**\n * Type guard that checks if a value is a non-positive finite number.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-positive finite number, `false` otherwise\n * @see {@link isNonPositiveFiniteNumber} for usage examples\n */\n is,\n\n /**\n * The largest value representable as `NonPositiveFiniteNumber`.\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given non-positive finite numbers.\n *\n * @param values - The non-positive finite numbers to compare (at least one required)\n * @returns The smallest value as a `NonPositiveFiniteNumber`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-positive finite numbers.\n *\n * @param values - The non-positive finite numbers to compare (at least one required)\n * @returns The largest value as a `NonPositiveFiniteNumber`\n */\n max: max_,\n\n /**\n * Clamps a `number` into the `NonPositiveFiniteNumber` range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * @param value - The value to clamp\n * @returns The clamped value as a `NonPositiveFiniteNumber`\n */\n clamp,\n\n /**\n * Returns the greatest integer less than or equal to a non-positive finite\n * number.\n *\n * @param a - The non-positive finite number value\n * @returns The floored value as an integer\n */\n floor,\n\n /**\n * Returns the smallest integer greater than or equal to a non-positive finite\n * number.\n *\n * @param a - The non-positive finite number value\n * @returns The ceiled value as an integer\n */\n ceil,\n\n /**\n * Returns the value of a non-positive finite number rounded to the nearest\n * integer.\n *\n * @param a - The non-positive finite number value\n * @returns The rounded value as an integer\n */\n round,\n\n /**\n * Generates a random `NonPositiveFiniteNumber` 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 `NonPositiveFiniteNumber` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a\n * `NonPositiveFiniteNumber`.\n *\n * @param a - The base non-positive finite number\n * @param b - The exponent non-positive finite number\n * @returns `a ** b` as a `NonPositiveFiniteNumber`\n */\n pow,\n\n /**\n * Adds two non-positive finite numbers, returning `a + b` as a\n * `NonPositiveFiniteNumber`.\n *\n * @param a - The first non-positive finite number\n * @param b - The second non-positive finite number\n * @returns The sum of `a` and `b` as a `NonPositiveFiniteNumber`\n */\n add,\n\n /**\n * Subtracts two non-positive finite numbers, returning `a - b` as a\n * `NonPositiveFiniteNumber`.\n *\n * @param a - The first non-positive finite number\n * @param b - The second non-positive finite number\n * @returns The difference of `a` and `b` as a `NonPositiveFiniteNumber`\n */\n sub,\n} as const;\n"],"names":[],"mappings":";;AAOA,MAAM,iBAAA,GAAoB,8BAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;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,iBAAA,CAI1C;AAAA,EACA,SAAA,EAAW,OAAO,SAAA,GAAY,EAAA;AAAA,EAC9B,SAAA,EAAW,CAAA;AAAA,EACX;AACF,CAAU,CAAA;AAEV,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAA;AAAA,IACH;AAAA;AACF,CAAA;AAIF,MAAM,OAAO,CACX,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAK,CAAC;AAAA,CAAA;AAIb,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAA;AAAA,IACH;AAAA;AACF,CAAA;AAaK,MAAM,yBAAA,GAA4B;AAYlC,MAAM,yBAAA,GAA4B;AAQlC,MAAM,uBAAA,GAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQrC,EAAA;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,EASA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,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;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AACF;;;;"}
|
|
@@ -3,43 +3,22 @@ export type NonPositiveInt = TtfImported_NonPositiveInt;
|
|
|
3
3
|
/**
|
|
4
4
|
* Type guard that checks if a value is a non-positive integer.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* assert.isTrue(isNonPositiveInt(0));
|
|
14
|
-
*
|
|
15
|
-
* assert.isTrue(isNonPositiveInt(-5));
|
|
16
|
-
*
|
|
17
|
-
* assert.isFalse(isNonPositiveInt(1));
|
|
18
|
-
* ```
|
|
6
|
+
* Returns `true` for a non-positive integer — a value with no fractional
|
|
7
|
+
* component, including values outside the safe integer range (unlike
|
|
8
|
+
* `SafeInt`).
|
|
19
9
|
*
|
|
20
10
|
* @param value - The value to check
|
|
21
11
|
* @returns `true` if the value is a non-positive integer, `false` otherwise
|
|
22
12
|
*/
|
|
23
13
|
export declare const isNonPositiveInt: (a: number) => a is TtfImported_NonPositiveInt;
|
|
24
14
|
/**
|
|
25
|
-
* Casts a number to
|
|
26
|
-
*
|
|
27
|
-
* This function validates that the input is a non-positive integer (<= 0) and
|
|
28
|
-
* returns it with the NonPositiveInt brand. This ensures type safety for
|
|
29
|
-
* operations that require non-positive integer values.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
15
|
+
* Casts a `number` to the `NonPositiveInt` branded type.
|
|
32
16
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* assert.isTrue(branded === -7);
|
|
37
|
-
*
|
|
38
|
-
* assert.isTrue(NonPositiveInt.is(branded));
|
|
39
|
-
* ```
|
|
17
|
+
* Validates that the value is a non-positive integer and returns it with the
|
|
18
|
+
* `NonPositiveInt` brand. Throws a `TypeError` otherwise.
|
|
40
19
|
*
|
|
41
20
|
* @param value - The value to cast
|
|
42
|
-
* @returns The value as a NonPositiveInt
|
|
21
|
+
* @returns The value as a `NonPositiveInt`
|
|
43
22
|
* @throws {TypeError} If the value is not a non-positive integer
|
|
44
23
|
*/
|
|
45
24
|
export declare const asNonPositiveInt: <N extends number>(x: N) => number & {
|
|
@@ -55,169 +34,85 @@ export declare const asNonPositiveInt: <N extends number>(x: N) => number & {
|
|
|
55
34
|
'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
|
|
56
35
|
}> & N;
|
|
57
36
|
/**
|
|
58
|
-
* Namespace providing type-safe operations for NonPositiveInt branded
|
|
59
|
-
*
|
|
60
|
-
* NonPositiveInt represents integers that are less than or equal to zero (<= 0).
|
|
61
|
-
* All operations automatically clamp results to maintain the non-positive
|
|
62
|
-
* constraint, ensuring that arithmetic operations never produce positive values.
|
|
37
|
+
* Namespace providing type-safe operations for the `NonPositiveInt` branded
|
|
38
|
+
* type.
|
|
63
39
|
*
|
|
64
|
-
*
|
|
40
|
+
* The `NonPositiveInt` type represents a non-positive integer. Division (`div`)
|
|
41
|
+
* uses floor division.
|
|
65
42
|
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* - Negative counts or differences
|
|
70
|
-
* - Depth or altitude below a reference point
|
|
43
|
+
* Unlike `SafeInt`, `NonPositiveInt` allows values outside the safe integer
|
|
44
|
+
* range (±2^53 − 1), so very large magnitudes may lose precision in
|
|
45
|
+
* JavaScript's `number` type.
|
|
71
46
|
*/
|
|
72
47
|
export declare const NonPositiveInt: {
|
|
73
48
|
/**
|
|
74
49
|
* Type guard that checks if a value is a non-positive integer.
|
|
75
50
|
*
|
|
76
|
-
* @example
|
|
77
|
-
*
|
|
78
|
-
* ```ts
|
|
79
|
-
* const value: number = -42;
|
|
80
|
-
*
|
|
81
|
-
* if (NonPositiveInt.is(value)) {
|
|
82
|
-
* // value is now typed as NonPositiveInt
|
|
83
|
-
* const debt = value;
|
|
84
|
-
* }
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
51
|
* @param value - The value to check
|
|
88
52
|
* @returns `true` if the value is a non-positive integer, `false` otherwise
|
|
53
|
+
* @see {@link isNonPositiveInt} for usage examples
|
|
89
54
|
*/
|
|
90
55
|
readonly is: (a: number) => a is TtfImported_NonPositiveInt;
|
|
91
56
|
/**
|
|
92
|
-
* The
|
|
93
|
-
*
|
|
94
|
-
* @readonly
|
|
57
|
+
* The largest value representable as `NonPositiveInt`.
|
|
95
58
|
*/
|
|
96
59
|
readonly MAX_VALUE: 0;
|
|
97
60
|
/**
|
|
98
|
-
* Returns the
|
|
99
|
-
*
|
|
100
|
-
* Since non-positive integers range from negative infinity to 0, the smaller
|
|
101
|
-
* value is the one further from zero (more negative).
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
61
|
+
* Returns the smallest of the given non-positive integers.
|
|
104
62
|
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* assert.strictEqual(result, -10);
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* @param a - The first non-positive integer
|
|
112
|
-
* @param b - The second non-positive integer
|
|
113
|
-
* @returns The minimum value as a non-positive integer
|
|
63
|
+
* @param values - The non-positive integers to compare (at least one required)
|
|
64
|
+
* @returns The smallest value as a `NonPositiveInt`
|
|
114
65
|
*/
|
|
115
66
|
readonly min: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>[]) => TtfImported_NonPositiveInt;
|
|
116
67
|
/**
|
|
117
|
-
* Returns the
|
|
118
|
-
*
|
|
119
|
-
* Since non-positive integers range from negative infinity to 0, the larger
|
|
120
|
-
* value is the one closer to zero (less negative).
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
*
|
|
124
|
-
* ```ts
|
|
125
|
-
* const result = NonPositiveInt.max(-5, -10);
|
|
126
|
-
*
|
|
127
|
-
* assert.strictEqual(result, -5);
|
|
128
|
-
* ```
|
|
68
|
+
* Returns the largest of the given non-positive integers.
|
|
129
69
|
*
|
|
130
|
-
* @param
|
|
131
|
-
* @
|
|
132
|
-
* @returns The maximum value as a non-positive integer
|
|
70
|
+
* @param values - The non-positive integers to compare (at least one required)
|
|
71
|
+
* @returns The largest value as a `NonPositiveInt`
|
|
133
72
|
*/
|
|
134
73
|
readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>[]) => TtfImported_NonPositiveInt;
|
|
135
74
|
/**
|
|
136
|
-
* Clamps a number
|
|
137
|
-
*
|
|
138
|
-
* Any positive value is clamped to 0 (the maximum non-positive integer).
|
|
139
|
-
* Negative values are preserved as long as they are valid integers.
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
*
|
|
143
|
-
* ```ts
|
|
144
|
-
* assert.strictEqual(NonPositiveInt.clamp(5), 0);
|
|
145
|
-
*
|
|
146
|
-
* assert.strictEqual(NonPositiveInt.clamp(-5), -5);
|
|
75
|
+
* Clamps a `number` into the `NonPositiveInt` range, rounding to the nearest
|
|
76
|
+
* integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
|
|
147
77
|
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* @param value - The number to clamp
|
|
152
|
-
* @returns The value clamped to the non-positive integer range
|
|
78
|
+
* @param value - The value to clamp
|
|
79
|
+
* @returns The clamped value as a `NonPositiveInt`
|
|
153
80
|
*/
|
|
154
81
|
readonly clamp: (x: number) => TtfImported_NonPositiveInt;
|
|
155
82
|
/**
|
|
156
|
-
* Generates a random
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
|
-
*
|
|
160
|
-
* ```ts
|
|
161
|
-
* const randomValue = NonPositiveInt.random();
|
|
83
|
+
* Generates a random `NonPositiveInt` within the given range.
|
|
162
84
|
*
|
|
163
|
-
*
|
|
164
|
-
* ```
|
|
85
|
+
* The range is inclusive on both ends.
|
|
165
86
|
*
|
|
166
|
-
* @
|
|
87
|
+
* @param min - The minimum value (inclusive)
|
|
88
|
+
* @param max - The maximum value (inclusive)
|
|
89
|
+
* @returns A random `NonPositiveInt` in `[min, max]`
|
|
167
90
|
*/
|
|
168
91
|
readonly random: (min?: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt> | undefined, max?: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt> | undefined) => TtfImported_NonPositiveInt;
|
|
169
92
|
/**
|
|
170
|
-
* Raises a
|
|
171
|
-
*
|
|
172
|
-
* The result is clamped to the non-positive integer range.
|
|
173
|
-
*
|
|
174
|
-
* @example
|
|
175
|
-
*
|
|
176
|
-
* ```ts
|
|
177
|
-
* const result = NonPositiveInt.pow(-2, -1);
|
|
178
|
-
* ```
|
|
93
|
+
* Raises `a` to the power `b`, returning `a ** b` as a `NonPositiveInt`
|
|
94
|
+
* (floored to an integer).
|
|
179
95
|
*
|
|
180
96
|
* @param a - The base non-positive integer
|
|
181
97
|
* @param b - The exponent non-positive integer
|
|
182
|
-
* @returns `a ** b`
|
|
98
|
+
* @returns `a ** b` as a `NonPositiveInt`
|
|
183
99
|
*/
|
|
184
100
|
readonly pow: (x: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>, y: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>) => TtfImported_NonPositiveInt;
|
|
185
101
|
/**
|
|
186
|
-
* Adds two non-positive integers
|
|
187
|
-
*
|
|
188
|
-
* The result is clamped to the non-positive integer range. If the sum is
|
|
189
|
-
* positive, it is clamped to 0.
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
*
|
|
193
|
-
* ```ts
|
|
194
|
-
* assert.strictEqual(NonPositiveInt.add(-5, -3), -8);
|
|
195
|
-
*
|
|
196
|
-
* assert.strictEqual(NonPositiveInt.add(-5, 10), 0);
|
|
197
|
-
* ```
|
|
102
|
+
* Adds two non-positive integers, returning `a + b` as a `NonPositiveInt`.
|
|
198
103
|
*
|
|
199
104
|
* @param a - The first non-positive integer
|
|
200
105
|
* @param b - The second non-positive integer
|
|
201
|
-
* @returns `a
|
|
106
|
+
* @returns The sum of `a` and `b` as a `NonPositiveInt`
|
|
202
107
|
*/
|
|
203
108
|
readonly add: (x: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>, y: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>) => TtfImported_NonPositiveInt;
|
|
204
109
|
/**
|
|
205
|
-
* Subtracts
|
|
206
|
-
*
|
|
207
|
-
* The result is clamped to the non-positive integer range. If the result is
|
|
208
|
-
* positive, it is clamped to 0.
|
|
110
|
+
* Subtracts two non-positive integers, returning `a - b` as a
|
|
111
|
+
* `NonPositiveInt`.
|
|
209
112
|
*
|
|
210
|
-
* @
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
* assert.strictEqual(NonPositiveInt.sub(-10, -3), -7);
|
|
214
|
-
*
|
|
215
|
-
* assert.strictEqual(NonPositiveInt.sub(-10, 5), 0);
|
|
216
|
-
* ```
|
|
217
|
-
*
|
|
218
|
-
* @param a - The minuend non-positive integer
|
|
219
|
-
* @param b - The subtrahend non-positive integer
|
|
220
|
-
* @returns `a - b` clamped to the non-positive integer range
|
|
113
|
+
* @param a - The first non-positive integer
|
|
114
|
+
* @param b - The second non-positive integer
|
|
115
|
+
* @returns The difference of `a` and `b` as a `NonPositiveInt`
|
|
221
116
|
*/
|
|
222
117
|
readonly sub: (x: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>, y: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>) => TtfImported_NonPositiveInt;
|
|
223
118
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-positive-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-positive-int.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,IAAI,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAGlF,MAAM,MAAM,cAAc,GAAG,0BAA0B,CAAC;AA4BxD
|
|
1
|
+
{"version":3,"file":"non-positive-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-positive-int.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,IAAI,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAGlF,MAAM,MAAM,cAAc,GAAG,0BAA0B,CAAC;AA4BxD;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,gDAAK,CAAC;AAEnC;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;MAAW,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc;IACzB;;;;;;OAMG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;OAOG;;CAEK,CAAC"}
|
|
@@ -24,151 +24,71 @@ const NonPositiveInt = {
|
|
|
24
24
|
/**
|
|
25
25
|
* Type guard that checks if a value is a non-positive integer.
|
|
26
26
|
*
|
|
27
|
-
* @example
|
|
28
|
-
*
|
|
29
|
-
* ```ts
|
|
30
|
-
* const value: number = -42;
|
|
31
|
-
*
|
|
32
|
-
* if (NonPositiveInt.is(value)) {
|
|
33
|
-
* // value is now typed as NonPositiveInt
|
|
34
|
-
* const debt = value;
|
|
35
|
-
* }
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
27
|
* @param value - The value to check
|
|
39
28
|
* @returns `true` if the value is a non-positive integer, `false` otherwise
|
|
29
|
+
* @see {@link isNonPositiveInt} for usage examples
|
|
40
30
|
*/
|
|
41
31
|
is,
|
|
42
32
|
/**
|
|
43
|
-
* The
|
|
44
|
-
*
|
|
45
|
-
* @readonly
|
|
33
|
+
* The largest value representable as `NonPositiveInt`.
|
|
46
34
|
*/
|
|
47
35
|
MAX_VALUE,
|
|
48
36
|
/**
|
|
49
|
-
* Returns the
|
|
50
|
-
*
|
|
51
|
-
* Since non-positive integers range from negative infinity to 0, the smaller
|
|
52
|
-
* value is the one further from zero (more negative).
|
|
37
|
+
* Returns the smallest of the given non-positive integers.
|
|
53
38
|
*
|
|
54
|
-
* @
|
|
55
|
-
*
|
|
56
|
-
* ```ts
|
|
57
|
-
* const result = NonPositiveInt.min(-5, -10);
|
|
58
|
-
*
|
|
59
|
-
* assert.strictEqual(result, -10);
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* @param a - The first non-positive integer
|
|
63
|
-
* @param b - The second non-positive integer
|
|
64
|
-
* @returns The minimum value as a non-positive integer
|
|
39
|
+
* @param values - The non-positive integers to compare (at least one required)
|
|
40
|
+
* @returns The smallest value as a `NonPositiveInt`
|
|
65
41
|
*/
|
|
66
42
|
min: min_,
|
|
67
43
|
/**
|
|
68
|
-
* Returns the
|
|
69
|
-
*
|
|
70
|
-
* Since non-positive integers range from negative infinity to 0, the larger
|
|
71
|
-
* value is the one closer to zero (less negative).
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
*
|
|
75
|
-
* ```ts
|
|
76
|
-
* const result = NonPositiveInt.max(-5, -10);
|
|
77
|
-
*
|
|
78
|
-
* assert.strictEqual(result, -5);
|
|
79
|
-
* ```
|
|
44
|
+
* Returns the largest of the given non-positive integers.
|
|
80
45
|
*
|
|
81
|
-
* @param
|
|
82
|
-
* @
|
|
83
|
-
* @returns The maximum value as a non-positive integer
|
|
46
|
+
* @param values - The non-positive integers to compare (at least one required)
|
|
47
|
+
* @returns The largest value as a `NonPositiveInt`
|
|
84
48
|
*/
|
|
85
49
|
max: max_,
|
|
86
50
|
/**
|
|
87
|
-
* Clamps a number
|
|
88
|
-
*
|
|
89
|
-
* Any positive value is clamped to 0 (the maximum non-positive integer).
|
|
90
|
-
* Negative values are preserved as long as they are valid integers.
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
51
|
+
* Clamps a `number` into the `NonPositiveInt` range, rounding to the nearest
|
|
52
|
+
* integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
|
|
93
53
|
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* assert.strictEqual(NonPositiveInt.clamp(-5), -5);
|
|
98
|
-
*
|
|
99
|
-
* assert.strictEqual(NonPositiveInt.clamp(0), 0);
|
|
100
|
-
* ```
|
|
101
|
-
*
|
|
102
|
-
* @param value - The number to clamp
|
|
103
|
-
* @returns The value clamped to the non-positive integer range
|
|
54
|
+
* @param value - The value to clamp
|
|
55
|
+
* @returns The clamped value as a `NonPositiveInt`
|
|
104
56
|
*/
|
|
105
57
|
clamp,
|
|
106
58
|
/**
|
|
107
|
-
* Generates a random
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
*
|
|
111
|
-
* ```ts
|
|
112
|
-
* const randomValue = NonPositiveInt.random();
|
|
59
|
+
* Generates a random `NonPositiveInt` within the given range.
|
|
113
60
|
*
|
|
114
|
-
*
|
|
115
|
-
* ```
|
|
61
|
+
* The range is inclusive on both ends.
|
|
116
62
|
*
|
|
117
|
-
* @
|
|
63
|
+
* @param min - The minimum value (inclusive)
|
|
64
|
+
* @param max - The maximum value (inclusive)
|
|
65
|
+
* @returns A random `NonPositiveInt` in `[min, max]`
|
|
118
66
|
*/
|
|
119
67
|
random,
|
|
120
68
|
/**
|
|
121
|
-
* Raises a
|
|
122
|
-
*
|
|
123
|
-
* The result is clamped to the non-positive integer range.
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
*
|
|
127
|
-
* ```ts
|
|
128
|
-
* const result = NonPositiveInt.pow(-2, -1);
|
|
129
|
-
* ```
|
|
69
|
+
* Raises `a` to the power `b`, returning `a ** b` as a `NonPositiveInt`
|
|
70
|
+
* (floored to an integer).
|
|
130
71
|
*
|
|
131
72
|
* @param a - The base non-positive integer
|
|
132
73
|
* @param b - The exponent non-positive integer
|
|
133
|
-
* @returns `a ** b`
|
|
74
|
+
* @returns `a ** b` as a `NonPositiveInt`
|
|
134
75
|
*/
|
|
135
76
|
pow,
|
|
136
77
|
/**
|
|
137
|
-
* Adds two non-positive integers
|
|
138
|
-
*
|
|
139
|
-
* The result is clamped to the non-positive integer range. If the sum is
|
|
140
|
-
* positive, it is clamped to 0.
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
*
|
|
144
|
-
* ```ts
|
|
145
|
-
* assert.strictEqual(NonPositiveInt.add(-5, -3), -8);
|
|
146
|
-
*
|
|
147
|
-
* assert.strictEqual(NonPositiveInt.add(-5, 10), 0);
|
|
148
|
-
* ```
|
|
78
|
+
* Adds two non-positive integers, returning `a + b` as a `NonPositiveInt`.
|
|
149
79
|
*
|
|
150
80
|
* @param a - The first non-positive integer
|
|
151
81
|
* @param b - The second non-positive integer
|
|
152
|
-
* @returns `a
|
|
82
|
+
* @returns The sum of `a` and `b` as a `NonPositiveInt`
|
|
153
83
|
*/
|
|
154
84
|
add,
|
|
155
85
|
/**
|
|
156
|
-
* Subtracts
|
|
157
|
-
*
|
|
158
|
-
* The result is clamped to the non-positive integer range. If the result is
|
|
159
|
-
* positive, it is clamped to 0.
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
86
|
+
* Subtracts two non-positive integers, returning `a - b` as a
|
|
87
|
+
* `NonPositiveInt`.
|
|
162
88
|
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* assert.strictEqual(NonPositiveInt.sub(-10, 5), 0);
|
|
167
|
-
* ```
|
|
168
|
-
*
|
|
169
|
-
* @param a - The minuend non-positive integer
|
|
170
|
-
* @param b - The subtrahend non-positive integer
|
|
171
|
-
* @returns `a - b` clamped to the non-positive integer range
|
|
89
|
+
* @param a - The first non-positive integer
|
|
90
|
+
* @param b - The second non-positive integer
|
|
91
|
+
* @returns The difference of `a` and `b` as a `NonPositiveInt`
|
|
172
92
|
*/
|
|
173
93
|
sub
|
|
174
94
|
};
|