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
@@ -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;
@@ -34,131 +34,135 @@ const {
34
34
  } as const);
35
35
 
36
36
  /**
37
- * Checks if a number is a PositiveUint16 (16-bit positive unsigned integer in
38
- * the range [1, 2^16)).
37
+ * Type guard that checks if a value is a positive integer in [1, 2^16).
39
38
  *
40
- * @param value The value to check.
41
- * @returns `true` if the value is a PositiveUint16, `false` otherwise.
39
+ * Returns `true` for a positive integer in [1, 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 positive integer in [1, 2^16), `false` otherwise
42
44
  */
43
45
  export const isPositiveUint16 = is;
44
46
 
45
47
  /**
46
- * Casts a number to a PositiveUint16 type.
48
+ * Casts a `number` to the `PositiveUint16` branded type.
49
+ *
50
+ * Validates that the value is a positive integer in [1, 2^16) and returns it
51
+ * with the `PositiveUint16` brand. Throws a `TypeError` otherwise.
47
52
  *
48
- * @param value The value to cast.
49
- * @returns The value as a PositiveUint16 type.
50
- * @throws {TypeError} If the value is not a positive integer in [1, 2^16).
53
+ * @param value - The value to cast
54
+ * @returns The value as a `PositiveUint16`
55
+ * @throws {TypeError} If the value is not a positive integer in [1, 2^16)
51
56
  */
52
57
  export const asPositiveUint16 = castType;
53
58
 
54
59
  /**
55
- * Namespace providing type-safe arithmetic operations for 16-bit positive
56
- * unsigned integers.
60
+ * Namespace providing type-safe operations for the `PositiveUint16` branded
61
+ * type.
57
62
  *
58
- * All operations automatically clamp results to the valid PositiveUint16 range
59
- * [1, 65535]. This ensures that all arithmetic maintains the 16-bit positive
60
- * unsigned integer constraint, with results below 1 clamped to MIN_VALUE and
61
- * overflow results clamped to MAX_VALUE.
63
+ * The `PositiveUint16` type represents a positive integer in [1, 2^16).
64
+ * Division (`div`) uses floor division.
62
65
  */
63
66
  export const PositiveUint16 = {
64
67
  /**
65
- * Type guard to check if a value is a PositiveUint16.
68
+ * Type guard that checks if a value is a positive integer in [1, 2^16).
66
69
  *
67
- * @param value The value to check.
68
- * @returns `true` if the value is a 16-bit positive unsigned integer, `false`
69
- * otherwise.
70
+ * @param value - The value to check
71
+ * @returns `true` if the value is a positive integer in [1, 2^16), `false` otherwise
72
+ * @see {@link isPositiveUint16} for usage examples
70
73
  */
71
74
  is,
72
75
 
73
76
  /**
74
- * The minimum value for a 16-bit positive unsigned integer.
75
- *
76
- * @readonly
77
+ * The smallest value representable as `PositiveUint16`.
77
78
  */
78
79
  MIN_VALUE,
79
80
 
80
81
  /**
81
- * The maximum value for a 16-bit positive unsigned integer.
82
- *
83
- * @readonly
82
+ * The largest value representable as `PositiveUint16`.
84
83
  */
85
84
  MAX_VALUE,
86
85
 
87
86
  /**
88
- * Returns the smaller of two PositiveUint16 values.
87
+ * Returns the smallest of the given positive integers.
89
88
  *
90
- * @param a The first PositiveUint16.
91
- * @param b The second PositiveUint16.
92
- * @returns The minimum value as a PositiveUint16.
89
+ * @param values - The positive integers to compare (at least one required)
90
+ * @returns The smallest value as a `PositiveUint16`
93
91
  */
94
92
  min: min_,
95
93
 
96
94
  /**
97
- * Returns the larger of two PositiveUint16 values.
95
+ * Returns the largest of the given positive integers.
98
96
  *
99
- * @param a The first PositiveUint16.
100
- * @param b The second PositiveUint16.
101
- * @returns The maximum value as a PositiveUint16.
97
+ * @param values - The positive integers to compare (at least one required)
98
+ * @returns The largest value as a `PositiveUint16`
102
99
  */
103
100
  max: max_,
104
101
 
105
102
  /**
106
- * Clamps a number to the PositiveUint16 range.
103
+ * Clamps a `number` into the `PositiveUint16` 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, 65535] as a PositiveUint16.
106
+ * @param value - The value to clamp
107
+ * @returns The clamped value as a `PositiveUint16`
110
108
  */
111
109
  clamp,
112
110
 
113
111
  /**
114
- * Generates a random PositiveUint16 value within the valid range.
112
+ * Generates a random `PositiveUint16` within the given range.
113
+ *
114
+ * The range is inclusive on both ends.
115
115
  *
116
- * @returns A random PositiveUint16 between 1 and 65535.
116
+ * @param min - The minimum value (inclusive)
117
+ * @param max - The maximum value (inclusive)
118
+ * @returns A random `PositiveUint16` in `[min, max]`
117
119
  */
118
120
  random,
119
121
 
120
122
  /**
121
- * Raises a PositiveUint16 to the power of another PositiveUint16.
123
+ * Raises `a` to the power `b`, returning `a ** b` as a `PositiveUint16`
124
+ * (floored to an integer).
122
125
  *
123
- * @param a The base PositiveUint16.
124
- * @param b The exponent PositiveUint16.
125
- * @returns `a ** b` clamped to [1, 65535] as a PositiveUint16.
126
+ * @param a - The base positive integer
127
+ * @param b - The exponent positive integer
128
+ * @returns `a ** b` as a `PositiveUint16`
126
129
  */
127
130
  pow,
128
131
 
129
132
  /**
130
- * Adds two PositiveUint16 values.
133
+ * Adds two positive integers, returning `a + b` as a `PositiveUint16`.
131
134
  *
132
- * @param a The first PositiveUint16.
133
- * @param b The second PositiveUint16.
134
- * @returns `a + b` clamped to [1, 65535] as a PositiveUint16.
135
+ * @param a - The first positive integer
136
+ * @param b - The second positive integer
137
+ * @returns The sum of `a` and `b` as a `PositiveUint16`
135
138
  */
136
139
  add,
137
140
 
138
141
  /**
139
- * Subtracts one PositiveUint16 from another.
142
+ * Subtracts two positive integers, returning `a - b` as a `PositiveUint16`.
140
143
  *
141
- * @param a The minuend PositiveUint16.
142
- * @param b The subtrahend PositiveUint16.
143
- * @returns `a - b` clamped to [1, 65535] as a PositiveUint16 (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 `PositiveUint16`
144
147
  */
145
148
  sub,
146
149
 
147
150
  /**
148
- * Multiplies two PositiveUint16 values.
151
+ * Multiplies two positive integers, returning `a * b` as a `PositiveUint16`.
149
152
  *
150
- * @param a The first PositiveUint16.
151
- * @param b The second PositiveUint16.
152
- * @returns `a * b` clamped to [1, 65535] as a PositiveUint16.
153
+ * @param a - The first positive integer
154
+ * @param b - The second positive integer
155
+ * @returns The product of `a` and `b` as a `PositiveUint16`
153
156
  */
154
157
  mul,
155
158
 
156
159
  /**
157
- * Divides one PositiveUint16 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 `PositiveUint16`.
158
162
  *
159
- * @param a The dividend PositiveUint16.
160
- * @param b The divisor PositiveUint16.
161
- * @returns `⌊a / b⌋` clamped to [1, 65535] as a PositiveUint16.
163
+ * @param a - The dividend
164
+ * @param b - The divisor (must be non-zero)
165
+ * @returns The floored quotient as a `PositiveUint16`
162
166
  */
163
167
  div,
164
168
  } as const;
@@ -34,132 +34,135 @@ const {
34
34
  } as const);
35
35
 
36
36
  /**
37
- * Checks if a number is a PositiveUint32 (32-bit positive unsigned integer in
38
- * the range [1, 2^32)).
37
+ * Type guard that checks if a value is a positive integer in [1, 2^32).
39
38
  *
40
- * @param value The value to check.
41
- * @returns `true` if the value is a PositiveUint32, `false` otherwise.
39
+ * Returns `true` for a positive integer in [1, 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 positive integer in [1, 2^32), `false` otherwise
42
44
  */
43
45
  export const isPositiveUint32 = is;
44
46
 
45
47
  /**
46
- * Casts a number to a PositiveUint32 type.
48
+ * Casts a `number` to the `PositiveUint32` branded type.
49
+ *
50
+ * Validates that the value is a positive integer in [1, 2^32) and returns it
51
+ * with the `PositiveUint32` brand. Throws a `TypeError` otherwise.
47
52
  *
48
- * @param value The value to cast.
49
- * @returns The value as a PositiveUint32 type.
50
- * @throws {TypeError} If the value is not a positive integer in [1, 2^32).
53
+ * @param value - The value to cast
54
+ * @returns The value as a `PositiveUint32`
55
+ * @throws {TypeError} If the value is not a positive integer in [1, 2^32)
51
56
  */
52
57
  export const asPositiveUint32 = castType;
53
58
 
54
59
  /**
55
- * Namespace providing type-safe arithmetic operations for 32-bit positive
56
- * unsigned integers.
60
+ * Namespace providing type-safe operations for the `PositiveUint32` branded
61
+ * type.
57
62
  *
58
- * All operations automatically clamp results to the valid PositiveUint32 range
59
- * [1, 4294967295]. This ensures that all arithmetic maintains the 32-bit
60
- * positive unsigned integer constraint, with results below 1 clamped to
61
- * MIN_VALUE and overflow results clamped to MAX_VALUE.
63
+ * The `PositiveUint32` type represents a positive integer in [1, 2^32).
64
+ * Division (`div`) uses floor division.
62
65
  */
63
66
  export const PositiveUint32 = {
64
67
  /**
65
- * Type guard to check if a value is a PositiveUint32.
68
+ * Type guard that checks if a value is a positive integer in [1, 2^32).
66
69
  *
67
- * @param value The value to check.
68
- * @returns `true` if the value is a 32-bit positive unsigned integer, `false`
69
- * otherwise.
70
+ * @param value - The value to check
71
+ * @returns `true` if the value is a positive integer in [1, 2^32), `false` otherwise
72
+ * @see {@link isPositiveUint32} for usage examples
70
73
  */
71
74
  is,
72
75
 
73
76
  /**
74
- * The minimum value for a 32-bit positive unsigned integer.
75
- *
76
- * @readonly
77
+ * The smallest value representable as `PositiveUint32`.
77
78
  */
78
79
  MIN_VALUE,
79
80
 
80
81
  /**
81
- * The maximum value for a 32-bit positive unsigned integer.
82
- *
83
- * @readonly
82
+ * The largest value representable as `PositiveUint32`.
84
83
  */
85
84
  MAX_VALUE,
86
85
 
87
86
  /**
88
- * Returns the smaller of two PositiveUint32 values.
87
+ * Returns the smallest of the given positive integers.
89
88
  *
90
- * @param a The first PositiveUint32.
91
- * @param b The second PositiveUint32.
92
- * @returns The minimum value as a PositiveUint32.
89
+ * @param values - The positive integers to compare (at least one required)
90
+ * @returns The smallest value as a `PositiveUint32`
93
91
  */
94
92
  min: min_,
95
93
 
96
94
  /**
97
- * Returns the larger of two PositiveUint32 values.
95
+ * Returns the largest of the given positive integers.
98
96
  *
99
- * @param a The first PositiveUint32.
100
- * @param b The second PositiveUint32.
101
- * @returns The maximum value as a PositiveUint32.
97
+ * @param values - The positive integers to compare (at least one required)
98
+ * @returns The largest value as a `PositiveUint32`
102
99
  */
103
100
  max: max_,
104
101
 
105
102
  /**
106
- * Clamps a number to the PositiveUint32 range.
103
+ * Clamps a `number` into the `PositiveUint32` 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, 4294967295] as a PositiveUint32.
106
+ * @param value - The value to clamp
107
+ * @returns The clamped value as a `PositiveUint32`
110
108
  */
111
109
  clamp,
112
110
 
113
111
  /**
114
- * Generates a random PositiveUint32 value within the valid range.
112
+ * Generates a random `PositiveUint32` within the given range.
113
+ *
114
+ * The range is inclusive on both ends.
115
115
  *
116
- * @returns A random PositiveUint32 between 1 and 4294967295.
116
+ * @param min - The minimum value (inclusive)
117
+ * @param max - The maximum value (inclusive)
118
+ * @returns A random `PositiveUint32` in `[min, max]`
117
119
  */
118
120
  random,
119
121
 
120
122
  /**
121
- * Raises a PositiveUint32 to the power of another PositiveUint32.
123
+ * Raises `a` to the power `b`, returning `a ** b` as a `PositiveUint32`
124
+ * (floored to an integer).
122
125
  *
123
- * @param a The base PositiveUint32.
124
- * @param b The exponent PositiveUint32.
125
- * @returns `a ** b` clamped to [1, 4294967295] as a PositiveUint32.
126
+ * @param a - The base positive integer
127
+ * @param b - The exponent positive integer
128
+ * @returns `a ** b` as a `PositiveUint32`
126
129
  */
127
130
  pow,
128
131
 
129
132
  /**
130
- * Adds two PositiveUint32 values.
133
+ * Adds two positive integers, returning `a + b` as a `PositiveUint32`.
131
134
  *
132
- * @param a The first PositiveUint32.
133
- * @param b The second PositiveUint32.
134
- * @returns `a + b` clamped to [1, 4294967295] as a PositiveUint32.
135
+ * @param a - The first positive integer
136
+ * @param b - The second positive integer
137
+ * @returns The sum of `a` and `b` as a `PositiveUint32`
135
138
  */
136
139
  add,
137
140
 
138
141
  /**
139
- * Subtracts one PositiveUint32 from another.
142
+ * Subtracts two positive integers, returning `a - b` as a `PositiveUint32`.
140
143
  *
141
- * @param a The minuend PositiveUint32.
142
- * @param b The subtrahend PositiveUint32.
143
- * @returns `a - b` clamped to [1, 4294967295] as a PositiveUint32 (minimum
144
- * 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 `PositiveUint32`
145
147
  */
146
148
  sub,
147
149
 
148
150
  /**
149
- * Multiplies two PositiveUint32 values.
151
+ * Multiplies two positive integers, returning `a * b` as a `PositiveUint32`.
150
152
  *
151
- * @param a The first PositiveUint32.
152
- * @param b The second PositiveUint32.
153
- * @returns `a * b` clamped to [1, 4294967295] as a PositiveUint32.
153
+ * @param a - The first positive integer
154
+ * @param b - The second positive integer
155
+ * @returns The product of `a` and `b` as a `PositiveUint32`
154
156
  */
155
157
  mul,
156
158
 
157
159
  /**
158
- * Divides one PositiveUint32 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 `PositiveUint32`.
159
162
  *
160
- * @param a The dividend PositiveUint32.
161
- * @param b The divisor PositiveUint32.
162
- * @returns `⌊a / b⌋` clamped to [1, 4294967295] as a PositiveUint32.
163
+ * @param a - The dividend
164
+ * @param b - The divisor (must be non-zero)
165
+ * @returns The floored quotient as a `PositiveUint32`
163
166
  */
164
167
  div,
165
168
  } as const;