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
@@ -35,139 +35,131 @@ const {
35
35
  typeNameInMessage,
36
36
  } as const);
37
37
 
38
- /**
39
- * Returns the absolute value of a negative safe integer.
40
- *
41
- * The absolute value of a negative safe integer is always a positive safe
42
- * integer (`>= 1`), so the result is typed as a {@link PositiveSafeInt}.
43
- *
44
- * @param x - The negative safe integer.
45
- * @returns `|x|` as a PositiveSafeInt.
46
- */
47
38
  const abs = (x: WithSmallInt<ElementType>): PositiveSafeInt =>
48
39
  PositiveSafeInt.clamp(Math.abs(x));
49
40
 
50
41
  /**
51
- * Checks if a number is a NegativeSafeInt (a negative safe integer in the range
52
- * `[Number.MIN_SAFE_INTEGER, -1]`).
42
+ * Type guard that checks if a value is a negative safe integer.
43
+ *
44
+ * Returns `true` for a negative safe integer — a value with no fractional
45
+ * component.
53
46
  *
54
- * @param value The value to check.
55
- * @returns `true` if the value is a NegativeSafeInt, `false` otherwise.
47
+ * @param value - The value to check
48
+ * @returns `true` if the value is a negative safe integer, `false` otherwise
56
49
  */
57
50
  export const isNegativeSafeInt = is;
58
51
 
59
52
  /**
60
- * Casts a number to a NegativeSafeInt type.
53
+ * Casts a `number` to the `NegativeSafeInt` branded type.
54
+ *
55
+ * Validates that the value is a negative safe integer and returns it with the
56
+ * `NegativeSafeInt` brand. Throws a `TypeError` otherwise.
61
57
  *
62
- * @param value The value to cast.
63
- * @returns The value as a NegativeSafeInt type.
64
- * @throws {TypeError} If the value is not a negative safe integer.
58
+ * @param value - The value to cast
59
+ * @returns The value as a `NegativeSafeInt`
60
+ * @throws {TypeError} If the value is not a negative safe integer
65
61
  */
66
62
  export const asNegativeSafeInt = castType;
67
63
 
68
64
  /**
69
- * Namespace providing type-safe arithmetic operations for negative safe
70
- * integers.
65
+ * Namespace providing type-safe operations for the `NegativeSafeInt` branded
66
+ * type.
71
67
  *
72
- * NegativeSafeInt represents safe integers that are strictly less than zero
73
- * (`[Number.MIN_SAFE_INTEGER, -1]`). Operations that stay within the negative
74
- * safe integers clamp their results to the valid range, while operations whose
75
- * result leaves the set (`mul`, `div`, `abs`) are typed to reflect the actual
76
- * sign of the result.
68
+ * The `NegativeSafeInt` type represents a negative safe integer. Division
69
+ * (`div`) uses floor division.
77
70
  */
78
71
  export const NegativeSafeInt = {
79
72
  /**
80
- * Type guard to check if a value is a NegativeSafeInt.
73
+ * Type guard that checks if a value is a negative safe integer.
81
74
  *
82
- * @param value The value to check.
83
- * @returns `true` if the value is a negative safe integer, `false` otherwise.
75
+ * @param value - The value to check
76
+ * @returns `true` if the value is a negative safe integer, `false` otherwise
77
+ * @see {@link isNegativeSafeInt} for usage examples
84
78
  */
85
79
  is,
86
80
 
87
81
  /**
88
- * The minimum value for a negative safe integer.
89
- *
90
- * @readonly
82
+ * The smallest value representable as `NegativeSafeInt`.
91
83
  */
92
84
  MIN_VALUE,
93
85
 
94
86
  /**
95
- * The maximum value for a negative safe integer.
96
- *
97
- * @readonly
87
+ * The largest value representable as `NegativeSafeInt`.
98
88
  */
99
89
  MAX_VALUE,
100
90
 
101
91
  /**
102
92
  * Returns the absolute value of a negative safe integer.
103
93
  *
104
- * @param a The negative safe integer.
105
- * @returns The absolute value as a PositiveSafeInt.
94
+ * The result is non-negative and keeps the `NegativeSafeInt` brand.
95
+ *
96
+ * @param a - The negative safe integer value
97
+ * @returns The absolute value as a non-negative `NegativeSafeInt`
106
98
  */
107
99
  abs,
108
100
 
109
101
  /**
110
- * Returns the smaller of two negative safe integers.
102
+ * Returns the smallest of the given negative safe integers.
111
103
  *
112
- * @param a The first negative safe integer.
113
- * @param b The second negative safe integer.
114
- * @returns The minimum value as a NegativeSafeInt.
104
+ * @param values - The negative safe integers to compare (at least one required)
105
+ * @returns The smallest value as a `NegativeSafeInt`
115
106
  */
116
107
  min: min_,
117
108
 
118
109
  /**
119
- * Returns the larger of two negative safe integers.
110
+ * Returns the largest of the given negative safe integers.
120
111
  *
121
- * @param a The first negative safe integer.
122
- * @param b The second negative safe integer.
123
- * @returns The maximum value as a NegativeSafeInt.
112
+ * @param values - The negative safe integers to compare (at least one required)
113
+ * @returns The largest value as a `NegativeSafeInt`
124
114
  */
125
115
  max: max_,
126
116
 
127
117
  /**
128
- * Clamps a number to the NegativeSafeInt range.
118
+ * Clamps a `number` into the `NegativeSafeInt` range, rounding to the nearest
119
+ * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
129
120
  *
130
- * @param value The number to clamp.
131
- * @returns The value clamped to `[Number.MIN_SAFE_INTEGER, -1]` as a
132
- * NegativeSafeInt.
121
+ * @param value - The value to clamp
122
+ * @returns The clamped value as a `NegativeSafeInt`
133
123
  */
134
124
  clamp,
135
125
 
136
126
  /**
137
- * Generates a random NegativeSafeInt value within the valid range.
127
+ * Generates a random `NegativeSafeInt` within the given range.
138
128
  *
139
- * @returns A random NegativeSafeInt between Number.MIN_SAFE_INTEGER and -1.
129
+ * The range is inclusive on both ends.
130
+ *
131
+ * @param min - The minimum value (inclusive)
132
+ * @param max - The maximum value (inclusive)
133
+ * @returns A random `NegativeSafeInt` in `[min, max]`
140
134
  */
141
135
  random,
142
136
 
143
137
  /**
144
- * Raises a negative safe integer to the power of another negative safe
145
- * integer.
138
+ * Raises `a` to the power `b`, returning `a ** b` as a `NegativeSafeInt`
139
+ * (floored to an integer).
146
140
  *
147
- * @param a The base negative safe integer.
148
- * @param b The exponent negative safe integer.
149
- * @returns `a ** b` clamped to the NegativeSafeInt range.
141
+ * @param a - The base negative safe integer
142
+ * @param b - The exponent negative safe integer
143
+ * @returns `a ** b` as a `NegativeSafeInt`
150
144
  */
151
145
  pow,
152
146
 
153
147
  /**
154
- * Adds two negative safe integers.
148
+ * Adds two negative safe integers, returning `a + b` as a `NegativeSafeInt`.
155
149
  *
156
- * @param a The first negative safe integer.
157
- * @param b The second negative safe integer.
158
- * @returns `a + b` clamped to the NegativeSafeInt range.
150
+ * @param a - The first negative safe integer
151
+ * @param b - The second negative safe integer
152
+ * @returns The sum of `a` and `b` as a `NegativeSafeInt`
159
153
  */
160
154
  add,
161
155
 
162
156
  /**
163
- * Subtracts one negative safe integer from another.
164
- *
165
- * The mathematical result can be positive, so it is clamped to the
166
- * NegativeSafeInt range (maximum `-1`).
157
+ * Subtracts two negative safe integers, returning `a - b` as a
158
+ * `NegativeSafeInt`.
167
159
  *
168
- * @param a The minuend negative safe integer.
169
- * @param b The subtrahend negative safe integer.
170
- * @returns `a - b` clamped to the NegativeSafeInt range.
160
+ * @param a - The first negative safe integer
161
+ * @param b - The second negative safe integer
162
+ * @returns The difference of `a` and `b` as a `NegativeSafeInt`
171
163
  */
172
164
  sub,
173
165
  } as const;
@@ -57,149 +57,159 @@ expectType<TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>, Uint>(
57
57
  );
58
58
 
59
59
  /**
60
- * Checks if a number is a NonNegativeFiniteNumber (a finite number >= 0).
60
+ * Type guard that checks if a value is a non-negative finite number.
61
61
  *
62
- * @param value The value to check.
63
- * @returns `true` if the value is a NonNegativeFiniteNumber, `false` otherwise.
62
+ * Returns `true` only for a finite value — never `NaN`, `Infinity`, or
63
+ * `-Infinity`.
64
+ *
65
+ * @param value - The value to check
66
+ * @returns `true` if the value is a non-negative finite number, `false` otherwise
64
67
  */
65
68
  export const isNonNegativeFiniteNumber = is;
66
69
 
67
70
  /**
68
- * Casts a number to a NonNegativeFiniteNumber type.
71
+ * Casts a `number` to the `NonNegativeFiniteNumber` branded type.
72
+ *
73
+ * Validates that the value is a non-negative finite number and returns it with
74
+ * the `NonNegativeFiniteNumber` brand. Throws a `TypeError` otherwise.
69
75
  *
70
- * @param value The value to cast.
71
- * @returns The value as a NonNegativeFiniteNumber type.
72
- * @throws {TypeError} If the value is not a non-negative finite number.
76
+ * @param value - The value to cast
77
+ * @returns The value as a `NonNegativeFiniteNumber`
78
+ * @throws {TypeError} If the value is not a non-negative finite number
73
79
  */
74
80
  export const asNonNegativeFiniteNumber = castType;
75
81
 
76
82
  /**
77
- * Namespace providing type-safe arithmetic operations for non-negative finite
78
- * numbers.
83
+ * Namespace providing type-safe operations for the `NonNegativeFiniteNumber`
84
+ * branded type.
79
85
  *
80
- * All operations maintain the non-negative constraint by clamping negative
81
- * results to 0, while ensuring results remain finite (excluding NaN and
82
- * Infinity). This type is useful for representing measurements, distances,
83
- * weights, and other inherently non-negative values.
86
+ * The `NonNegativeFiniteNumber` type represents a non-negative finite number.
84
87
  */
85
88
  export const NonNegativeFiniteNumber = {
86
89
  /**
87
- * Type guard to check if a value is a NonNegativeFiniteNumber.
90
+ * Type guard that checks if a value is a non-negative finite number.
88
91
  *
89
- * @param value The value to check.
90
- * @returns `true` if the value is a non-negative finite number, `false`
91
- * otherwise.
92
+ * @param value - The value to check
93
+ * @returns `true` if the value is a non-negative finite number, `false` otherwise
94
+ * @see {@link isNonNegativeFiniteNumber} for usage examples
92
95
  */
93
96
  is,
94
97
 
95
98
  /**
96
- * The minimum value for a non-negative finite number.
97
- *
98
- * @readonly
99
+ * The smallest value representable as `NonNegativeFiniteNumber`.
99
100
  */
100
101
  MIN_VALUE,
101
102
 
102
103
  /**
103
- * Returns the smaller of two NonNegativeFiniteNumber values.
104
+ * Returns the smallest of the given non-negative finite numbers.
104
105
  *
105
- * @param a The first NonNegativeFiniteNumber.
106
- * @param b The second NonNegativeFiniteNumber.
107
- * @returns The minimum value as a NonNegativeFiniteNumber.
106
+ * @param values - The non-negative finite numbers to compare (at least one required)
107
+ * @returns The smallest value as a `NonNegativeFiniteNumber`
108
108
  */
109
109
  min: min_,
110
110
 
111
111
  /**
112
- * Returns the larger of two NonNegativeFiniteNumber values.
112
+ * Returns the largest of the given non-negative finite numbers.
113
113
  *
114
- * @param a The first NonNegativeFiniteNumber.
115
- * @param b The second NonNegativeFiniteNumber.
116
- * @returns The maximum value as a NonNegativeFiniteNumber.
114
+ * @param values - The non-negative finite numbers to compare (at least one required)
115
+ * @returns The largest value as a `NonNegativeFiniteNumber`
117
116
  */
118
117
  max: max_,
119
118
 
120
119
  /**
121
- * Clamps a number to the non-negative finite range.
120
+ * Clamps a `number` into the `NonNegativeFiniteNumber` range `[MIN_VALUE,
121
+ * MAX_VALUE]`.
122
122
  *
123
- * @param value The number to clamp.
124
- * @returns The value clamped to [0, +∞) as a NonNegativeFiniteNumber.
123
+ * @param value - The value to clamp
124
+ * @returns The clamped value as a `NonNegativeFiniteNumber`
125
125
  */
126
126
  clamp,
127
127
 
128
128
  /**
129
- * Rounds down a NonNegativeFiniteNumber to the nearest integer.
129
+ * Returns the greatest integer less than or equal to a non-negative finite
130
+ * number.
130
131
  *
131
- * @param x The NonNegativeFiniteNumber to round down.
132
- * @returns The floor value as a Uint.
132
+ * @param a - The non-negative finite number value
133
+ * @returns The floored value as an integer
133
134
  */
134
135
  floor,
135
136
 
136
137
  /**
137
- * Rounds up a NonNegativeFiniteNumber to the nearest integer.
138
+ * Returns the smallest integer greater than or equal to a non-negative finite
139
+ * number.
138
140
  *
139
- * @param x The NonNegativeFiniteNumber to round up.
140
- * @returns The ceiling value as a Uint.
141
+ * @param a - The non-negative finite number value
142
+ * @returns The ceiled value as an integer
141
143
  */
142
144
  ceil,
143
145
 
144
146
  /**
145
- * Rounds a NonNegativeFiniteNumber to the nearest integer.
147
+ * Returns the value of a non-negative finite number rounded to the nearest
148
+ * integer.
146
149
  *
147
- * @param x The NonNegativeFiniteNumber to round.
148
- * @returns The rounded value as a Uint.
150
+ * @param a - The non-negative finite number value
151
+ * @returns The rounded value as an integer
149
152
  */
150
153
  round,
151
154
 
152
155
  /**
153
- * Generates a random NonNegativeFiniteNumber value.
156
+ * Generates a random `NonNegativeFiniteNumber` within the given range.
157
+ *
158
+ * The range is inclusive on both ends.
154
159
  *
155
- * @returns A random non-negative finite number.
160
+ * @param min - The minimum value (inclusive)
161
+ * @param max - The maximum value (inclusive)
162
+ * @returns A random `NonNegativeFiniteNumber` in `[min, max]`
156
163
  */
157
164
  random,
158
165
 
159
166
  /**
160
- * Raises a NonNegativeFiniteNumber to the power of another
161
- * NonNegativeFiniteNumber.
167
+ * Raises `a` to the power `b`, returning `a ** b` as a
168
+ * `NonNegativeFiniteNumber`.
162
169
  *
163
- * @param a The base NonNegativeFiniteNumber.
164
- * @param b The exponent NonNegativeFiniteNumber.
165
- * @returns `a ** b` clamped to [0, +∞) as a NonNegativeFiniteNumber.
170
+ * @param a - The base non-negative finite number
171
+ * @param b - The exponent non-negative finite number
172
+ * @returns `a ** b` as a `NonNegativeFiniteNumber`
166
173
  */
167
174
  pow,
168
175
 
169
176
  /**
170
- * Adds two NonNegativeFiniteNumber values.
177
+ * Adds two non-negative finite numbers, returning `a + b` as a
178
+ * `NonNegativeFiniteNumber`.
171
179
  *
172
- * @param a The first NonNegativeFiniteNumber.
173
- * @param b The second NonNegativeFiniteNumber.
174
- * @returns `a + b` clamped to [0, +∞) as a NonNegativeFiniteNumber.
180
+ * @param a - The first non-negative finite number
181
+ * @param b - The second non-negative finite number
182
+ * @returns The sum of `a` and `b` as a `NonNegativeFiniteNumber`
175
183
  */
176
184
  add,
177
185
 
178
186
  /**
179
- * Subtracts one NonNegativeFiniteNumber from another.
187
+ * Subtracts two non-negative finite numbers, returning `a - b` as a
188
+ * `NonNegativeFiniteNumber`.
180
189
  *
181
- * @param a The minuend NonNegativeFiniteNumber.
182
- * @param b The subtrahend NonNegativeFiniteNumber.
183
- * @returns `a - b` clamped to [0, +∞) as a NonNegativeFiniteNumber (minimum
184
- * 0).
190
+ * @param a - The first non-negative finite number
191
+ * @param b - The second non-negative finite number
192
+ * @returns The difference of `a` and `b` as a `NonNegativeFiniteNumber`
185
193
  */
186
194
  sub,
187
195
 
188
196
  /**
189
- * Multiplies two NonNegativeFiniteNumber values.
197
+ * Multiplies two non-negative finite numbers, returning `a * b` as a
198
+ * `NonNegativeFiniteNumber`.
190
199
  *
191
- * @param a The first NonNegativeFiniteNumber.
192
- * @param b The second NonNegativeFiniteNumber.
193
- * @returns `a * b` clamped to [0, +∞) as a NonNegativeFiniteNumber.
200
+ * @param a - The first non-negative finite number
201
+ * @param b - The second non-negative finite number
202
+ * @returns The product of `a` and `b` as a `NonNegativeFiniteNumber`
194
203
  */
195
204
  mul,
196
205
 
197
206
  /**
198
- * Divides one NonNegativeFiniteNumber by another.
207
+ * Divides two non-negative finite numbers, returning `a / b` as a
208
+ * `NonNegativeFiniteNumber`.
199
209
  *
200
- * @param a The dividend NonNegativeFiniteNumber.
201
- * @param b The divisor NonNegativeFiniteNumber.
202
- * @returns `a / b` clamped to [0, +∞) as a NonNegativeFiniteNumber.
210
+ * @param a - The dividend
211
+ * @param b - The divisor (must be non-zero)
212
+ * @returns `a / b` as a `NonNegativeFiniteNumber`
203
213
  */
204
214
  div,
205
215
  } as const;
@@ -34,131 +34,138 @@ const {
34
34
  } as const);
35
35
 
36
36
  /**
37
- * Checks if a number is a NonNegativeInt16 (16-bit non-negative signed integer
38
- * in the range [0, 2^15)).
37
+ * Type guard that checks if a value is a non-negative integer in [0, 2^15).
39
38
  *
40
- * @param value The value to check.
41
- * @returns `true` if the value is a NonNegativeInt16, `false` otherwise.
39
+ * Returns `true` for a non-negative integer in [0, 2^15) — a value with no
40
+ * fractional component.
41
+ *
42
+ * @param value - The value to check
43
+ * @returns `true` if the value is a non-negative integer in [0, 2^15), `false` otherwise
42
44
  */
43
45
  export const isNonNegativeInt16 = is;
44
46
 
45
47
  /**
46
- * Casts a number to a NonNegativeInt16 type.
48
+ * Casts a `number` to the `NonNegativeInt16` branded type.
49
+ *
50
+ * Validates that the value is a non-negative integer in [0, 2^15) and returns
51
+ * it with the `NonNegativeInt16` brand. Throws a `TypeError` otherwise.
47
52
  *
48
- * @param value The value to cast.
49
- * @returns The value as a NonNegativeInt16 type.
50
- * @throws {TypeError} If the value is not a non-negative integer in [0, 2^15).
53
+ * @param value - The value to cast
54
+ * @returns The value as a `NonNegativeInt16`
55
+ * @throws {TypeError} If the value is not a non-negative integer in [0, 2^15)
51
56
  */
52
57
  export const asNonNegativeInt16 = castType;
53
58
 
54
59
  /**
55
- * Namespace providing type-safe arithmetic operations for 16-bit non-negative
56
- * integers.
60
+ * Namespace providing type-safe operations for the `NonNegativeInt16` branded
61
+ * type.
57
62
  *
58
- * All operations automatically clamp results to the valid NonNegativeInt16
59
- * range [0, 32767]. This ensures that all arithmetic maintains the 16-bit
60
- * non-negative integer constraint, with negative results clamped to 0 and
61
- * overflow results clamped to MAX_VALUE.
63
+ * The `NonNegativeInt16` type represents a non-negative integer in [0, 2^15).
64
+ * Division (`div`) uses floor division.
62
65
  */
63
66
  export const NonNegativeInt16 = {
64
67
  /**
65
- * Type guard to check if a value is a NonNegativeInt16.
68
+ * Type guard that checks if a value is a non-negative integer in [0, 2^15).
66
69
  *
67
- * @param value The value to check.
68
- * @returns `true` if the value is a 16-bit non-negative integer, `false`
69
- * otherwise.
70
+ * @param value - The value to check
71
+ * @returns `true` if the value is a non-negative integer in [0, 2^15), `false` otherwise
72
+ * @see {@link isNonNegativeInt16} for usage examples
70
73
  */
71
74
  is,
72
75
 
73
76
  /**
74
- * The minimum value for a 16-bit non-negative integer.
75
- *
76
- * @readonly
77
+ * The smallest value representable as `NonNegativeInt16`.
77
78
  */
78
79
  MIN_VALUE,
79
80
 
80
81
  /**
81
- * The maximum value for a 16-bit non-negative integer.
82
- *
83
- * @readonly
82
+ * The largest value representable as `NonNegativeInt16`.
84
83
  */
85
84
  MAX_VALUE,
86
85
 
87
86
  /**
88
- * Returns the smaller of two NonNegativeInt16 values.
87
+ * Returns the smallest of the given non-negative integers.
89
88
  *
90
- * @param a The first NonNegativeInt16.
91
- * @param b The second NonNegativeInt16.
92
- * @returns The minimum value as a NonNegativeInt16.
89
+ * @param values - The non-negative integers to compare (at least one required)
90
+ * @returns The smallest value as a `NonNegativeInt16`
93
91
  */
94
92
  min: min_,
95
93
 
96
94
  /**
97
- * Returns the larger of two NonNegativeInt16 values.
95
+ * Returns the largest of the given non-negative integers.
98
96
  *
99
- * @param a The first NonNegativeInt16.
100
- * @param b The second NonNegativeInt16.
101
- * @returns The maximum value as a NonNegativeInt16.
97
+ * @param values - The non-negative integers to compare (at least one required)
98
+ * @returns The largest value as a `NonNegativeInt16`
102
99
  */
103
100
  max: max_,
104
101
 
105
102
  /**
106
- * Clamps a number to the NonNegativeInt16 range.
103
+ * Clamps a `number` into the `NonNegativeInt16` range, rounding to the
104
+ * nearest 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 [0, 32767] as a NonNegativeInt16.
106
+ * @param value - The value to clamp
107
+ * @returns The clamped value as a `NonNegativeInt16`
110
108
  */
111
109
  clamp,
112
110
 
113
111
  /**
114
- * Generates a random NonNegativeInt16 value within the valid range.
112
+ * Generates a random `NonNegativeInt16` within the given range.
113
+ *
114
+ * The range is inclusive on both ends.
115
115
  *
116
- * @returns A random NonNegativeInt16 between 0 and 32767.
116
+ * @param min - The minimum value (inclusive)
117
+ * @param max - The maximum value (inclusive)
118
+ * @returns A random `NonNegativeInt16` in `[min, max]`
117
119
  */
118
120
  random,
119
121
 
120
122
  /**
121
- * Raises a NonNegativeInt16 to the power of another NonNegativeInt16.
123
+ * Raises `a` to the power `b`, returning `a ** b` as a `NonNegativeInt16`
124
+ * (floored to an integer).
122
125
  *
123
- * @param a The base NonNegativeInt16.
124
- * @param b The exponent NonNegativeInt16.
125
- * @returns `a ** b` clamped to [0, 32767] as a NonNegativeInt16.
126
+ * @param a - The base non-negative integer
127
+ * @param b - The exponent non-negative integer
128
+ * @returns `a ** b` as a `NonNegativeInt16`
126
129
  */
127
130
  pow,
128
131
 
129
132
  /**
130
- * Adds two NonNegativeInt16 values.
133
+ * Adds two non-negative integers, returning `a + b` as a `NonNegativeInt16`.
131
134
  *
132
- * @param a The first NonNegativeInt16.
133
- * @param b The second NonNegativeInt16.
134
- * @returns `a + b` clamped to [0, 32767] as a NonNegativeInt16.
135
+ * @param a - The first non-negative integer
136
+ * @param b - The second non-negative integer
137
+ * @returns The sum of `a` and `b` as a `NonNegativeInt16`
135
138
  */
136
139
  add,
137
140
 
138
141
  /**
139
- * Subtracts one NonNegativeInt16 from another.
142
+ * Subtracts two non-negative integers, returning `a - b` as a
143
+ * `NonNegativeInt16`.
140
144
  *
141
- * @param a The minuend NonNegativeInt16.
142
- * @param b The subtrahend NonNegativeInt16.
143
- * @returns `a - b` clamped to [0, 32767] as a NonNegativeInt16 (minimum 0).
145
+ * @param a - The first non-negative integer
146
+ * @param b - The second non-negative integer
147
+ * @returns The difference of `a` and `b` as a `NonNegativeInt16`
144
148
  */
145
149
  sub,
146
150
 
147
151
  /**
148
- * Multiplies two NonNegativeInt16 values.
152
+ * Multiplies two non-negative integers, returning `a * b` as a
153
+ * `NonNegativeInt16`.
149
154
  *
150
- * @param a The first NonNegativeInt16.
151
- * @param b The second NonNegativeInt16.
152
- * @returns `a * b` clamped to [0, 32767] as a NonNegativeInt16.
155
+ * @param a - The first non-negative integer
156
+ * @param b - The second non-negative integer
157
+ * @returns The product of `a` and `b` as a `NonNegativeInt16`
153
158
  */
154
159
  mul,
155
160
 
156
161
  /**
157
- * Divides one NonNegativeInt16 by another using floor division.
162
+ * Divides two non-negative integers using floor division (`⌊a / b⌋`): the
163
+ * result is `a / b` rounded toward negative infinity, as a
164
+ * `NonNegativeInt16`.
158
165
  *
159
- * @param a The dividend NonNegativeInt16.
160
- * @param b The divisor NonNegativeInt16.
161
- * @returns `⌊a / b⌋` clamped to [0, 32767] as a NonNegativeInt16.
166
+ * @param a - The dividend
167
+ * @param b - The divisor (must be non-zero)
168
+ * @returns The floored quotient as a `NonNegativeInt16`
162
169
  */
163
170
  div,
164
171
  } as const;