ts-data-forge 10.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 (249) hide show
  1. package/dist/array/impl/array-utils-creation.d.mts +3 -3
  2. package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
  3. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  4. package/dist/array/impl/array-utils-element-access.d.mts +4 -4
  5. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  6. package/dist/{guard/as-length-bounded-array.d.mts → array/impl/array-utils-length-bounded-array-cast.d.mts} +9 -9
  7. package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts.map +1 -0
  8. package/dist/{guard/as-length-bounded-array.mjs → array/impl/array-utils-length-bounded-array-cast.mjs} +2 -2
  9. package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -0
  10. package/dist/{guard/is-length-bounded-array.d.mts → array/impl/array-utils-length-bounded-array-guard.d.mts} +13 -13
  11. package/dist/array/impl/array-utils-length-bounded-array-guard.d.mts.map +1 -0
  12. package/dist/{guard/is-length-bounded-array.mjs → array/impl/array-utils-length-bounded-array-guard.mjs} +1 -1
  13. package/dist/array/impl/array-utils-length-bounded-array-guard.mjs.map +1 -0
  14. package/dist/array/impl/array-utils-modification.d.mts +9 -9
  15. package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
  16. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  17. package/dist/array/impl/array-utils-reducing-value.d.mts +9 -9
  18. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  19. package/dist/array/impl/array-utils-size.d.mts +3 -3
  20. package/dist/array/impl/array-utils-size.mjs.map +1 -1
  21. package/dist/array/impl/array-utils-slicing.d.mts +9 -9
  22. package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
  23. package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
  24. package/dist/array/impl/array-utils-transformation.d.mts +16 -10
  25. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
  26. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  27. package/dist/array/impl/index.d.mts +2 -0
  28. package/dist/array/impl/index.d.mts.map +1 -1
  29. package/dist/array/impl/index.mjs +2 -0
  30. package/dist/array/impl/index.mjs.map +1 -1
  31. package/dist/entry-point.mjs +1 -3
  32. package/dist/entry-point.mjs.map +1 -1
  33. package/dist/guard/index.d.mts +0 -3
  34. package/dist/guard/index.d.mts.map +1 -1
  35. package/dist/guard/index.mjs +0 -3
  36. package/dist/guard/index.mjs.map +1 -1
  37. package/dist/index.d.mts +1 -0
  38. package/dist/index.d.mts.map +1 -1
  39. package/dist/index.mjs +1 -3
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/number/branded-types/finite-number.d.mts +47 -61
  42. package/dist/number/branded-types/finite-number.d.mts.map +1 -1
  43. package/dist/number/branded-types/finite-number.mjs +37 -41
  44. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  45. package/dist/number/branded-types/int.d.mts +40 -46
  46. package/dist/number/branded-types/int.d.mts.map +1 -1
  47. package/dist/number/branded-types/int.mjs +29 -31
  48. package/dist/number/branded-types/int.mjs.map +1 -1
  49. package/dist/number/branded-types/int16.d.mts +65 -58
  50. package/dist/number/branded-types/int16.d.mts.map +1 -1
  51. package/dist/number/branded-types/int16.mjs +49 -45
  52. package/dist/number/branded-types/int16.mjs.map +1 -1
  53. package/dist/number/branded-types/int32.d.mts +65 -58
  54. package/dist/number/branded-types/int32.d.mts.map +1 -1
  55. package/dist/number/branded-types/int32.mjs +49 -45
  56. package/dist/number/branded-types/int32.mjs.map +1 -1
  57. package/dist/number/branded-types/negative-finite-number.d.mts +68 -59
  58. package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
  59. package/dist/number/branded-types/negative-finite-number.mjs +52 -46
  60. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  61. package/dist/number/branded-types/negative-int.d.mts +60 -48
  62. package/dist/number/branded-types/negative-int.d.mts.map +1 -1
  63. package/dist/number/branded-types/negative-int.mjs +40 -36
  64. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  65. package/dist/number/branded-types/negative-safe-int.d.mts +57 -56
  66. package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
  67. package/dist/number/branded-types/negative-safe-int.mjs +40 -41
  68. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  69. package/dist/number/branded-types/non-negative-finite-number.d.mts +74 -64
  70. package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
  71. package/dist/number/branded-types/non-negative-finite-number.mjs +58 -51
  72. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  73. package/dist/number/branded-types/non-negative-int16.d.mts +64 -57
  74. package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
  75. package/dist/number/branded-types/non-negative-int16.mjs +47 -43
  76. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  77. package/dist/number/branded-types/non-negative-int32.d.mts +64 -58
  78. package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
  79. package/dist/number/branded-types/non-negative-int32.mjs +47 -44
  80. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  81. package/dist/number/branded-types/non-positive-finite-number.d.mts +64 -54
  82. package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
  83. package/dist/number/branded-types/non-positive-finite-number.mjs +48 -41
  84. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  85. package/dist/number/branded-types/non-positive-int.d.mts +41 -146
  86. package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
  87. package/dist/number/branded-types/non-positive-int.mjs +27 -107
  88. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  89. package/dist/number/branded-types/non-positive-safe-int.d.mts +54 -53
  90. package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
  91. package/dist/number/branded-types/non-positive-safe-int.mjs +37 -39
  92. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  93. package/dist/number/branded-types/non-zero-finite-number.d.mts +62 -49
  94. package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
  95. package/dist/number/branded-types/non-zero-finite-number.mjs +46 -37
  96. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  97. package/dist/number/branded-types/non-zero-int.d.mts +51 -38
  98. package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
  99. package/dist/number/branded-types/non-zero-int.mjs +31 -27
  100. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  101. package/dist/number/branded-types/non-zero-int16.d.mts +52 -53
  102. package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
  103. package/dist/number/branded-types/non-zero-int16.mjs +36 -39
  104. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  105. package/dist/number/branded-types/non-zero-int32.d.mts +52 -54
  106. package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
  107. package/dist/number/branded-types/non-zero-int32.mjs +36 -40
  108. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  109. package/dist/number/branded-types/non-zero-safe-int.d.mts +53 -54
  110. package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
  111. package/dist/number/branded-types/non-zero-safe-int.mjs +36 -40
  112. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  113. package/dist/number/branded-types/non-zero-uint16.d.mts +52 -53
  114. package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
  115. package/dist/number/branded-types/non-zero-uint16.mjs +35 -39
  116. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  117. package/dist/number/branded-types/non-zero-uint32.d.mts +52 -53
  118. package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
  119. package/dist/number/branded-types/non-zero-uint32.mjs +35 -39
  120. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  121. package/dist/number/branded-types/positive-finite-number.d.mts +74 -63
  122. package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
  123. package/dist/number/branded-types/positive-finite-number.mjs +58 -50
  124. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  125. package/dist/number/branded-types/positive-int.d.mts +46 -68
  126. package/dist/number/branded-types/positive-int.d.mts.map +1 -1
  127. package/dist/number/branded-types/positive-int.mjs +34 -49
  128. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  129. package/dist/number/branded-types/positive-int16.d.mts +61 -57
  130. package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
  131. package/dist/number/branded-types/positive-int16.mjs +44 -43
  132. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  133. package/dist/number/branded-types/positive-int32.d.mts +61 -57
  134. package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
  135. package/dist/number/branded-types/positive-int32.mjs +44 -43
  136. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  137. package/dist/number/branded-types/positive-safe-int.d.mts +62 -57
  138. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
  139. package/dist/number/branded-types/positive-safe-int.mjs +45 -43
  140. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  141. package/dist/number/branded-types/positive-uint16.d.mts +61 -57
  142. package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
  143. package/dist/number/branded-types/positive-uint16.mjs +44 -43
  144. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  145. package/dist/number/branded-types/positive-uint32.d.mts +61 -58
  146. package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
  147. package/dist/number/branded-types/positive-uint32.mjs +44 -44
  148. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  149. package/dist/number/branded-types/safe-int.d.mts +43 -62
  150. package/dist/number/branded-types/safe-int.d.mts.map +1 -1
  151. package/dist/number/branded-types/safe-int.mjs +35 -42
  152. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  153. package/dist/number/branded-types/safe-uint.d.mts +62 -57
  154. package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
  155. package/dist/number/branded-types/safe-uint.mjs +46 -44
  156. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  157. package/dist/number/branded-types/uint.d.mts +63 -50
  158. package/dist/number/branded-types/uint.d.mts.map +1 -1
  159. package/dist/number/branded-types/uint.mjs +42 -39
  160. package/dist/number/branded-types/uint.mjs.map +1 -1
  161. package/dist/number/branded-types/uint16.d.mts +60 -58
  162. package/dist/number/branded-types/uint16.d.mts.map +1 -1
  163. package/dist/number/branded-types/uint16.mjs +44 -43
  164. package/dist/number/branded-types/uint16.mjs.map +1 -1
  165. package/dist/number/branded-types/uint32.d.mts +59 -55
  166. package/dist/number/branded-types/uint32.d.mts.map +1 -1
  167. package/dist/number/branded-types/uint32.mjs +42 -42
  168. package/dist/number/branded-types/uint32.mjs.map +1 -1
  169. package/dist/number/enum/int8.d.mts +56 -65
  170. package/dist/number/enum/int8.d.mts.map +1 -1
  171. package/dist/number/enum/int8.mjs +44 -43
  172. package/dist/number/enum/int8.mjs.map +1 -1
  173. package/dist/number/enum/uint8.d.mts +60 -58
  174. package/dist/number/enum/uint8.d.mts.map +1 -1
  175. package/dist/number/enum/uint8.mjs +44 -43
  176. package/dist/number/enum/uint8.mjs.map +1 -1
  177. package/dist/string/index.d.mts +2 -0
  178. package/dist/string/index.d.mts.map +1 -0
  179. package/dist/string/index.mjs +2 -0
  180. package/dist/string/index.mjs.map +1 -0
  181. package/dist/string/str.d.mts +273 -0
  182. package/dist/string/str.d.mts.map +1 -0
  183. package/dist/string/str.mjs +42 -0
  184. package/dist/string/str.mjs.map +1 -0
  185. package/package.json +31 -92
  186. package/src/array/impl/array-utils-creation.mts +2 -1
  187. package/src/array/impl/array-utils-element-access.mts +3 -3
  188. package/src/array/impl/array-utils-element-access.test.mts +3 -3
  189. package/src/{guard/as-length-bounded-array.mts → array/impl/array-utils-length-bounded-array-cast.mts} +9 -9
  190. package/src/{guard/as-length-bounded-array.test.mts → array/impl/array-utils-length-bounded-array-cast.test.mts} +2 -2
  191. package/src/{guard/is-length-bounded-array.mts → array/impl/array-utils-length-bounded-array-guard.mts} +12 -12
  192. package/src/{guard/is-length-bounded-array.test.mts → array/impl/array-utils-length-bounded-array-guard.test.mts} +2 -2
  193. package/src/array/impl/array-utils-modification.mts +9 -8
  194. package/src/array/impl/array-utils-modification.test.mts +6 -1
  195. package/src/array/impl/array-utils-reducing-value.mts +9 -9
  196. package/src/array/impl/array-utils-size.mts +2 -2
  197. package/src/array/impl/array-utils-slicing.mts +24 -13
  198. package/src/array/impl/array-utils-transformation.mts +18 -12
  199. package/src/array/impl/array-utils-transformation.test.mts +12 -12
  200. package/src/array/impl/index.mts +2 -0
  201. package/src/guard/index.mts +0 -3
  202. package/src/index.mts +1 -0
  203. package/src/number/branded-types/finite-number.mts +47 -61
  204. package/src/number/branded-types/int.mts +40 -46
  205. package/src/number/branded-types/int16.mts +65 -58
  206. package/src/number/branded-types/int32.mts +65 -58
  207. package/src/number/branded-types/negative-finite-number.mts +68 -68
  208. package/src/number/branded-types/negative-int.mts +60 -57
  209. package/src/number/branded-types/negative-safe-int.mts +57 -65
  210. package/src/number/branded-types/non-negative-finite-number.mts +74 -64
  211. package/src/number/branded-types/non-negative-int16.mts +64 -57
  212. package/src/number/branded-types/non-negative-int32.mts +64 -58
  213. package/src/number/branded-types/non-positive-finite-number.mts +64 -54
  214. package/src/number/branded-types/non-positive-int.mts +41 -146
  215. package/src/number/branded-types/non-positive-safe-int.mts +54 -53
  216. package/src/number/branded-types/non-zero-finite-number.mts +62 -51
  217. package/src/number/branded-types/non-zero-int.mts +51 -38
  218. package/src/number/branded-types/non-zero-int16.mts +52 -53
  219. package/src/number/branded-types/non-zero-int32.mts +52 -54
  220. package/src/number/branded-types/non-zero-safe-int.mts +53 -54
  221. package/src/number/branded-types/non-zero-uint16.mts +52 -53
  222. package/src/number/branded-types/non-zero-uint32.mts +52 -53
  223. package/src/number/branded-types/positive-finite-number.mts +74 -63
  224. package/src/number/branded-types/positive-int.mts +46 -68
  225. package/src/number/branded-types/positive-int16.mts +61 -57
  226. package/src/number/branded-types/positive-int32.mts +61 -57
  227. package/src/number/branded-types/positive-safe-int.mts +62 -57
  228. package/src/number/branded-types/positive-uint16.mts +61 -57
  229. package/src/number/branded-types/positive-uint32.mts +61 -58
  230. package/src/number/branded-types/safe-int.mts +43 -62
  231. package/src/number/branded-types/safe-uint.mts +62 -57
  232. package/src/number/branded-types/uint.mts +63 -50
  233. package/src/number/branded-types/uint16.mts +60 -58
  234. package/src/number/branded-types/uint32.mts +59 -55
  235. package/src/number/enum/int8.mts +56 -65
  236. package/src/number/enum/uint8.mts +60 -58
  237. package/src/string/index.mts +1 -0
  238. package/src/string/str.mts +371 -0
  239. package/src/string/str.test.mts +215 -0
  240. package/dist/guard/as-length-bounded-array.d.mts.map +0 -1
  241. package/dist/guard/as-length-bounded-array.mjs.map +0 -1
  242. package/dist/guard/is-length-bounded-array.d.mts.map +0 -1
  243. package/dist/guard/is-length-bounded-array.mjs.map +0 -1
  244. package/dist/guard/is-length-bounded-string.d.mts +0 -163
  245. package/dist/guard/is-length-bounded-string.d.mts.map +0 -1
  246. package/dist/guard/is-length-bounded-string.mjs +0 -7
  247. package/dist/guard/is-length-bounded-string.mjs.map +0 -1
  248. package/src/guard/is-length-bounded-string.mts +0 -199
  249. package/src/guard/is-length-bounded-string.test.mts +0 -170
@@ -33,7 +33,11 @@ const {
33
33
  } as const);
34
34
 
35
35
  /**
36
- * Checks if a number is a Uint.
36
+ * Type guard that checks if a value is a non-negative integer.
37
+ *
38
+ * Returns `true` for a non-negative integer — a value with no fractional
39
+ * component, including values outside the safe integer range (unlike
40
+ * `SafeInt`).
37
41
  *
38
42
  * @example
39
43
  *
@@ -45,13 +49,16 @@ const {
45
49
  * assert.isTrue(Uint.is(0));
46
50
  * ```
47
51
  *
48
- * @param value The value to check.
49
- * @returns `true` if the value is a Uint, `false` otherwise.
52
+ * @param value - The value to check
53
+ * @returns `true` if the value is a non-negative integer, `false` otherwise
50
54
  */
51
55
  export const isUint = is;
52
56
 
53
57
  /**
54
- * Casts a number to a Uint type.
58
+ * Casts a `number` to the `Uint` branded type.
59
+ *
60
+ * Validates that the value is a non-negative integer and returns it with the
61
+ * `Uint` brand. Throws a `TypeError` otherwise.
55
62
  *
56
63
  * @example
57
64
  *
@@ -63,22 +70,25 @@ export const isUint = is;
63
70
  * assert.isTrue(Uint.is(branded));
64
71
  * ```
65
72
  *
66
- * @param value The value to cast.
67
- * @returns The value as a Uint type.
68
- * @throws {TypeError} If the value is not a non-negative integer.
73
+ * @param value - The value to cast
74
+ * @returns The value as an `Uint`
75
+ * @throws {TypeError} If the value is not a non-negative integer
69
76
  */
70
77
  export const asUint = castType;
71
78
 
72
79
  /**
73
- * Namespace providing type-safe arithmetic operations for unsigned integers.
80
+ * Namespace providing type-safe operations for the `Uint` branded type.
81
+ *
82
+ * The `Uint` type represents a non-negative integer. Division (`div`) uses
83
+ * floor division.
74
84
  *
75
- * All operations maintain the non-negative constraint by clamping negative
76
- * results to 0. This ensures that all arithmetic preserves the unsigned integer
77
- * property.
85
+ * Unlike `SafeInt`, `Uint` allows values outside the safe integer range (±2^53
86
+ * − 1), so very large magnitudes may lose precision in JavaScript's `number`
87
+ * type.
78
88
  */
79
89
  export const Uint = {
80
90
  /**
81
- * Type guard to check if a value is a Uint.
91
+ * Type guard that checks if a value is a non-negative integer.
82
92
  *
83
93
  * @example
84
94
  *
@@ -90,21 +100,19 @@ export const Uint = {
90
100
  * assert.isTrue(Uint.is(0));
91
101
  * ```
92
102
  *
93
- * @param value The value to check.
94
- * @returns `true` if the value is a non-negative integer, `false` otherwise.
103
+ * @param value - The value to check
104
+ * @returns `true` if the value is a non-negative integer, `false` otherwise
95
105
  * @see {@link isUint} for usage examples
96
106
  */
97
107
  is,
98
108
 
99
109
  /**
100
- * The minimum value for an unsigned integer.
101
- *
102
- * @readonly
110
+ * The smallest value representable as `Uint`.
103
111
  */
104
112
  MIN_VALUE,
105
113
 
106
114
  /**
107
- * Returns the smaller of two Uint values.
115
+ * Returns the smallest of the given non-negative integers.
108
116
  *
109
117
  * @example
110
118
  *
@@ -114,14 +122,13 @@ export const Uint = {
114
122
  * assert.isTrue(smallest === 3);
115
123
  * ```
116
124
  *
117
- * @param a The first Uint.
118
- * @param b The second Uint.
119
- * @returns The minimum value as a Uint.
125
+ * @param values - The non-negative integers to compare (at least one required)
126
+ * @returns The smallest value as an `Uint`
120
127
  */
121
128
  min: min_,
122
129
 
123
130
  /**
124
- * Returns the larger of two Uint values.
131
+ * Returns the largest of the given non-negative integers.
125
132
  *
126
133
  * @example
127
134
  *
@@ -131,14 +138,14 @@ export const Uint = {
131
138
  * assert.isTrue(largest === 7);
132
139
  * ```
133
140
  *
134
- * @param a The first Uint.
135
- * @param b The second Uint.
136
- * @returns The maximum value as a Uint.
141
+ * @param values - The non-negative integers to compare (at least one required)
142
+ * @returns The largest value as an `Uint`
137
143
  */
138
144
  max: max_,
139
145
 
140
146
  /**
141
- * Clamps a number to the Uint range (non-negative).
147
+ * Clamps a `number` into the `Uint` range, rounding to the nearest integer
148
+ * and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
142
149
  *
143
150
  * @example
144
151
  *
@@ -152,13 +159,15 @@ export const Uint = {
152
159
  * assert.isTrue(clampedPositive === 42);
153
160
  * ```
154
161
  *
155
- * @param value The number to clamp.
156
- * @returns The value clamped to [0, +∞) as a Uint.
162
+ * @param value - The value to clamp
163
+ * @returns The clamped value as an `Uint`
157
164
  */
158
165
  clamp,
159
166
 
160
167
  /**
161
- * Generates a random Uint value.
168
+ * Generates a random `Uint` within the given range.
169
+ *
170
+ * The range is inclusive on both ends.
162
171
  *
163
172
  * @example
164
173
  *
@@ -174,12 +183,15 @@ export const Uint = {
174
183
  * assert.isTrue(randomValue >= 0 && randomValue <= 3);
175
184
  * ```
176
185
  *
177
- * @returns A random non-negative integer as a Uint.
186
+ * @param min - The minimum value (inclusive)
187
+ * @param max - The maximum value (inclusive)
188
+ * @returns A random `Uint` in `[min, max]`
178
189
  */
179
190
  random,
180
191
 
181
192
  /**
182
- * Raises a Uint to the power of another Uint.
193
+ * Raises `a` to the power `b`, returning `a ** b` as an `Uint` (floored to an
194
+ * integer).
183
195
  *
184
196
  * @example
185
197
  *
@@ -193,14 +205,14 @@ export const Uint = {
193
205
  * assert.isTrue(power === 32);
194
206
  * ```
195
207
  *
196
- * @param a The base Uint.
197
- * @param b The exponent Uint.
198
- * @returns `a ** b` clamped to [0, +∞) as a Uint.
208
+ * @param a - The base non-negative integer
209
+ * @param b - The exponent non-negative integer
210
+ * @returns `a ** b` as an `Uint`
199
211
  */
200
212
  pow,
201
213
 
202
214
  /**
203
- * Adds two Uint values.
215
+ * Adds two non-negative integers, returning `a + b` as an `Uint`.
204
216
  *
205
217
  * @example
206
218
  *
@@ -210,14 +222,14 @@ export const Uint = {
210
222
  * assert.isTrue(sum === 13);
211
223
  * ```
212
224
  *
213
- * @param a The first Uint.
214
- * @param b The second Uint.
215
- * @returns `a + b` clamped to [0, +∞) as a Uint.
225
+ * @param a - The first non-negative integer
226
+ * @param b - The second non-negative integer
227
+ * @returns The sum of `a` and `b` as an `Uint`
216
228
  */
217
229
  add,
218
230
 
219
231
  /**
220
- * Subtracts one Uint from another.
232
+ * Subtracts two non-negative integers, returning `a - b` as an `Uint`.
221
233
  *
222
234
  * @example
223
235
  *
@@ -227,14 +239,14 @@ export const Uint = {
227
239
  * assert.isTrue(difference === 0);
228
240
  * ```
229
241
  *
230
- * @param a The minuend Uint.
231
- * @param b The subtrahend Uint.
232
- * @returns `a - b` clamped to [0, +∞) as a Uint (minimum 0).
242
+ * @param a - The first non-negative integer
243
+ * @param b - The second non-negative integer
244
+ * @returns The difference of `a` and `b` as an `Uint`
233
245
  */
234
246
  sub,
235
247
 
236
248
  /**
237
- * Multiplies two Uint values.
249
+ * Multiplies two non-negative integers, returning `a * b` as an `Uint`.
238
250
  *
239
251
  * @example
240
252
  *
@@ -244,14 +256,15 @@ export const Uint = {
244
256
  * assert.isTrue(product === 42);
245
257
  * ```
246
258
  *
247
- * @param a The first Uint.
248
- * @param b The second Uint.
249
- * @returns `a * b` clamped to [0, +∞) as a Uint.
259
+ * @param a - The first non-negative integer
260
+ * @param b - The second non-negative integer
261
+ * @returns The product of `a` and `b` as an `Uint`
250
262
  */
251
263
  mul,
252
264
 
253
265
  /**
254
- * Divides one Uint by another using floor division.
266
+ * Divides two non-negative integers using floor division (`⌊a / b⌋`): the
267
+ * result is `a / b` rounded toward negative infinity, as an `Uint`.
255
268
  *
256
269
  * @example
257
270
  *
@@ -261,9 +274,9 @@ export const Uint = {
261
274
  * assert.isTrue(quotient === 2);
262
275
  * ```
263
276
  *
264
- * @param a The dividend Uint.
265
- * @param b The divisor Uint.
266
- * @returns `⌊a / b⌋` clamped to [0, +∞) as a Uint.
277
+ * @param a - The dividend
278
+ * @param b - The divisor (must be non-zero)
279
+ * @returns The floored quotient as an `Uint`
267
280
  */
268
281
  div,
269
282
  } as const;
@@ -34,132 +34,134 @@ const {
34
34
  } as const);
35
35
 
36
36
  /**
37
- * Checks if a number is a Uint16 (16-bit unsigned integer in the range [0,
38
- * 2^16)).
37
+ * Type guard that checks if a value is a non-negative integer less than 2^16.
39
38
  *
40
- * @param value The value to check.
41
- * @returns `true` if the value is a Uint16, `false` otherwise.
39
+ * Returns `true` for a non-negative integer less than 2^16 — a value with no
40
+ * fractional component.
41
+ *
42
+ * @param value - The value to check
43
+ * @returns `true` if the value is a non-negative integer less than 2^16, `false` otherwise
42
44
  */
43
45
  export const isUint16 = is;
44
46
 
45
47
  /**
46
- * Casts a number to a Uint16 type.
48
+ * Casts a `number` to the `Uint16` branded type.
49
+ *
50
+ * Validates that the value is a non-negative integer less than 2^16 and returns
51
+ * it with the `Uint16` brand. Throws a `TypeError` otherwise.
47
52
  *
48
- * @param value The value to cast.
49
- * @returns The value as a Uint16 type.
50
- * @throws {TypeError} If the value is not a non-negative integer less than
51
- * 2^16.
53
+ * @param value - The value to cast
54
+ * @returns The value as an `Uint16`
55
+ * @throws {TypeError} If the value is not a non-negative integer less than 2^16
52
56
  */
53
57
  export const asUint16 = castType;
54
58
 
55
59
  /**
56
- * Namespace providing type-safe arithmetic operations for 16-bit unsigned
57
- * integers.
60
+ * Namespace providing type-safe operations for the `Uint16` branded type.
58
61
  *
59
- * All operations automatically clamp results to the valid Uint16 range [0,
60
- * 65535]. This ensures that all arithmetic maintains the 16-bit unsigned
61
- * integer constraint, with negative results clamped to 0 and overflow results
62
- * clamped to MAX_VALUE.
62
+ * The `Uint16` type represents a non-negative integer less than 2^16. Division
63
+ * (`div`) uses floor division.
63
64
  */
64
65
  export const Uint16 = {
65
66
  /**
66
- * Type guard to check if a value is a Uint16.
67
+ * Type guard that checks if a value is a non-negative integer less than 2^16.
67
68
  *
68
- * @param value The value to check.
69
- * @returns `true` if the value is a 16-bit unsigned integer, `false`
70
- * otherwise.
69
+ * @param value - The value to check
70
+ * @returns `true` if the value is a non-negative integer less than 2^16, `false` otherwise
71
+ * @see {@link isUint16} for usage examples
71
72
  */
72
73
  is,
73
74
 
74
75
  /**
75
- * The minimum value for a 16-bit unsigned integer.
76
- *
77
- * @readonly
76
+ * The smallest value representable as `Uint16`.
78
77
  */
79
78
  MIN_VALUE,
80
79
 
81
80
  /**
82
- * The maximum value for a 16-bit unsigned integer.
83
- *
84
- * @readonly
81
+ * The largest value representable as `Uint16`.
85
82
  */
86
83
  MAX_VALUE,
87
84
 
88
85
  /**
89
- * Returns the smaller of two Uint16 values.
86
+ * Returns the smallest of the given non-negative integers.
90
87
  *
91
- * @param a The first Uint16.
92
- * @param b The second Uint16.
93
- * @returns The minimum value as a Uint16.
88
+ * @param values - The non-negative integers to compare (at least one required)
89
+ * @returns The smallest value as an `Uint16`
94
90
  */
95
91
  min: min_,
96
92
 
97
93
  /**
98
- * Returns the larger of two Uint16 values.
94
+ * Returns the largest of the given non-negative integers.
99
95
  *
100
- * @param a The first Uint16.
101
- * @param b The second Uint16.
102
- * @returns The maximum value as a Uint16.
96
+ * @param values - The non-negative integers to compare (at least one required)
97
+ * @returns The largest value as an `Uint16`
103
98
  */
104
99
  max: max_,
105
100
 
106
101
  /**
107
- * Clamps a number to the Uint16 range.
102
+ * Clamps a `number` into the `Uint16` range, rounding to the nearest integer
103
+ * and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
108
104
  *
109
- * @param value The number to clamp.
110
- * @returns The value clamped to [0, 65535] as a Uint16.
105
+ * @param value - The value to clamp
106
+ * @returns The clamped value as an `Uint16`
111
107
  */
112
108
  clamp,
113
109
 
114
110
  /**
115
- * Generates a random Uint16 value within the valid range.
111
+ * Generates a random `Uint16` within the given range.
112
+ *
113
+ * The range is inclusive on both ends.
116
114
  *
117
- * @returns A random Uint16 between 0 and 65535.
115
+ * @param min - The minimum value (inclusive)
116
+ * @param max - The maximum value (inclusive)
117
+ * @returns A random `Uint16` in `[min, max]`
118
118
  */
119
119
  random,
120
120
 
121
121
  /**
122
- * Raises a Uint16 to the power of another Uint16.
122
+ * Raises `a` to the power `b`, returning `a ** b` as an `Uint16` (floored to
123
+ * an integer).
123
124
  *
124
- * @param a The base Uint16.
125
- * @param b The exponent Uint16.
126
- * @returns `a ** b` clamped to [0, 65535] as a Uint16.
125
+ * @param a - The base non-negative integer
126
+ * @param b - The exponent non-negative integer
127
+ * @returns `a ** b` as an `Uint16`
127
128
  */
128
129
  pow,
129
130
 
130
131
  /**
131
- * Adds two Uint16 values.
132
+ * Adds two non-negative integers, returning `a + b` as an `Uint16`.
132
133
  *
133
- * @param a The first Uint16.
134
- * @param b The second Uint16.
135
- * @returns `a + b` clamped to [0, 65535] as a Uint16.
134
+ * @param a - The first non-negative integer
135
+ * @param b - The second non-negative integer
136
+ * @returns The sum of `a` and `b` as an `Uint16`
136
137
  */
137
138
  add,
138
139
 
139
140
  /**
140
- * Subtracts one Uint16 from another.
141
+ * Subtracts two non-negative integers, returning `a - b` as an `Uint16`.
141
142
  *
142
- * @param a The minuend Uint16.
143
- * @param b The subtrahend Uint16.
144
- * @returns `a - b` clamped to [0, 65535] as a Uint16 (minimum 0).
143
+ * @param a - The first non-negative integer
144
+ * @param b - The second non-negative integer
145
+ * @returns The difference of `a` and `b` as an `Uint16`
145
146
  */
146
147
  sub,
147
148
 
148
149
  /**
149
- * Multiplies two Uint16 values.
150
+ * Multiplies two non-negative integers, returning `a * b` as an `Uint16`.
150
151
  *
151
- * @param a The first Uint16.
152
- * @param b The second Uint16.
153
- * @returns `a * b` clamped to [0, 65535] as a Uint16.
152
+ * @param a - The first non-negative integer
153
+ * @param b - The second non-negative integer
154
+ * @returns The product of `a` and `b` as an `Uint16`
154
155
  */
155
156
  mul,
156
157
 
157
158
  /**
158
- * Divides one Uint16 by another using floor division.
159
+ * Divides two non-negative integers using floor division (`⌊a / b⌋`): the
160
+ * result is `a / b` rounded toward negative infinity, as an `Uint16`.
159
161
  *
160
- * @param a The dividend Uint16.
161
- * @param b The divisor Uint16.
162
- * @returns `⌊a / b⌋` clamped to [0, 65535] as a Uint16.
162
+ * @param a - The dividend
163
+ * @param b - The divisor (must be non-zero)
164
+ * @returns The floored quotient as an `Uint16`
163
165
  */
164
166
  div,
165
167
  } as const;
@@ -34,130 +34,134 @@ const {
34
34
  } as const);
35
35
 
36
36
  /**
37
- * Checks if a number is a Uint32 (32-bit unsigned integer in the range [0,
38
- * 2^32)).
37
+ * Type guard that checks if a value is a non-negative integer less than 2^32.
39
38
  *
40
- * @param value The value to check.
41
- * @returns `true` if the value is a Uint32, `false` otherwise.
39
+ * Returns `true` for a non-negative integer less than 2^32 — a value with no
40
+ * fractional component.
41
+ *
42
+ * @param value - The value to check
43
+ * @returns `true` if the value is a non-negative integer less than 2^32, `false` otherwise
42
44
  */
43
45
  export const isUint32 = is;
44
46
 
45
47
  /**
46
- * Casts a number to a Uint32 type.
48
+ * Casts a `number` to the `Uint32` branded type.
49
+ *
50
+ * Validates that the value is a non-negative integer less than 2^32 and returns
51
+ * it with the `Uint32` brand. Throws a `TypeError` otherwise.
47
52
  *
48
- * @param value The value to cast.
49
- * @returns The value as a Uint32 type.
50
- * @throws {TypeError} If the value is not a non-negative integer less than
51
- * 2^32.
53
+ * @param value - The value to cast
54
+ * @returns The value as an `Uint32`
55
+ * @throws {TypeError} If the value is not a non-negative integer less than 2^32
52
56
  */
53
57
  export const asUint32 = castType;
54
58
 
55
59
  /**
56
- * Utility functions for working with Uint32 (32-bit unsigned integer) branded
57
- * types. Provides type-safe operations that ensure results remain within the
58
- * valid range [0, 2^32). All arithmetic operations are clamped to maintain the
59
- * Uint32 constraint.
60
+ * Namespace providing type-safe operations for the `Uint32` branded type.
61
+ *
62
+ * The `Uint32` type represents a non-negative integer less than 2^32. Division
63
+ * (`div`) uses floor division.
60
64
  */
61
65
  export const Uint32 = {
62
66
  /**
63
- * Type guard that checks if a value is a 32-bit unsigned integer.
67
+ * Type guard that checks if a value is a non-negative integer less than 2^32.
64
68
  *
65
69
  * @param value - The value to check
66
- * @returns `true` if the value is within the range [0, 2^32), `false`
67
- * otherwise
70
+ * @returns `true` if the value is a non-negative integer less than 2^32, `false` otherwise
71
+ * @see {@link isUint32} for usage examples
68
72
  */
69
73
  is,
70
74
 
71
75
  /**
72
- * The minimum value for a Uint32.
73
- *
74
- * @readonly
76
+ * The smallest value representable as `Uint32`.
75
77
  */
76
78
  MIN_VALUE,
77
79
 
78
80
  /**
79
- * The maximum value for a Uint32.
80
- *
81
- * @readonly
81
+ * The largest value representable as `Uint32`.
82
82
  */
83
83
  MAX_VALUE,
84
84
 
85
85
  /**
86
- * Returns the minimum of multiple Uint32 values.
86
+ * Returns the smallest of the given non-negative integers.
87
87
  *
88
- * @param values - The Uint32 values to compare
89
- * @returns The smallest value as a Uint32
88
+ * @param values - The non-negative integers to compare (at least one required)
89
+ * @returns The smallest value as an `Uint32`
90
90
  */
91
91
  min: min_,
92
92
 
93
93
  /**
94
- * Returns the maximum of multiple Uint32 values.
94
+ * Returns the largest of the given non-negative integers.
95
95
  *
96
- * @param values - The Uint32 values to compare
97
- * @returns The largest value as a Uint32
96
+ * @param values - The non-negative integers to compare (at least one required)
97
+ * @returns The largest value as an `Uint32`
98
98
  */
99
99
  max: max_,
100
100
 
101
101
  /**
102
- * Clamps a Uint32 to be within the specified range.
102
+ * Clamps a `number` into the `Uint32` range, rounding to the nearest integer
103
+ * and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
103
104
  *
104
105
  * @param value - The value to clamp
105
- * @param min - The minimum value
106
- * @param max - The maximum value
107
- * @returns The clamped value as a Uint32
106
+ * @returns The clamped value as an `Uint32`
108
107
  */
109
108
  clamp,
110
109
 
111
110
  /**
112
- * Generates a random Uint32 value.
111
+ * Generates a random `Uint32` within the given range.
112
+ *
113
+ * The range is inclusive on both ends.
113
114
  *
114
- * @returns A random Uint32 value within [0, 2^32)
115
+ * @param min - The minimum value (inclusive)
116
+ * @param max - The maximum value (inclusive)
117
+ * @returns A random `Uint32` in `[min, max]`
115
118
  */
116
119
  random,
117
120
 
118
121
  /**
119
- * Raises a Uint32 to a power, with result clamped to [0, 2^32).
122
+ * Raises `a` to the power `b`, returning `a ** b` as an `Uint32` (floored to
123
+ * an integer).
120
124
  *
121
- * @param a - The base Uint32
122
- * @param b - The exponent Uint32
123
- * @returns `a ** b` as a Uint32, clamped to valid range
125
+ * @param a - The base non-negative integer
126
+ * @param b - The exponent non-negative integer
127
+ * @returns `a ** b` as an `Uint32`
124
128
  */
125
129
  pow,
126
130
 
127
131
  /**
128
- * Adds two Uint32 values, with result clamped to [0, 2^32).
132
+ * Adds two non-negative integers, returning `a + b` as an `Uint32`.
129
133
  *
130
- * @param a - First Uint32
131
- * @param b - Second Uint32
132
- * @returns `a + b` as a Uint32, clamped to valid range
134
+ * @param a - The first non-negative integer
135
+ * @param b - The second non-negative integer
136
+ * @returns The sum of `a` and `b` as an `Uint32`
133
137
  */
134
138
  add,
135
139
 
136
140
  /**
137
- * Subtracts two Uint32 values, with result clamped to [0, 2^32).
141
+ * Subtracts two non-negative integers, returning `a - b` as an `Uint32`.
138
142
  *
139
- * @param a - First Uint32
140
- * @param b - Second Uint32
141
- * @returns `a - b` as a Uint32, clamped to valid range (minimum 0)
143
+ * @param a - The first non-negative integer
144
+ * @param b - The second non-negative integer
145
+ * @returns The difference of `a` and `b` as an `Uint32`
142
146
  */
143
147
  sub,
144
148
 
145
149
  /**
146
- * Multiplies two Uint32 values, with result clamped to [0, 2^32).
150
+ * Multiplies two non-negative integers, returning `a * b` as an `Uint32`.
147
151
  *
148
- * @param a - First Uint32
149
- * @param b - Second Uint32
150
- * @returns `a * b` as a Uint32, clamped to valid range
152
+ * @param a - The first non-negative integer
153
+ * @param b - The second non-negative integer
154
+ * @returns The product of `a` and `b` as an `Uint32`
151
155
  */
152
156
  mul,
153
157
 
154
158
  /**
155
- * Divides two Uint32 values using floor division, with result clamped to [0,
156
- * 2^32).
159
+ * Divides two non-negative integers using floor division (`⌊a / b⌋`): the
160
+ * result is `a / b` rounded toward negative infinity, as an `Uint32`.
157
161
  *
158
- * @param a - The dividend Uint32
159
- * @param b - The divisor Uint32
160
- * @returns `⌊a / b⌋` as a Uint32, clamped to valid range
162
+ * @param a - The dividend
163
+ * @param b - The divisor (must be non-zero)
164
+ * @returns The floored quotient as an `Uint32`
161
165
  */
162
166
  div,
163
167
  } as const;