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
@@ -57,149 +57,159 @@ expectType<TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>, Uint>(
57
57
  );
58
58
 
59
59
  /**
60
- * Checks if a number is a NonNegativeFiniteNumber (a finite number >= 0).
60
+ * Type guard that checks if a value is a non-negative finite number.
61
61
  *
62
- * @param value The value to check.
63
- * @returns `true` if the value is a NonNegativeFiniteNumber, `false` otherwise.
62
+ * Returns `true` only for a finite value — never `NaN`, `Infinity`, or
63
+ * `-Infinity`.
64
+ *
65
+ * @param value - The value to check
66
+ * @returns `true` if the value is a non-negative finite number, `false` otherwise
64
67
  */
65
68
  export const isNonNegativeFiniteNumber = is;
66
69
 
67
70
  /**
68
- * Casts a number to a NonNegativeFiniteNumber type.
71
+ * Casts a `number` to the `NonNegativeFiniteNumber` branded type.
72
+ *
73
+ * Validates that the value is a non-negative finite number and returns it with
74
+ * the `NonNegativeFiniteNumber` brand. Throws a `TypeError` otherwise.
69
75
  *
70
- * @param value The value to cast.
71
- * @returns The value as a NonNegativeFiniteNumber type.
72
- * @throws {TypeError} If the value is not a non-negative finite number.
76
+ * @param value - The value to cast
77
+ * @returns The value as a `NonNegativeFiniteNumber`
78
+ * @throws {TypeError} If the value is not a non-negative finite number
73
79
  */
74
80
  export const asNonNegativeFiniteNumber = castType;
75
81
 
76
82
  /**
77
- * Namespace providing type-safe arithmetic operations for non-negative finite
78
- * numbers.
83
+ * Namespace providing type-safe operations for the `NonNegativeFiniteNumber`
84
+ * branded type.
79
85
  *
80
- * All operations maintain the non-negative constraint by clamping negative
81
- * results to 0, while ensuring results remain finite (excluding NaN and
82
- * Infinity). This type is useful for representing measurements, distances,
83
- * weights, and other inherently non-negative values.
86
+ * The `NonNegativeFiniteNumber` type represents a non-negative finite number.
84
87
  */
85
88
  export const NonNegativeFiniteNumber = {
86
89
  /**
87
- * Type guard to check if a value is a NonNegativeFiniteNumber.
90
+ * Type guard that checks if a value is a non-negative finite number.
88
91
  *
89
- * @param value The value to check.
90
- * @returns `true` if the value is a non-negative finite number, `false`
91
- * otherwise.
92
+ * @param value - The value to check
93
+ * @returns `true` if the value is a non-negative finite number, `false` otherwise
94
+ * @see {@link isNonNegativeFiniteNumber} for usage examples
92
95
  */
93
96
  is,
94
97
 
95
98
  /**
96
- * The minimum value for a non-negative finite number.
97
- *
98
- * @readonly
99
+ * The smallest value representable as `NonNegativeFiniteNumber`.
99
100
  */
100
101
  MIN_VALUE,
101
102
 
102
103
  /**
103
- * Returns the smaller of two NonNegativeFiniteNumber values.
104
+ * Returns the smallest of the given non-negative finite numbers.
104
105
  *
105
- * @param a The first NonNegativeFiniteNumber.
106
- * @param b The second NonNegativeFiniteNumber.
107
- * @returns The minimum value as a NonNegativeFiniteNumber.
106
+ * @param values - The non-negative finite numbers to compare (at least one required)
107
+ * @returns The smallest value as a `NonNegativeFiniteNumber`
108
108
  */
109
109
  min: min_,
110
110
 
111
111
  /**
112
- * Returns the larger of two NonNegativeFiniteNumber values.
112
+ * Returns the largest of the given non-negative finite numbers.
113
113
  *
114
- * @param a The first NonNegativeFiniteNumber.
115
- * @param b The second NonNegativeFiniteNumber.
116
- * @returns The maximum value as a NonNegativeFiniteNumber.
114
+ * @param values - The non-negative finite numbers to compare (at least one required)
115
+ * @returns The largest value as a `NonNegativeFiniteNumber`
117
116
  */
118
117
  max: max_,
119
118
 
120
119
  /**
121
- * Clamps a number to the non-negative finite range.
120
+ * Clamps a `number` into the `NonNegativeFiniteNumber` range `[MIN_VALUE,
121
+ * MAX_VALUE]`.
122
122
  *
123
- * @param value The number to clamp.
124
- * @returns The value clamped to [0, +∞) as a NonNegativeFiniteNumber.
123
+ * @param value - The value to clamp
124
+ * @returns The clamped value as a `NonNegativeFiniteNumber`
125
125
  */
126
126
  clamp,
127
127
 
128
128
  /**
129
- * Rounds down a NonNegativeFiniteNumber to the nearest integer.
129
+ * Returns the greatest integer less than or equal to a non-negative finite
130
+ * number.
130
131
  *
131
- * @param x The NonNegativeFiniteNumber to round down.
132
- * @returns The floor value as a Uint.
132
+ * @param a - The non-negative finite number value
133
+ * @returns The floored value as an integer
133
134
  */
134
135
  floor,
135
136
 
136
137
  /**
137
- * Rounds up a NonNegativeFiniteNumber to the nearest integer.
138
+ * Returns the smallest integer greater than or equal to a non-negative finite
139
+ * number.
138
140
  *
139
- * @param x The NonNegativeFiniteNumber to round up.
140
- * @returns The ceiling value as a Uint.
141
+ * @param a - The non-negative finite number value
142
+ * @returns The ceiled value as an integer
141
143
  */
142
144
  ceil,
143
145
 
144
146
  /**
145
- * Rounds a NonNegativeFiniteNumber to the nearest integer.
147
+ * Returns the value of a non-negative finite number rounded to the nearest
148
+ * integer.
146
149
  *
147
- * @param x The NonNegativeFiniteNumber to round.
148
- * @returns The rounded value as a Uint.
150
+ * @param a - The non-negative finite number value
151
+ * @returns The rounded value as an integer
149
152
  */
150
153
  round,
151
154
 
152
155
  /**
153
- * Generates a random NonNegativeFiniteNumber value.
156
+ * Generates a random `NonNegativeFiniteNumber` within the given range.
157
+ *
158
+ * The range is inclusive on both ends.
154
159
  *
155
- * @returns A random non-negative finite number.
160
+ * @param min - The minimum value (inclusive)
161
+ * @param max - The maximum value (inclusive)
162
+ * @returns A random `NonNegativeFiniteNumber` in `[min, max]`
156
163
  */
157
164
  random,
158
165
 
159
166
  /**
160
- * Raises a NonNegativeFiniteNumber to the power of another
161
- * NonNegativeFiniteNumber.
167
+ * Raises `a` to the power `b`, returning `a ** b` as a
168
+ * `NonNegativeFiniteNumber`.
162
169
  *
163
- * @param a The base NonNegativeFiniteNumber.
164
- * @param b The exponent NonNegativeFiniteNumber.
165
- * @returns `a ** b` clamped to [0, +∞) as a NonNegativeFiniteNumber.
170
+ * @param a - The base non-negative finite number
171
+ * @param b - The exponent non-negative finite number
172
+ * @returns `a ** b` as a `NonNegativeFiniteNumber`
166
173
  */
167
174
  pow,
168
175
 
169
176
  /**
170
- * Adds two NonNegativeFiniteNumber values.
177
+ * Adds two non-negative finite numbers, returning `a + b` as a
178
+ * `NonNegativeFiniteNumber`.
171
179
  *
172
- * @param a The first NonNegativeFiniteNumber.
173
- * @param b The second NonNegativeFiniteNumber.
174
- * @returns `a + b` clamped to [0, +∞) as a NonNegativeFiniteNumber.
180
+ * @param a - The first non-negative finite number
181
+ * @param b - The second non-negative finite number
182
+ * @returns The sum of `a` and `b` as a `NonNegativeFiniteNumber`
175
183
  */
176
184
  add,
177
185
 
178
186
  /**
179
- * Subtracts one NonNegativeFiniteNumber from another.
187
+ * Subtracts two non-negative finite numbers, returning `a - b` as a
188
+ * `NonNegativeFiniteNumber`.
180
189
  *
181
- * @param a The minuend NonNegativeFiniteNumber.
182
- * @param b The subtrahend NonNegativeFiniteNumber.
183
- * @returns `a - b` clamped to [0, +∞) as a NonNegativeFiniteNumber (minimum
184
- * 0).
190
+ * @param a - The first non-negative finite number
191
+ * @param b - The second non-negative finite number
192
+ * @returns The difference of `a` and `b` as a `NonNegativeFiniteNumber`
185
193
  */
186
194
  sub,
187
195
 
188
196
  /**
189
- * Multiplies two NonNegativeFiniteNumber values.
197
+ * Multiplies two non-negative finite numbers, returning `a * b` as a
198
+ * `NonNegativeFiniteNumber`.
190
199
  *
191
- * @param a The first NonNegativeFiniteNumber.
192
- * @param b The second NonNegativeFiniteNumber.
193
- * @returns `a * b` clamped to [0, +∞) as a NonNegativeFiniteNumber.
200
+ * @param a - The first non-negative finite number
201
+ * @param b - The second non-negative finite number
202
+ * @returns The product of `a` and `b` as a `NonNegativeFiniteNumber`
194
203
  */
195
204
  mul,
196
205
 
197
206
  /**
198
- * Divides one NonNegativeFiniteNumber by another.
207
+ * Divides two non-negative finite numbers, returning `a / b` as a
208
+ * `NonNegativeFiniteNumber`.
199
209
  *
200
- * @param a The dividend NonNegativeFiniteNumber.
201
- * @param b The divisor NonNegativeFiniteNumber.
202
- * @returns `a / b` clamped to [0, +∞) as a NonNegativeFiniteNumber.
210
+ * @param a - The dividend
211
+ * @param b - The divisor (must be non-zero)
212
+ * @returns `a / b` as a `NonNegativeFiniteNumber`
203
213
  */
204
214
  div,
205
215
  } as const;
@@ -34,131 +34,138 @@ const {
34
34
  } as const);
35
35
 
36
36
  /**
37
- * Checks if a number is a NonNegativeInt16 (16-bit non-negative signed integer
38
- * in the range [0, 2^15)).
37
+ * Type guard that checks if a value is a non-negative integer in [0, 2^15).
39
38
  *
40
- * @param value The value to check.
41
- * @returns `true` if the value is a NonNegativeInt16, `false` otherwise.
39
+ * Returns `true` for a non-negative integer in [0, 2^15) — a value with no
40
+ * fractional component.
41
+ *
42
+ * @param value - The value to check
43
+ * @returns `true` if the value is a non-negative integer in [0, 2^15), `false` otherwise
42
44
  */
43
45
  export const isNonNegativeInt16 = is;
44
46
 
45
47
  /**
46
- * Casts a number to a NonNegativeInt16 type.
48
+ * Casts a `number` to the `NonNegativeInt16` branded type.
49
+ *
50
+ * Validates that the value is a non-negative integer in [0, 2^15) and returns
51
+ * it with the `NonNegativeInt16` brand. Throws a `TypeError` otherwise.
47
52
  *
48
- * @param value The value to cast.
49
- * @returns The value as a NonNegativeInt16 type.
50
- * @throws {TypeError} If the value is not a non-negative integer in [0, 2^15).
53
+ * @param value - The value to cast
54
+ * @returns The value as a `NonNegativeInt16`
55
+ * @throws {TypeError} If the value is not a non-negative integer in [0, 2^15)
51
56
  */
52
57
  export const asNonNegativeInt16 = castType;
53
58
 
54
59
  /**
55
- * Namespace providing type-safe arithmetic operations for 16-bit non-negative
56
- * integers.
60
+ * Namespace providing type-safe operations for the `NonNegativeInt16` branded
61
+ * type.
57
62
  *
58
- * All operations automatically clamp results to the valid NonNegativeInt16
59
- * range [0, 32767]. This ensures that all arithmetic maintains the 16-bit
60
- * non-negative integer constraint, with negative results clamped to 0 and
61
- * overflow results clamped to MAX_VALUE.
63
+ * The `NonNegativeInt16` type represents a non-negative integer in [0, 2^15).
64
+ * Division (`div`) uses floor division.
62
65
  */
63
66
  export const NonNegativeInt16 = {
64
67
  /**
65
- * Type guard to check if a value is a NonNegativeInt16.
68
+ * Type guard that checks if a value is a non-negative integer in [0, 2^15).
66
69
  *
67
- * @param value The value to check.
68
- * @returns `true` if the value is a 16-bit non-negative integer, `false`
69
- * otherwise.
70
+ * @param value - The value to check
71
+ * @returns `true` if the value is a non-negative integer in [0, 2^15), `false` otherwise
72
+ * @see {@link isNonNegativeInt16} for usage examples
70
73
  */
71
74
  is,
72
75
 
73
76
  /**
74
- * The minimum value for a 16-bit non-negative integer.
75
- *
76
- * @readonly
77
+ * The smallest value representable as `NonNegativeInt16`.
77
78
  */
78
79
  MIN_VALUE,
79
80
 
80
81
  /**
81
- * The maximum value for a 16-bit non-negative integer.
82
- *
83
- * @readonly
82
+ * The largest value representable as `NonNegativeInt16`.
84
83
  */
85
84
  MAX_VALUE,
86
85
 
87
86
  /**
88
- * Returns the smaller of two NonNegativeInt16 values.
87
+ * Returns the smallest of the given non-negative integers.
89
88
  *
90
- * @param a The first NonNegativeInt16.
91
- * @param b The second NonNegativeInt16.
92
- * @returns The minimum value as a NonNegativeInt16.
89
+ * @param values - The non-negative integers to compare (at least one required)
90
+ * @returns The smallest value as a `NonNegativeInt16`
93
91
  */
94
92
  min: min_,
95
93
 
96
94
  /**
97
- * Returns the larger of two NonNegativeInt16 values.
95
+ * Returns the largest of the given non-negative integers.
98
96
  *
99
- * @param a The first NonNegativeInt16.
100
- * @param b The second NonNegativeInt16.
101
- * @returns The maximum value as a NonNegativeInt16.
97
+ * @param values - The non-negative integers to compare (at least one required)
98
+ * @returns The largest value as a `NonNegativeInt16`
102
99
  */
103
100
  max: max_,
104
101
 
105
102
  /**
106
- * Clamps a number to the NonNegativeInt16 range.
103
+ * Clamps a `number` into the `NonNegativeInt16` range, rounding to the
104
+ * nearest integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
107
105
  *
108
- * @param value The number to clamp.
109
- * @returns The value clamped to [0, 32767] as a NonNegativeInt16.
106
+ * @param value - The value to clamp
107
+ * @returns The clamped value as a `NonNegativeInt16`
110
108
  */
111
109
  clamp,
112
110
 
113
111
  /**
114
- * Generates a random NonNegativeInt16 value within the valid range.
112
+ * Generates a random `NonNegativeInt16` within the given range.
113
+ *
114
+ * The range is inclusive on both ends.
115
115
  *
116
- * @returns A random NonNegativeInt16 between 0 and 32767.
116
+ * @param min - The minimum value (inclusive)
117
+ * @param max - The maximum value (inclusive)
118
+ * @returns A random `NonNegativeInt16` in `[min, max]`
117
119
  */
118
120
  random,
119
121
 
120
122
  /**
121
- * Raises a NonNegativeInt16 to the power of another NonNegativeInt16.
123
+ * Raises `a` to the power `b`, returning `a ** b` as a `NonNegativeInt16`
124
+ * (floored to an integer).
122
125
  *
123
- * @param a The base NonNegativeInt16.
124
- * @param b The exponent NonNegativeInt16.
125
- * @returns `a ** b` clamped to [0, 32767] as a NonNegativeInt16.
126
+ * @param a - The base non-negative integer
127
+ * @param b - The exponent non-negative integer
128
+ * @returns `a ** b` as a `NonNegativeInt16`
126
129
  */
127
130
  pow,
128
131
 
129
132
  /**
130
- * Adds two NonNegativeInt16 values.
133
+ * Adds two non-negative integers, returning `a + b` as a `NonNegativeInt16`.
131
134
  *
132
- * @param a The first NonNegativeInt16.
133
- * @param b The second NonNegativeInt16.
134
- * @returns `a + b` clamped to [0, 32767] as a NonNegativeInt16.
135
+ * @param a - The first non-negative integer
136
+ * @param b - The second non-negative integer
137
+ * @returns The sum of `a` and `b` as a `NonNegativeInt16`
135
138
  */
136
139
  add,
137
140
 
138
141
  /**
139
- * Subtracts one NonNegativeInt16 from another.
142
+ * Subtracts two non-negative integers, returning `a - b` as a
143
+ * `NonNegativeInt16`.
140
144
  *
141
- * @param a The minuend NonNegativeInt16.
142
- * @param b The subtrahend NonNegativeInt16.
143
- * @returns `a - b` clamped to [0, 32767] as a NonNegativeInt16 (minimum 0).
145
+ * @param a - The first non-negative integer
146
+ * @param b - The second non-negative integer
147
+ * @returns The difference of `a` and `b` as a `NonNegativeInt16`
144
148
  */
145
149
  sub,
146
150
 
147
151
  /**
148
- * Multiplies two NonNegativeInt16 values.
152
+ * Multiplies two non-negative integers, returning `a * b` as a
153
+ * `NonNegativeInt16`.
149
154
  *
150
- * @param a The first NonNegativeInt16.
151
- * @param b The second NonNegativeInt16.
152
- * @returns `a * b` clamped to [0, 32767] as a NonNegativeInt16.
155
+ * @param a - The first non-negative integer
156
+ * @param b - The second non-negative integer
157
+ * @returns The product of `a` and `b` as a `NonNegativeInt16`
153
158
  */
154
159
  mul,
155
160
 
156
161
  /**
157
- * Divides one NonNegativeInt16 by another using floor division.
162
+ * Divides two non-negative integers using floor division (`⌊a / b⌋`): the
163
+ * result is `a / b` rounded toward negative infinity, as a
164
+ * `NonNegativeInt16`.
158
165
  *
159
- * @param a The dividend NonNegativeInt16.
160
- * @param b The divisor NonNegativeInt16.
161
- * @returns `⌊a / b⌋` clamped to [0, 32767] as a NonNegativeInt16.
166
+ * @param a - The dividend
167
+ * @param b - The divisor (must be non-zero)
168
+ * @returns The floored quotient as a `NonNegativeInt16`
162
169
  */
163
170
  div,
164
171
  } as const;
@@ -34,132 +34,138 @@ const {
34
34
  } as const);
35
35
 
36
36
  /**
37
- * Checks if a number is a NonNegativeInt32 (32-bit non-negative signed integer
38
- * in the range [0, 2^31)).
37
+ * Type guard that checks if a value is a non-negative integer in [0, 2^31).
39
38
  *
40
- * @param value The value to check.
41
- * @returns `true` if the value is a NonNegativeInt32, `false` otherwise.
39
+ * Returns `true` for a non-negative integer in [0, 2^31) — a value with no
40
+ * fractional component.
41
+ *
42
+ * @param value - The value to check
43
+ * @returns `true` if the value is a non-negative integer in [0, 2^31), `false` otherwise
42
44
  */
43
45
  export const isNonNegativeInt32 = is;
44
46
 
45
47
  /**
46
- * Casts a number to a NonNegativeInt32 type.
48
+ * Casts a `number` to the `NonNegativeInt32` branded type.
49
+ *
50
+ * Validates that the value is a non-negative integer in [0, 2^31) and returns
51
+ * it with the `NonNegativeInt32` brand. Throws a `TypeError` otherwise.
47
52
  *
48
- * @param value The value to cast.
49
- * @returns The value as a NonNegativeInt32 type.
50
- * @throws {TypeError} If the value is not a non-negative integer in [0, 2^31).
53
+ * @param value - The value to cast
54
+ * @returns The value as a `NonNegativeInt32`
55
+ * @throws {TypeError} If the value is not a non-negative integer in [0, 2^31)
51
56
  */
52
57
  export const asNonNegativeInt32 = castType;
53
58
 
54
59
  /**
55
- * Namespace providing type-safe arithmetic operations for 32-bit non-negative
56
- * integers.
60
+ * Namespace providing type-safe operations for the `NonNegativeInt32` branded
61
+ * type.
57
62
  *
58
- * All operations automatically clamp results to the valid NonNegativeInt32
59
- * range [0, 2147483647]. This ensures that all arithmetic maintains the 32-bit
60
- * non-negative integer constraint, with negative results clamped to 0 and
61
- * overflow results clamped to MAX_VALUE.
63
+ * The `NonNegativeInt32` type represents a non-negative integer in [0, 2^31).
64
+ * Division (`div`) uses floor division.
62
65
  */
63
66
  export const NonNegativeInt32 = {
64
67
  /**
65
- * Type guard to check if a value is a NonNegativeInt32.
68
+ * Type guard that checks if a value is a non-negative integer in [0, 2^31).
66
69
  *
67
- * @param value The value to check.
68
- * @returns `true` if the value is a 32-bit non-negative integer, `false`
69
- * otherwise.
70
+ * @param value - The value to check
71
+ * @returns `true` if the value is a non-negative integer in [0, 2^31), `false` otherwise
72
+ * @see {@link isNonNegativeInt32} for usage examples
70
73
  */
71
74
  is,
72
75
 
73
76
  /**
74
- * The minimum value for a 32-bit non-negative integer.
75
- *
76
- * @readonly
77
+ * The smallest value representable as `NonNegativeInt32`.
77
78
  */
78
79
  MIN_VALUE,
79
80
 
80
81
  /**
81
- * The maximum value for a 32-bit non-negative integer.
82
- *
83
- * @readonly
82
+ * The largest value representable as `NonNegativeInt32`.
84
83
  */
85
84
  MAX_VALUE,
86
85
 
87
86
  /**
88
- * Returns the smaller of two NonNegativeInt32 values.
87
+ * Returns the smallest of the given non-negative integers.
89
88
  *
90
- * @param a The first NonNegativeInt32.
91
- * @param b The second NonNegativeInt32.
92
- * @returns The minimum value as a NonNegativeInt32.
89
+ * @param values - The non-negative integers to compare (at least one required)
90
+ * @returns The smallest value as a `NonNegativeInt32`
93
91
  */
94
92
  min: min_,
95
93
 
96
94
  /**
97
- * Returns the larger of two NonNegativeInt32 values.
95
+ * Returns the largest of the given non-negative integers.
98
96
  *
99
- * @param a The first NonNegativeInt32.
100
- * @param b The second NonNegativeInt32.
101
- * @returns The maximum value as a NonNegativeInt32.
97
+ * @param values - The non-negative integers to compare (at least one required)
98
+ * @returns The largest value as a `NonNegativeInt32`
102
99
  */
103
100
  max: max_,
104
101
 
105
102
  /**
106
- * Clamps a number to the NonNegativeInt32 range.
103
+ * Clamps a `number` into the `NonNegativeInt32` range, rounding to the
104
+ * nearest integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
107
105
  *
108
- * @param value The number to clamp.
109
- * @returns The value clamped to [0, 2147483647] as a NonNegativeInt32.
106
+ * @param value - The value to clamp
107
+ * @returns The clamped value as a `NonNegativeInt32`
110
108
  */
111
109
  clamp,
112
110
 
113
111
  /**
114
- * Generates a random NonNegativeInt32 value within the valid range.
112
+ * Generates a random `NonNegativeInt32` within the given range.
113
+ *
114
+ * The range is inclusive on both ends.
115
115
  *
116
- * @returns A random NonNegativeInt32 between 0 and 2147483647.
116
+ * @param min - The minimum value (inclusive)
117
+ * @param max - The maximum value (inclusive)
118
+ * @returns A random `NonNegativeInt32` in `[min, max]`
117
119
  */
118
120
  random,
119
121
 
120
122
  /**
121
- * Raises a NonNegativeInt32 to the power of another NonNegativeInt32.
123
+ * Raises `a` to the power `b`, returning `a ** b` as a `NonNegativeInt32`
124
+ * (floored to an integer).
122
125
  *
123
- * @param a The base NonNegativeInt32.
124
- * @param b The exponent NonNegativeInt32.
125
- * @returns `a ** b` clamped to [0, 2147483647] as a NonNegativeInt32.
126
+ * @param a - The base non-negative integer
127
+ * @param b - The exponent non-negative integer
128
+ * @returns `a ** b` as a `NonNegativeInt32`
126
129
  */
127
130
  pow,
128
131
 
129
132
  /**
130
- * Adds two NonNegativeInt32 values.
133
+ * Adds two non-negative integers, returning `a + b` as a `NonNegativeInt32`.
131
134
  *
132
- * @param a The first NonNegativeInt32.
133
- * @param b The second NonNegativeInt32.
134
- * @returns `a + b` clamped to [0, 2147483647] as a NonNegativeInt32.
135
+ * @param a - The first non-negative integer
136
+ * @param b - The second non-negative integer
137
+ * @returns The sum of `a` and `b` as a `NonNegativeInt32`
135
138
  */
136
139
  add,
137
140
 
138
141
  /**
139
- * Subtracts one NonNegativeInt32 from another.
142
+ * Subtracts two non-negative integers, returning `a - b` as a
143
+ * `NonNegativeInt32`.
140
144
  *
141
- * @param a The minuend NonNegativeInt32.
142
- * @param b The subtrahend NonNegativeInt32.
143
- * @returns `a - b` clamped to [0, 2147483647] as a NonNegativeInt32 (minimum
144
- * 0).
145
+ * @param a - The first non-negative integer
146
+ * @param b - The second non-negative integer
147
+ * @returns The difference of `a` and `b` as a `NonNegativeInt32`
145
148
  */
146
149
  sub,
147
150
 
148
151
  /**
149
- * Multiplies two NonNegativeInt32 values.
152
+ * Multiplies two non-negative integers, returning `a * b` as a
153
+ * `NonNegativeInt32`.
150
154
  *
151
- * @param a The first NonNegativeInt32.
152
- * @param b The second NonNegativeInt32.
153
- * @returns `a * b` clamped to [0, 2147483647] as a NonNegativeInt32.
155
+ * @param a - The first non-negative integer
156
+ * @param b - The second non-negative integer
157
+ * @returns The product of `a` and `b` as a `NonNegativeInt32`
154
158
  */
155
159
  mul,
156
160
 
157
161
  /**
158
- * Divides one NonNegativeInt32 by another using floor division.
162
+ * Divides two non-negative integers using floor division (`⌊a / b⌋`): the
163
+ * result is `a / b` rounded toward negative infinity, as a
164
+ * `NonNegativeInt32`.
159
165
  *
160
- * @param a The dividend NonNegativeInt32.
161
- * @param b The divisor NonNegativeInt32.
162
- * @returns `⌊a / b⌋` clamped to [0, 2147483647] as a NonNegativeInt32.
166
+ * @param a - The dividend
167
+ * @param b - The divisor (must be non-zero)
168
+ * @returns The floored quotient as a `NonNegativeInt32`
163
169
  */
164
170
  div,
165
171
  } as const;