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
@@ -34,9 +34,8 @@ const {
34
34
  /**
35
35
  * Type guard that checks if a value is an integer.
36
36
  *
37
- * Returns `true` if the value is any integer (positive, negative, or zero),
38
- * with no fractional component. This includes values outside the safe integer
39
- * range, unlike SafeInt.
37
+ * Returns `true` for an integer — a value with no fractional component,
38
+ * including values outside the safe integer range (unlike `SafeInt`).
40
39
  *
41
40
  * @example
42
41
  *
@@ -54,11 +53,10 @@ const {
54
53
  export const isInt = is;
55
54
 
56
55
  /**
57
- * Casts a number to an Int branded type.
56
+ * Casts a `number` to the `Int` branded type.
58
57
  *
59
- * This function validates that the input is an integer and returns it with the
60
- * Int brand. Throws a TypeError if the value has a fractional component or is
61
- * not a finite number.
58
+ * Validates that the value is an integer and returns it with the `Int` brand.
59
+ * Throws a `TypeError` otherwise.
62
60
  *
63
61
  * @example
64
62
  *
@@ -71,21 +69,19 @@ export const isInt = is;
71
69
  * ```
72
70
  *
73
71
  * @param value - The value to cast
74
- * @returns The value as an Int branded type
72
+ * @returns The value as an `Int`
75
73
  * @throws {TypeError} If the value is not an integer
76
74
  */
77
75
  export const asInt = castType;
78
76
 
79
77
  /**
80
- * Namespace providing type-safe operations for Int branded types.
78
+ * Namespace providing type-safe operations for the `Int` branded type.
81
79
  *
82
- * The Int type represents any integer value (no fractional component) without
83
- * range restrictions. All operations preserve the integer constraint, using
84
- * floor division for division operations.
80
+ * The `Int` type represents an integer. Division (`div`) uses floor division.
85
81
  *
86
- * Unlike SafeInt, Int allows values outside the safe integer range (±2^53 - 1),
87
- * but be aware that very large integers may lose precision in JavaScript's
88
- * number type.
82
+ * Unlike `SafeInt`, `Int` allows values outside the safe integer range (±2^53 −
83
+ * 1), so very large magnitudes may lose precision in JavaScript's `number`
84
+ * type.
89
85
  */
90
86
  export const Int = {
91
87
  /**
@@ -110,9 +106,9 @@ export const Int = {
110
106
  /**
111
107
  * Returns the absolute value of an integer.
112
108
  *
113
- * The result is always non-negative and maintains the Int brand. Note that
114
- * Math.abs(Number.MIN_SAFE_INTEGER) exceeds Number.MAX_SAFE_INTEGER, so use
115
- * SafeInt for guaranteed precision.
109
+ * The result is non-negative and keeps the `Int` brand. Note that
110
+ * `Math.abs(Number.MIN_SAFE_INTEGER)` exceeds `Number.MAX_SAFE_INTEGER`, so
111
+ * use `SafeInt` for guaranteed precision.
116
112
  *
117
113
  * @example
118
114
  *
@@ -127,12 +123,12 @@ export const Int = {
127
123
  * ```
128
124
  *
129
125
  * @param a - The integer value
130
- * @returns The absolute value as a non-negative Int
126
+ * @returns The absolute value as a non-negative `Int`
131
127
  */
132
128
  abs,
133
129
 
134
130
  /**
135
- * Returns the minimum value from a list of integers.
131
+ * Returns the smallest of the given integers.
136
132
  *
137
133
  * @example
138
134
  *
@@ -143,12 +139,12 @@ export const Int = {
143
139
  * ```
144
140
  *
145
141
  * @param values - The integers to compare (at least one required)
146
- * @returns The smallest value as an Int
142
+ * @returns The smallest value as an `Int`
147
143
  */
148
144
  min: min_,
149
145
 
150
146
  /**
151
- * Returns the maximum value from a list of integers.
147
+ * Returns the largest of the given integers.
152
148
  *
153
149
  * @example
154
150
  *
@@ -159,15 +155,14 @@ export const Int = {
159
155
  * ```
160
156
  *
161
157
  * @param values - The integers to compare (at least one required)
162
- * @returns The largest value as an Int
158
+ * @returns The largest value as an `Int`
163
159
  */
164
160
  max: max_,
165
161
 
166
162
  /**
167
- * Generates a random integer within the specified range (inclusive).
163
+ * Generates a random `Int` within the given range.
168
164
  *
169
- * The range is inclusive on both ends, so random(1, 6) can return any of: 1,
170
- * 2, 3, 4, 5, or 6.
165
+ * The range is inclusive on both ends.
171
166
  *
172
167
  * @example
173
168
  *
@@ -185,12 +180,13 @@ export const Int = {
185
180
  *
186
181
  * @param min - The minimum value (inclusive)
187
182
  * @param max - The maximum value (inclusive)
188
- * @returns A random Int in the range [min, max]
183
+ * @returns A random `Int` in `[min, max]`
189
184
  */
190
185
  random,
191
186
 
192
187
  /**
193
- * Raises an integer to a power.
188
+ * Raises `a` to the power `b`, returning `a ** b` as an `Int` (floored to an
189
+ * integer).
194
190
  *
195
191
  * @example
196
192
  *
@@ -206,12 +202,12 @@ export const Int = {
206
202
  *
207
203
  * @param a - The base integer
208
204
  * @param b - The exponent integer
209
- * @returns `a ** b` as an Int
205
+ * @returns `a ** b` as an `Int`
210
206
  */
211
207
  pow,
212
208
 
213
209
  /**
214
- * Adds two integers.
210
+ * Adds two integers, returning `a + b` as an `Int`.
215
211
  *
216
212
  * @example
217
213
  *
@@ -221,14 +217,14 @@ export const Int = {
221
217
  * assert.isTrue(sum === 20);
222
218
  * ```
223
219
  *
224
- * @param a - First integer
225
- * @param b - Second integer
226
- * @returns `a + b` as an Int
220
+ * @param a - The first integer
221
+ * @param b - The second integer
222
+ * @returns The sum of `a` and `b` as an `Int`
227
223
  */
228
224
  add,
229
225
 
230
226
  /**
231
- * Subtracts two integers.
227
+ * Subtracts two integers, returning `a - b` as an `Int`.
232
228
  *
233
229
  * @example
234
230
  *
@@ -238,14 +234,14 @@ export const Int = {
238
234
  * assert.isTrue(difference === 4);
239
235
  * ```
240
236
  *
241
- * @param a - First integer
242
- * @param b - Second integer
243
- * @returns `a - b` as an Int
237
+ * @param a - The first integer
238
+ * @param b - The second integer
239
+ * @returns The difference of `a` and `b` as an `Int`
244
240
  */
245
241
  sub,
246
242
 
247
243
  /**
248
- * Multiplies two integers.
244
+ * Multiplies two integers, returning `a * b` as an `Int`.
249
245
  *
250
246
  * @example
251
247
  *
@@ -255,17 +251,15 @@ export const Int = {
255
251
  * assert.isTrue(product === -24);
256
252
  * ```
257
253
  *
258
- * @param a - First integer
259
- * @param b - Second integer
260
- * @returns `a * b` as an Int
254
+ * @param a - The first integer
255
+ * @param b - The second integer
256
+ * @returns The product of `a` and `b` as an `Int`
261
257
  */
262
258
  mul,
263
259
 
264
260
  /**
265
- * Divides two integers using floor division.
266
- *
267
- * Performs mathematical floor division: `⌊a / b⌋`. The result is always an
268
- * integer, rounding toward negative infinity.
261
+ * Divides two integers using floor division (`⌊a / b⌋`): the result is `a /
262
+ * b` rounded toward negative infinity, as an `Int`.
269
263
  *
270
264
  * @example
271
265
  *
@@ -281,7 +275,7 @@ export const Int = {
281
275
  *
282
276
  * @param a - The dividend
283
277
  * @param b - The divisor (must be non-zero)
284
- * @returns The integer quotient as an Int
278
+ * @returns The floored quotient as an `Int`
285
279
  */
286
280
  div,
287
281
  } as const;
@@ -35,137 +35,144 @@ const {
35
35
  } as const);
36
36
 
37
37
  /**
38
- * Checks if a number is an Int16 (16-bit signed integer in the range [-2^15,
39
- * 2^15)).
38
+ * Type guard that checks if a value is an integer in [-2^15, 2^15).
40
39
  *
41
- * @param value The value to check.
42
- * @returns `true` if the value is an Int16, `false` otherwise.
40
+ * Returns `true` for an integer in [-2^15, 2^15) — a value with no fractional
41
+ * component.
42
+ *
43
+ * @param value - The value to check
44
+ * @returns `true` if the value is an integer in [-2^15, 2^15), `false` otherwise
43
45
  */
44
46
  export const isInt16 = is;
45
47
 
46
48
  /**
47
- * Casts a number to an Int16 type.
49
+ * Casts a `number` to the `Int16` branded type.
50
+ *
51
+ * Validates that the value is an integer in [-2^15, 2^15) and returns it with
52
+ * the `Int16` brand. Throws a `TypeError` otherwise.
48
53
  *
49
- * @param value The value to cast.
50
- * @returns The value as an Int16 type.
51
- * @throws {TypeError} If the value is not an integer in [-2^15, 2^15).
54
+ * @param value - The value to cast
55
+ * @returns The value as an `Int16`
56
+ * @throws {TypeError} If the value is not an integer in [-2^15, 2^15)
52
57
  */
53
58
  export const asInt16 = castType;
54
59
 
55
60
  /**
56
- * Namespace providing type-safe arithmetic operations for 16-bit signed
57
- * integers.
61
+ * Namespace providing type-safe operations for the `Int16` branded type.
58
62
  *
59
- * All operations automatically clamp results to the valid Int16 range [-32768,
60
- * 32767]. This ensures that all arithmetic maintains the 16-bit signed integer
61
- * constraint.
63
+ * The `Int16` type represents an integer in [-2^15, 2^15). Division (`div`)
64
+ * uses floor division.
62
65
  */
63
66
  export const Int16 = {
64
67
  /**
65
- * Type guard to check if a value is an Int16.
68
+ * Type guard that checks if a value is an integer in [-2^15, 2^15).
66
69
  *
67
- * @param value The value to check.
68
- * @returns `true` if the value is a 16-bit signed integer, `false` otherwise.
70
+ * @param value - The value to check
71
+ * @returns `true` if the value is an integer in [-2^15, 2^15), `false` otherwise
72
+ * @see {@link isInt16} for usage examples
69
73
  */
70
74
  is,
71
75
 
72
76
  /**
73
- * The minimum value for a 16-bit signed integer.
74
- *
75
- * @readonly
77
+ * The smallest value representable as `Int16`.
76
78
  */
77
79
  MIN_VALUE,
78
80
 
79
81
  /**
80
- * The maximum value for a 16-bit signed integer.
81
- *
82
- * @readonly
82
+ * The largest value representable as `Int16`.
83
83
  */
84
84
  MAX_VALUE,
85
85
 
86
86
  /**
87
- * Returns the absolute value of a 16-bit signed integer.
87
+ * Returns the absolute value of an integer in [-2^15, 2^15).
88
+ *
89
+ * The result is non-negative and keeps the `Int16` brand.
88
90
  *
89
- * @param a The Int16 value.
90
- * @returns The absolute value as an Int16, clamped to valid range.
91
+ * @param a - The integer value
92
+ * @returns The absolute value as a non-negative `Int16`
91
93
  */
92
94
  abs,
93
95
 
94
96
  /**
95
- * Returns the smaller of two Int16 values.
97
+ * Returns the smallest of the given integers.
96
98
  *
97
- * @param a The first Int16.
98
- * @param b The second Int16.
99
- * @returns The minimum value as an Int16.
99
+ * @param values - The integers to compare (at least one required)
100
+ * @returns The smallest value as an `Int16`
100
101
  */
101
102
  min: min_,
102
103
 
103
104
  /**
104
- * Returns the larger of two Int16 values.
105
+ * Returns the largest of the given integers.
105
106
  *
106
- * @param a The first Int16.
107
- * @param b The second Int16.
108
- * @returns The maximum value as an Int16.
107
+ * @param values - The integers to compare (at least one required)
108
+ * @returns The largest value as an `Int16`
109
109
  */
110
110
  max: max_,
111
111
 
112
112
  /**
113
- * Clamps a number to the Int16 range.
113
+ * Clamps a `number` into the `Int16` range, rounding to the nearest integer
114
+ * and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
114
115
  *
115
- * @param value The number to clamp.
116
- * @returns The value clamped to [-32768, 32767] as an Int16.
116
+ * @param value - The value to clamp
117
+ * @returns The clamped value as an `Int16`
117
118
  */
118
119
  clamp,
119
120
 
120
121
  /**
121
- * Generates a random Int16 value within the valid range.
122
+ * Generates a random `Int16` within the given range.
123
+ *
124
+ * The range is inclusive on both ends.
122
125
  *
123
- * @returns A random Int16 between MIN_VALUE and MAX_VALUE.
126
+ * @param min - The minimum value (inclusive)
127
+ * @param max - The maximum value (inclusive)
128
+ * @returns A random `Int16` in `[min, max]`
124
129
  */
125
130
  random,
126
131
 
127
132
  /**
128
- * Raises an Int16 to the power of another Int16.
133
+ * Raises `a` to the power `b`, returning `a ** b` as an `Int16` (floored to
134
+ * an integer).
129
135
  *
130
- * @param a The base Int16.
131
- * @param b The exponent Int16.
132
- * @returns `a ** b` clamped to [-32768, 32767] as an Int16.
136
+ * @param a - The base integer
137
+ * @param b - The exponent integer
138
+ * @returns `a ** b` as an `Int16`
133
139
  */
134
140
  pow,
135
141
 
136
142
  /**
137
- * Adds two Int16 values.
143
+ * Adds two integers, returning `a + b` as an `Int16`.
138
144
  *
139
- * @param a The first Int16.
140
- * @param b The second Int16.
141
- * @returns `a + b` clamped to [-32768, 32767] as an Int16.
145
+ * @param a - The first integer
146
+ * @param b - The second integer
147
+ * @returns The sum of `a` and `b` as an `Int16`
142
148
  */
143
149
  add,
144
150
 
145
151
  /**
146
- * Subtracts one Int16 from another.
152
+ * Subtracts two integers, returning `a - b` as an `Int16`.
147
153
  *
148
- * @param a The minuend Int16.
149
- * @param b The subtrahend Int16.
150
- * @returns `a - b` clamped to [-32768, 32767] as an Int16.
154
+ * @param a - The first integer
155
+ * @param b - The second integer
156
+ * @returns The difference of `a` and `b` as an `Int16`
151
157
  */
152
158
  sub,
153
159
 
154
160
  /**
155
- * Multiplies two Int16 values.
161
+ * Multiplies two integers, returning `a * b` as an `Int16`.
156
162
  *
157
- * @param a The first Int16.
158
- * @param b The second Int16.
159
- * @returns `a * b` clamped to [-32768, 32767] as an Int16.
163
+ * @param a - The first integer
164
+ * @param b - The second integer
165
+ * @returns The product of `a` and `b` as an `Int16`
160
166
  */
161
167
  mul,
162
168
 
163
169
  /**
164
- * Divides one Int16 by another using floor division.
170
+ * Divides two integers using floor division (`⌊a / b⌋`): the result is `a /
171
+ * b` rounded toward negative infinity, as an `Int16`.
165
172
  *
166
- * @param a The dividend Int16.
167
- * @param b The divisor Int16.
168
- * @returns `⌊a / b⌋` clamped to [-32768, 32767] as an Int16.
173
+ * @param a - The dividend
174
+ * @param b - The divisor (must be non-zero)
175
+ * @returns The floored quotient as an `Int16`
169
176
  */
170
177
  div,
171
178
  } as const;
@@ -35,137 +35,144 @@ const {
35
35
  } as const);
36
36
 
37
37
  /**
38
- * Checks if a number is an Int32 (32-bit signed integer in the range [-2^31,
39
- * 2^31)).
38
+ * Type guard that checks if a value is an integer in [-2^31, 2^31).
40
39
  *
41
- * @param value The value to check.
42
- * @returns `true` if the value is an Int32, `false` otherwise.
40
+ * Returns `true` for an integer in [-2^31, 2^31) — a value with no fractional
41
+ * component.
42
+ *
43
+ * @param value - The value to check
44
+ * @returns `true` if the value is an integer in [-2^31, 2^31), `false` otherwise
43
45
  */
44
46
  export const isInt32 = is;
45
47
 
46
48
  /**
47
- * Casts a number to an Int32 type.
49
+ * Casts a `number` to the `Int32` branded type.
50
+ *
51
+ * Validates that the value is an integer in [-2^31, 2^31) and returns it with
52
+ * the `Int32` brand. Throws a `TypeError` otherwise.
48
53
  *
49
- * @param value The value to cast.
50
- * @returns The value as an Int32 type.
51
- * @throws {TypeError} If the value is not an integer in [-2^31, 2^31).
54
+ * @param value - The value to cast
55
+ * @returns The value as an `Int32`
56
+ * @throws {TypeError} If the value is not an integer in [-2^31, 2^31)
52
57
  */
53
58
  export const asInt32 = castType;
54
59
 
55
60
  /**
56
- * Namespace providing type-safe arithmetic operations for 32-bit signed
57
- * integers.
61
+ * Namespace providing type-safe operations for the `Int32` branded type.
58
62
  *
59
- * All operations automatically clamp results to the valid Int32 range
60
- * [-2147483648, 2147483647]. This ensures that all arithmetic maintains the
61
- * 32-bit signed integer constraint, preventing overflow.
63
+ * The `Int32` type represents an integer in [-2^31, 2^31). Division (`div`)
64
+ * uses floor division.
62
65
  */
63
66
  export const Int32 = {
64
67
  /**
65
- * Type guard to check if a value is an Int32.
68
+ * Type guard that checks if a value is an integer in [-2^31, 2^31).
66
69
  *
67
- * @param value The value to check.
68
- * @returns `true` if the value is a 32-bit signed integer, `false` otherwise.
70
+ * @param value - The value to check
71
+ * @returns `true` if the value is an integer in [-2^31, 2^31), `false` otherwise
72
+ * @see {@link isInt32} for usage examples
69
73
  */
70
74
  is,
71
75
 
72
76
  /**
73
- * The minimum value for a 32-bit signed integer.
74
- *
75
- * @readonly
77
+ * The smallest value representable as `Int32`.
76
78
  */
77
79
  MIN_VALUE,
78
80
 
79
81
  /**
80
- * The maximum value for a 32-bit signed integer.
81
- *
82
- * @readonly
82
+ * The largest value representable as `Int32`.
83
83
  */
84
84
  MAX_VALUE,
85
85
 
86
86
  /**
87
- * Returns the absolute value of a 32-bit signed integer.
87
+ * Returns the absolute value of an integer in [-2^31, 2^31).
88
+ *
89
+ * The result is non-negative and keeps the `Int32` brand.
88
90
  *
89
- * @param a The Int32 value.
90
- * @returns The absolute value as an Int32, clamped to valid range.
91
+ * @param a - The integer value
92
+ * @returns The absolute value as a non-negative `Int32`
91
93
  */
92
94
  abs,
93
95
 
94
96
  /**
95
- * Returns the smaller of two Int32 values.
97
+ * Returns the smallest of the given integers.
96
98
  *
97
- * @param a The first Int32.
98
- * @param b The second Int32.
99
- * @returns The minimum value as an Int32.
99
+ * @param values - The integers to compare (at least one required)
100
+ * @returns The smallest value as an `Int32`
100
101
  */
101
102
  min: min_,
102
103
 
103
104
  /**
104
- * Returns the larger of two Int32 values.
105
+ * Returns the largest of the given integers.
105
106
  *
106
- * @param a The first Int32.
107
- * @param b The second Int32.
108
- * @returns The maximum value as an Int32.
107
+ * @param values - The integers to compare (at least one required)
108
+ * @returns The largest value as an `Int32`
109
109
  */
110
110
  max: max_,
111
111
 
112
112
  /**
113
- * Clamps a number to the Int32 range.
113
+ * Clamps a `number` into the `Int32` range, rounding to the nearest integer
114
+ * and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
114
115
  *
115
- * @param value The number to clamp.
116
- * @returns The value clamped to [-2147483648, 2147483647] as an Int32.
116
+ * @param value - The value to clamp
117
+ * @returns The clamped value as an `Int32`
117
118
  */
118
119
  clamp,
119
120
 
120
121
  /**
121
- * Generates a random Int32 value within the valid range.
122
+ * Generates a random `Int32` within the given range.
123
+ *
124
+ * The range is inclusive on both ends.
122
125
  *
123
- * @returns A random Int32 between MIN_VALUE and MAX_VALUE.
126
+ * @param min - The minimum value (inclusive)
127
+ * @param max - The maximum value (inclusive)
128
+ * @returns A random `Int32` in `[min, max]`
124
129
  */
125
130
  random,
126
131
 
127
132
  /**
128
- * Raises an Int32 to the power of another Int32.
133
+ * Raises `a` to the power `b`, returning `a ** b` as an `Int32` (floored to
134
+ * an integer).
129
135
  *
130
- * @param a The base Int32.
131
- * @param b The exponent Int32.
132
- * @returns `a ** b` clamped to [-2147483648, 2147483647] as an Int32.
136
+ * @param a - The base integer
137
+ * @param b - The exponent integer
138
+ * @returns `a ** b` as an `Int32`
133
139
  */
134
140
  pow,
135
141
 
136
142
  /**
137
- * Adds two Int32 values.
143
+ * Adds two integers, returning `a + b` as an `Int32`.
138
144
  *
139
- * @param a The first Int32.
140
- * @param b The second Int32.
141
- * @returns `a + b` clamped to [-2147483648, 2147483647] as an Int32.
145
+ * @param a - The first integer
146
+ * @param b - The second integer
147
+ * @returns The sum of `a` and `b` as an `Int32`
142
148
  */
143
149
  add,
144
150
 
145
151
  /**
146
- * Subtracts one Int32 from another.
152
+ * Subtracts two integers, returning `a - b` as an `Int32`.
147
153
  *
148
- * @param a The minuend Int32.
149
- * @param b The subtrahend Int32.
150
- * @returns `a - b` clamped to [-2147483648, 2147483647] as an Int32.
154
+ * @param a - The first integer
155
+ * @param b - The second integer
156
+ * @returns The difference of `a` and `b` as an `Int32`
151
157
  */
152
158
  sub,
153
159
 
154
160
  /**
155
- * Multiplies two Int32 values.
161
+ * Multiplies two integers, returning `a * b` as an `Int32`.
156
162
  *
157
- * @param a The first Int32.
158
- * @param b The second Int32.
159
- * @returns `a * b` clamped to [-2147483648, 2147483647] as an Int32.
163
+ * @param a - The first integer
164
+ * @param b - The second integer
165
+ * @returns The product of `a` and `b` as an `Int32`
160
166
  */
161
167
  mul,
162
168
 
163
169
  /**
164
- * Divides one Int32 by another using floor division.
170
+ * Divides two integers using floor division (`⌊a / b⌋`): the result is `a /
171
+ * b` rounded toward negative infinity, as an `Int32`.
165
172
  *
166
- * @param a The dividend Int32.
167
- * @param b The divisor Int32.
168
- * @returns `⌊a / b⌋` clamped to [-2147483648, 2147483647] as an Int32.
173
+ * @param a - The dividend
174
+ * @param b - The divisor (must be non-zero)
175
+ * @returns The floored quotient as an `Int32`
169
176
  */
170
177
  div,
171
178
  } as const;