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,131 +34,135 @@ const {
34
34
  } as const);
35
35
 
36
36
  /**
37
- * Checks if a number is a PositiveInt16 (16-bit positive signed integer in the
38
- * range [1, 2^15)).
37
+ * Type guard that checks if a value is a positive integer in [1, 2^15).
39
38
  *
40
- * @param value The value to check.
41
- * @returns `true` if the value is a PositiveInt16, `false` otherwise.
39
+ * Returns `true` for a positive integer in [1, 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 positive integer in [1, 2^15), `false` otherwise
42
44
  */
43
45
  export const isPositiveInt16 = is;
44
46
 
45
47
  /**
46
- * Casts a number to a PositiveInt16 type.
48
+ * Casts a `number` to the `PositiveInt16` branded type.
49
+ *
50
+ * Validates that the value is a positive integer in [1, 2^15) and returns it
51
+ * with the `PositiveInt16` brand. Throws a `TypeError` otherwise.
47
52
  *
48
- * @param value The value to cast.
49
- * @returns The value as a PositiveInt16 type.
50
- * @throws {TypeError} If the value is not a positive integer in [1, 2^15).
53
+ * @param value - The value to cast
54
+ * @returns The value as a `PositiveInt16`
55
+ * @throws {TypeError} If the value is not a positive integer in [1, 2^15)
51
56
  */
52
57
  export const asPositiveInt16 = castType;
53
58
 
54
59
  /**
55
- * Namespace providing type-safe arithmetic operations for 16-bit positive
56
- * integers.
60
+ * Namespace providing type-safe operations for the `PositiveInt16` branded
61
+ * type.
57
62
  *
58
- * All operations automatically clamp results to the valid PositiveInt16 range
59
- * [1, 32767]. This ensures that all arithmetic maintains the 16-bit positive
60
- * integer constraint, with results below 1 clamped to MIN_VALUE and overflow
61
- * results clamped to MAX_VALUE.
63
+ * The `PositiveInt16` type represents a positive integer in [1, 2^15). Division
64
+ * (`div`) uses floor division.
62
65
  */
63
66
  export const PositiveInt16 = {
64
67
  /**
65
- * Type guard to check if a value is a PositiveInt16.
68
+ * Type guard that checks if a value is a positive integer in [1, 2^15).
66
69
  *
67
- * @param value The value to check.
68
- * @returns `true` if the value is a 16-bit positive integer, `false`
69
- * otherwise.
70
+ * @param value - The value to check
71
+ * @returns `true` if the value is a positive integer in [1, 2^15), `false` otherwise
72
+ * @see {@link isPositiveInt16} for usage examples
70
73
  */
71
74
  is,
72
75
 
73
76
  /**
74
- * The minimum value for a 16-bit positive integer.
75
- *
76
- * @readonly
77
+ * The smallest value representable as `PositiveInt16`.
77
78
  */
78
79
  MIN_VALUE,
79
80
 
80
81
  /**
81
- * The maximum value for a 16-bit positive integer.
82
- *
83
- * @readonly
82
+ * The largest value representable as `PositiveInt16`.
84
83
  */
85
84
  MAX_VALUE,
86
85
 
87
86
  /**
88
- * Returns the smaller of two PositiveInt16 values.
87
+ * Returns the smallest of the given positive integers.
89
88
  *
90
- * @param a The first PositiveInt16.
91
- * @param b The second PositiveInt16.
92
- * @returns The minimum value as a PositiveInt16.
89
+ * @param values - The positive integers to compare (at least one required)
90
+ * @returns The smallest value as a `PositiveInt16`
93
91
  */
94
92
  min: min_,
95
93
 
96
94
  /**
97
- * Returns the larger of two PositiveInt16 values.
95
+ * Returns the largest of the given positive integers.
98
96
  *
99
- * @param a The first PositiveInt16.
100
- * @param b The second PositiveInt16.
101
- * @returns The maximum value as a PositiveInt16.
97
+ * @param values - The positive integers to compare (at least one required)
98
+ * @returns The largest value as a `PositiveInt16`
102
99
  */
103
100
  max: max_,
104
101
 
105
102
  /**
106
- * Clamps a number to the PositiveInt16 range.
103
+ * Clamps a `number` into the `PositiveInt16` range, rounding to the nearest
104
+ * 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 [1, 32767] as a PositiveInt16.
106
+ * @param value - The value to clamp
107
+ * @returns The clamped value as a `PositiveInt16`
110
108
  */
111
109
  clamp,
112
110
 
113
111
  /**
114
- * Generates a random PositiveInt16 value within the valid range.
112
+ * Generates a random `PositiveInt16` within the given range.
113
+ *
114
+ * The range is inclusive on both ends.
115
115
  *
116
- * @returns A random PositiveInt16 between 1 and 32767.
116
+ * @param min - The minimum value (inclusive)
117
+ * @param max - The maximum value (inclusive)
118
+ * @returns A random `PositiveInt16` in `[min, max]`
117
119
  */
118
120
  random,
119
121
 
120
122
  /**
121
- * Raises a PositiveInt16 to the power of another PositiveInt16.
123
+ * Raises `a` to the power `b`, returning `a ** b` as a `PositiveInt16`
124
+ * (floored to an integer).
122
125
  *
123
- * @param a The base PositiveInt16.
124
- * @param b The exponent PositiveInt16.
125
- * @returns `a ** b` clamped to [1, 32767] as a PositiveInt16.
126
+ * @param a - The base positive integer
127
+ * @param b - The exponent positive integer
128
+ * @returns `a ** b` as a `PositiveInt16`
126
129
  */
127
130
  pow,
128
131
 
129
132
  /**
130
- * Adds two PositiveInt16 values.
133
+ * Adds two positive integers, returning `a + b` as a `PositiveInt16`.
131
134
  *
132
- * @param a The first PositiveInt16.
133
- * @param b The second PositiveInt16.
134
- * @returns `a + b` clamped to [1, 32767] as a PositiveInt16.
135
+ * @param a - The first positive integer
136
+ * @param b - The second positive integer
137
+ * @returns The sum of `a` and `b` as a `PositiveInt16`
135
138
  */
136
139
  add,
137
140
 
138
141
  /**
139
- * Subtracts one PositiveInt16 from another.
142
+ * Subtracts two positive integers, returning `a - b` as a `PositiveInt16`.
140
143
  *
141
- * @param a The minuend PositiveInt16.
142
- * @param b The subtrahend PositiveInt16.
143
- * @returns `a - b` clamped to [1, 32767] as a PositiveInt16 (minimum 1).
144
+ * @param a - The first positive integer
145
+ * @param b - The second positive integer
146
+ * @returns The difference of `a` and `b` as a `PositiveInt16`
144
147
  */
145
148
  sub,
146
149
 
147
150
  /**
148
- * Multiplies two PositiveInt16 values.
151
+ * Multiplies two positive integers, returning `a * b` as a `PositiveInt16`.
149
152
  *
150
- * @param a The first PositiveInt16.
151
- * @param b The second PositiveInt16.
152
- * @returns `a * b` clamped to [1, 32767] as a PositiveInt16.
153
+ * @param a - The first positive integer
154
+ * @param b - The second positive integer
155
+ * @returns The product of `a` and `b` as a `PositiveInt16`
153
156
  */
154
157
  mul,
155
158
 
156
159
  /**
157
- * Divides one PositiveInt16 by another using floor division.
160
+ * Divides two positive integers using floor division (`⌊a / b⌋`): the result
161
+ * is `a / b` rounded toward negative infinity, as a `PositiveInt16`.
158
162
  *
159
- * @param a The dividend PositiveInt16.
160
- * @param b The divisor PositiveInt16.
161
- * @returns `⌊a / b⌋` clamped to [1, 32767] as a PositiveInt16.
163
+ * @param a - The dividend
164
+ * @param b - The divisor (must be non-zero)
165
+ * @returns The floored quotient as a `PositiveInt16`
162
166
  */
163
167
  div,
164
168
  } as const;
@@ -34,131 +34,135 @@ const {
34
34
  } as const);
35
35
 
36
36
  /**
37
- * Checks if a number is a PositiveInt32 (32-bit positive signed integer in the
38
- * range [1, 2^31)).
37
+ * Type guard that checks if a value is a positive integer in [1, 2^31).
39
38
  *
40
- * @param value The value to check.
41
- * @returns `true` if the value is a PositiveInt32, `false` otherwise.
39
+ * Returns `true` for a positive integer in [1, 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 positive integer in [1, 2^31), `false` otherwise
42
44
  */
43
45
  export const isPositiveInt32 = is;
44
46
 
45
47
  /**
46
- * Casts a number to a PositiveInt32 type.
48
+ * Casts a `number` to the `PositiveInt32` branded type.
49
+ *
50
+ * Validates that the value is a positive integer in [1, 2^31) and returns it
51
+ * with the `PositiveInt32` brand. Throws a `TypeError` otherwise.
47
52
  *
48
- * @param value The value to cast.
49
- * @returns The value as a PositiveInt32 type.
50
- * @throws {TypeError} If the value is not a positive integer in [1, 2^31).
53
+ * @param value - The value to cast
54
+ * @returns The value as a `PositiveInt32`
55
+ * @throws {TypeError} If the value is not a positive integer in [1, 2^31)
51
56
  */
52
57
  export const asPositiveInt32 = castType;
53
58
 
54
59
  /**
55
- * Namespace providing type-safe arithmetic operations for 32-bit positive
56
- * integers.
60
+ * Namespace providing type-safe operations for the `PositiveInt32` branded
61
+ * type.
57
62
  *
58
- * All operations automatically clamp results to the valid PositiveInt32 range
59
- * [1, 2147483647]. This ensures that all arithmetic maintains the 32-bit
60
- * positive integer constraint, with results below 1 clamped to MIN_VALUE and
61
- * overflow results clamped to MAX_VALUE.
63
+ * The `PositiveInt32` type represents a positive integer in [1, 2^31). Division
64
+ * (`div`) uses floor division.
62
65
  */
63
66
  export const PositiveInt32 = {
64
67
  /**
65
- * Type guard to check if a value is a PositiveInt32.
68
+ * Type guard that checks if a value is a positive integer in [1, 2^31).
66
69
  *
67
- * @param value The value to check.
68
- * @returns `true` if the value is a 32-bit positive integer, `false`
69
- * otherwise.
70
+ * @param value - The value to check
71
+ * @returns `true` if the value is a positive integer in [1, 2^31), `false` otherwise
72
+ * @see {@link isPositiveInt32} for usage examples
70
73
  */
71
74
  is,
72
75
 
73
76
  /**
74
- * The minimum value for a 32-bit positive integer.
75
- *
76
- * @readonly
77
+ * The smallest value representable as `PositiveInt32`.
77
78
  */
78
79
  MIN_VALUE,
79
80
 
80
81
  /**
81
- * The maximum value for a 32-bit positive integer.
82
- *
83
- * @readonly
82
+ * The largest value representable as `PositiveInt32`.
84
83
  */
85
84
  MAX_VALUE,
86
85
 
87
86
  /**
88
- * Returns the smaller of two PositiveInt32 values.
87
+ * Returns the smallest of the given positive integers.
89
88
  *
90
- * @param a The first PositiveInt32.
91
- * @param b The second PositiveInt32.
92
- * @returns The minimum value as a PositiveInt32.
89
+ * @param values - The positive integers to compare (at least one required)
90
+ * @returns The smallest value as a `PositiveInt32`
93
91
  */
94
92
  min: min_,
95
93
 
96
94
  /**
97
- * Returns the larger of two PositiveInt32 values.
95
+ * Returns the largest of the given positive integers.
98
96
  *
99
- * @param a The first PositiveInt32.
100
- * @param b The second PositiveInt32.
101
- * @returns The maximum value as a PositiveInt32.
97
+ * @param values - The positive integers to compare (at least one required)
98
+ * @returns The largest value as a `PositiveInt32`
102
99
  */
103
100
  max: max_,
104
101
 
105
102
  /**
106
- * Clamps a number to the PositiveInt32 range.
103
+ * Clamps a `number` into the `PositiveInt32` range, rounding to the nearest
104
+ * 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 [1, 2147483647] as a PositiveInt32.
106
+ * @param value - The value to clamp
107
+ * @returns The clamped value as a `PositiveInt32`
110
108
  */
111
109
  clamp,
112
110
 
113
111
  /**
114
- * Generates a random PositiveInt32 value within the valid range.
112
+ * Generates a random `PositiveInt32` within the given range.
113
+ *
114
+ * The range is inclusive on both ends.
115
115
  *
116
- * @returns A random PositiveInt32 between 1 and 2147483647.
116
+ * @param min - The minimum value (inclusive)
117
+ * @param max - The maximum value (inclusive)
118
+ * @returns A random `PositiveInt32` in `[min, max]`
117
119
  */
118
120
  random,
119
121
 
120
122
  /**
121
- * Raises a PositiveInt32 to the power of another PositiveInt32.
123
+ * Raises `a` to the power `b`, returning `a ** b` as a `PositiveInt32`
124
+ * (floored to an integer).
122
125
  *
123
- * @param a The base PositiveInt32.
124
- * @param b The exponent PositiveInt32.
125
- * @returns `a ** b` clamped to [1, 2147483647] as a PositiveInt32.
126
+ * @param a - The base positive integer
127
+ * @param b - The exponent positive integer
128
+ * @returns `a ** b` as a `PositiveInt32`
126
129
  */
127
130
  pow,
128
131
 
129
132
  /**
130
- * Adds two PositiveInt32 values.
133
+ * Adds two positive integers, returning `a + b` as a `PositiveInt32`.
131
134
  *
132
- * @param a The first PositiveInt32.
133
- * @param b The second PositiveInt32.
134
- * @returns `a + b` clamped to [1, 2147483647] as a PositiveInt32.
135
+ * @param a - The first positive integer
136
+ * @param b - The second positive integer
137
+ * @returns The sum of `a` and `b` as a `PositiveInt32`
135
138
  */
136
139
  add,
137
140
 
138
141
  /**
139
- * Subtracts one PositiveInt32 from another.
142
+ * Subtracts two positive integers, returning `a - b` as a `PositiveInt32`.
140
143
  *
141
- * @param a The minuend PositiveInt32.
142
- * @param b The subtrahend PositiveInt32.
143
- * @returns `a - b` clamped to [1, 2147483647] as a PositiveInt32 (minimum 1).
144
+ * @param a - The first positive integer
145
+ * @param b - The second positive integer
146
+ * @returns The difference of `a` and `b` as a `PositiveInt32`
144
147
  */
145
148
  sub,
146
149
 
147
150
  /**
148
- * Multiplies two PositiveInt32 values.
151
+ * Multiplies two positive integers, returning `a * b` as a `PositiveInt32`.
149
152
  *
150
- * @param a The first PositiveInt32.
151
- * @param b The second PositiveInt32.
152
- * @returns `a * b` clamped to [1, 2147483647] as a PositiveInt32.
153
+ * @param a - The first positive integer
154
+ * @param b - The second positive integer
155
+ * @returns The product of `a` and `b` as a `PositiveInt32`
153
156
  */
154
157
  mul,
155
158
 
156
159
  /**
157
- * Divides one PositiveInt32 by another using floor division.
160
+ * Divides two positive integers using floor division (`⌊a / b⌋`): the result
161
+ * is `a / b` rounded toward negative infinity, as a `PositiveInt32`.
158
162
  *
159
- * @param a The dividend PositiveInt32.
160
- * @param b The divisor PositiveInt32.
161
- * @returns `⌊a / b⌋` clamped to [1, 2147483647] as a PositiveInt32.
163
+ * @param a - The dividend
164
+ * @param b - The divisor (must be non-zero)
165
+ * @returns The floored quotient as a `PositiveInt32`
162
166
  */
163
167
  div,
164
168
  } as const;
@@ -38,8 +38,10 @@ const {
38
38
  } as const);
39
39
 
40
40
  /**
41
- * Checks if a number is a PositiveSafeInt (a positive safe integer in the range
42
- * [1, MAX_SAFE_INTEGER]).
41
+ * Type guard that checks if a value is a positive safe integer.
42
+ *
43
+ * Returns `true` for a positive safe integer — a value with no fractional
44
+ * component.
43
45
  *
44
46
  * @example
45
47
  *
@@ -53,13 +55,16 @@ const {
53
55
  * assert.isTrue(PositiveSafeInt.is(42));
54
56
  * ```
55
57
  *
56
- * @param value The value to check.
57
- * @returns `true` if the value is a PositiveSafeInt, `false` otherwise.
58
+ * @param value - The value to check
59
+ * @returns `true` if the value is a positive safe integer, `false` otherwise
58
60
  */
59
61
  export const isPositiveSafeInt = is;
60
62
 
61
63
  /**
62
- * Casts a number to a PositiveSafeInt type.
64
+ * Casts a `number` to the `PositiveSafeInt` branded type.
65
+ *
66
+ * Validates that the value is a positive safe integer and returns it with the
67
+ * `PositiveSafeInt` brand. Throws a `TypeError` otherwise.
63
68
  *
64
69
  * @example
65
70
  *
@@ -71,24 +76,22 @@ export const isPositiveSafeInt = is;
71
76
  * assert.isTrue(PositiveSafeInt.is(branded));
72
77
  * ```
73
78
  *
74
- * @param value The value to cast.
75
- * @returns The value as a PositiveSafeInt type.
76
- * @throws {TypeError} If the value is not a positive safe integer.
79
+ * @param value - The value to cast
80
+ * @returns The value as a `PositiveSafeInt`
81
+ * @throws {TypeError} If the value is not a positive safe integer
77
82
  */
78
83
  export const asPositiveSafeInt = castType;
79
84
 
80
85
  /**
81
- * Namespace providing type-safe arithmetic operations for positive safe
82
- * integers.
86
+ * Namespace providing type-safe operations for the `PositiveSafeInt` branded
87
+ * type.
83
88
  *
84
- * All operations automatically clamp results to the positive safe integer range
85
- * [1, MAX_SAFE_INTEGER]. This ensures that all arithmetic maintains both the
86
- * positive constraint and IEEE 754 precision guarantees, preventing precision
87
- * loss and ensuring results are always positive.
89
+ * The `PositiveSafeInt` type represents a positive safe integer. Division
90
+ * (`div`) uses floor division.
88
91
  */
89
92
  export const PositiveSafeInt = {
90
93
  /**
91
- * Type guard to check if a value is a PositiveSafeInt.
94
+ * Type guard that checks if a value is a positive safe integer.
92
95
  *
93
96
  * @example
94
97
  *
@@ -102,28 +105,24 @@ export const PositiveSafeInt = {
102
105
  * assert.isTrue(PositiveSafeInt.is(42));
103
106
  * ```
104
107
  *
105
- * @param value The value to check.
106
- * @returns `true` if the value is a positive safe integer, `false` otherwise.
108
+ * @param value - The value to check
109
+ * @returns `true` if the value is a positive safe integer, `false` otherwise
107
110
  * @see {@link isPositiveSafeInt} for usage examples
108
111
  */
109
112
  is,
110
113
 
111
114
  /**
112
- * The minimum value for a positive safe integer.
113
- *
114
- * @readonly
115
+ * The smallest value representable as `PositiveSafeInt`.
115
116
  */
116
117
  MIN_VALUE,
117
118
 
118
119
  /**
119
- * The maximum safe integer value (2^53 - 1).
120
- *
121
- * @readonly
120
+ * The largest value representable as `PositiveSafeInt`.
122
121
  */
123
122
  MAX_VALUE,
124
123
 
125
124
  /**
126
- * Returns the smaller of two PositiveSafeInt values.
125
+ * Returns the smallest of the given positive safe integers.
127
126
  *
128
127
  * @example
129
128
  *
@@ -136,14 +135,13 @@ export const PositiveSafeInt = {
136
135
  * assert.isTrue(smallest === 5);
137
136
  * ```
138
137
  *
139
- * @param a The first PositiveSafeInt.
140
- * @param b The second PositiveSafeInt.
141
- * @returns The minimum value as a PositiveSafeInt.
138
+ * @param values - The positive safe integers to compare (at least one required)
139
+ * @returns The smallest value as a `PositiveSafeInt`
142
140
  */
143
141
  min: min_,
144
142
 
145
143
  /**
146
- * Returns the larger of two PositiveSafeInt values.
144
+ * Returns the largest of the given positive safe integers.
147
145
  *
148
146
  * @example
149
147
  *
@@ -156,14 +154,14 @@ export const PositiveSafeInt = {
156
154
  * assert.isTrue(largest === 10);
157
155
  * ```
158
156
  *
159
- * @param a The first PositiveSafeInt.
160
- * @param b The second PositiveSafeInt.
161
- * @returns The maximum value as a PositiveSafeInt.
157
+ * @param values - The positive safe integers to compare (at least one required)
158
+ * @returns The largest value as a `PositiveSafeInt`
162
159
  */
163
160
  max: max_,
164
161
 
165
162
  /**
166
- * Clamps a number to the positive safe integer range.
163
+ * Clamps a `number` into the `PositiveSafeInt` range, rounding to the nearest
164
+ * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
167
165
  *
168
166
  * @example
169
167
  *
@@ -181,13 +179,15 @@ export const PositiveSafeInt = {
181
179
  * assert.isTrue(aboveRange === Number.MAX_SAFE_INTEGER);
182
180
  * ```
183
181
  *
184
- * @param value The number to clamp.
185
- * @returns The value clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.
182
+ * @param value - The value to clamp
183
+ * @returns The clamped value as a `PositiveSafeInt`
186
184
  */
187
185
  clamp,
188
186
 
189
187
  /**
190
- * Generates a random PositiveSafeInt value within the valid range.
188
+ * Generates a random `PositiveSafeInt` within the given range.
189
+ *
190
+ * The range is inclusive on both ends.
191
191
  *
192
192
  * @example
193
193
  *
@@ -203,12 +203,15 @@ export const PositiveSafeInt = {
203
203
  * assert.isTrue(randomValue >= 1 && randomValue <= 6);
204
204
  * ```
205
205
  *
206
- * @returns A random PositiveSafeInt between 1 and MAX_SAFE_INTEGER.
206
+ * @param min - The minimum value (inclusive)
207
+ * @param max - The maximum value (inclusive)
208
+ * @returns A random `PositiveSafeInt` in `[min, max]`
207
209
  */
208
210
  random,
209
211
 
210
212
  /**
211
- * Raises a PositiveSafeInt to the power of another PositiveSafeInt.
213
+ * Raises `a` to the power `b`, returning `a ** b` as a `PositiveSafeInt`
214
+ * (floored to an integer).
212
215
  *
213
216
  * @example
214
217
  *
@@ -222,14 +225,14 @@ export const PositiveSafeInt = {
222
225
  * assert.isTrue(power === 27);
223
226
  * ```
224
227
  *
225
- * @param a The base PositiveSafeInt.
226
- * @param b The exponent PositiveSafeInt.
227
- * @returns `a ** b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.
228
+ * @param a - The base positive safe integer
229
+ * @param b - The exponent positive safe integer
230
+ * @returns `a ** b` as a `PositiveSafeInt`
228
231
  */
229
232
  pow,
230
233
 
231
234
  /**
232
- * Adds two PositiveSafeInt values.
235
+ * Adds two positive safe integers, returning `a + b` as a `PositiveSafeInt`.
233
236
  *
234
237
  * @example
235
238
  *
@@ -244,14 +247,15 @@ export const PositiveSafeInt = {
244
247
  * assert.isTrue(PositiveSafeInt.is(sum));
245
248
  * ```
246
249
  *
247
- * @param a The first PositiveSafeInt.
248
- * @param b The second PositiveSafeInt.
249
- * @returns `a + b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.
250
+ * @param a - The first positive safe integer
251
+ * @param b - The second positive safe integer
252
+ * @returns The sum of `a` and `b` as a `PositiveSafeInt`
250
253
  */
251
254
  add,
252
255
 
253
256
  /**
254
- * Subtracts one PositiveSafeInt from another.
257
+ * Subtracts two positive safe integers, returning `a - b` as a
258
+ * `PositiveSafeInt`.
255
259
  *
256
260
  * @example
257
261
  *
@@ -266,15 +270,15 @@ export const PositiveSafeInt = {
266
270
  * assert.isTrue(PositiveSafeInt.is(difference));
267
271
  * ```
268
272
  *
269
- * @param a The minuend PositiveSafeInt.
270
- * @param b The subtrahend PositiveSafeInt.
271
- * @returns `a - b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt
272
- * (minimum 1).
273
+ * @param a - The first positive safe integer
274
+ * @param b - The second positive safe integer
275
+ * @returns The difference of `a` and `b` as a `PositiveSafeInt`
273
276
  */
274
277
  sub,
275
278
 
276
279
  /**
277
- * Multiplies two PositiveSafeInt values.
280
+ * Multiplies two positive safe integers, returning `a * b` as a
281
+ * `PositiveSafeInt`.
278
282
  *
279
283
  * @example
280
284
  *
@@ -289,14 +293,15 @@ export const PositiveSafeInt = {
289
293
  * assert.isTrue(PositiveSafeInt.is(product));
290
294
  * ```
291
295
  *
292
- * @param a The first PositiveSafeInt.
293
- * @param b The second PositiveSafeInt.
294
- * @returns `a * b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.
296
+ * @param a - The first positive safe integer
297
+ * @param b - The second positive safe integer
298
+ * @returns The product of `a` and `b` as a `PositiveSafeInt`
295
299
  */
296
300
  mul,
297
301
 
298
302
  /**
299
- * Divides one PositiveSafeInt by another using floor division.
303
+ * Divides two positive safe integers using floor division (`⌊a / b⌋`): the
304
+ * result is `a / b` rounded toward negative infinity, as a `PositiveSafeInt`.
300
305
  *
301
306
  * @example
302
307
  *
@@ -316,9 +321,9 @@ export const PositiveSafeInt = {
316
321
  * assert.isTrue(clamped === 1);
317
322
  * ```
318
323
  *
319
- * @param a The dividend PositiveSafeInt.
320
- * @param b The divisor PositiveSafeInt.
321
- * @returns `⌊a / b⌋` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.
324
+ * @param a - The dividend
325
+ * @param b - The divisor (must be non-zero)
326
+ * @returns The floored quotient as a `PositiveSafeInt`
322
327
  */
323
328
  div,
324
329
  } as const;