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.
Files changed (171) hide show
  1. package/dist/number/branded-types/finite-number.d.mts +47 -61
  2. package/dist/number/branded-types/finite-number.d.mts.map +1 -1
  3. package/dist/number/branded-types/finite-number.mjs +37 -41
  4. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  5. package/dist/number/branded-types/int.d.mts +40 -46
  6. package/dist/number/branded-types/int.d.mts.map +1 -1
  7. package/dist/number/branded-types/int.mjs +29 -31
  8. package/dist/number/branded-types/int.mjs.map +1 -1
  9. package/dist/number/branded-types/int16.d.mts +65 -58
  10. package/dist/number/branded-types/int16.d.mts.map +1 -1
  11. package/dist/number/branded-types/int16.mjs +49 -45
  12. package/dist/number/branded-types/int16.mjs.map +1 -1
  13. package/dist/number/branded-types/int32.d.mts +65 -58
  14. package/dist/number/branded-types/int32.d.mts.map +1 -1
  15. package/dist/number/branded-types/int32.mjs +49 -45
  16. package/dist/number/branded-types/int32.mjs.map +1 -1
  17. package/dist/number/branded-types/negative-finite-number.d.mts +68 -59
  18. package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
  19. package/dist/number/branded-types/negative-finite-number.mjs +52 -46
  20. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  21. package/dist/number/branded-types/negative-int.d.mts +60 -48
  22. package/dist/number/branded-types/negative-int.d.mts.map +1 -1
  23. package/dist/number/branded-types/negative-int.mjs +40 -36
  24. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  25. package/dist/number/branded-types/negative-safe-int.d.mts +57 -56
  26. package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
  27. package/dist/number/branded-types/negative-safe-int.mjs +40 -41
  28. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  29. package/dist/number/branded-types/non-negative-finite-number.d.mts +74 -64
  30. package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
  31. package/dist/number/branded-types/non-negative-finite-number.mjs +58 -51
  32. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  33. package/dist/number/branded-types/non-negative-int16.d.mts +64 -57
  34. package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
  35. package/dist/number/branded-types/non-negative-int16.mjs +47 -43
  36. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  37. package/dist/number/branded-types/non-negative-int32.d.mts +64 -58
  38. package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
  39. package/dist/number/branded-types/non-negative-int32.mjs +47 -44
  40. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  41. package/dist/number/branded-types/non-positive-finite-number.d.mts +64 -54
  42. package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
  43. package/dist/number/branded-types/non-positive-finite-number.mjs +48 -41
  44. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  45. package/dist/number/branded-types/non-positive-int.d.mts +41 -146
  46. package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
  47. package/dist/number/branded-types/non-positive-int.mjs +27 -107
  48. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  49. package/dist/number/branded-types/non-positive-safe-int.d.mts +54 -53
  50. package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
  51. package/dist/number/branded-types/non-positive-safe-int.mjs +37 -39
  52. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  53. package/dist/number/branded-types/non-zero-finite-number.d.mts +62 -49
  54. package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
  55. package/dist/number/branded-types/non-zero-finite-number.mjs +46 -37
  56. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  57. package/dist/number/branded-types/non-zero-int.d.mts +51 -38
  58. package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
  59. package/dist/number/branded-types/non-zero-int.mjs +31 -27
  60. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  61. package/dist/number/branded-types/non-zero-int16.d.mts +52 -53
  62. package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
  63. package/dist/number/branded-types/non-zero-int16.mjs +36 -39
  64. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  65. package/dist/number/branded-types/non-zero-int32.d.mts +52 -54
  66. package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
  67. package/dist/number/branded-types/non-zero-int32.mjs +36 -40
  68. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  69. package/dist/number/branded-types/non-zero-safe-int.d.mts +53 -54
  70. package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
  71. package/dist/number/branded-types/non-zero-safe-int.mjs +36 -40
  72. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  73. package/dist/number/branded-types/non-zero-uint16.d.mts +52 -53
  74. package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
  75. package/dist/number/branded-types/non-zero-uint16.mjs +35 -39
  76. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  77. package/dist/number/branded-types/non-zero-uint32.d.mts +52 -53
  78. package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
  79. package/dist/number/branded-types/non-zero-uint32.mjs +35 -39
  80. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  81. package/dist/number/branded-types/positive-finite-number.d.mts +74 -63
  82. package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
  83. package/dist/number/branded-types/positive-finite-number.mjs +58 -50
  84. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  85. package/dist/number/branded-types/positive-int.d.mts +46 -68
  86. package/dist/number/branded-types/positive-int.d.mts.map +1 -1
  87. package/dist/number/branded-types/positive-int.mjs +34 -49
  88. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  89. package/dist/number/branded-types/positive-int16.d.mts +61 -57
  90. package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
  91. package/dist/number/branded-types/positive-int16.mjs +44 -43
  92. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  93. package/dist/number/branded-types/positive-int32.d.mts +61 -57
  94. package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
  95. package/dist/number/branded-types/positive-int32.mjs +44 -43
  96. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  97. package/dist/number/branded-types/positive-safe-int.d.mts +62 -57
  98. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
  99. package/dist/number/branded-types/positive-safe-int.mjs +45 -43
  100. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  101. package/dist/number/branded-types/positive-uint16.d.mts +61 -57
  102. package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
  103. package/dist/number/branded-types/positive-uint16.mjs +44 -43
  104. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  105. package/dist/number/branded-types/positive-uint32.d.mts +61 -58
  106. package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
  107. package/dist/number/branded-types/positive-uint32.mjs +44 -44
  108. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  109. package/dist/number/branded-types/safe-int.d.mts +43 -62
  110. package/dist/number/branded-types/safe-int.d.mts.map +1 -1
  111. package/dist/number/branded-types/safe-int.mjs +35 -42
  112. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  113. package/dist/number/branded-types/safe-uint.d.mts +62 -57
  114. package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
  115. package/dist/number/branded-types/safe-uint.mjs +46 -44
  116. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  117. package/dist/number/branded-types/uint.d.mts +63 -50
  118. package/dist/number/branded-types/uint.d.mts.map +1 -1
  119. package/dist/number/branded-types/uint.mjs +42 -39
  120. package/dist/number/branded-types/uint.mjs.map +1 -1
  121. package/dist/number/branded-types/uint16.d.mts +60 -58
  122. package/dist/number/branded-types/uint16.d.mts.map +1 -1
  123. package/dist/number/branded-types/uint16.mjs +44 -43
  124. package/dist/number/branded-types/uint16.mjs.map +1 -1
  125. package/dist/number/branded-types/uint32.d.mts +59 -55
  126. package/dist/number/branded-types/uint32.d.mts.map +1 -1
  127. package/dist/number/branded-types/uint32.mjs +42 -42
  128. package/dist/number/branded-types/uint32.mjs.map +1 -1
  129. package/dist/number/enum/int8.d.mts +56 -65
  130. package/dist/number/enum/int8.d.mts.map +1 -1
  131. package/dist/number/enum/int8.mjs +44 -43
  132. package/dist/number/enum/int8.mjs.map +1 -1
  133. package/dist/number/enum/uint8.d.mts +60 -58
  134. package/dist/number/enum/uint8.d.mts.map +1 -1
  135. package/dist/number/enum/uint8.mjs +44 -43
  136. package/dist/number/enum/uint8.mjs.map +1 -1
  137. package/package.json +2 -1
  138. package/src/number/branded-types/finite-number.mts +47 -61
  139. package/src/number/branded-types/int.mts +40 -46
  140. package/src/number/branded-types/int16.mts +65 -58
  141. package/src/number/branded-types/int32.mts +65 -58
  142. package/src/number/branded-types/negative-finite-number.mts +68 -68
  143. package/src/number/branded-types/negative-int.mts +60 -57
  144. package/src/number/branded-types/negative-safe-int.mts +57 -65
  145. package/src/number/branded-types/non-negative-finite-number.mts +74 -64
  146. package/src/number/branded-types/non-negative-int16.mts +64 -57
  147. package/src/number/branded-types/non-negative-int32.mts +64 -58
  148. package/src/number/branded-types/non-positive-finite-number.mts +64 -54
  149. package/src/number/branded-types/non-positive-int.mts +41 -146
  150. package/src/number/branded-types/non-positive-safe-int.mts +54 -53
  151. package/src/number/branded-types/non-zero-finite-number.mts +62 -51
  152. package/src/number/branded-types/non-zero-int.mts +51 -38
  153. package/src/number/branded-types/non-zero-int16.mts +52 -53
  154. package/src/number/branded-types/non-zero-int32.mts +52 -54
  155. package/src/number/branded-types/non-zero-safe-int.mts +53 -54
  156. package/src/number/branded-types/non-zero-uint16.mts +52 -53
  157. package/src/number/branded-types/non-zero-uint32.mts +52 -53
  158. package/src/number/branded-types/positive-finite-number.mts +74 -63
  159. package/src/number/branded-types/positive-int.mts +46 -68
  160. package/src/number/branded-types/positive-int16.mts +61 -57
  161. package/src/number/branded-types/positive-int32.mts +61 -57
  162. package/src/number/branded-types/positive-safe-int.mts +62 -57
  163. package/src/number/branded-types/positive-uint16.mts +61 -57
  164. package/src/number/branded-types/positive-uint32.mts +61 -58
  165. package/src/number/branded-types/safe-int.mts +43 -62
  166. package/src/number/branded-types/safe-uint.mts +62 -57
  167. package/src/number/branded-types/uint.mts +63 -50
  168. package/src/number/branded-types/uint16.mts +60 -58
  169. package/src/number/branded-types/uint32.mts +59 -55
  170. package/src/number/enum/int8.mts +56 -65
  171. 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
- * Checks if a number is a Uint8 (8-bit unsigned integer in the range [0, 255]).
4
+ * Type guard that checks if a value is an non-negative integer less than 256.
5
5
  *
6
- * @param value The value to check.
7
- * @returns `true` if the value is a Uint8, `false` otherwise.
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 a Uint8 type. This function validates that the input is
12
- * within the Uint8 range [0, 255] and is an integer, then returns it with the
13
- * Uint8 brand.
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 a Uint8 type.
17
- * @throws {TypeError} If the value is not a valid 8-bit unsigned integer.
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 arithmetic operations for 8-bit unsigned
22
- * integers.
25
+ * Namespace providing type-safe operations for the `Uint8` branded type.
23
26
  *
24
- * All operations automatically clamp results to the valid Uint8 range [0, 255].
25
- * This ensures that all arithmetic maintains the 8-bit unsigned integer
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 8-bit unsigned integer.
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 8-bit unsigned integer, `false`
35
- * otherwise.
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 minimum value for an 8-bit unsigned integer.
40
- *
41
- * @readonly
40
+ * The smallest value representable as `Uint8`.
42
41
  */
43
42
  readonly MIN_VALUE: 0;
44
43
  /**
45
- * The maximum value for an 8-bit unsigned integer.
46
- *
47
- * @readonly
44
+ * The largest value representable as `Uint8`.
48
45
  */
49
46
  readonly MAX_VALUE: 255;
50
47
  /**
51
- * Returns the larger of the given Uint8 values.
48
+ * Returns the largest of the given non-negative integers.
52
49
  *
53
- * @param values The Uint8 values to compare.
54
- * @returns The maximum value as a Uint8.
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 smaller of the given Uint8 values.
55
+ * Returns the smallest of the given non-negative integers.
59
56
  *
60
- * @param values The Uint8 values to compare.
61
- * @returns The minimum value as a Uint8.
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 to the Uint8 range.
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 number to clamp.
68
- * @returns The value clamped to [0, 255] as a Uint8.
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 value within the specified range.
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 between min and max.
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 x to the power of y, clamped to Uint8 range.
80
+ * Raises `a` to the power `b`, returning `a ** b` as an `Uint8` (floored to
81
+ * an integer).
81
82
  *
82
- * @param x - The base
83
- * @param y - The exponent
84
- * @returns `x ** y` clamped to [0, 255]
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 Uint8 values, clamped to Uint8 range.
89
+ * Adds two non-negative integers, returning `a + b` as an `Uint8`.
89
90
  *
90
- * @param x - First operand
91
- * @param y - Second operand
92
- * @returns `x + y` clamped to [0, 255]
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 Uint8 values, clamped to Uint8 range.
97
+ * Subtracts two non-negative integers, returning `a - b` as an `Uint8`.
97
98
  *
98
- * @param x - First operand
99
- * @param y - Second operand
100
- * @returns `x - y` clamped to [0, 255]
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 Uint8 values, clamped to Uint8 range.
105
+ * Multiplies two non-negative integers, returning `a * b` as an `Uint8`.
105
106
  *
106
- * @param x - First operand
107
- * @param y - Second operand
108
- * @returns `x * y` clamped to [0, 255]
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 Uint8 values, clamped to Uint8 range.
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 x - The dividend
115
- * @param y - The divisor (cannot be 0)
116
- * @returns `⌊x / y⌋` clamped to [0, 255]
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;;;;;GAKG;AACH,eAAO,MAAM,OAAO,MAjCL,MAAM,KAAG,CAAC,IAAI,KAiCJ,CAAC;AAE1B;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,MA1CC,MAAM,KAAG,KA0CC,CAAC;AAEhC;;;;;;;;GAQG;AACH,eAAO,MAAM,KAAK;IAChB;;;;;;OAMG;qBA9DU,MAAM,KAAG,CAAC,IAAI,K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fa,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 8-bit unsigned integer.
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 8-bit unsigned integer, `false`
41
- * otherwise.
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 minimum value for an 8-bit unsigned integer.
46
- *
47
- * @readonly
45
+ * The smallest value representable as `Uint8`.
48
46
  */
49
47
  MIN_VALUE,
50
48
  /**
51
- * The maximum value for an 8-bit unsigned integer.
52
- *
53
- * @readonly
49
+ * The largest value representable as `Uint8`.
54
50
  */
55
51
  MAX_VALUE,
56
52
  /**
57
- * Returns the larger of the given Uint8 values.
53
+ * Returns the largest of the given non-negative integers.
58
54
  *
59
- * @param values The Uint8 values to compare.
60
- * @returns The maximum value as a Uint8.
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 smaller of the given Uint8 values.
60
+ * Returns the smallest of the given non-negative integers.
65
61
  *
66
- * @param values The Uint8 values to compare.
67
- * @returns The minimum value as a Uint8.
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 to the Uint8 range.
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 number to clamp.
74
- * @returns The value clamped to [0, 255] as a Uint8.
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 value within the specified range.
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 between min and max.
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 x to the power of y, clamped to Uint8 range.
85
+ * Raises `a` to the power `b`, returning `a ** b` as an `Uint8` (floored to
86
+ * an integer).
87
87
  *
88
- * @param x - The base
89
- * @param y - The exponent
90
- * @returns `x ** y` clamped to [0, 255]
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 Uint8 values, clamped to Uint8 range.
94
+ * Adds two non-negative integers, returning `a + b` as an `Uint8`.
95
95
  *
96
- * @param x - First operand
97
- * @param y - Second operand
98
- * @returns `x + y` clamped to [0, 255]
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 Uint8 values, clamped to Uint8 range.
102
+ * Subtracts two non-negative integers, returning `a - b` as an `Uint8`.
103
103
  *
104
- * @param x - First operand
105
- * @param y - Second operand
106
- * @returns `x - y` clamped to [0, 255]
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 Uint8 values, clamped to Uint8 range.
110
+ * Multiplies two non-negative integers, returning `a * b` as an `Uint8`.
111
111
  *
112
- * @param x - First operand
113
- * @param y - Second operand
114
- * @returns `x * y` clamped to [0, 255]
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 Uint8 values, clamped to Uint8 range.
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 x - The dividend
121
- * @param y - The divisor (cannot be 0)
122
- * @returns `⌊x / y⌋` clamped to [0, 255]
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 * Checks if a number is a Uint8 (8-bit unsigned integer in the range [0, 255]).\n *\n * @param value The value to check.\n * @returns `true` if the value is a Uint8, `false` otherwise.\n */\nexport const isUint8 = is;\n\n/**\n * Casts a number to a Uint8 type. This function validates that the input is\n * within the Uint8 range [0, 255] and is an integer, then returns it with the\n * Uint8 brand.\n *\n * @param value The value to cast.\n * @returns The value as a Uint8 type.\n * @throws {TypeError} If the value is not a valid 8-bit unsigned integer.\n */\nexport const asUint8 = castType;\n\n/**\n * Namespace providing type-safe arithmetic operations for 8-bit unsigned\n * integers.\n *\n * All operations automatically clamp results to the valid Uint8 range [0, 255].\n * This ensures that all arithmetic maintains the 8-bit unsigned integer\n * constraint, with negative results clamped to 0 and overflow results clamped\n * to MAX_VALUE.\n */\nexport const Uint8 = {\n /**\n * Type guard that checks if a value is an 8-bit unsigned integer.\n *\n * @param value The value to check.\n * @returns `true` if the value is an 8-bit unsigned integer, `false`\n * otherwise.\n */\n is,\n\n /**\n * The minimum value for an 8-bit unsigned integer.\n *\n * @readonly\n */\n MIN_VALUE,\n\n /**\n * The maximum value for an 8-bit unsigned integer.\n *\n * @readonly\n */\n MAX_VALUE,\n\n /**\n * Returns the larger of the given Uint8 values.\n *\n * @param values The Uint8 values to compare.\n * @returns The maximum value as a Uint8.\n */\n max: max_,\n\n /**\n * Returns the smaller of the given Uint8 values.\n *\n * @param values The Uint8 values to compare.\n * @returns The minimum value as a Uint8.\n */\n min: min_,\n\n /**\n * Clamps a number to the Uint8 range.\n *\n * @param value The number to clamp.\n * @returns The value clamped to [0, 255] as a Uint8.\n */\n clamp,\n\n /**\n * Generates a random Uint8 value within the specified range.\n *\n * @param min The minimum value (inclusive).\n * @param max The maximum value (inclusive).\n * @returns A random Uint8 between min and max.\n */\n random,\n\n /**\n * Raises x to the power of y, clamped to Uint8 range.\n *\n * @param x - The base\n * @param y - The exponent\n * @returns `x ** y` clamped to [0, 255]\n */\n pow,\n\n /**\n * Adds two Uint8 values, clamped to Uint8 range.\n *\n * @param x - First operand\n * @param y - Second operand\n * @returns `x + y` clamped to [0, 255]\n */\n add,\n\n /**\n * Subtracts two Uint8 values, clamped to Uint8 range.\n *\n * @param x - First operand\n * @param y - Second operand\n * @returns `x - y` clamped to [0, 255]\n */\n sub,\n\n /**\n * Multiplies two Uint8 values, clamped to Uint8 range.\n *\n * @param x - First operand\n * @param y - Second operand\n * @returns `x * y` clamped to [0, 255]\n */\n mul,\n\n /**\n * Divides two Uint8 values, clamped to Uint8 range.\n *\n * @param x - The dividend\n * @param y - The divisor (cannot be 0)\n * @returns `⌊x / y⌋` clamped to [0, 255]\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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hB,MAAM,OAAA,GAAU;AAWhB,MAAM,KAAA,GAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQnB,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,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,EAQL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAA;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,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA;AACF;;;;"}
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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AAM,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.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` if the value is a finite number (not NaN, Infinity, or
63
- * -Infinity). This is stricter than the standard number type, which includes
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 a FiniteNumber branded type.
71
+ * Casts a `number` to the `FiniteNumber` branded type.
73
72
  *
74
- * This function validates that the input is finite (not NaN, Infinity, or
75
- * -Infinity) and returns it with the FiniteNumber brand. This ensures type
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 branded type
80
- * @throws {TypeError} If the value is NaN, Infinity, or -Infinity
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 types.
83
+ * Namespace providing type-safe operations for the `FiniteNumber` branded type.
86
84
  *
87
- * The FiniteNumber type represents any finite numeric value, excluding the
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
- * @param x - The finite number to get the absolute value of
111
- * @returns The absolute value as a FiniteNumber
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 minimum value from a list of finite numbers.
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 maximum value from a list of finite numbers.
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 largest integer less than or equal to the given finite number.
124
+ * Returns the greatest integer less than or equal to a finite number.
133
125
  *
134
- * @param x - The finite number to floor
135
- * @returns The floor value as an Int
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 the given finite
141
- * number.
132
+ * Returns the smallest integer greater than or equal to a finite number.
142
133
  *
143
- * @param x - The finite number to ceil
144
- * @returns The ceiling value as an Int
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
- * Rounds a finite number to the nearest integer.
140
+ * Returns the value of a finite number rounded to the nearest integer.
150
141
  *
151
- * @param x - The finite number to round
152
- * @returns The rounded value as an Int
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 finite number within the specified range.
148
+ * Generates a random `FiniteNumber` within the given range.
158
149
  *
159
- * The generated value is uniformly distributed in the range [min, max]. Both
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 the range [min, max]
154
+ * @returns A random `FiniteNumber` in `[min, max]`
165
155
  */
166
156
  random,
167
157
 
168
158
  /**
169
- * Raises a finite number to a power.
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 - First finite number
181
- * @param b - Second finite number
182
- * @returns `a + b` as a FiniteNumber
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 - First finite number
190
- * @param b - Second finite number
191
- * @returns `a - b` as a FiniteNumber
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 - First finite number
199
- * @param b - Second finite number
200
- * @returns `a * b` as a FiniteNumber
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 The quotient `a / b` as a FiniteNumber
199
+ * @returns `a / b` as a `FiniteNumber`
214
200
  */
215
201
  div,
216
202
  } as const;