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.
Files changed (185) hide show
  1. package/README.md +2 -2
  2. package/dist/number/branded-types/finite-number.d.mts +47 -61
  3. package/dist/number/branded-types/finite-number.d.mts.map +1 -1
  4. package/dist/number/branded-types/finite-number.mjs +37 -41
  5. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  6. package/dist/number/branded-types/int.d.mts +40 -46
  7. package/dist/number/branded-types/int.d.mts.map +1 -1
  8. package/dist/number/branded-types/int.mjs +29 -31
  9. package/dist/number/branded-types/int.mjs.map +1 -1
  10. package/dist/number/branded-types/int16.d.mts +71 -59
  11. package/dist/number/branded-types/int16.d.mts.map +1 -1
  12. package/dist/number/branded-types/int16.mjs +56 -47
  13. package/dist/number/branded-types/int16.mjs.map +1 -1
  14. package/dist/number/branded-types/int32.d.mts +71 -59
  15. package/dist/number/branded-types/int32.d.mts.map +1 -1
  16. package/dist/number/branded-types/int32.mjs +56 -47
  17. package/dist/number/branded-types/int32.mjs.map +1 -1
  18. package/dist/number/branded-types/negative-finite-number.d.mts +76 -60
  19. package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
  20. package/dist/number/branded-types/negative-finite-number.mjs +62 -49
  21. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  22. package/dist/number/branded-types/negative-int.d.mts +66 -49
  23. package/dist/number/branded-types/negative-int.d.mts.map +1 -1
  24. package/dist/number/branded-types/negative-int.mjs +48 -39
  25. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  26. package/dist/number/branded-types/negative-safe-int.d.mts +64 -57
  27. package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
  28. package/dist/number/branded-types/negative-safe-int.mjs +49 -44
  29. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  30. package/dist/number/branded-types/non-negative-finite-number.d.mts +80 -65
  31. package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
  32. package/dist/number/branded-types/non-negative-finite-number.mjs +65 -53
  33. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  34. package/dist/number/branded-types/non-negative-int16.d.mts +71 -58
  35. package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
  36. package/dist/number/branded-types/non-negative-int16.mjs +55 -45
  37. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  38. package/dist/number/branded-types/non-negative-int32.d.mts +71 -59
  39. package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
  40. package/dist/number/branded-types/non-negative-int32.mjs +55 -46
  41. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  42. package/dist/number/branded-types/non-positive-finite-number.d.mts +70 -55
  43. package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
  44. package/dist/number/branded-types/non-positive-finite-number.mjs +55 -43
  45. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  46. package/dist/number/branded-types/non-positive-int.d.mts +46 -146
  47. package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
  48. package/dist/number/branded-types/non-positive-int.mjs +33 -108
  49. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  50. package/dist/number/branded-types/non-positive-safe-int.d.mts +62 -54
  51. package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
  52. package/dist/number/branded-types/non-positive-safe-int.mjs +46 -41
  53. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  54. package/dist/number/branded-types/non-zero-finite-number.d.mts +62 -49
  55. package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
  56. package/dist/number/branded-types/non-zero-finite-number.mjs +46 -37
  57. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  58. package/dist/number/branded-types/non-zero-int.d.mts +51 -38
  59. package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
  60. package/dist/number/branded-types/non-zero-int.mjs +31 -27
  61. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  62. package/dist/number/branded-types/non-zero-int16.d.mts +59 -54
  63. package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
  64. package/dist/number/branded-types/non-zero-int16.mjs +44 -41
  65. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  66. package/dist/number/branded-types/non-zero-int32.d.mts +59 -55
  67. package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
  68. package/dist/number/branded-types/non-zero-int32.mjs +44 -42
  69. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  70. package/dist/number/branded-types/non-zero-safe-int.d.mts +60 -55
  71. package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
  72. package/dist/number/branded-types/non-zero-safe-int.mjs +44 -42
  73. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  74. package/dist/number/branded-types/non-zero-uint16.d.mts +59 -54
  75. package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
  76. package/dist/number/branded-types/non-zero-uint16.mjs +43 -41
  77. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  78. package/dist/number/branded-types/non-zero-uint32.d.mts +59 -54
  79. package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
  80. package/dist/number/branded-types/non-zero-uint32.mjs +43 -41
  81. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  82. package/dist/number/branded-types/positive-finite-number.d.mts +82 -64
  83. package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
  84. package/dist/number/branded-types/positive-finite-number.mjs +67 -52
  85. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  86. package/dist/number/branded-types/positive-int.d.mts +53 -70
  87. package/dist/number/branded-types/positive-int.d.mts.map +1 -1
  88. package/dist/number/branded-types/positive-int.mjs +42 -52
  89. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  90. package/dist/number/branded-types/positive-int16.d.mts +68 -58
  91. package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
  92. package/dist/number/branded-types/positive-int16.mjs +52 -45
  93. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  94. package/dist/number/branded-types/positive-int32.d.mts +68 -58
  95. package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
  96. package/dist/number/branded-types/positive-int32.mjs +52 -45
  97. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  98. package/dist/number/branded-types/positive-safe-int.d.mts +72 -61
  99. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
  100. package/dist/number/branded-types/positive-safe-int.mjs +56 -48
  101. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  102. package/dist/number/branded-types/positive-uint16.d.mts +68 -58
  103. package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
  104. package/dist/number/branded-types/positive-uint16.mjs +52 -45
  105. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  106. package/dist/number/branded-types/positive-uint32.d.mts +68 -59
  107. package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
  108. package/dist/number/branded-types/positive-uint32.mjs +52 -46
  109. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  110. package/dist/number/branded-types/safe-int.d.mts +52 -66
  111. package/dist/number/branded-types/safe-int.d.mts.map +1 -1
  112. package/dist/number/branded-types/safe-int.mjs +45 -47
  113. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  114. package/dist/number/branded-types/safe-uint.d.mts +68 -58
  115. package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
  116. package/dist/number/branded-types/safe-uint.mjs +53 -46
  117. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  118. package/dist/number/branded-types/uint.d.mts +72 -55
  119. package/dist/number/branded-types/uint.d.mts.map +1 -1
  120. package/dist/number/branded-types/uint.mjs +52 -45
  121. package/dist/number/branded-types/uint.mjs.map +1 -1
  122. package/dist/number/branded-types/uint16.d.mts +66 -59
  123. package/dist/number/branded-types/uint16.d.mts.map +1 -1
  124. package/dist/number/branded-types/uint16.mjs +51 -45
  125. package/dist/number/branded-types/uint16.mjs.map +1 -1
  126. package/dist/number/branded-types/uint32.d.mts +66 -57
  127. package/dist/number/branded-types/uint32.d.mts.map +1 -1
  128. package/dist/number/branded-types/uint32.mjs +50 -45
  129. package/dist/number/branded-types/uint32.mjs.map +1 -1
  130. package/dist/number/enum/int8.d.mts +62 -66
  131. package/dist/number/enum/int8.d.mts.map +1 -1
  132. package/dist/number/enum/int8.mjs +57 -51
  133. package/dist/number/enum/int8.mjs.map +1 -1
  134. package/dist/number/enum/uint8.d.mts +66 -59
  135. package/dist/number/enum/uint8.d.mts.map +1 -1
  136. package/dist/number/enum/uint8.mjs +57 -51
  137. package/dist/number/enum/uint8.mjs.map +1 -1
  138. package/dist/number/refined-number-utils.d.mts +9 -9
  139. package/dist/number/refined-number-utils.d.mts.map +1 -1
  140. package/dist/number/refined-number-utils.mjs +7 -7
  141. package/dist/number/refined-number-utils.mjs.map +1 -1
  142. package/package.json +2 -1
  143. package/src/number/branded-types/finite-number.mts +47 -61
  144. package/src/number/branded-types/int.mts +40 -46
  145. package/src/number/branded-types/int16.mts +72 -60
  146. package/src/number/branded-types/int32.mts +72 -60
  147. package/src/number/branded-types/negative-finite-number.mts +78 -71
  148. package/src/number/branded-types/negative-finite-number.test.mts +4 -4
  149. package/src/number/branded-types/negative-int.mts +68 -60
  150. package/src/number/branded-types/negative-int.test.mts +5 -5
  151. package/src/number/branded-types/negative-safe-int.mts +66 -68
  152. package/src/number/branded-types/negative-safe-int.test.mts +4 -4
  153. package/src/number/branded-types/non-negative-finite-number.mts +81 -66
  154. package/src/number/branded-types/non-negative-int16.mts +72 -59
  155. package/src/number/branded-types/non-negative-int32.mts +72 -60
  156. package/src/number/branded-types/non-positive-finite-number.mts +71 -56
  157. package/src/number/branded-types/non-positive-finite-number.test.mts +7 -7
  158. package/src/number/branded-types/non-positive-int.mts +47 -147
  159. package/src/number/branded-types/non-positive-int.test.mts +7 -7
  160. package/src/number/branded-types/non-positive-safe-int.mts +63 -55
  161. package/src/number/branded-types/non-positive-safe-int.test.mts +7 -7
  162. package/src/number/branded-types/non-zero-finite-number.mts +62 -51
  163. package/src/number/branded-types/non-zero-int.mts +51 -38
  164. package/src/number/branded-types/non-zero-int16.mts +60 -55
  165. package/src/number/branded-types/non-zero-int32.mts +60 -56
  166. package/src/number/branded-types/non-zero-safe-int.mts +61 -56
  167. package/src/number/branded-types/non-zero-uint16.mts +60 -55
  168. package/src/number/branded-types/non-zero-uint32.mts +60 -55
  169. package/src/number/branded-types/positive-finite-number.mts +83 -65
  170. package/src/number/branded-types/positive-int.mts +54 -71
  171. package/src/number/branded-types/positive-int16.mts +69 -59
  172. package/src/number/branded-types/positive-int32.mts +69 -59
  173. package/src/number/branded-types/positive-safe-int.mts +73 -62
  174. package/src/number/branded-types/positive-uint16.mts +69 -59
  175. package/src/number/branded-types/positive-uint32.mts +69 -60
  176. package/src/number/branded-types/safe-int.mts +53 -67
  177. package/src/number/branded-types/safe-uint.mts +69 -59
  178. package/src/number/branded-types/uint.mts +73 -56
  179. package/src/number/branded-types/uint16.mts +67 -60
  180. package/src/number/branded-types/uint32.mts +67 -58
  181. package/src/number/enum/int8.mts +70 -73
  182. package/src/number/enum/int8.test.mts +7 -4
  183. package/src/number/enum/uint8.mts +74 -66
  184. package/src/number/enum/uint8.test.mts +7 -4
  185. package/src/number/refined-number-utils.mts +22 -19
package/README.md CHANGED
@@ -350,11 +350,11 @@ assert.isTrue(positiveInt === 10);
350
350
  // Type-safe arithmetic with automatic clamping
351
351
  const sum = Int16.add(int16, asInt16(2000)); // Int16 (3000)
352
352
 
353
- const clamped = Int16.clamp(100_000); // Int16 (32767 - clamped to MAX_VALUE)
353
+ const coerced = Int16.fromNumber(100_000); // Int16 (32767 - saturated to MAX_VALUE)
354
354
 
355
355
  assert.isTrue(sum === 3000);
356
356
 
357
- assert.isTrue(clamped === 32_767);
357
+ assert.isTrue(coerced === 32_767);
358
358
 
359
359
  // Safe division with non-zero types
360
360
  const ratio = Num.divInt(asNonZeroInt(10), nonZeroInt); // No division by zero risk
@@ -5,24 +5,22 @@ type ElementType = FiniteNumber;
5
5
  /**
6
6
  * Type guard that checks if a value is a finite number.
7
7
  *
8
- * Returns `true` if the value is a finite number (not NaN, Infinity, or
9
- * -Infinity). This is stricter than the standard number type, which includes
10
- * these special values.
8
+ * Returns `true` only for a finite value — never `NaN`, `Infinity`, or
9
+ * `-Infinity`.
11
10
  *
12
11
  * @param value - The value to check
13
- * @returns `true` if the value is finite, `false` otherwise
12
+ * @returns `true` if the value is a finite number, `false` otherwise
14
13
  */
15
14
  export declare const isFiniteNumber: (a: number) => a is TtfImported_FiniteNumber;
16
15
  /**
17
- * Casts a number to a FiniteNumber branded type.
16
+ * Casts a `number` to the `FiniteNumber` branded type.
18
17
  *
19
- * This function validates that the input is finite (not NaN, Infinity, or
20
- * -Infinity) and returns it with the FiniteNumber brand. This ensures type
21
- * safety for operations that require finite numeric values.
18
+ * Validates that the value is a finite number and returns it with the
19
+ * `FiniteNumber` brand. Throws a `TypeError` otherwise.
22
20
  *
23
21
  * @param value - The value to cast
24
- * @returns The value as a FiniteNumber branded type
25
- * @throws {TypeError} If the value is NaN, Infinity, or -Infinity
22
+ * @returns The value as a `FiniteNumber`
23
+ * @throws {TypeError} If the value is not a finite number
26
24
  */
27
25
  export declare const asFiniteNumber: <N extends number>(x: N) => number & {
28
26
  readonly Finite: true;
@@ -31,123 +29,111 @@ export declare const asFiniteNumber: <N extends number>(x: N) => number & {
31
29
  'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
32
30
  }> & N;
33
31
  /**
34
- * Namespace providing type-safe operations for FiniteNumber branded types.
32
+ * Namespace providing type-safe operations for the `FiniteNumber` branded type.
35
33
  *
36
- * The FiniteNumber type represents any finite numeric value, excluding the
37
- * special values NaN, Infinity, and -Infinity. All operations are guaranteed to
38
- * maintain the finite constraint when given finite inputs.
39
- *
40
- * This type is essential for:
41
- *
42
- * - Mathematical operations that require real numbers
43
- * - Preventing NaN/Infinity propagation in calculations
44
- * - Ensuring numeric stability in algorithms
34
+ * The `FiniteNumber` type represents a finite number.
45
35
  */
46
36
  export declare const FiniteNumber: {
47
37
  /**
48
38
  * Type guard that checks if a value is a finite number.
49
39
  *
50
40
  * @param value - The value to check
51
- * @returns `true` if the value is finite, `false` otherwise
41
+ * @returns `true` if the value is a finite number, `false` otherwise
52
42
  * @see {@link isFiniteNumber} for usage examples
53
43
  */
54
44
  readonly is: (a: number) => a is TtfImported_FiniteNumber;
55
45
  /**
56
46
  * Returns the absolute value of a finite number.
57
47
  *
58
- * @param x - The finite number to get the absolute value of
59
- * @returns The absolute value as a FiniteNumber
48
+ * The result is non-negative and keeps the `FiniteNumber` brand.
49
+ *
50
+ * @param a - The finite number value
51
+ * @returns The absolute value as a non-negative `FiniteNumber`
60
52
  */
61
53
  readonly abs: (x: TtfImported_FiniteNumber) => import("ts-type-forge").IntersectBrand<TtfImported_FiniteNumber, import("ts-type-forge").NonNegativeNumber>;
62
54
  /**
63
- * Returns the minimum value from a list of finite numbers.
55
+ * Returns the smallest of the given finite numbers.
64
56
  *
65
57
  * @param values - The finite numbers to compare (at least one required)
66
- * @returns The smallest value as a FiniteNumber
58
+ * @returns The smallest value as a `FiniteNumber`
67
59
  */
68
60
  readonly min: (...values: readonly TtfImported_FiniteNumber[]) => TtfImported_FiniteNumber;
69
61
  /**
70
- * Returns the maximum value from a list of finite numbers.
62
+ * Returns the largest of the given finite numbers.
71
63
  *
72
64
  * @param values - The finite numbers to compare (at least one required)
73
- * @returns The largest value as a FiniteNumber
65
+ * @returns The largest value as a `FiniteNumber`
74
66
  */
75
67
  readonly max: (...values: readonly TtfImported_FiniteNumber[]) => TtfImported_FiniteNumber;
76
68
  /**
77
- * Returns the largest integer less than or equal to the given finite number.
69
+ * Returns the greatest integer less than or equal to a finite number.
78
70
  *
79
- * @param x - The finite number to floor
80
- * @returns The floor value as an Int
71
+ * @param a - The finite number value
72
+ * @returns The floored value as an integer
81
73
  */
82
74
  readonly floor: (x: ElementType) => TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;
83
75
  /**
84
- * Returns the smallest integer greater than or equal to the given finite
85
- * number.
76
+ * Returns the smallest integer greater than or equal to a finite number.
86
77
  *
87
- * @param x - The finite number to ceil
88
- * @returns The ceiling value as an Int
78
+ * @param a - The finite number value
79
+ * @returns The ceiled value as an integer
89
80
  */
90
81
  readonly ceil: (x: ElementType) => TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;
91
82
  /**
92
- * Rounds a finite number to the nearest integer.
83
+ * Returns the value of a finite number rounded to the nearest integer.
93
84
  *
94
- * @param x - The finite number to round
95
- * @returns The rounded value as an Int
85
+ * @param a - The finite number value
86
+ * @returns The rounded value as an integer
96
87
  */
97
88
  readonly round: (x: ElementType) => TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;
98
89
  /**
99
- * Generates a random finite number within the specified range.
90
+ * Generates a random `FiniteNumber` within the given range.
100
91
  *
101
- * The generated value is uniformly distributed in the range [min, max]. Both
102
- * bounds are inclusive.
92
+ * The range is inclusive on both ends.
103
93
  *
104
94
  * @param min - The minimum value (inclusive)
105
95
  * @param max - The maximum value (inclusive)
106
- * @returns A random FiniteNumber in the range [min, max]
96
+ * @returns A random `FiniteNumber` in `[min, max]`
107
97
  */
108
98
  readonly random: (min?: TtfImported_FiniteNumber | undefined, max?: TtfImported_FiniteNumber | undefined) => TtfImported_FiniteNumber;
109
99
  /**
110
- * Raises a finite number to a power.
100
+ * Raises `a` to the power `b`, returning `a ** b` as a `FiniteNumber`.
111
101
  *
112
102
  * @param a - The base finite number
113
103
  * @param b - The exponent finite number
114
- * @returns `a ** b` as a FiniteNumber
104
+ * @returns `a ** b` as a `FiniteNumber`
115
105
  */
116
106
  readonly pow: (x: TtfImported_FiniteNumber, y: TtfImported_FiniteNumber) => TtfImported_FiniteNumber;
117
107
  /**
118
- * Adds two finite numbers.
108
+ * Adds two finite numbers, returning `a + b` as a `FiniteNumber`.
119
109
  *
120
- * @param a - First finite number
121
- * @param b - Second finite number
122
- * @returns `a + b` as a FiniteNumber
110
+ * @param a - The first finite number
111
+ * @param b - The second finite number
112
+ * @returns The sum of `a` and `b` as a `FiniteNumber`
123
113
  */
124
114
  readonly add: (x: TtfImported_FiniteNumber, y: TtfImported_FiniteNumber) => TtfImported_FiniteNumber;
125
115
  /**
126
- * Subtracts two finite numbers.
116
+ * Subtracts two finite numbers, returning `a - b` as a `FiniteNumber`.
127
117
  *
128
- * @param a - First finite number
129
- * @param b - Second finite number
130
- * @returns `a - b` as a FiniteNumber
118
+ * @param a - The first finite number
119
+ * @param b - The second finite number
120
+ * @returns The difference of `a` and `b` as a `FiniteNumber`
131
121
  */
132
122
  readonly sub: (x: TtfImported_FiniteNumber, y: TtfImported_FiniteNumber) => TtfImported_FiniteNumber;
133
123
  /**
134
- * Multiplies two finite numbers.
124
+ * Multiplies two finite numbers, returning `a * b` as a `FiniteNumber`.
135
125
  *
136
- * @param a - First finite number
137
- * @param b - Second finite number
138
- * @returns `a * b` as a FiniteNumber
126
+ * @param a - The first finite number
127
+ * @param b - The second finite number
128
+ * @returns The product of `a` and `b` as a `FiniteNumber`
139
129
  */
140
130
  readonly mul: (x: TtfImported_FiniteNumber, y: TtfImported_FiniteNumber) => TtfImported_FiniteNumber;
141
131
  /**
142
- * Divides two finite numbers.
143
- *
144
- * The divisor must be non-zero (enforced by type constraints). The result is
145
- * guaranteed to be finite when both inputs are finite and the divisor is
146
- * non-zero.
132
+ * Divides two finite numbers, returning `a / b` as a `FiniteNumber`.
147
133
  *
148
134
  * @param a - The dividend
149
135
  * @param b - The divisor (must be non-zero)
150
- * @returns The quotient `a / b` as a FiniteNumber
136
+ * @returns `a / b` as a `FiniteNumber`
151
137
  */
152
138
  readonly div: (x: TtfImported_FiniteNumber, y: number & {
153
139
  readonly "!=0": true;
@@ -1 +1 @@
1
- {"version":3,"file":"finite-number.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/finite-number.mts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,IAAI,wBAAwB,EAC9C,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAEpD,KAAK,WAAW,GAAG,YAAY,CAAC;AAgDhC;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,8CAAK,CAAC;AAEjC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc;;;;;MAAW,CAAC;AAEvC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY;IACvB;;;;;;OAMG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;wBAlGA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC;IAoG3D;;;;;;OAMG;uBArGA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC;IAuG3D;;;;;OAKG;wBAvGA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC;IAyG3D;;;;;;;;;OASG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;;;;OAUG;;;;;;;;CAEK,CAAC"}
1
+ {"version":3,"file":"finite-number.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/finite-number.mts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,IAAI,wBAAwB,EAC9C,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAEpD,KAAK,WAAW,GAAG,YAAY,CAAC;AAgDhC;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,8CAAK,CAAC;AAEjC;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc;;;;;MAAW,CAAC;AAEvC;;;;GAIG;AACH,eAAO,MAAM,YAAY;IACvB;;;;;;OAMG;;IAGH;;;;;;;OAOG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;wBA1FA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC;IA4F3D;;;;;OAKG;uBA5FA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC;IA8F3D;;;;;OAKG;wBA9FA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC;IAgG3D;;;;;;;;OAQG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;;;;;;;CAEK,CAAC"}
@@ -37,106 +37,102 @@ const FiniteNumber = {
37
37
  * Type guard that checks if a value is a finite number.
38
38
  *
39
39
  * @param value - The value to check
40
- * @returns `true` if the value is finite, `false` otherwise
40
+ * @returns `true` if the value is a finite number, `false` otherwise
41
41
  * @see {@link isFiniteNumber} for usage examples
42
42
  */
43
43
  is,
44
44
  /**
45
45
  * Returns the absolute value of a finite number.
46
46
  *
47
- * @param x - The finite number to get the absolute value of
48
- * @returns The absolute value as a FiniteNumber
47
+ * The result is non-negative and keeps the `FiniteNumber` brand.
48
+ *
49
+ * @param a - The finite number value
50
+ * @returns The absolute value as a non-negative `FiniteNumber`
49
51
  */
50
52
  abs,
51
53
  /**
52
- * Returns the minimum value from a list of finite numbers.
54
+ * Returns the smallest of the given finite numbers.
53
55
  *
54
56
  * @param values - The finite numbers to compare (at least one required)
55
- * @returns The smallest value as a FiniteNumber
57
+ * @returns The smallest value as a `FiniteNumber`
56
58
  */
57
59
  min: min_,
58
60
  /**
59
- * Returns the maximum value from a list of finite numbers.
61
+ * Returns the largest of the given finite numbers.
60
62
  *
61
63
  * @param values - The finite numbers to compare (at least one required)
62
- * @returns The largest value as a FiniteNumber
64
+ * @returns The largest value as a `FiniteNumber`
63
65
  */
64
66
  max: max_,
65
67
  /**
66
- * Returns the largest integer less than or equal to the given finite number.
68
+ * Returns the greatest integer less than or equal to a finite number.
67
69
  *
68
- * @param x - The finite number to floor
69
- * @returns The floor value as an Int
70
+ * @param a - The finite number value
71
+ * @returns The floored value as an integer
70
72
  */
71
73
  floor,
72
74
  /**
73
- * Returns the smallest integer greater than or equal to the given finite
74
- * number.
75
+ * Returns the smallest integer greater than or equal to a finite number.
75
76
  *
76
- * @param x - The finite number to ceil
77
- * @returns The ceiling value as an Int
77
+ * @param a - The finite number value
78
+ * @returns The ceiled value as an integer
78
79
  */
79
80
  ceil,
80
81
  /**
81
- * Rounds a finite number to the nearest integer.
82
+ * Returns the value of a finite number rounded to the nearest integer.
82
83
  *
83
- * @param x - The finite number to round
84
- * @returns The rounded value as an Int
84
+ * @param a - The finite number value
85
+ * @returns The rounded value as an integer
85
86
  */
86
87
  round,
87
88
  /**
88
- * Generates a random finite number within the specified range.
89
+ * Generates a random `FiniteNumber` within the given range.
89
90
  *
90
- * The generated value is uniformly distributed in the range [min, max]. Both
91
- * bounds are inclusive.
91
+ * The range is inclusive on both ends.
92
92
  *
93
93
  * @param min - The minimum value (inclusive)
94
94
  * @param max - The maximum value (inclusive)
95
- * @returns A random FiniteNumber in the range [min, max]
95
+ * @returns A random `FiniteNumber` in `[min, max]`
96
96
  */
97
97
  random,
98
98
  /**
99
- * Raises a finite number to a power.
99
+ * Raises `a` to the power `b`, returning `a ** b` as a `FiniteNumber`.
100
100
  *
101
101
  * @param a - The base finite number
102
102
  * @param b - The exponent finite number
103
- * @returns `a ** b` as a FiniteNumber
103
+ * @returns `a ** b` as a `FiniteNumber`
104
104
  */
105
105
  pow,
106
106
  /**
107
- * Adds two finite numbers.
107
+ * Adds two finite numbers, returning `a + b` as a `FiniteNumber`.
108
108
  *
109
- * @param a - First finite number
110
- * @param b - Second finite number
111
- * @returns `a + b` as a FiniteNumber
109
+ * @param a - The first finite number
110
+ * @param b - The second finite number
111
+ * @returns The sum of `a` and `b` as a `FiniteNumber`
112
112
  */
113
113
  add,
114
114
  /**
115
- * Subtracts two finite numbers.
115
+ * Subtracts two finite numbers, returning `a - b` as a `FiniteNumber`.
116
116
  *
117
- * @param a - First finite number
118
- * @param b - Second finite number
119
- * @returns `a - b` as a FiniteNumber
117
+ * @param a - The first finite number
118
+ * @param b - The second finite number
119
+ * @returns The difference of `a` and `b` as a `FiniteNumber`
120
120
  */
121
121
  sub,
122
122
  /**
123
- * Multiplies two finite numbers.
123
+ * Multiplies two finite numbers, returning `a * b` as a `FiniteNumber`.
124
124
  *
125
- * @param a - First finite number
126
- * @param b - Second finite number
127
- * @returns `a * b` as a FiniteNumber
125
+ * @param a - The first finite number
126
+ * @param b - The second finite number
127
+ * @returns The product of `a` and `b` as a `FiniteNumber`
128
128
  */
129
129
  mul,
130
130
  /**
131
- * Divides two finite numbers.
132
- *
133
- * The divisor must be non-zero (enforced by type constraints). The result is
134
- * guaranteed to be finite when both inputs are finite and the divisor is
135
- * non-zero.
131
+ * Divides two finite numbers, returning `a / b` as a `FiniteNumber`.
136
132
  *
137
133
  * @param a - The dividend
138
134
  * @param b - The divisor (must be non-zero)
139
- * @returns The quotient `a / b` as a FiniteNumber
135
+ * @returns `a / b` as a `FiniteNumber`
140
136
  */
141
137
  div
142
138
  };
@@ -1 +1 @@
1
- {"version":3,"file":"finite-number.mjs","sources":["../../../src/number/branded-types/finite-number.mts"],"sourcesContent":["import {\n type Int,\n type NonNegativeFiniteNumber,\n type FiniteNumber as TtfImported_FiniteNumber,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type FiniteNumber = TtfImported_FiniteNumber;\n\ntype ElementType = FiniteNumber;\n\nconst typeNameInMessage = 'a finite number';\n\nconst {\n abs,\n add,\n castType,\n div,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForFloat<\n ElementType,\n number,\n number\n>({\n MIN_VALUE: -Number.MAX_VALUE,\n MAX_VALUE: Number.MAX_VALUE,\n typeNameInMessage,\n} as const);\n\nconst floor = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.floor(x) as TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;\n\nconst ceil = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.ceil(x) as TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;\n\nconst round = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.round(x) as TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;\n\nexpectType<TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>, Int>(\n '=',\n);\n\n/**\n * Type guard that checks if a value is a finite number.\n *\n * Returns `true` if the value is a finite number (not NaN, Infinity, or\n * -Infinity). This is stricter than the standard number type, which includes\n * these special values.\n *\n * @param value - The value to check\n * @returns `true` if the value is finite, `false` otherwise\n */\nexport const isFiniteNumber = is;\n\n/**\n * Casts a number to a FiniteNumber branded type.\n *\n * This function validates that the input is finite (not NaN, Infinity, or\n * -Infinity) and returns it with the FiniteNumber brand. This ensures type\n * safety for operations that require finite numeric values.\n *\n * @param value - The value to cast\n * @returns The value as a FiniteNumber branded type\n * @throws {TypeError} If the value is NaN, Infinity, or -Infinity\n */\nexport const asFiniteNumber = castType;\n\n/**\n * Namespace providing type-safe operations for FiniteNumber branded types.\n *\n * The FiniteNumber type represents any finite numeric value, excluding the\n * special values NaN, Infinity, and -Infinity. All operations are guaranteed to\n * maintain the finite constraint when given finite inputs.\n *\n * This type is essential for:\n *\n * - Mathematical operations that require real numbers\n * - Preventing NaN/Infinity propagation in calculations\n * - Ensuring numeric stability in algorithms\n */\nexport const FiniteNumber = {\n /**\n * Type guard that checks if a value is a finite number.\n *\n * @param value - The value to check\n * @returns `true` if the value is finite, `false` otherwise\n * @see {@link isFiniteNumber} for usage examples\n */\n is,\n\n /**\n * Returns the absolute value of a finite number.\n *\n * @param x - The finite number to get the absolute value of\n * @returns The absolute value as a FiniteNumber\n */\n abs,\n\n /**\n * Returns the minimum value from a list of finite numbers.\n *\n * @param values - The finite numbers to compare (at least one required)\n * @returns The smallest value as a FiniteNumber\n */\n min: min_,\n\n /**\n * Returns the maximum value from a list of finite numbers.\n *\n * @param values - The finite numbers to compare (at least one required)\n * @returns The largest value as a FiniteNumber\n */\n max: max_,\n\n /**\n * Returns the largest integer less than or equal to the given finite number.\n *\n * @param x - The finite number to floor\n * @returns The floor value as an Int\n */\n floor,\n\n /**\n * Returns the smallest integer greater than or equal to the given finite\n * number.\n *\n * @param x - The finite number to ceil\n * @returns The ceiling value as an Int\n */\n ceil,\n\n /**\n * Rounds a finite number to the nearest integer.\n *\n * @param x - The finite number to round\n * @returns The rounded value as an Int\n */\n round,\n\n /**\n * Generates a random finite number within the specified range.\n *\n * The generated value is uniformly distributed in the range [min, max]. Both\n * bounds are inclusive.\n *\n * @param min - The minimum value (inclusive)\n * @param max - The maximum value (inclusive)\n * @returns A random FiniteNumber in the range [min, max]\n */\n random,\n\n /**\n * Raises a finite number to a power.\n *\n * @param a - The base finite number\n * @param b - The exponent finite number\n * @returns `a ** b` as a FiniteNumber\n */\n pow,\n\n /**\n * Adds two finite numbers.\n *\n * @param a - First finite number\n * @param b - Second finite number\n * @returns `a + b` as a FiniteNumber\n */\n add,\n\n /**\n * Subtracts two finite numbers.\n *\n * @param a - First finite number\n * @param b - Second finite number\n * @returns `a - b` as a FiniteNumber\n */\n sub,\n\n /**\n * Multiplies two finite numbers.\n *\n * @param a - First finite number\n * @param b - Second finite number\n * @returns `a * b` as a FiniteNumber\n */\n mul,\n\n /**\n * Divides two finite numbers.\n *\n * The divisor must be non-zero (enforced by type constraints). The result is\n * guaranteed to be finite when both inputs are finite and the divisor is\n * non-zero.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The quotient `a / b` as a FiniteNumber\n */\n div,\n} as const;\n\nexpectType<\n TsDataForgeInternals.RefinedNumberUtils.ToNonNegative<ElementType>,\n NonNegativeFiniteNumber\n>('=');\n\nexpectType<\n keyof typeof FiniteNumber,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<ElementType, never>\n>('=');\n\nexpectType<\n typeof FiniteNumber,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<ElementType, never>\n>('<=');\n"],"names":[],"mappings":";;AAYA,MAAM,iBAAA,GAAoB,iBAAA;AAE1B,MAAM;AAAA,EACJ,GAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,iBAAA,CAI1C;AAAA,EACA,SAAA,EAAW,CAAC,MAAA,CAAO,SAAA;AAAA,EACnB,WAAW,MAAA,CAAO,SAAA;AAAA,EAClB;AACF,CAAU,CAAA;AAEV,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAGA,IAAA,CAAK,MAAM,CAAC;AAAA,CAAA;AAEd,MAAM,OAAO,CACX,CAAA;AAAA;AAAA,EAGA,IAAA,CAAK,KAAK,CAAC;AAAA,CAAA;AAEb,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAGA,IAAA,CAAK,MAAM,CAAC;AAAA,CAAA;AAgBP,MAAM,cAAA,GAAiB;AAavB,MAAM,cAAA,GAAiB;AAevB,MAAM,YAAA,GAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ1B,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,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,EAQL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,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;AAAA;AAAA;AAAA;AAAA,EAaA;AACF;;;;"}
1
+ {"version":3,"file":"finite-number.mjs","sources":["../../../src/number/branded-types/finite-number.mts"],"sourcesContent":["import {\n type Int,\n type NonNegativeFiniteNumber,\n type FiniteNumber as TtfImported_FiniteNumber,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type FiniteNumber = TtfImported_FiniteNumber;\n\ntype ElementType = FiniteNumber;\n\nconst typeNameInMessage = 'a finite number';\n\nconst {\n abs,\n add,\n castType,\n div,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForFloat<\n ElementType,\n number,\n number\n>({\n MIN_VALUE: -Number.MAX_VALUE,\n MAX_VALUE: Number.MAX_VALUE,\n typeNameInMessage,\n} as const);\n\nconst floor = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.floor(x) as TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;\n\nconst ceil = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.ceil(x) as TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;\n\nconst round = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.round(x) as TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;\n\nexpectType<TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>, Int>(\n '=',\n);\n\n/**\n * Type guard that checks if a value is a 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 finite number, `false` otherwise\n */\nexport const isFiniteNumber = is;\n\n/**\n * Casts a `number` to the `FiniteNumber` branded type.\n *\n * Validates that the value is a finite number and returns it with the\n * `FiniteNumber` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `FiniteNumber`\n * @throws {TypeError} If the value is not a finite number\n */\nexport const asFiniteNumber = castType;\n\n/**\n * Namespace providing type-safe operations for the `FiniteNumber` branded type.\n *\n * The `FiniteNumber` type represents a finite number.\n */\nexport const FiniteNumber = {\n /**\n * Type guard that checks if a value is a finite number.\n *\n * @param value - The value to check\n * @returns `true` if the value is a finite number, `false` otherwise\n * @see {@link isFiniteNumber} for usage examples\n */\n is,\n\n /**\n * Returns the absolute value of a finite number.\n *\n * The result is non-negative and keeps the `FiniteNumber` brand.\n *\n * @param a - The finite number value\n * @returns The absolute value as a non-negative `FiniteNumber`\n */\n abs,\n\n /**\n * Returns the smallest of the given finite numbers.\n *\n * @param values - The finite numbers to compare (at least one required)\n * @returns The smallest value as a `FiniteNumber`\n */\n min: min_,\n\n /**\n * Returns the largest of the given finite numbers.\n *\n * @param values - The finite numbers to compare (at least one required)\n * @returns The largest value as a `FiniteNumber`\n */\n max: max_,\n\n /**\n * Returns the greatest integer less than or equal to a finite number.\n *\n * @param a - The 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 finite number.\n *\n * @param a - The finite number value\n * @returns The ceiled value as an integer\n */\n ceil,\n\n /**\n * Returns the value of a finite number rounded to the nearest integer.\n *\n * @param a - The finite number value\n * @returns The rounded value as an integer\n */\n round,\n\n /**\n * Generates a random `FiniteNumber` 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 `FiniteNumber` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `FiniteNumber`.\n *\n * @param a - The base finite number\n * @param b - The exponent finite number\n * @returns `a ** b` as a `FiniteNumber`\n */\n pow,\n\n /**\n * Adds two finite numbers, returning `a + b` as a `FiniteNumber`.\n *\n * @param a - The first finite number\n * @param b - The second finite number\n * @returns The sum of `a` and `b` as a `FiniteNumber`\n */\n add,\n\n /**\n * Subtracts two finite numbers, returning `a - b` as a `FiniteNumber`.\n *\n * @param a - The first finite number\n * @param b - The second finite number\n * @returns The difference of `a` and `b` as a `FiniteNumber`\n */\n sub,\n\n /**\n * Multiplies two finite numbers, returning `a * b` as a `FiniteNumber`.\n *\n * @param a - The first finite number\n * @param b - The second finite number\n * @returns The product of `a` and `b` as a `FiniteNumber`\n */\n mul,\n\n /**\n * Divides two finite numbers, returning `a / b` as a `FiniteNumber`.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns `a / b` as a `FiniteNumber`\n */\n div,\n} as const;\n\nexpectType<\n TsDataForgeInternals.RefinedNumberUtils.ToNonNegative<ElementType>,\n NonNegativeFiniteNumber\n>('=');\n\nexpectType<\n keyof typeof FiniteNumber,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<ElementType, never>\n>('=');\n\nexpectType<\n typeof FiniteNumber,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<ElementType, never>\n>('<=');\n"],"names":[],"mappings":";;AAYA,MAAM,iBAAA,GAAoB,iBAAA;AAE1B,MAAM;AAAA,EACJ,GAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,iBAAA,CAI1C;AAAA,EACA,SAAA,EAAW,CAAC,MAAA,CAAO,SAAA;AAAA,EACnB,WAAW,MAAA,CAAO,SAAA;AAAA,EAClB;AACF,CAAU,CAAA;AAEV,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAGA,IAAA,CAAK,MAAM,CAAC;AAAA,CAAA;AAEd,MAAM,OAAO,CACX,CAAA;AAAA;AAAA,EAGA,IAAA,CAAK,KAAK,CAAC;AAAA,CAAA;AAEb,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAGA,IAAA,CAAK,MAAM,CAAC;AAAA,CAAA;AAeP,MAAM,cAAA,GAAiB;AAYvB,MAAM,cAAA,GAAiB;AAOvB,MAAM,YAAA,GAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ1B,EAAA;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,EAQL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,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;;;;"}
@@ -3,9 +3,8 @@ export type Int = TtfImported_Int;
3
3
  /**
4
4
  * Type guard that checks if a value is an integer.
5
5
  *
6
- * Returns `true` if the value is any integer (positive, negative, or zero),
7
- * with no fractional component. This includes values outside the safe integer
8
- * range, unlike SafeInt.
6
+ * Returns `true` for an integer — a value with no fractional component,
7
+ * including values outside the safe integer range (unlike `SafeInt`).
9
8
  *
10
9
  * @example
11
10
  *
@@ -22,11 +21,10 @@ export type Int = TtfImported_Int;
22
21
  */
23
22
  export declare const isInt: (a: number) => a is TtfImported_Int;
24
23
  /**
25
- * Casts a number to an Int branded type.
24
+ * Casts a `number` to the `Int` branded type.
26
25
  *
27
- * This function validates that the input is an integer and returns it with the
28
- * Int brand. Throws a TypeError if the value has a fractional component or is
29
- * not a finite number.
26
+ * Validates that the value is an integer and returns it with the `Int` brand.
27
+ * Throws a `TypeError` otherwise.
30
28
  *
31
29
  * @example
32
30
  *
@@ -39,7 +37,7 @@ export declare const isInt: (a: number) => a is TtfImported_Int;
39
37
  * ```
40
38
  *
41
39
  * @param value - The value to cast
42
- * @returns The value as an Int branded type
40
+ * @returns The value as an `Int`
43
41
  * @throws {TypeError} If the value is not an integer
44
42
  */
45
43
  export declare const asInt: <N extends number>(x: N) => number & {
@@ -50,15 +48,13 @@ export declare const asInt: <N extends number>(x: N) => number & {
50
48
  'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
51
49
  }> & N;
52
50
  /**
53
- * Namespace providing type-safe operations for Int branded types.
51
+ * Namespace providing type-safe operations for the `Int` branded type.
54
52
  *
55
- * The Int type represents any integer value (no fractional component) without
56
- * range restrictions. All operations preserve the integer constraint, using
57
- * floor division for division operations.
53
+ * The `Int` type represents an integer. Division (`div`) uses floor division.
58
54
  *
59
- * Unlike SafeInt, Int allows values outside the safe integer range (±2^53 - 1),
60
- * but be aware that very large integers may lose precision in JavaScript's
61
- * number type.
55
+ * Unlike `SafeInt`, `Int` allows values outside the safe integer range (±2^53 −
56
+ * 1), so very large magnitudes may lose precision in JavaScript's `number`
57
+ * type.
62
58
  */
63
59
  export declare const Int: {
64
60
  /**
@@ -82,9 +78,9 @@ export declare const Int: {
82
78
  /**
83
79
  * Returns the absolute value of an integer.
84
80
  *
85
- * The result is always non-negative and maintains the Int brand. Note that
86
- * Math.abs(Number.MIN_SAFE_INTEGER) exceeds Number.MAX_SAFE_INTEGER, so use
87
- * SafeInt for guaranteed precision.
81
+ * The result is non-negative and keeps the `Int` brand. Note that
82
+ * `Math.abs(Number.MIN_SAFE_INTEGER)` exceeds `Number.MAX_SAFE_INTEGER`, so
83
+ * use `SafeInt` for guaranteed precision.
88
84
  *
89
85
  * @example
90
86
  *
@@ -99,11 +95,11 @@ export declare const Int: {
99
95
  * ```
100
96
  *
101
97
  * @param a - The integer value
102
- * @returns The absolute value as a non-negative Int
98
+ * @returns The absolute value as a non-negative `Int`
103
99
  */
104
100
  readonly abs: (x: import("ts-type-forge").WithSmallInt<TtfImported_Int>) => import("ts-type-forge").IntersectBrand<TtfImported_Int, import("ts-type-forge").NonNegativeNumber>;
105
101
  /**
106
- * Returns the minimum value from a list of integers.
102
+ * Returns the smallest of the given integers.
107
103
  *
108
104
  * @example
109
105
  *
@@ -114,11 +110,11 @@ export declare const Int: {
114
110
  * ```
115
111
  *
116
112
  * @param values - The integers to compare (at least one required)
117
- * @returns The smallest value as an Int
113
+ * @returns The smallest value as an `Int`
118
114
  */
119
115
  readonly min: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_Int>[]) => TtfImported_Int;
120
116
  /**
121
- * Returns the maximum value from a list of integers.
117
+ * Returns the largest of the given integers.
122
118
  *
123
119
  * @example
124
120
  *
@@ -129,14 +125,13 @@ export declare const Int: {
129
125
  * ```
130
126
  *
131
127
  * @param values - The integers to compare (at least one required)
132
- * @returns The largest value as an Int
128
+ * @returns The largest value as an `Int`
133
129
  */
134
130
  readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_Int>[]) => TtfImported_Int;
135
131
  /**
136
- * Generates a random integer within the specified range (inclusive).
132
+ * Generates a random `Int` within the given range.
137
133
  *
138
- * The range is inclusive on both ends, so random(1, 6) can return any of: 1,
139
- * 2, 3, 4, 5, or 6.
134
+ * The range is inclusive on both ends.
140
135
  *
141
136
  * @example
142
137
  *
@@ -154,11 +149,12 @@ export declare const Int: {
154
149
  *
155
150
  * @param min - The minimum value (inclusive)
156
151
  * @param max - The maximum value (inclusive)
157
- * @returns A random Int in the range [min, max]
152
+ * @returns A random `Int` in `[min, max]`
158
153
  */
159
154
  readonly random: (min?: import("ts-type-forge").WithSmallInt<TtfImported_Int> | undefined, max?: import("ts-type-forge").WithSmallInt<TtfImported_Int> | undefined) => TtfImported_Int;
160
155
  /**
161
- * Raises an integer to a power.
156
+ * Raises `a` to the power `b`, returning `a ** b` as an `Int` (floored to an
157
+ * integer).
162
158
  *
163
159
  * @example
164
160
  *
@@ -174,11 +170,11 @@ export declare const Int: {
174
170
  *
175
171
  * @param a - The base integer
176
172
  * @param b - The exponent integer
177
- * @returns `a ** b` as an Int
173
+ * @returns `a ** b` as an `Int`
178
174
  */
179
175
  readonly pow: (x: import("ts-type-forge").WithSmallInt<TtfImported_Int>, y: import("ts-type-forge").WithSmallInt<TtfImported_Int>) => TtfImported_Int;
180
176
  /**
181
- * Adds two integers.
177
+ * Adds two integers, returning `a + b` as an `Int`.
182
178
  *
183
179
  * @example
184
180
  *
@@ -188,13 +184,13 @@ export declare const Int: {
188
184
  * assert.isTrue(sum === 20);
189
185
  * ```
190
186
  *
191
- * @param a - First integer
192
- * @param b - Second integer
193
- * @returns `a + b` as an Int
187
+ * @param a - The first integer
188
+ * @param b - The second integer
189
+ * @returns The sum of `a` and `b` as an `Int`
194
190
  */
195
191
  readonly add: (x: import("ts-type-forge").WithSmallInt<TtfImported_Int>, y: import("ts-type-forge").WithSmallInt<TtfImported_Int>) => TtfImported_Int;
196
192
  /**
197
- * Subtracts two integers.
193
+ * Subtracts two integers, returning `a - b` as an `Int`.
198
194
  *
199
195
  * @example
200
196
  *
@@ -204,13 +200,13 @@ export declare const Int: {
204
200
  * assert.isTrue(difference === 4);
205
201
  * ```
206
202
  *
207
- * @param a - First integer
208
- * @param b - Second integer
209
- * @returns `a - b` as an Int
203
+ * @param a - The first integer
204
+ * @param b - The second integer
205
+ * @returns The difference of `a` and `b` as an `Int`
210
206
  */
211
207
  readonly sub: (x: import("ts-type-forge").WithSmallInt<TtfImported_Int>, y: import("ts-type-forge").WithSmallInt<TtfImported_Int>) => TtfImported_Int;
212
208
  /**
213
- * Multiplies two integers.
209
+ * Multiplies two integers, returning `a * b` as an `Int`.
214
210
  *
215
211
  * @example
216
212
  *
@@ -220,16 +216,14 @@ export declare const Int: {
220
216
  * assert.isTrue(product === -24);
221
217
  * ```
222
218
  *
223
- * @param a - First integer
224
- * @param b - Second integer
225
- * @returns `a * b` as an Int
219
+ * @param a - The first integer
220
+ * @param b - The second integer
221
+ * @returns The product of `a` and `b` as an `Int`
226
222
  */
227
223
  readonly mul: (x: import("ts-type-forge").WithSmallInt<TtfImported_Int>, y: import("ts-type-forge").WithSmallInt<TtfImported_Int>) => TtfImported_Int;
228
224
  /**
229
- * Divides two integers using floor division.
230
- *
231
- * Performs mathematical floor division: `⌊a / b⌋`. The result is always an
232
- * integer, rounding toward negative infinity.
225
+ * Divides two integers using floor division (`⌊a / b⌋`): the result is `a /
226
+ * b` rounded toward negative infinity, as an `Int`.
233
227
  *
234
228
  * @example
235
229
  *
@@ -245,7 +239,7 @@ export declare const Int: {
245
239
  *
246
240
  * @param a - The dividend
247
241
  * @param b - The divisor (must be non-zero)
248
- * @returns The integer quotient as an Int
242
+ * @returns The floored quotient as an `Int`
249
243
  */
250
244
  readonly div: (x: import("ts-type-forge").WithSmallInt<TtfImported_Int>, y: -40 | -39 | -38 | -37 | -36 | -35 | -34 | -33 | -32 | -31 | -30 | -29 | -28 | -27 | -26 | -25 | -24 | -23 | -22 | -21 | -20 | -19 | -18 | -17 | -16 | -15 | -14 | -13 | -12 | -11 | -10 | -9 | -8 | -7 | -6 | -5 | -4 | -3 | -2 | -1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | import("ts-type-forge").NormalizeBrandUnion<number & {
251
245
  readonly "!=0": true;
@@ -1 +1 @@
1
- {"version":3,"file":"int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/int.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AAI5D,MAAM,MAAM,GAAG,GAAG,eAAe,CAAC;AA6BlC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,KAAK,qCAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,KAAK;;;;;;MAAW,CAAC;AAE9B;;;;;;;;;;GAUG;AACH,eAAO,MAAM,GAAG;IACd;;;;;;;;;;;;;;;;OAgBG;;IAGH;;;;;;;;;;;;;;;;;;;;;OAqBG;;IAGH;;;;;;;;;;;;;OAaG;;IAGH;;;;;;;;;;;;;OAaG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;OAuBG;;IAGH;;;;;;;;;;;;;;;;;;OAkBG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;;;;;;;;OAqBG;;;;;;;;;CAEK,CAAC"}
1
+ {"version":3,"file":"int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/int.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AAI5D,MAAM,MAAM,GAAG,GAAG,eAAe,CAAC;AA6BlC;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,KAAK,qCAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,KAAK;;;;;;MAAW,CAAC;AAE9B;;;;;;;;GAQG;AACH,eAAO,MAAM,GAAG;IACd;;;;;;;;;;;;;;;;OAgBG;;IAGH;;;;;;;;;;;;;;;;;;;;;OAqBG;;IAGH;;;;;;;;;;;;;OAaG;;IAGH;;;;;;;;;;;;;OAaG;;IAGH;;;;;;;;;;;;;;;;;;;;;;OAsBG;;IAGH;;;;;;;;;;;;;;;;;;;OAmBG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;;;;;;OAmBG;;;;;;;;;CAEK,CAAC"}