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
@@ -33,117 +33,116 @@ const {
33
33
  } as const);
34
34
 
35
35
  /**
36
- * Checks if a number is a NonZeroUint32 (32-bit non-zero unsigned integer in
37
- * the range [1, 2^32)).
36
+ * Type guard that checks if a value is a non-zero integer in [1, 2^32).
38
37
  *
39
- * @param value The value to check.
40
- * @returns `true` if the value is a NonZeroUint32, `false` otherwise.
38
+ * Returns `true` for a non-zero integer in [1, 2^32) — a value with no
39
+ * fractional component.
40
+ *
41
+ * @param value - The value to check
42
+ * @returns `true` if the value is a non-zero integer in [1, 2^32), `false` otherwise
41
43
  */
42
44
  export const isNonZeroUint32 = is;
43
45
 
44
46
  /**
45
- * Casts a number to a NonZeroUint32 type.
47
+ * Casts a `number` to the `NonZeroUint32` branded type.
48
+ *
49
+ * Validates that the value is a non-zero integer in [1, 2^32) and returns it
50
+ * with the `NonZeroUint32` brand. Throws a `TypeError` otherwise.
46
51
  *
47
- * @param value The value to cast.
48
- * @returns The value as a NonZeroUint32 type.
49
- * @throws {TypeError} If the value is not a non-zero integer in [1, 2^32).
52
+ * @param value - The value to cast
53
+ * @returns The value as a `NonZeroUint32`
54
+ * @throws {TypeError} If the value is not a non-zero integer in [1, 2^32)
50
55
  */
51
56
  export const asNonZeroUint32 = castType;
52
57
 
53
58
  /**
54
- * Namespace providing type-safe arithmetic operations for 32-bit non-zero
55
- * unsigned integers.
59
+ * Namespace providing type-safe operations for the `NonZeroUint32` branded
60
+ * type.
56
61
  *
57
- * All operations automatically clamp results to the valid NonZeroUint32 range
58
- * [1, 4294967295]. This ensures that all arithmetic maintains the 32-bit
59
- * non-zero unsigned integer constraint, with results below 1 clamped to
60
- * MIN_VALUE and overflow results clamped to MAX_VALUE.
62
+ * The `NonZeroUint32` type represents a non-zero integer in [1, 2^32). Division
63
+ * (`div`) uses floor division.
61
64
  */
62
65
  export const NonZeroUint32 = {
63
66
  /**
64
- * Type guard to check if a value is a NonZeroUint32.
67
+ * Type guard that checks if a value is a non-zero integer in [1, 2^32).
65
68
  *
66
- * @param value The value to check.
67
- * @returns `true` if the value is a 32-bit non-zero unsigned integer, `false`
68
- * otherwise.
69
+ * @param value - The value to check
70
+ * @returns `true` if the value is a non-zero integer in [1, 2^32), `false` otherwise
71
+ * @see {@link isNonZeroUint32} for usage examples
69
72
  */
70
73
  is,
71
74
 
72
75
  /**
73
- * The minimum value for a 32-bit non-zero unsigned integer.
74
- *
75
- * @readonly
76
+ * The smallest value representable as `NonZeroUint32`.
76
77
  */
77
78
  MIN_VALUE,
78
79
 
79
80
  /**
80
- * The maximum value for a 32-bit non-zero unsigned integer.
81
- *
82
- * @readonly
81
+ * The largest value representable as `NonZeroUint32`.
83
82
  */
84
83
  MAX_VALUE,
85
84
 
86
85
  /**
87
- * Returns the smaller of two NonZeroUint32 values.
86
+ * Returns the smallest of the given non-zero integers.
88
87
  *
89
- * @param a The first NonZeroUint32.
90
- * @param b The second NonZeroUint32.
91
- * @returns The minimum value as a NonZeroUint32.
88
+ * @param values - The non-zero integers to compare (at least one required)
89
+ * @returns The smallest value as a `NonZeroUint32`
92
90
  */
93
91
  min: min_,
94
92
 
95
93
  /**
96
- * Returns the larger of two NonZeroUint32 values.
94
+ * Returns the largest of the given non-zero integers.
97
95
  *
98
- * @param a The first NonZeroUint32.
99
- * @param b The second NonZeroUint32.
100
- * @returns The maximum value as a NonZeroUint32.
96
+ * @param values - The non-zero integers to compare (at least one required)
97
+ * @returns The largest value as a `NonZeroUint32`
101
98
  */
102
99
  max: max_,
103
100
 
104
101
  /**
105
- * Clamps a number to the NonZeroUint32 range.
102
+ * Clamps a `number` into the `NonZeroUint32` range, rounding to the nearest
103
+ * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
106
104
  *
107
- * @param value The number to clamp.
108
- * @returns The value clamped to [1, 4294967295] as a NonZeroUint32.
105
+ * @param value - The value to clamp
106
+ * @returns The clamped value as a `NonZeroUint32`
109
107
  */
110
108
  clamp,
111
109
 
112
110
  /**
113
- * Generates a random NonZeroUint32 value within the valid range.
111
+ * Generates a random `NonZeroUint32` within the given range.
112
+ *
113
+ * The range is inclusive on both ends.
114
114
  *
115
- * @returns A random NonZeroUint32 between 1 and 4294967295.
115
+ * @param min - The minimum value (inclusive)
116
+ * @param max - The maximum value (inclusive)
117
+ * @returns A random `NonZeroUint32` in `[min, max]`
116
118
  */
117
119
  random,
118
120
 
119
121
  /**
120
- * Raises a NonZeroUint32 to the power of another NonZeroUint32.
122
+ * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroUint32`
123
+ * (floored to an integer).
121
124
  *
122
- * @param a The base NonZeroUint32.
123
- * @param b The exponent NonZeroUint32.
124
- * @returns `a ** b` clamped to [1, 4294967295] as a NonZeroUint32.
125
+ * @param a - The base non-zero integer
126
+ * @param b - The exponent non-zero integer
127
+ * @returns `a ** b` as a `NonZeroUint32`
125
128
  */
126
129
  pow,
127
130
 
128
131
  /**
129
- * Adds two NonZeroUint32 values.
132
+ * Adds two non-zero integers, returning `a + b` as a `NonZeroUint32`.
130
133
  *
131
- * @param a The first NonZeroUint32.
132
- * @param b The second NonZeroUint32.
133
- * @returns `a + b` clamped to [1, 4294967295] as a NonZeroUint32.
134
+ * @param a - The first non-zero integer
135
+ * @param b - The second non-zero integer
136
+ * @returns The sum of `a` and `b` as a `NonZeroUint32`
134
137
  */
135
138
  add,
136
139
 
137
140
  /**
138
- * Multiplies two NonZeroUint32 values.
139
- *
140
- * Both `add` and `mul` stay within `[1, 4294967295]`. For the non-closed
141
- * operations (`sub`/`div`, whose result may be `0`) use {@link Num.sub} /
142
- * {@link Num.divInt}.
141
+ * Multiplies two non-zero integers, returning `a * b` as a `NonZeroUint32`.
143
142
  *
144
- * @param a The first NonZeroUint32.
145
- * @param b The second NonZeroUint32.
146
- * @returns `a * b` clamped to [1, 4294967295] as a NonZeroUint32.
143
+ * @param a - The first non-zero integer
144
+ * @param b - The second non-zero integer
145
+ * @returns The product of `a` and `b` as a `NonZeroUint32`
147
146
  */
148
147
  mul,
149
148
  } as const;
@@ -78,148 +78,159 @@ expectType<
78
78
  >('=');
79
79
 
80
80
  /**
81
- * Checks if a number is a PositiveFiniteNumber (a finite number > 0).
81
+ * Type guard that checks if a value is a positive finite number.
82
82
  *
83
- * @param value The value to check.
84
- * @returns `true` if the value is a PositiveFiniteNumber, `false` otherwise.
83
+ * Returns `true` only for a finite value — never `NaN`, `Infinity`, or
84
+ * `-Infinity`.
85
+ *
86
+ * @param value - The value to check
87
+ * @returns `true` if the value is a positive finite number, `false` otherwise
85
88
  */
86
89
  export const isPositiveFiniteNumber = is;
87
90
 
88
91
  /**
89
- * Casts a number to a PositiveFiniteNumber type.
92
+ * Casts a `number` to the `PositiveFiniteNumber` branded type.
93
+ *
94
+ * Validates that the value is a positive finite number and returns it with the
95
+ * `PositiveFiniteNumber` brand. Throws a `TypeError` otherwise.
90
96
  *
91
- * @param value The value to cast.
92
- * @returns The value as a PositiveFiniteNumber type.
93
- * @throws {TypeError} If the value is not a positive finite number.
97
+ * @param value - The value to cast
98
+ * @returns The value as a `PositiveFiniteNumber`
99
+ * @throws {TypeError} If the value is not a positive finite number
94
100
  */
95
101
  export const asPositiveFiniteNumber = castType;
96
102
 
97
103
  /**
98
- * Namespace providing type-safe arithmetic operations for positive finite
99
- * numbers.
104
+ * Namespace providing type-safe operations for the `PositiveFiniteNumber`
105
+ * branded type.
100
106
  *
101
- * All operations maintain the positive constraint by clamping non-positive
102
- * results to MIN_VALUE, while ensuring results remain finite (excluding NaN and
103
- * Infinity). This type is useful for representing quantities that must always
104
- * be positive, such as probabilities, magnitudes, and physical measurements.
107
+ * The `PositiveFiniteNumber` type represents a positive finite number.
105
108
  */
106
109
  export const PositiveFiniteNumber = {
107
110
  /**
108
- * Type guard to check if a value is a PositiveFiniteNumber.
111
+ * Type guard that checks if a value is a positive finite number.
109
112
  *
110
- * @param value The value to check.
111
- * @returns `true` if the value is a positive finite number, `false`
112
- * otherwise.
113
+ * @param value - The value to check
114
+ * @returns `true` if the value is a positive finite number, `false` otherwise
115
+ * @see {@link isPositiveFiniteNumber} for usage examples
113
116
  */
114
117
  is,
115
118
 
116
119
  /**
117
- * The minimum value for a positive finite number.
118
- *
119
- * @readonly
120
+ * The smallest value representable as `PositiveFiniteNumber`.
120
121
  */
121
122
  MIN_VALUE,
122
123
 
123
124
  /**
124
- * Returns the smaller of two PositiveFiniteNumber values.
125
+ * Returns the smallest of the given positive finite numbers.
125
126
  *
126
- * @param a The first PositiveFiniteNumber.
127
- * @param b The second PositiveFiniteNumber.
128
- * @returns The minimum value as a PositiveFiniteNumber.
127
+ * @param values - The positive finite numbers to compare (at least one required)
128
+ * @returns The smallest value as a `PositiveFiniteNumber`
129
129
  */
130
130
  min: min_,
131
131
 
132
132
  /**
133
- * Returns the larger of two PositiveFiniteNumber values.
133
+ * Returns the largest of the given positive finite numbers.
134
134
  *
135
- * @param a The first PositiveFiniteNumber.
136
- * @param b The second PositiveFiniteNumber.
137
- * @returns The maximum value as a PositiveFiniteNumber.
135
+ * @param values - The positive finite numbers to compare (at least one required)
136
+ * @returns The largest value as a `PositiveFiniteNumber`
138
137
  */
139
138
  max: max_,
140
139
 
141
140
  /**
142
- * Clamps a number to the positive finite range.
141
+ * Clamps a `number` into the `PositiveFiniteNumber` range `[MIN_VALUE,
142
+ * MAX_VALUE]`.
143
143
  *
144
- * @param value The number to clamp.
145
- * @returns The value clamped to (0, +∞) as a PositiveFiniteNumber.
144
+ * @param value - The value to clamp
145
+ * @returns The clamped value as a `PositiveFiniteNumber`
146
146
  */
147
147
  clamp,
148
148
 
149
149
  /**
150
- * Rounds down a PositiveFiniteNumber to the nearest integer.
150
+ * Returns the greatest integer less than or equal to a positive finite
151
+ * number.
151
152
  *
152
- * @param x The PositiveFiniteNumber to round down.
153
- * @returns The floor value as a Uint (can be 0).
153
+ * @param a - The positive finite number value
154
+ * @returns The floored value as an integer
154
155
  */
155
156
  floor,
156
157
 
157
158
  /**
158
- * Rounds up a PositiveFiniteNumber to the nearest integer.
159
+ * Returns the smallest integer greater than or equal to a positive finite
160
+ * number.
159
161
  *
160
- * @param x The PositiveFiniteNumber to round up.
161
- * @returns The ceiling value as a PositiveInt (always >= 1).
162
+ * @param a - The positive finite number value
163
+ * @returns The ceiled value as an integer
162
164
  */
163
165
  ceil,
164
166
 
165
167
  /**
166
- * Rounds a PositiveFiniteNumber to the nearest integer.
168
+ * Returns the value of a positive finite number rounded to the nearest
169
+ * integer.
167
170
  *
168
- * @param x The PositiveFiniteNumber to round.
169
- * @returns The rounded value as a Uint (can be 0 if x < 0.5).
171
+ * @param a - The positive finite number value
172
+ * @returns The rounded value as an integer
170
173
  */
171
174
  round,
172
175
 
173
176
  /**
174
- * Generates a random PositiveFiniteNumber value.
177
+ * Generates a random `PositiveFiniteNumber` within the given range.
178
+ *
179
+ * The range is inclusive on both ends.
175
180
  *
176
- * @returns A random positive finite number.
181
+ * @param min - The minimum value (inclusive)
182
+ * @param max - The maximum value (inclusive)
183
+ * @returns A random `PositiveFiniteNumber` in `[min, max]`
177
184
  */
178
185
  random,
179
186
 
180
187
  /**
181
- * Raises a PositiveFiniteNumber to the power of another PositiveFiniteNumber.
188
+ * Raises `a` to the power `b`, returning `a ** b` as a
189
+ * `PositiveFiniteNumber`.
182
190
  *
183
- * @param a The base PositiveFiniteNumber.
184
- * @param b The exponent PositiveFiniteNumber.
185
- * @returns `a ** b` clamped to (0, +∞) as a PositiveFiniteNumber.
191
+ * @param a - The base positive finite number
192
+ * @param b - The exponent positive finite number
193
+ * @returns `a ** b` as a `PositiveFiniteNumber`
186
194
  */
187
195
  pow,
188
196
 
189
197
  /**
190
- * Adds two PositiveFiniteNumber values.
198
+ * Adds two positive finite numbers, returning `a + b` as a
199
+ * `PositiveFiniteNumber`.
191
200
  *
192
- * @param a The first PositiveFiniteNumber.
193
- * @param b The second PositiveFiniteNumber.
194
- * @returns `a + b` clamped to (0, +∞) as a PositiveFiniteNumber.
201
+ * @param a - The first positive finite number
202
+ * @param b - The second positive finite number
203
+ * @returns The sum of `a` and `b` as a `PositiveFiniteNumber`
195
204
  */
196
205
  add,
197
206
 
198
207
  /**
199
- * Subtracts one PositiveFiniteNumber from another.
208
+ * Subtracts two positive finite numbers, returning `a - b` as a
209
+ * `PositiveFiniteNumber`.
200
210
  *
201
- * @param a The minuend PositiveFiniteNumber.
202
- * @param b The subtrahend PositiveFiniteNumber.
203
- * @returns `a - b` clamped to (0, +∞) as a PositiveFiniteNumber (minimum
204
- * MIN_VALUE).
211
+ * @param a - The first positive finite number
212
+ * @param b - The second positive finite number
213
+ * @returns The difference of `a` and `b` as a `PositiveFiniteNumber`
205
214
  */
206
215
  sub,
207
216
 
208
217
  /**
209
- * Multiplies two PositiveFiniteNumber values.
218
+ * Multiplies two positive finite numbers, returning `a * b` as a
219
+ * `PositiveFiniteNumber`.
210
220
  *
211
- * @param a The first PositiveFiniteNumber.
212
- * @param b The second PositiveFiniteNumber.
213
- * @returns `a * b` clamped to (0, +∞) as a PositiveFiniteNumber.
221
+ * @param a - The first positive finite number
222
+ * @param b - The second positive finite number
223
+ * @returns The product of `a` and `b` as a `PositiveFiniteNumber`
214
224
  */
215
225
  mul,
216
226
 
217
227
  /**
218
- * Divides one PositiveFiniteNumber by another.
228
+ * Divides two positive finite numbers, returning `a / b` as a
229
+ * `PositiveFiniteNumber`.
219
230
  *
220
- * @param a The dividend PositiveFiniteNumber.
221
- * @param b The divisor PositiveFiniteNumber.
222
- * @returns `a / b` clamped to (0, +∞) as a PositiveFiniteNumber.
231
+ * @param a - The dividend
232
+ * @param b - The divisor (must be non-zero)
233
+ * @returns `a / b` as a `PositiveFiniteNumber`
223
234
  */
224
235
  div,
225
236
  } as const;
@@ -35,8 +35,8 @@ const {
35
35
  /**
36
36
  * Type guard that checks if a value is a positive integer.
37
37
  *
38
- * A positive integer is any integer greater than zero (>= 1). This excludes
39
- * zero, negative numbers, and non-integers.
38
+ * Returns `true` for a positive integer — a value with no fractional component,
39
+ * including values outside the safe integer range (unlike `SafeInt`).
40
40
  *
41
41
  * @example
42
42
  *
@@ -54,11 +54,10 @@ const {
54
54
  export const isPositiveInt = is;
55
55
 
56
56
  /**
57
- * Casts a number to a PositiveInt branded type.
57
+ * Casts a `number` to the `PositiveInt` branded type.
58
58
  *
59
- * This function validates that the input is a positive integer (>= 1) and
60
- * returns it with the PositiveInt brand. This ensures type safety for
61
- * operations that require strictly positive integer values.
59
+ * Validates that the value is a positive integer and returns it with the
60
+ * `PositiveInt` brand. Throws a `TypeError` otherwise.
62
61
  *
63
62
  * @example
64
63
  *
@@ -71,26 +70,20 @@ export const isPositiveInt = is;
71
70
  * ```
72
71
  *
73
72
  * @param value - The value to cast
74
- * @returns The value as a PositiveInt branded type
73
+ * @returns The value as a `PositiveInt`
75
74
  * @throws {TypeError} If the value is not a positive integer
76
75
  */
77
76
  export const asPositiveInt = castType;
78
77
 
79
78
  /**
80
- * Namespace providing type-safe operations for PositiveInt branded types.
79
+ * Namespace providing type-safe operations for the `PositiveInt` branded type.
81
80
  *
82
- * PositiveInt represents integers that are strictly greater than zero (>= 1).
83
- * All operations automatically clamp results to maintain the positive
84
- * constraint, ensuring that arithmetic operations never produce zero or
85
- * negative values.
81
+ * The `PositiveInt` type represents a positive integer. Division (`div`) uses
82
+ * floor division.
86
83
  *
87
- * This type is essential for:
88
- *
89
- * - Array lengths and sizes (length >= 1)
90
- * - Counts and quantities that must be positive
91
- * - Denominators in division operations
92
- * - Loop counters and iteration counts
93
- * - Database primary keys and IDs
84
+ * Unlike `SafeInt`, `PositiveInt` allows values outside the safe integer range
85
+ * (±2^53 − 1), so very large magnitudes may lose precision in JavaScript's
86
+ * `number` type.
94
87
  */
95
88
  export const PositiveInt = {
96
89
  /**
@@ -113,17 +106,12 @@ export const PositiveInt = {
113
106
  is,
114
107
 
115
108
  /**
116
- * The minimum value for a PositiveInt.
117
- *
118
- * @readonly
109
+ * The smallest value representable as `PositiveInt`.
119
110
  */
120
111
  MIN_VALUE,
121
112
 
122
113
  /**
123
- * Returns the minimum value from a list of positive integers.
124
- *
125
- * Since all inputs are guaranteed to be >= 1, the result is also guaranteed
126
- * to be a positive integer.
114
+ * Returns the smallest of the given positive integers.
127
115
  *
128
116
  * @example
129
117
  *
@@ -138,12 +126,12 @@ export const PositiveInt = {
138
126
  * ```
139
127
  *
140
128
  * @param values - The positive integers to compare (at least one required)
141
- * @returns The smallest value as a PositiveInt
129
+ * @returns The smallest value as a `PositiveInt`
142
130
  */
143
131
  min: min_,
144
132
 
145
133
  /**
146
- * Returns the maximum value from a list of positive integers.
134
+ * Returns the largest of the given positive integers.
147
135
  *
148
136
  * @example
149
137
  *
@@ -158,15 +146,13 @@ export const PositiveInt = {
158
146
  * ```
159
147
  *
160
148
  * @param values - The positive integers to compare (at least one required)
161
- * @returns The largest value as a PositiveInt
149
+ * @returns The largest value as a `PositiveInt`
162
150
  */
163
151
  max: max_,
164
152
 
165
153
  /**
166
- * Clamps a number to the positive integer range.
167
- *
168
- * Since PositiveInt has a minimum value of 1, this function ensures that any
169
- * input less than 1 is clamped to 1.
154
+ * Clamps a `number` into the `PositiveInt` range, rounding to the nearest
155
+ * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
170
156
  *
171
157
  * @example
172
158
  *
@@ -180,16 +166,15 @@ export const PositiveInt = {
180
166
  * assert.isTrue(withinRange === 10);
181
167
  * ```
182
168
  *
183
- * @param value - The number to clamp
184
- * @returns The value clamped to >= 1 as a PositiveInt
169
+ * @param value - The value to clamp
170
+ * @returns The clamped value as a `PositiveInt`
185
171
  */
186
172
  clamp,
187
173
 
188
174
  /**
189
- * Generates a random positive integer within the specified range (inclusive).
175
+ * Generates a random `PositiveInt` within the given range.
190
176
  *
191
- * Both bounds are inclusive, and both min and max must be positive integers.
192
- * If min > max, they are automatically swapped.
177
+ * The range is inclusive on both ends.
193
178
  *
194
179
  * @example
195
180
  *
@@ -205,15 +190,15 @@ export const PositiveInt = {
205
190
  * assert.isTrue(randomValue >= 3 && randomValue <= 6);
206
191
  * ```
207
192
  *
208
- * @param min - The minimum value (inclusive, must be >= 1)
209
- * @param max - The maximum value (inclusive, must be >= min)
210
- * @returns A random PositiveInt in the range [min, max]
193
+ * @param min - The minimum value (inclusive)
194
+ * @param max - The maximum value (inclusive)
195
+ * @returns A random `PositiveInt` in `[min, max]`
211
196
  */
212
197
  random,
213
198
 
214
199
  /**
215
- * Raises a positive integer to a power, ensuring the result is never less
216
- * than 1.
200
+ * Raises `a` to the power `b`, returning `a ** b` as a `PositiveInt` (floored
201
+ * to an integer).
217
202
  *
218
203
  * @example
219
204
  *
@@ -229,12 +214,12 @@ export const PositiveInt = {
229
214
  *
230
215
  * @param a - The base positive integer
231
216
  * @param b - The exponent positive integer
232
- * @returns `a ** b` as a PositiveInt, but never less than 1
217
+ * @returns `a ** b` as a `PositiveInt`
233
218
  */
234
219
  pow,
235
220
 
236
221
  /**
237
- * Adds two positive integers, ensuring the result is never less than 1.
222
+ * Adds two positive integers, returning `a + b` as a `PositiveInt`.
238
223
  *
239
224
  * @example
240
225
  *
@@ -244,17 +229,14 @@ export const PositiveInt = {
244
229
  * assert.isTrue(sum === 9);
245
230
  * ```
246
231
  *
247
- * @param a - First positive integer
248
- * @param b - Second positive integer
249
- * @returns `a + b` as a PositiveInt, but never less than 1
232
+ * @param a - The first positive integer
233
+ * @param b - The second positive integer
234
+ * @returns The sum of `a` and `b` as a `PositiveInt`
250
235
  */
251
236
  add,
252
237
 
253
238
  /**
254
- * Subtracts two positive integers, clamping the result to remain positive.
255
- *
256
- * If the mathematical result would be <= 0, it is clamped to 1 to maintain
257
- * the positive integer constraint.
239
+ * Subtracts two positive integers, returning `a - b` as a `PositiveInt`.
258
240
  *
259
241
  * @example
260
242
  *
@@ -264,14 +246,14 @@ export const PositiveInt = {
264
246
  * assert.isTrue(difference === 1);
265
247
  * ```
266
248
  *
267
- * @param a - The minuend (positive integer)
268
- * @param b - The subtrahend (positive integer)
269
- * @returns `max(1, a - b)` as a PositiveInt
249
+ * @param a - The first positive integer
250
+ * @param b - The second positive integer
251
+ * @returns The difference of `a` and `b` as a `PositiveInt`
270
252
  */
271
253
  sub,
272
254
 
273
255
  /**
274
- * Multiplies two positive integers, ensuring the result is never less than 1.
256
+ * Multiplies two positive integers, returning `a * b` as a `PositiveInt`.
275
257
  *
276
258
  * @example
277
259
  *
@@ -281,19 +263,15 @@ export const PositiveInt = {
281
263
  * assert.isTrue(product === 21);
282
264
  * ```
283
265
  *
284
- * @param a - First positive integer
285
- * @param b - Second positive integer
286
- * @returns `a * b` as a PositiveInt, but never less than 1
266
+ * @param a - The first positive integer
267
+ * @param b - The second positive integer
268
+ * @returns The product of `a` and `b` as a `PositiveInt`
287
269
  */
288
270
  mul,
289
271
 
290
272
  /**
291
- * Divides two positive integers using floor division, clamping to remain
292
- * positive.
293
- *
294
- * Performs mathematical floor division: `⌊a / b⌋`. If the result would be 0
295
- * (when a < b), it is clamped to 1 to maintain the positive integer
296
- * constraint.
273
+ * Divides two positive integers using floor division (`⌊a / b⌋`): the result
274
+ * is `a / b` rounded toward negative infinity, as a `PositiveInt`.
297
275
  *
298
276
  * @example
299
277
  *
@@ -307,9 +285,9 @@ export const PositiveInt = {
307
285
  * assert.isTrue(clamped === 1);
308
286
  * ```
309
287
  *
310
- * @param a - The dividend (positive integer)
311
- * @param b - The divisor (positive integer, guaranteed non-zero)
312
- * @returns `max(1, ⌊a / b⌋)` as a PositiveInt
288
+ * @param a - The dividend
289
+ * @param b - The divisor (must be non-zero)
290
+ * @returns The floored quotient as a `PositiveInt`
313
291
  */
314
292
  div,
315
293
  } as const;