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
@@ -59,47 +59,37 @@ expectType<TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>, Int>(
59
59
  /**
60
60
  * Type guard that checks if a value is a finite number.
61
61
  *
62
- * Returns `true` if the value is a finite number (not NaN, Infinity, or
63
- * -Infinity). This is stricter than the standard number type, which includes
64
- * these special values.
62
+ * Returns `true` only for a finite value — never `NaN`, `Infinity`, or
63
+ * `-Infinity`.
65
64
  *
66
65
  * @param value - The value to check
67
- * @returns `true` if the value is finite, `false` otherwise
66
+ * @returns `true` if the value is a finite number, `false` otherwise
68
67
  */
69
68
  export const isFiniteNumber = is;
70
69
 
71
70
  /**
72
- * Casts a number to a FiniteNumber branded type.
71
+ * Casts a `number` to the `FiniteNumber` branded type.
73
72
  *
74
- * This function validates that the input is finite (not NaN, Infinity, or
75
- * -Infinity) and returns it with the FiniteNumber brand. This ensures type
76
- * safety for operations that require finite numeric values.
73
+ * Validates that the value is a finite number and returns it with the
74
+ * `FiniteNumber` brand. Throws a `TypeError` otherwise.
77
75
  *
78
76
  * @param value - The value to cast
79
- * @returns The value as a FiniteNumber branded type
80
- * @throws {TypeError} If the value is NaN, Infinity, or -Infinity
77
+ * @returns The value as a `FiniteNumber`
78
+ * @throws {TypeError} If the value is not a finite number
81
79
  */
82
80
  export const asFiniteNumber = castType;
83
81
 
84
82
  /**
85
- * Namespace providing type-safe operations for FiniteNumber branded types.
83
+ * Namespace providing type-safe operations for the `FiniteNumber` branded type.
86
84
  *
87
- * The FiniteNumber type represents any finite numeric value, excluding the
88
- * special values NaN, Infinity, and -Infinity. All operations are guaranteed to
89
- * maintain the finite constraint when given finite inputs.
90
- *
91
- * This type is essential for:
92
- *
93
- * - Mathematical operations that require real numbers
94
- * - Preventing NaN/Infinity propagation in calculations
95
- * - Ensuring numeric stability in algorithms
85
+ * The `FiniteNumber` type represents a finite number.
96
86
  */
97
87
  export const FiniteNumber = {
98
88
  /**
99
89
  * Type guard that checks if a value is a finite number.
100
90
  *
101
91
  * @param value - The value to check
102
- * @returns `true` if the value is finite, `false` otherwise
92
+ * @returns `true` if the value is a finite number, `false` otherwise
103
93
  * @see {@link isFiniteNumber} for usage examples
104
94
  */
105
95
  is,
@@ -107,110 +97,106 @@ export const FiniteNumber = {
107
97
  /**
108
98
  * Returns the absolute value of a finite number.
109
99
  *
110
- * @param x - The finite number to get the absolute value of
111
- * @returns The absolute value as a FiniteNumber
100
+ * The result is non-negative and keeps the `FiniteNumber` brand.
101
+ *
102
+ * @param a - The finite number value
103
+ * @returns The absolute value as a non-negative `FiniteNumber`
112
104
  */
113
105
  abs,
114
106
 
115
107
  /**
116
- * Returns the minimum value from a list of finite numbers.
108
+ * Returns the smallest of the given finite numbers.
117
109
  *
118
110
  * @param values - The finite numbers to compare (at least one required)
119
- * @returns The smallest value as a FiniteNumber
111
+ * @returns The smallest value as a `FiniteNumber`
120
112
  */
121
113
  min: min_,
122
114
 
123
115
  /**
124
- * Returns the maximum value from a list of finite numbers.
116
+ * Returns the largest of the given finite numbers.
125
117
  *
126
118
  * @param values - The finite numbers to compare (at least one required)
127
- * @returns The largest value as a FiniteNumber
119
+ * @returns The largest value as a `FiniteNumber`
128
120
  */
129
121
  max: max_,
130
122
 
131
123
  /**
132
- * Returns the largest integer less than or equal to the given finite number.
124
+ * Returns the greatest integer less than or equal to a finite number.
133
125
  *
134
- * @param x - The finite number to floor
135
- * @returns The floor value as an Int
126
+ * @param a - The finite number value
127
+ * @returns The floored value as an integer
136
128
  */
137
129
  floor,
138
130
 
139
131
  /**
140
- * Returns the smallest integer greater than or equal to the given finite
141
- * number.
132
+ * Returns the smallest integer greater than or equal to a finite number.
142
133
  *
143
- * @param x - The finite number to ceil
144
- * @returns The ceiling value as an Int
134
+ * @param a - The finite number value
135
+ * @returns The ceiled value as an integer
145
136
  */
146
137
  ceil,
147
138
 
148
139
  /**
149
- * Rounds a finite number to the nearest integer.
140
+ * Returns the value of a finite number rounded to the nearest integer.
150
141
  *
151
- * @param x - The finite number to round
152
- * @returns The rounded value as an Int
142
+ * @param a - The finite number value
143
+ * @returns The rounded value as an integer
153
144
  */
154
145
  round,
155
146
 
156
147
  /**
157
- * Generates a random finite number within the specified range.
148
+ * Generates a random `FiniteNumber` within the given range.
158
149
  *
159
- * The generated value is uniformly distributed in the range [min, max]. Both
160
- * bounds are inclusive.
150
+ * The range is inclusive on both ends.
161
151
  *
162
152
  * @param min - The minimum value (inclusive)
163
153
  * @param max - The maximum value (inclusive)
164
- * @returns A random FiniteNumber in the range [min, max]
154
+ * @returns A random `FiniteNumber` in `[min, max]`
165
155
  */
166
156
  random,
167
157
 
168
158
  /**
169
- * Raises a finite number to a power.
159
+ * Raises `a` to the power `b`, returning `a ** b` as a `FiniteNumber`.
170
160
  *
171
161
  * @param a - The base finite number
172
162
  * @param b - The exponent finite number
173
- * @returns `a ** b` as a FiniteNumber
163
+ * @returns `a ** b` as a `FiniteNumber`
174
164
  */
175
165
  pow,
176
166
 
177
167
  /**
178
- * Adds two finite numbers.
168
+ * Adds two finite numbers, returning `a + b` as a `FiniteNumber`.
179
169
  *
180
- * @param a - First finite number
181
- * @param b - Second finite number
182
- * @returns `a + b` as a FiniteNumber
170
+ * @param a - The first finite number
171
+ * @param b - The second finite number
172
+ * @returns The sum of `a` and `b` as a `FiniteNumber`
183
173
  */
184
174
  add,
185
175
 
186
176
  /**
187
- * Subtracts two finite numbers.
177
+ * Subtracts two finite numbers, returning `a - b` as a `FiniteNumber`.
188
178
  *
189
- * @param a - First finite number
190
- * @param b - Second finite number
191
- * @returns `a - b` as a FiniteNumber
179
+ * @param a - The first finite number
180
+ * @param b - The second finite number
181
+ * @returns The difference of `a` and `b` as a `FiniteNumber`
192
182
  */
193
183
  sub,
194
184
 
195
185
  /**
196
- * Multiplies two finite numbers.
186
+ * Multiplies two finite numbers, returning `a * b` as a `FiniteNumber`.
197
187
  *
198
- * @param a - First finite number
199
- * @param b - Second finite number
200
- * @returns `a * b` as a FiniteNumber
188
+ * @param a - The first finite number
189
+ * @param b - The second finite number
190
+ * @returns The product of `a` and `b` as a `FiniteNumber`
201
191
  */
202
192
  mul,
203
193
 
204
194
  /**
205
- * Divides two finite numbers.
206
- *
207
- * The divisor must be non-zero (enforced by type constraints). The result is
208
- * guaranteed to be finite when both inputs are finite and the divisor is
209
- * non-zero.
195
+ * Divides two finite numbers, returning `a / b` as a `FiniteNumber`.
210
196
  *
211
197
  * @param a - The dividend
212
198
  * @param b - The divisor (must be non-zero)
213
- * @returns The quotient `a / b` as a FiniteNumber
199
+ * @returns `a / b` as a `FiniteNumber`
214
200
  */
215
201
  div,
216
202
  } as const;
@@ -34,9 +34,8 @@ const {
34
34
  /**
35
35
  * Type guard that checks if a value is an integer.
36
36
  *
37
- * Returns `true` if the value is any integer (positive, negative, or zero),
38
- * with no fractional component. This includes values outside the safe integer
39
- * range, unlike SafeInt.
37
+ * Returns `true` for an integer — a value with no fractional component,
38
+ * including values outside the safe integer range (unlike `SafeInt`).
40
39
  *
41
40
  * @example
42
41
  *
@@ -54,11 +53,10 @@ const {
54
53
  export const isInt = is;
55
54
 
56
55
  /**
57
- * Casts a number to an Int branded type.
56
+ * Casts a `number` to the `Int` branded type.
58
57
  *
59
- * This function validates that the input is an integer and returns it with the
60
- * Int brand. Throws a TypeError if the value has a fractional component or is
61
- * not a finite number.
58
+ * Validates that the value is an integer and returns it with the `Int` brand.
59
+ * Throws a `TypeError` otherwise.
62
60
  *
63
61
  * @example
64
62
  *
@@ -71,21 +69,19 @@ export const isInt = is;
71
69
  * ```
72
70
  *
73
71
  * @param value - The value to cast
74
- * @returns The value as an Int branded type
72
+ * @returns The value as an `Int`
75
73
  * @throws {TypeError} If the value is not an integer
76
74
  */
77
75
  export const asInt = castType;
78
76
 
79
77
  /**
80
- * Namespace providing type-safe operations for Int branded types.
78
+ * Namespace providing type-safe operations for the `Int` branded type.
81
79
  *
82
- * The Int type represents any integer value (no fractional component) without
83
- * range restrictions. All operations preserve the integer constraint, using
84
- * floor division for division operations.
80
+ * The `Int` type represents an integer. Division (`div`) uses floor division.
85
81
  *
86
- * Unlike SafeInt, Int allows values outside the safe integer range (±2^53 - 1),
87
- * but be aware that very large integers may lose precision in JavaScript's
88
- * number type.
82
+ * Unlike `SafeInt`, `Int` allows values outside the safe integer range (±2^53 −
83
+ * 1), so very large magnitudes may lose precision in JavaScript's `number`
84
+ * type.
89
85
  */
90
86
  export const Int = {
91
87
  /**
@@ -110,9 +106,9 @@ export const Int = {
110
106
  /**
111
107
  * Returns the absolute value of an integer.
112
108
  *
113
- * The result is always non-negative and maintains the Int brand. Note that
114
- * Math.abs(Number.MIN_SAFE_INTEGER) exceeds Number.MAX_SAFE_INTEGER, so use
115
- * SafeInt for guaranteed precision.
109
+ * The result is non-negative and keeps the `Int` brand. Note that
110
+ * `Math.abs(Number.MIN_SAFE_INTEGER)` exceeds `Number.MAX_SAFE_INTEGER`, so
111
+ * use `SafeInt` for guaranteed precision.
116
112
  *
117
113
  * @example
118
114
  *
@@ -127,12 +123,12 @@ export const Int = {
127
123
  * ```
128
124
  *
129
125
  * @param a - The integer value
130
- * @returns The absolute value as a non-negative Int
126
+ * @returns The absolute value as a non-negative `Int`
131
127
  */
132
128
  abs,
133
129
 
134
130
  /**
135
- * Returns the minimum value from a list of integers.
131
+ * Returns the smallest of the given integers.
136
132
  *
137
133
  * @example
138
134
  *
@@ -143,12 +139,12 @@ export const Int = {
143
139
  * ```
144
140
  *
145
141
  * @param values - The integers to compare (at least one required)
146
- * @returns The smallest value as an Int
142
+ * @returns The smallest value as an `Int`
147
143
  */
148
144
  min: min_,
149
145
 
150
146
  /**
151
- * Returns the maximum value from a list of integers.
147
+ * Returns the largest of the given integers.
152
148
  *
153
149
  * @example
154
150
  *
@@ -159,15 +155,14 @@ export const Int = {
159
155
  * ```
160
156
  *
161
157
  * @param values - The integers to compare (at least one required)
162
- * @returns The largest value as an Int
158
+ * @returns The largest value as an `Int`
163
159
  */
164
160
  max: max_,
165
161
 
166
162
  /**
167
- * Generates a random integer within the specified range (inclusive).
163
+ * Generates a random `Int` within the given range.
168
164
  *
169
- * The range is inclusive on both ends, so random(1, 6) can return any of: 1,
170
- * 2, 3, 4, 5, or 6.
165
+ * The range is inclusive on both ends.
171
166
  *
172
167
  * @example
173
168
  *
@@ -185,12 +180,13 @@ export const Int = {
185
180
  *
186
181
  * @param min - The minimum value (inclusive)
187
182
  * @param max - The maximum value (inclusive)
188
- * @returns A random Int in the range [min, max]
183
+ * @returns A random `Int` in `[min, max]`
189
184
  */
190
185
  random,
191
186
 
192
187
  /**
193
- * Raises an integer to a power.
188
+ * Raises `a` to the power `b`, returning `a ** b` as an `Int` (floored to an
189
+ * integer).
194
190
  *
195
191
  * @example
196
192
  *
@@ -206,12 +202,12 @@ export const Int = {
206
202
  *
207
203
  * @param a - The base integer
208
204
  * @param b - The exponent integer
209
- * @returns `a ** b` as an Int
205
+ * @returns `a ** b` as an `Int`
210
206
  */
211
207
  pow,
212
208
 
213
209
  /**
214
- * Adds two integers.
210
+ * Adds two integers, returning `a + b` as an `Int`.
215
211
  *
216
212
  * @example
217
213
  *
@@ -221,14 +217,14 @@ export const Int = {
221
217
  * assert.isTrue(sum === 20);
222
218
  * ```
223
219
  *
224
- * @param a - First integer
225
- * @param b - Second integer
226
- * @returns `a + b` as an Int
220
+ * @param a - The first integer
221
+ * @param b - The second integer
222
+ * @returns The sum of `a` and `b` as an `Int`
227
223
  */
228
224
  add,
229
225
 
230
226
  /**
231
- * Subtracts two integers.
227
+ * Subtracts two integers, returning `a - b` as an `Int`.
232
228
  *
233
229
  * @example
234
230
  *
@@ -238,14 +234,14 @@ export const Int = {
238
234
  * assert.isTrue(difference === 4);
239
235
  * ```
240
236
  *
241
- * @param a - First integer
242
- * @param b - Second integer
243
- * @returns `a - b` as an Int
237
+ * @param a - The first integer
238
+ * @param b - The second integer
239
+ * @returns The difference of `a` and `b` as an `Int`
244
240
  */
245
241
  sub,
246
242
 
247
243
  /**
248
- * Multiplies two integers.
244
+ * Multiplies two integers, returning `a * b` as an `Int`.
249
245
  *
250
246
  * @example
251
247
  *
@@ -255,17 +251,15 @@ export const Int = {
255
251
  * assert.isTrue(product === -24);
256
252
  * ```
257
253
  *
258
- * @param a - First integer
259
- * @param b - Second integer
260
- * @returns `a * b` as an Int
254
+ * @param a - The first integer
255
+ * @param b - The second integer
256
+ * @returns The product of `a` and `b` as an `Int`
261
257
  */
262
258
  mul,
263
259
 
264
260
  /**
265
- * Divides two integers using floor division.
266
- *
267
- * Performs mathematical floor division: `⌊a / b⌋`. The result is always an
268
- * integer, rounding toward negative infinity.
261
+ * Divides two integers using floor division (`⌊a / b⌋`): the result is `a /
262
+ * b` rounded toward negative infinity, as an `Int`.
269
263
  *
270
264
  * @example
271
265
  *
@@ -281,7 +275,7 @@ export const Int = {
281
275
  *
282
276
  * @param a - The dividend
283
277
  * @param b - The divisor (must be non-zero)
284
- * @returns The integer quotient as an Int
278
+ * @returns The floored quotient as an `Int`
285
279
  */
286
280
  div,
287
281
  } as const;
@@ -35,137 +35,144 @@ const {
35
35
  } as const);
36
36
 
37
37
  /**
38
- * Checks if a number is an Int16 (16-bit signed integer in the range [-2^15,
39
- * 2^15)).
38
+ * Type guard that checks if a value is an integer in [-2^15, 2^15).
40
39
  *
41
- * @param value The value to check.
42
- * @returns `true` if the value is an Int16, `false` otherwise.
40
+ * Returns `true` for an integer in [-2^15, 2^15) — a value with no fractional
41
+ * component.
42
+ *
43
+ * @param value - The value to check
44
+ * @returns `true` if the value is an integer in [-2^15, 2^15), `false` otherwise
43
45
  */
44
46
  export const isInt16 = is;
45
47
 
46
48
  /**
47
- * Casts a number to an Int16 type.
49
+ * Casts a `number` to the `Int16` branded type.
50
+ *
51
+ * Validates that the value is an integer in [-2^15, 2^15) and returns it with
52
+ * the `Int16` brand. Throws a `TypeError` otherwise.
48
53
  *
49
- * @param value The value to cast.
50
- * @returns The value as an Int16 type.
51
- * @throws {TypeError} If the value is not an integer in [-2^15, 2^15).
54
+ * @param value - The value to cast
55
+ * @returns The value as an `Int16`
56
+ * @throws {TypeError} If the value is not an integer in [-2^15, 2^15)
52
57
  */
53
58
  export const asInt16 = castType;
54
59
 
55
60
  /**
56
- * Namespace providing type-safe arithmetic operations for 16-bit signed
57
- * integers.
61
+ * Namespace providing type-safe operations for the `Int16` branded type.
58
62
  *
59
- * All operations automatically clamp results to the valid Int16 range [-32768,
60
- * 32767]. This ensures that all arithmetic maintains the 16-bit signed integer
61
- * constraint.
63
+ * The `Int16` type represents an integer in [-2^15, 2^15). Division (`div`)
64
+ * uses floor division.
62
65
  */
63
66
  export const Int16 = {
64
67
  /**
65
- * Type guard to check if a value is an Int16.
68
+ * Type guard that checks if a value is an integer in [-2^15, 2^15).
66
69
  *
67
- * @param value The value to check.
68
- * @returns `true` if the value is a 16-bit signed integer, `false` otherwise.
70
+ * @param value - The value to check
71
+ * @returns `true` if the value is an integer in [-2^15, 2^15), `false` otherwise
72
+ * @see {@link isInt16} for usage examples
69
73
  */
70
74
  is,
71
75
 
72
76
  /**
73
- * The minimum value for a 16-bit signed integer.
74
- *
75
- * @readonly
77
+ * The smallest value representable as `Int16`.
76
78
  */
77
79
  MIN_VALUE,
78
80
 
79
81
  /**
80
- * The maximum value for a 16-bit signed integer.
81
- *
82
- * @readonly
82
+ * The largest value representable as `Int16`.
83
83
  */
84
84
  MAX_VALUE,
85
85
 
86
86
  /**
87
- * Returns the absolute value of a 16-bit signed integer.
87
+ * Returns the absolute value of an integer in [-2^15, 2^15).
88
+ *
89
+ * The result is non-negative and keeps the `Int16` brand.
88
90
  *
89
- * @param a The Int16 value.
90
- * @returns The absolute value as an Int16, clamped to valid range.
91
+ * @param a - The integer value
92
+ * @returns The absolute value as a non-negative `Int16`
91
93
  */
92
94
  abs,
93
95
 
94
96
  /**
95
- * Returns the smaller of two Int16 values.
97
+ * Returns the smallest of the given integers.
96
98
  *
97
- * @param a The first Int16.
98
- * @param b The second Int16.
99
- * @returns The minimum value as an Int16.
99
+ * @param values - The integers to compare (at least one required)
100
+ * @returns The smallest value as an `Int16`
100
101
  */
101
102
  min: min_,
102
103
 
103
104
  /**
104
- * Returns the larger of two Int16 values.
105
+ * Returns the largest of the given integers.
105
106
  *
106
- * @param a The first Int16.
107
- * @param b The second Int16.
108
- * @returns The maximum value as an Int16.
107
+ * @param values - The integers to compare (at least one required)
108
+ * @returns The largest value as an `Int16`
109
109
  */
110
110
  max: max_,
111
111
 
112
112
  /**
113
- * Clamps a number to the Int16 range.
113
+ * Clamps a `number` into the `Int16` range, rounding to the nearest integer
114
+ * and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
114
115
  *
115
- * @param value The number to clamp.
116
- * @returns The value clamped to [-32768, 32767] as an Int16.
116
+ * @param value - The value to clamp
117
+ * @returns The clamped value as an `Int16`
117
118
  */
118
119
  clamp,
119
120
 
120
121
  /**
121
- * Generates a random Int16 value within the valid range.
122
+ * Generates a random `Int16` within the given range.
123
+ *
124
+ * The range is inclusive on both ends.
122
125
  *
123
- * @returns A random Int16 between MIN_VALUE and MAX_VALUE.
126
+ * @param min - The minimum value (inclusive)
127
+ * @param max - The maximum value (inclusive)
128
+ * @returns A random `Int16` in `[min, max]`
124
129
  */
125
130
  random,
126
131
 
127
132
  /**
128
- * Raises an Int16 to the power of another Int16.
133
+ * Raises `a` to the power `b`, returning `a ** b` as an `Int16` (floored to
134
+ * an integer).
129
135
  *
130
- * @param a The base Int16.
131
- * @param b The exponent Int16.
132
- * @returns `a ** b` clamped to [-32768, 32767] as an Int16.
136
+ * @param a - The base integer
137
+ * @param b - The exponent integer
138
+ * @returns `a ** b` as an `Int16`
133
139
  */
134
140
  pow,
135
141
 
136
142
  /**
137
- * Adds two Int16 values.
143
+ * Adds two integers, returning `a + b` as an `Int16`.
138
144
  *
139
- * @param a The first Int16.
140
- * @param b The second Int16.
141
- * @returns `a + b` clamped to [-32768, 32767] as an Int16.
145
+ * @param a - The first integer
146
+ * @param b - The second integer
147
+ * @returns The sum of `a` and `b` as an `Int16`
142
148
  */
143
149
  add,
144
150
 
145
151
  /**
146
- * Subtracts one Int16 from another.
152
+ * Subtracts two integers, returning `a - b` as an `Int16`.
147
153
  *
148
- * @param a The minuend Int16.
149
- * @param b The subtrahend Int16.
150
- * @returns `a - b` clamped to [-32768, 32767] as an Int16.
154
+ * @param a - The first integer
155
+ * @param b - The second integer
156
+ * @returns The difference of `a` and `b` as an `Int16`
151
157
  */
152
158
  sub,
153
159
 
154
160
  /**
155
- * Multiplies two Int16 values.
161
+ * Multiplies two integers, returning `a * b` as an `Int16`.
156
162
  *
157
- * @param a The first Int16.
158
- * @param b The second Int16.
159
- * @returns `a * b` clamped to [-32768, 32767] as an Int16.
163
+ * @param a - The first integer
164
+ * @param b - The second integer
165
+ * @returns The product of `a` and `b` as an `Int16`
160
166
  */
161
167
  mul,
162
168
 
163
169
  /**
164
- * Divides one Int16 by another using floor division.
170
+ * Divides two integers using floor division (`⌊a / b⌋`): the result is `a /
171
+ * b` rounded toward negative infinity, as an `Int16`.
165
172
  *
166
- * @param a The dividend Int16.
167
- * @param b The divisor Int16.
168
- * @returns `⌊a / b⌋` clamped to [-32768, 32767] as an Int16.
173
+ * @param a - The dividend
174
+ * @param b - The divisor (must be non-zero)
175
+ * @returns The floored quotient as an `Int16`
169
176
  */
170
177
  div,
171
178
  } as const;