ts-data-forge 11.0.0 → 11.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/dist/number/branded-types/finite-number.d.mts +47 -61
  2. package/dist/number/branded-types/finite-number.d.mts.map +1 -1
  3. package/dist/number/branded-types/finite-number.mjs +37 -41
  4. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  5. package/dist/number/branded-types/int.d.mts +40 -46
  6. package/dist/number/branded-types/int.d.mts.map +1 -1
  7. package/dist/number/branded-types/int.mjs +29 -31
  8. package/dist/number/branded-types/int.mjs.map +1 -1
  9. package/dist/number/branded-types/int16.d.mts +65 -58
  10. package/dist/number/branded-types/int16.d.mts.map +1 -1
  11. package/dist/number/branded-types/int16.mjs +49 -45
  12. package/dist/number/branded-types/int16.mjs.map +1 -1
  13. package/dist/number/branded-types/int32.d.mts +65 -58
  14. package/dist/number/branded-types/int32.d.mts.map +1 -1
  15. package/dist/number/branded-types/int32.mjs +49 -45
  16. package/dist/number/branded-types/int32.mjs.map +1 -1
  17. package/dist/number/branded-types/negative-finite-number.d.mts +68 -59
  18. package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
  19. package/dist/number/branded-types/negative-finite-number.mjs +52 -46
  20. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  21. package/dist/number/branded-types/negative-int.d.mts +60 -48
  22. package/dist/number/branded-types/negative-int.d.mts.map +1 -1
  23. package/dist/number/branded-types/negative-int.mjs +40 -36
  24. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  25. package/dist/number/branded-types/negative-safe-int.d.mts +57 -56
  26. package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
  27. package/dist/number/branded-types/negative-safe-int.mjs +40 -41
  28. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  29. package/dist/number/branded-types/non-negative-finite-number.d.mts +74 -64
  30. package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
  31. package/dist/number/branded-types/non-negative-finite-number.mjs +58 -51
  32. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  33. package/dist/number/branded-types/non-negative-int16.d.mts +64 -57
  34. package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
  35. package/dist/number/branded-types/non-negative-int16.mjs +47 -43
  36. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  37. package/dist/number/branded-types/non-negative-int32.d.mts +64 -58
  38. package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
  39. package/dist/number/branded-types/non-negative-int32.mjs +47 -44
  40. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  41. package/dist/number/branded-types/non-positive-finite-number.d.mts +64 -54
  42. package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
  43. package/dist/number/branded-types/non-positive-finite-number.mjs +48 -41
  44. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  45. package/dist/number/branded-types/non-positive-int.d.mts +41 -146
  46. package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
  47. package/dist/number/branded-types/non-positive-int.mjs +27 -107
  48. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  49. package/dist/number/branded-types/non-positive-safe-int.d.mts +54 -53
  50. package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
  51. package/dist/number/branded-types/non-positive-safe-int.mjs +37 -39
  52. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  53. package/dist/number/branded-types/non-zero-finite-number.d.mts +62 -49
  54. package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
  55. package/dist/number/branded-types/non-zero-finite-number.mjs +46 -37
  56. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  57. package/dist/number/branded-types/non-zero-int.d.mts +51 -38
  58. package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
  59. package/dist/number/branded-types/non-zero-int.mjs +31 -27
  60. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  61. package/dist/number/branded-types/non-zero-int16.d.mts +52 -53
  62. package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
  63. package/dist/number/branded-types/non-zero-int16.mjs +36 -39
  64. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  65. package/dist/number/branded-types/non-zero-int32.d.mts +52 -54
  66. package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
  67. package/dist/number/branded-types/non-zero-int32.mjs +36 -40
  68. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  69. package/dist/number/branded-types/non-zero-safe-int.d.mts +53 -54
  70. package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
  71. package/dist/number/branded-types/non-zero-safe-int.mjs +36 -40
  72. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  73. package/dist/number/branded-types/non-zero-uint16.d.mts +52 -53
  74. package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
  75. package/dist/number/branded-types/non-zero-uint16.mjs +35 -39
  76. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  77. package/dist/number/branded-types/non-zero-uint32.d.mts +52 -53
  78. package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
  79. package/dist/number/branded-types/non-zero-uint32.mjs +35 -39
  80. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  81. package/dist/number/branded-types/positive-finite-number.d.mts +74 -63
  82. package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
  83. package/dist/number/branded-types/positive-finite-number.mjs +58 -50
  84. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  85. package/dist/number/branded-types/positive-int.d.mts +46 -68
  86. package/dist/number/branded-types/positive-int.d.mts.map +1 -1
  87. package/dist/number/branded-types/positive-int.mjs +34 -49
  88. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  89. package/dist/number/branded-types/positive-int16.d.mts +61 -57
  90. package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
  91. package/dist/number/branded-types/positive-int16.mjs +44 -43
  92. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  93. package/dist/number/branded-types/positive-int32.d.mts +61 -57
  94. package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
  95. package/dist/number/branded-types/positive-int32.mjs +44 -43
  96. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  97. package/dist/number/branded-types/positive-safe-int.d.mts +62 -57
  98. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
  99. package/dist/number/branded-types/positive-safe-int.mjs +45 -43
  100. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  101. package/dist/number/branded-types/positive-uint16.d.mts +61 -57
  102. package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
  103. package/dist/number/branded-types/positive-uint16.mjs +44 -43
  104. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  105. package/dist/number/branded-types/positive-uint32.d.mts +61 -58
  106. package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
  107. package/dist/number/branded-types/positive-uint32.mjs +44 -44
  108. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  109. package/dist/number/branded-types/safe-int.d.mts +43 -62
  110. package/dist/number/branded-types/safe-int.d.mts.map +1 -1
  111. package/dist/number/branded-types/safe-int.mjs +35 -42
  112. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  113. package/dist/number/branded-types/safe-uint.d.mts +62 -57
  114. package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
  115. package/dist/number/branded-types/safe-uint.mjs +46 -44
  116. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  117. package/dist/number/branded-types/uint.d.mts +63 -50
  118. package/dist/number/branded-types/uint.d.mts.map +1 -1
  119. package/dist/number/branded-types/uint.mjs +42 -39
  120. package/dist/number/branded-types/uint.mjs.map +1 -1
  121. package/dist/number/branded-types/uint16.d.mts +60 -58
  122. package/dist/number/branded-types/uint16.d.mts.map +1 -1
  123. package/dist/number/branded-types/uint16.mjs +44 -43
  124. package/dist/number/branded-types/uint16.mjs.map +1 -1
  125. package/dist/number/branded-types/uint32.d.mts +59 -55
  126. package/dist/number/branded-types/uint32.d.mts.map +1 -1
  127. package/dist/number/branded-types/uint32.mjs +42 -42
  128. package/dist/number/branded-types/uint32.mjs.map +1 -1
  129. package/dist/number/enum/int8.d.mts +56 -65
  130. package/dist/number/enum/int8.d.mts.map +1 -1
  131. package/dist/number/enum/int8.mjs +44 -43
  132. package/dist/number/enum/int8.mjs.map +1 -1
  133. package/dist/number/enum/uint8.d.mts +60 -58
  134. package/dist/number/enum/uint8.d.mts.map +1 -1
  135. package/dist/number/enum/uint8.mjs +44 -43
  136. package/dist/number/enum/uint8.mjs.map +1 -1
  137. package/package.json +2 -1
  138. package/src/number/branded-types/finite-number.mts +47 -61
  139. package/src/number/branded-types/int.mts +40 -46
  140. package/src/number/branded-types/int16.mts +65 -58
  141. package/src/number/branded-types/int32.mts +65 -58
  142. package/src/number/branded-types/negative-finite-number.mts +68 -68
  143. package/src/number/branded-types/negative-int.mts +60 -57
  144. package/src/number/branded-types/negative-safe-int.mts +57 -65
  145. package/src/number/branded-types/non-negative-finite-number.mts +74 -64
  146. package/src/number/branded-types/non-negative-int16.mts +64 -57
  147. package/src/number/branded-types/non-negative-int32.mts +64 -58
  148. package/src/number/branded-types/non-positive-finite-number.mts +64 -54
  149. package/src/number/branded-types/non-positive-int.mts +41 -146
  150. package/src/number/branded-types/non-positive-safe-int.mts +54 -53
  151. package/src/number/branded-types/non-zero-finite-number.mts +62 -51
  152. package/src/number/branded-types/non-zero-int.mts +51 -38
  153. package/src/number/branded-types/non-zero-int16.mts +52 -53
  154. package/src/number/branded-types/non-zero-int32.mts +52 -54
  155. package/src/number/branded-types/non-zero-safe-int.mts +53 -54
  156. package/src/number/branded-types/non-zero-uint16.mts +52 -53
  157. package/src/number/branded-types/non-zero-uint32.mts +52 -53
  158. package/src/number/branded-types/positive-finite-number.mts +74 -63
  159. package/src/number/branded-types/positive-int.mts +46 -68
  160. package/src/number/branded-types/positive-int16.mts +61 -57
  161. package/src/number/branded-types/positive-int32.mts +61 -57
  162. package/src/number/branded-types/positive-safe-int.mts +62 -57
  163. package/src/number/branded-types/positive-uint16.mts +61 -57
  164. package/src/number/branded-types/positive-uint32.mts +61 -58
  165. package/src/number/branded-types/safe-int.mts +43 -62
  166. package/src/number/branded-types/safe-uint.mts +62 -57
  167. package/src/number/branded-types/uint.mts +63 -50
  168. package/src/number/branded-types/uint16.mts +60 -58
  169. package/src/number/branded-types/uint32.mts +59 -55
  170. package/src/number/enum/int8.mts +56 -65
  171. package/src/number/enum/uint8.mts +60 -58
@@ -33,118 +33,116 @@ const {
33
33
  } as const);
34
34
 
35
35
  /**
36
- * Checks if a number is a NonZeroInt32 (32-bit non-zero signed integer in the
37
- * range [-2^31, 2^31) excluding 0).
36
+ * Type guard that checks if a value is a non-zero integer in [-2^31, 2^31).
38
37
  *
39
- * @param value The value to check.
40
- * @returns `true` if the value is a NonZeroInt32, `false` otherwise.
38
+ * Returns `true` for a non-zero integer in [-2^31, 2^31) — a value with no
39
+ * fractional component.
40
+ *
41
+ * @param value - The value to check
42
+ * @returns `true` if the value is a non-zero integer in [-2^31, 2^31), `false` otherwise
41
43
  */
42
44
  export const isNonZeroInt32 = is;
43
45
 
44
46
  /**
45
- * Casts a number to a NonZeroInt32 type.
47
+ * Casts a `number` to the `NonZeroInt32` branded type.
48
+ *
49
+ * Validates that the value is a non-zero integer in [-2^31, 2^31) and returns
50
+ * it with the `NonZeroInt32` brand. Throws a `TypeError` otherwise.
46
51
  *
47
- * @param value The value to cast.
48
- * @returns The value as a NonZeroInt32 type.
49
- * @throws {TypeError} If the value is not a non-zero integer in [-2^31, 2^31).
52
+ * @param value - The value to cast
53
+ * @returns The value as a `NonZeroInt32`
54
+ * @throws {TypeError} If the value is not a non-zero integer in [-2^31, 2^31)
50
55
  */
51
56
  export const asNonZeroInt32 = castType;
52
57
 
53
58
  /**
54
- * Namespace providing type-safe arithmetic operations for 32-bit non-zero
55
- * signed integers.
59
+ * Namespace providing type-safe operations for the `NonZeroInt32` branded type.
56
60
  *
57
- * All operations automatically clamp results to the valid NonZeroInt32 range
58
- * [-2147483648, 2147483647] excluding 0. This ensures that all arithmetic
59
- * maintains the 32-bit non-zero signed integer constraint, preventing zero
60
- * results and overflow.
61
+ * The `NonZeroInt32` type represents a non-zero integer in [-2^31, 2^31).
62
+ * Division (`div`) uses floor division.
61
63
  */
62
64
  export const NonZeroInt32 = {
63
65
  /**
64
- * Type guard to check if a value is a NonZeroInt32.
66
+ * Type guard that checks if a value is a non-zero integer in [-2^31, 2^31).
65
67
  *
66
- * @param value The value to check.
67
- * @returns `true` if the value is a 32-bit non-zero signed integer, `false`
68
- * otherwise.
68
+ * @param value - The value to check
69
+ * @returns `true` if the value is a non-zero integer in [-2^31, 2^31), `false` otherwise
70
+ * @see {@link isNonZeroInt32} for usage examples
69
71
  */
70
72
  is,
71
73
 
72
74
  /**
73
- * The minimum value for a 32-bit non-zero signed integer.
74
- *
75
- * @readonly
75
+ * The smallest value representable as `NonZeroInt32`.
76
76
  */
77
77
  MIN_VALUE,
78
78
 
79
79
  /**
80
- * The maximum value for a 32-bit non-zero signed integer.
81
- *
82
- * @readonly
80
+ * The largest value representable as `NonZeroInt32`.
83
81
  */
84
82
  MAX_VALUE,
85
83
 
86
84
  /**
87
- * Returns the absolute value of a 32-bit non-zero signed integer.
85
+ * Returns the absolute value of a non-zero integer in [-2^31, 2^31).
88
86
  *
89
- * @param a The NonZeroInt32 value.
90
- * @returns The absolute value as a NonZeroInt32, clamped to valid range.
87
+ * The result is non-negative and keeps the `NonZeroInt32` brand.
88
+ *
89
+ * @param a - The non-zero integer value
90
+ * @returns The absolute value as a non-negative `NonZeroInt32`
91
91
  */
92
92
  abs,
93
93
 
94
94
  /**
95
- * Returns the smaller of two NonZeroInt32 values.
95
+ * Returns the smallest of the given non-zero integers.
96
96
  *
97
- * @param a The first NonZeroInt32.
98
- * @param b The second NonZeroInt32.
99
- * @returns The minimum value as a NonZeroInt32.
97
+ * @param values - The non-zero integers to compare (at least one required)
98
+ * @returns The smallest value as a `NonZeroInt32`
100
99
  */
101
100
  min: min_,
102
101
 
103
102
  /**
104
- * Returns the larger of two NonZeroInt32 values.
103
+ * Returns the largest of the given non-zero integers.
105
104
  *
106
- * @param a The first NonZeroInt32.
107
- * @param b The second NonZeroInt32.
108
- * @returns The maximum value as a NonZeroInt32.
105
+ * @param values - The non-zero integers to compare (at least one required)
106
+ * @returns The largest value as a `NonZeroInt32`
109
107
  */
110
108
  max: max_,
111
109
 
112
110
  /**
113
- * Clamps a number to the NonZeroInt32 range (avoiding zero).
111
+ * Clamps a `number` into the `NonZeroInt32` range, rounding to the nearest
112
+ * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
114
113
  *
115
- * @param value The number to clamp.
116
- * @returns The value clamped to [-2147483648, 2147483647] \ {0} as a
117
- * NonZeroInt32.
114
+ * @param value - The value to clamp
115
+ * @returns The clamped value as a `NonZeroInt32`
118
116
  */
119
117
  clamp,
120
118
 
121
119
  /**
122
- * Generates a random NonZeroInt32 value within the valid range.
120
+ * Generates a random `NonZeroInt32` within the given range.
121
+ *
122
+ * The range is inclusive on both ends.
123
123
  *
124
- * @returns A random NonZeroInt32 between MIN_VALUE and MAX_VALUE (excluding
125
- * 0).
124
+ * @param min - The minimum value (inclusive)
125
+ * @param max - The maximum value (inclusive)
126
+ * @returns A random `NonZeroInt32` in `[min, max]`
126
127
  */
127
128
  random,
128
129
 
129
130
  /**
130
- * Raises a NonZeroInt32 to the power of another NonZeroInt32.
131
+ * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroInt32`
132
+ * (floored to an integer).
131
133
  *
132
- * @param a The base NonZeroInt32.
133
- * @param b The exponent NonZeroInt32.
134
- * @returns `a ** b` clamped to [-2147483648, 2147483647] as a NonZeroInt32.
134
+ * @param a - The base non-zero integer
135
+ * @param b - The exponent non-zero integer
136
+ * @returns `a ** b` as a `NonZeroInt32`
135
137
  */
136
138
  pow,
137
139
 
138
140
  /**
139
- * Multiplies two NonZeroInt32 values.
140
- *
141
- * The product of two non-zero integers is always non-zero, so this stays
142
- * closed; for the non-closed operations (`add`/`sub`/`div`, whose result may
143
- * be `0`) use {@link Num.add}/{@link Num.sub}/{@link Num.divInt}.
141
+ * Multiplies two non-zero integers, returning `a * b` as a `NonZeroInt32`.
144
142
  *
145
- * @param a The first NonZeroInt32.
146
- * @param b The second NonZeroInt32.
147
- * @returns `a * b` clamped to [-2147483648, 2147483647] as a NonZeroInt32.
143
+ * @param a - The first non-zero integer
144
+ * @param b - The second non-zero integer
145
+ * @returns The product of `a` and `b` as a `NonZeroInt32`
148
146
  */
149
147
  mul,
150
148
  } as const;
@@ -39,119 +39,118 @@ const {
39
39
  } as const);
40
40
 
41
41
  /**
42
- * Checks if a number is a NonZeroSafeInt (a non-zero safe integer in the range
43
- * [MIN_SAFE_INTEGER, MAX_SAFE_INTEGER] excluding 0).
42
+ * Type guard that checks if a value is a non-zero safe integer.
44
43
  *
45
- * @param value The value to check.
46
- * @returns `true` if the value is a NonZeroSafeInt, `false` otherwise.
44
+ * Returns `true` for a non-zero safe integer — a value with no fractional
45
+ * component.
46
+ *
47
+ * @param value - The value to check
48
+ * @returns `true` if the value is a non-zero safe integer, `false` otherwise
47
49
  */
48
50
  export const isNonZeroSafeInt = is;
49
51
 
50
52
  /**
51
- * Casts a number to a NonZeroSafeInt type.
53
+ * Casts a `number` to the `NonZeroSafeInt` branded type.
54
+ *
55
+ * Validates that the value is a non-zero safe integer and returns it with the
56
+ * `NonZeroSafeInt` brand. Throws a `TypeError` otherwise.
52
57
  *
53
- * @param value The value to cast.
54
- * @returns The value as a NonZeroSafeInt type.
55
- * @throws {TypeError} If the value is not a non-zero safe integer.
58
+ * @param value - The value to cast
59
+ * @returns The value as a `NonZeroSafeInt`
60
+ * @throws {TypeError} If the value is not a non-zero safe integer
56
61
  */
57
62
  export const asNonZeroSafeInt = castType;
58
63
 
59
64
  /**
60
- * Namespace providing type-safe arithmetic operations for non-zero safe
61
- * integers.
65
+ * Namespace providing type-safe operations for the `NonZeroSafeInt` branded
66
+ * type.
62
67
  *
63
- * All operations automatically clamp results to the non-zero safe integer
64
- * range, excluding zero. This ensures that all arithmetic maintains both the
65
- * non-zero constraint and IEEE 754 precision guarantees, preventing precision
66
- * loss while ensuring results are never zero.
68
+ * The `NonZeroSafeInt` type represents a non-zero safe integer. Division
69
+ * (`div`) uses floor division.
67
70
  */
68
71
  export const NonZeroSafeInt = {
69
72
  /**
70
- * Type guard to check if a value is a NonZeroSafeInt.
73
+ * Type guard that checks if a value is a non-zero safe integer.
71
74
  *
72
- * @param value The value to check.
73
- * @returns `true` if the value is a non-zero safe integer, `false` otherwise.
75
+ * @param value - The value to check
76
+ * @returns `true` if the value is a non-zero safe integer, `false` otherwise
77
+ * @see {@link isNonZeroSafeInt} for usage examples
74
78
  */
75
79
  is,
76
80
 
77
81
  /**
78
- * The minimum safe integer value (-(2^53 - 1)).
79
- *
80
- * @readonly
82
+ * The smallest value representable as `NonZeroSafeInt`.
81
83
  */
82
84
  MIN_VALUE,
83
85
 
84
86
  /**
85
- * The maximum safe integer value (2^53 - 1).
86
- *
87
- * @readonly
87
+ * The largest value representable as `NonZeroSafeInt`.
88
88
  */
89
89
  MAX_VALUE,
90
90
 
91
91
  /**
92
92
  * Returns the absolute value of a non-zero safe integer.
93
93
  *
94
- * @param a The NonZeroSafeInt value.
95
- * @returns The absolute value as a NonZeroSafeInt, clamped to safe range.
94
+ * The result is non-negative and keeps the `NonZeroSafeInt` brand.
95
+ *
96
+ * @param a - The non-zero safe integer value
97
+ * @returns The absolute value as a non-negative `NonZeroSafeInt`
96
98
  */
97
99
  abs,
98
100
 
99
101
  /**
100
- * Returns the smaller of two NonZeroSafeInt values.
102
+ * Returns the smallest of the given non-zero safe integers.
101
103
  *
102
- * @param a The first NonZeroSafeInt.
103
- * @param b The second NonZeroSafeInt.
104
- * @returns The minimum value as a NonZeroSafeInt.
104
+ * @param values - The non-zero safe integers to compare (at least one required)
105
+ * @returns The smallest value as a `NonZeroSafeInt`
105
106
  */
106
107
  min: min_,
107
108
 
108
109
  /**
109
- * Returns the larger of two NonZeroSafeInt values.
110
+ * Returns the largest of the given non-zero safe integers.
110
111
  *
111
- * @param a The first NonZeroSafeInt.
112
- * @param b The second NonZeroSafeInt.
113
- * @returns The maximum value as a NonZeroSafeInt.
112
+ * @param values - The non-zero safe integers to compare (at least one required)
113
+ * @returns The largest value as a `NonZeroSafeInt`
114
114
  */
115
115
  max: max_,
116
116
 
117
117
  /**
118
- * Clamps a number to the non-zero safe integer range.
118
+ * Clamps a `number` into the `NonZeroSafeInt` range, rounding to the nearest
119
+ * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
119
120
  *
120
- * @param value The number to clamp.
121
- * @returns The value clamped to [MIN_SAFE_INTEGER, MAX_SAFE_INTEGER] \ {0} as
122
- * a NonZeroSafeInt.
121
+ * @param value - The value to clamp
122
+ * @returns The clamped value as a `NonZeroSafeInt`
123
123
  */
124
124
  clamp,
125
125
 
126
126
  /**
127
- * Generates a random NonZeroSafeInt value within the valid range.
127
+ * Generates a random `NonZeroSafeInt` within the given range.
128
+ *
129
+ * The range is inclusive on both ends.
128
130
  *
129
- * @returns A random non-zero safe integer between MIN_SAFE_INTEGER and
130
- * MAX_SAFE_INTEGER.
131
+ * @param min - The minimum value (inclusive)
132
+ * @param max - The maximum value (inclusive)
133
+ * @returns A random `NonZeroSafeInt` in `[min, max]`
131
134
  */
132
135
  random,
133
136
 
134
137
  /**
135
- * Raises a NonZeroSafeInt to the power of another NonZeroSafeInt.
138
+ * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroSafeInt`
139
+ * (floored to an integer).
136
140
  *
137
- * @param a The base NonZeroSafeInt.
138
- * @param b The exponent NonZeroSafeInt.
139
- * @returns `a ** b` clamped to non-zero safe integer range as a
140
- * NonZeroSafeInt.
141
+ * @param a - The base non-zero safe integer
142
+ * @param b - The exponent non-zero safe integer
143
+ * @returns `a ** b` as a `NonZeroSafeInt`
141
144
  */
142
145
  pow,
143
146
 
144
147
  /**
145
- * Multiplies two NonZeroSafeInt values.
146
- *
147
- * The product of two non-zero safe integers is always non-zero, so this stays
148
- * closed; for the non-closed operations (`add`/`sub`/`div`, whose result may
149
- * be `0`) use {@link Num.add}/{@link Num.sub}/{@link Num.divInt}.
148
+ * Multiplies two non-zero safe integers, returning `a * b` as a
149
+ * `NonZeroSafeInt`.
150
150
  *
151
- * @param a The first NonZeroSafeInt.
152
- * @param b The second NonZeroSafeInt.
153
- * @returns `a * b` clamped to non-zero safe integer range as a
154
- * NonZeroSafeInt.
151
+ * @param a - The first non-zero safe integer
152
+ * @param b - The second non-zero safe integer
153
+ * @returns The product of `a` and `b` as a `NonZeroSafeInt`
155
154
  */
156
155
  mul,
157
156
  } as const;
@@ -33,117 +33,116 @@ const {
33
33
  } as const);
34
34
 
35
35
  /**
36
- * Checks if a number is a NonZeroUint16 (16-bit non-zero unsigned integer in
37
- * the range [1, 2^16)).
36
+ * Type guard that checks if a value is a non-zero integer in [1, 2^16).
38
37
  *
39
- * @param value The value to check.
40
- * @returns `true` if the value is a NonZeroUint16, `false` otherwise.
38
+ * Returns `true` for a non-zero integer in [1, 2^16) — a value with no
39
+ * fractional component.
40
+ *
41
+ * @param value - The value to check
42
+ * @returns `true` if the value is a non-zero integer in [1, 2^16), `false` otherwise
41
43
  */
42
44
  export const isNonZeroUint16 = is;
43
45
 
44
46
  /**
45
- * Casts a number to a NonZeroUint16 type.
47
+ * Casts a `number` to the `NonZeroUint16` branded type.
48
+ *
49
+ * Validates that the value is a non-zero integer in [1, 2^16) and returns it
50
+ * with the `NonZeroUint16` brand. Throws a `TypeError` otherwise.
46
51
  *
47
- * @param value The value to cast.
48
- * @returns The value as a NonZeroUint16 type.
49
- * @throws {TypeError} If the value is not a non-zero integer in [1, 2^16).
52
+ * @param value - The value to cast
53
+ * @returns The value as a `NonZeroUint16`
54
+ * @throws {TypeError} If the value is not a non-zero integer in [1, 2^16)
50
55
  */
51
56
  export const asNonZeroUint16 = castType;
52
57
 
53
58
  /**
54
- * Namespace providing type-safe arithmetic operations for 16-bit non-zero
55
- * unsigned integers.
59
+ * Namespace providing type-safe operations for the `NonZeroUint16` branded
60
+ * type.
56
61
  *
57
- * All operations automatically clamp results to the valid NonZeroUint16 range
58
- * [1, 65535]. This ensures that all arithmetic maintains the 16-bit non-zero
59
- * unsigned integer constraint, with results below 1 clamped to MIN_VALUE and
60
- * overflow results clamped to MAX_VALUE.
62
+ * The `NonZeroUint16` type represents a non-zero integer in [1, 2^16). Division
63
+ * (`div`) uses floor division.
61
64
  */
62
65
  export const NonZeroUint16 = {
63
66
  /**
64
- * Type guard to check if a value is a NonZeroUint16.
67
+ * Type guard that checks if a value is a non-zero integer in [1, 2^16).
65
68
  *
66
- * @param value The value to check.
67
- * @returns `true` if the value is a 16-bit non-zero unsigned integer, `false`
68
- * otherwise.
69
+ * @param value - The value to check
70
+ * @returns `true` if the value is a non-zero integer in [1, 2^16), `false` otherwise
71
+ * @see {@link isNonZeroUint16} for usage examples
69
72
  */
70
73
  is,
71
74
 
72
75
  /**
73
- * The minimum value for a 16-bit non-zero unsigned integer.
74
- *
75
- * @readonly
76
+ * The smallest value representable as `NonZeroUint16`.
76
77
  */
77
78
  MIN_VALUE,
78
79
 
79
80
  /**
80
- * The maximum value for a 16-bit non-zero unsigned integer.
81
- *
82
- * @readonly
81
+ * The largest value representable as `NonZeroUint16`.
83
82
  */
84
83
  MAX_VALUE,
85
84
 
86
85
  /**
87
- * Returns the smaller of two NonZeroUint16 values.
86
+ * Returns the smallest of the given non-zero integers.
88
87
  *
89
- * @param a The first NonZeroUint16.
90
- * @param b The second NonZeroUint16.
91
- * @returns The minimum value as a NonZeroUint16.
88
+ * @param values - The non-zero integers to compare (at least one required)
89
+ * @returns The smallest value as a `NonZeroUint16`
92
90
  */
93
91
  min: min_,
94
92
 
95
93
  /**
96
- * Returns the larger of two NonZeroUint16 values.
94
+ * Returns the largest of the given non-zero integers.
97
95
  *
98
- * @param a The first NonZeroUint16.
99
- * @param b The second NonZeroUint16.
100
- * @returns The maximum value as a NonZeroUint16.
96
+ * @param values - The non-zero integers to compare (at least one required)
97
+ * @returns The largest value as a `NonZeroUint16`
101
98
  */
102
99
  max: max_,
103
100
 
104
101
  /**
105
- * Clamps a number to the NonZeroUint16 range.
102
+ * Clamps a `number` into the `NonZeroUint16` range, rounding to the nearest
103
+ * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
106
104
  *
107
- * @param value The number to clamp.
108
- * @returns The value clamped to [1, 65535] as a NonZeroUint16.
105
+ * @param value - The value to clamp
106
+ * @returns The clamped value as a `NonZeroUint16`
109
107
  */
110
108
  clamp,
111
109
 
112
110
  /**
113
- * Generates a random NonZeroUint16 value within the valid range.
111
+ * Generates a random `NonZeroUint16` within the given range.
112
+ *
113
+ * The range is inclusive on both ends.
114
114
  *
115
- * @returns A random NonZeroUint16 between 1 and 65535.
115
+ * @param min - The minimum value (inclusive)
116
+ * @param max - The maximum value (inclusive)
117
+ * @returns A random `NonZeroUint16` in `[min, max]`
116
118
  */
117
119
  random,
118
120
 
119
121
  /**
120
- * Raises a NonZeroUint16 to the power of another NonZeroUint16.
122
+ * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroUint16`
123
+ * (floored to an integer).
121
124
  *
122
- * @param a The base NonZeroUint16.
123
- * @param b The exponent NonZeroUint16.
124
- * @returns `a ** b` clamped to [1, 65535] as a NonZeroUint16.
125
+ * @param a - The base non-zero integer
126
+ * @param b - The exponent non-zero integer
127
+ * @returns `a ** b` as a `NonZeroUint16`
125
128
  */
126
129
  pow,
127
130
 
128
131
  /**
129
- * Adds two NonZeroUint16 values.
132
+ * Adds two non-zero integers, returning `a + b` as a `NonZeroUint16`.
130
133
  *
131
- * @param a The first NonZeroUint16.
132
- * @param b The second NonZeroUint16.
133
- * @returns `a + b` clamped to [1, 65535] as a NonZeroUint16.
134
+ * @param a - The first non-zero integer
135
+ * @param b - The second non-zero integer
136
+ * @returns The sum of `a` and `b` as a `NonZeroUint16`
134
137
  */
135
138
  add,
136
139
 
137
140
  /**
138
- * Multiplies two NonZeroUint16 values.
139
- *
140
- * Both `add` and `mul` stay within `[1, 65535]`. For the non-closed
141
- * operations (`sub`/`div`, whose result may be `0`) use {@link Num.sub} /
142
- * {@link Num.divInt}.
141
+ * Multiplies two non-zero integers, returning `a * b` as a `NonZeroUint16`.
143
142
  *
144
- * @param a The first NonZeroUint16.
145
- * @param b The second NonZeroUint16.
146
- * @returns `a * b` clamped to [1, 65535] as a NonZeroUint16.
143
+ * @param a - The first non-zero integer
144
+ * @param b - The second non-zero integer
145
+ * @returns The product of `a` and `b` as a `NonZeroUint16`
147
146
  */
148
147
  mul,
149
148
  } as const;