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
@@ -60,153 +60,144 @@ const random = (min: Int8, max: Int8): Int8 =>
60
60
  castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));
61
61
 
62
62
  /**
63
- * Type guard that checks if a value is an 8-bit signed integer.
63
+ * Type guard that checks if a value is an integer in [-128, 127].
64
64
  *
65
- * An Int8 is a signed integer in the range [-128, 127], representing values
66
- * that fit in exactly 8 bits of memory.
65
+ * Returns `true` for an integer in [-128, 127] — a value with no fractional
66
+ * component.
67
67
  *
68
68
  * @param value - The value to check
69
- * @returns `true` if the value is an Int8, `false` otherwise
69
+ * @returns `true` if the value is an integer in [-128, 127], `false` otherwise
70
70
  */
71
71
  export const isInt8 = is;
72
72
 
73
73
  /**
74
- * Casts a number to an Int8 branded type.
74
+ * Casts a `number` to the `Int8` branded type.
75
75
  *
76
- * This function validates that the input is within the Int8 range [-128, 127]
77
- * and is an integer, then returns it with the Int8 brand.
76
+ * Validates that the value is an integer in [-128, 127] and returns it with the
77
+ * `Int8` brand. Throws a `TypeError` otherwise.
78
78
  *
79
79
  * @param value - The value to cast
80
- * @returns The value as an Int8 branded type
81
- * @throws {TypeError} If the value is not a valid 8-bit signed integer
80
+ * @returns The value as an `Int8`
81
+ * @throws {TypeError} If the value is not an integer in [-128, 127]
82
82
  */
83
83
  export const asInt8 = castType;
84
84
 
85
85
  /**
86
- * Namespace providing type-safe operations for Int8 (8-bit signed integer)
87
- * branded types.
86
+ * Namespace providing type-safe operations for the `Int8` branded type.
88
87
  *
89
- * Int8 represents signed integers in the range [-128, 127], equivalent to a
90
- * signed byte in many programming languages. All operations automatically clamp
91
- * results to stay within this range, preventing overflow/underflow issues.
92
- *
93
- * This type is useful for:
94
- *
95
- * - Binary data processing (signed bytes)
96
- * - Small integer values with known bounds
97
- * - Embedded systems programming
98
- * - Memory-efficient integer storage
99
- * - Image processing (signed pixel offsets)
88
+ * The `Int8` type represents an integer in [-128, 127]. Division (`div`) uses
89
+ * floor division.
100
90
  */
101
91
  export const Int8 = {
102
92
  /**
103
- * Type guard that checks if a value is an 8-bit signed integer.
93
+ * Type guard that checks if a value is an integer in [-128, 127].
104
94
  *
105
95
  * @param value - The value to check
106
- * @returns `true` if the value is in range [-128, 127] and is an integer
96
+ * @returns `true` if the value is an integer in [-128, 127], `false` otherwise
107
97
  * @see {@link isInt8} for usage examples
108
98
  */
109
99
  is,
110
100
 
111
101
  /**
112
- * The minimum value for an 8-bit signed integer.
113
- *
114
- * @readonly
102
+ * The smallest value representable as `Int8`.
115
103
  */
116
104
  MIN_VALUE,
117
105
 
118
106
  /**
119
- * The maximum value for an 8-bit signed integer.
120
- *
121
- * @readonly
107
+ * The largest value representable as `Int8`.
122
108
  */
123
109
  MAX_VALUE,
124
110
 
125
111
  /**
126
- * Returns the minimum value from a list of Int8 values.
112
+ * Returns the smallest of the given integers.
127
113
  *
128
- * @param values - The Int8 values to compare (at least one required)
129
- * @returns The smallest value as an Int8
114
+ * @param values - The integers to compare (at least one required)
115
+ * @returns The smallest value as an `Int8`
130
116
  */
131
117
  min: min_,
132
118
 
133
119
  /**
134
- * Returns the maximum value from a list of Int8 values.
120
+ * Returns the largest of the given integers.
135
121
  *
136
- * @param values - The Int8 values to compare (at least one required)
137
- * @returns The largest value as an Int8
122
+ * @param values - The integers to compare (at least one required)
123
+ * @returns The largest value as an `Int8`
138
124
  */
139
125
  max: max_,
140
126
 
141
127
  /**
142
- * Clamps a number to the Int8 range.
128
+ * Clamps a `number` into the `Int8` range, rounding to the nearest integer
129
+ * and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
143
130
  *
144
- * @param value The number to clamp.
145
- * @returns The value clamped to [-128, 127] as an Int8.
131
+ * @param value - The value to clamp
132
+ * @returns The clamped value as an `Int8`
146
133
  */
147
134
  clamp,
148
135
 
149
136
  /**
150
- * Returns the absolute value of an Int8.
137
+ * Returns the absolute value of an integer in [-128, 127].
138
+ *
139
+ * The result is non-negative and keeps the `Int8` brand.
151
140
  *
152
- * @param value The Int8 value.
153
- * @returns The absolute value as an Int8, clamped to valid range.
141
+ * @param a - The integer value
142
+ * @returns The absolute value as a non-negative `Int8`
154
143
  */
155
144
  abs,
156
145
 
157
146
  /**
158
- * Generates a random Int8 value within the specified range (inclusive).
147
+ * Generates a random `Int8` within the given range.
159
148
  *
160
- * Both bounds are inclusive. If min > max, they are automatically swapped.
149
+ * The range is inclusive on both ends.
161
150
  *
162
151
  * @param min - The minimum value (inclusive)
163
152
  * @param max - The maximum value (inclusive)
164
- * @returns A random Int8 in the range [min, max]
153
+ * @returns A random `Int8` in `[min, max]`
165
154
  */
166
155
  random,
167
156
 
168
157
  /**
169
- * Raises x to the power of y, clamped to Int8 range.
158
+ * Raises `a` to the power `b`, returning `a ** b` as an `Int8` (floored to an
159
+ * integer).
170
160
  *
171
- * @param x - The base
172
- * @param y - The exponent
173
- * @returns `x ** y` clamped to [-128, 127]
161
+ * @param a - The base integer
162
+ * @param b - The exponent integer
163
+ * @returns `a ** b` as an `Int8`
174
164
  */
175
165
  pow,
176
166
 
177
167
  /**
178
- * Adds two Int8 values, clamped to Int8 range.
168
+ * Adds two integers, returning `a + b` as an `Int8`.
179
169
  *
180
- * @param x - First operand
181
- * @param y - Second operand
182
- * @returns `x + y` clamped to [-128, 127]
170
+ * @param a - The first integer
171
+ * @param b - The second integer
172
+ * @returns The sum of `a` and `b` as an `Int8`
183
173
  */
184
174
  add,
185
175
 
186
176
  /**
187
- * Subtracts two Int8 values, clamped to Int8 range.
177
+ * Subtracts two integers, returning `a - b` as an `Int8`.
188
178
  *
189
- * @param x - First operand
190
- * @param y - Second operand
191
- * @returns `x - y` clamped to [-128, 127]
179
+ * @param a - The first integer
180
+ * @param b - The second integer
181
+ * @returns The difference of `a` and `b` as an `Int8`
192
182
  */
193
183
  sub,
194
184
 
195
185
  /**
196
- * Multiplies two Int8 values, clamped to Int8 range.
186
+ * Multiplies two integers, returning `a * b` as an `Int8`.
197
187
  *
198
- * @param x - First operand
199
- * @param y - Second operand
200
- * @returns `x * y` clamped to [-128, 127]
188
+ * @param a - The first integer
189
+ * @param b - The second integer
190
+ * @returns The product of `a` and `b` as an `Int8`
201
191
  */
202
192
  mul,
203
193
 
204
194
  /**
205
- * Divides two Int8 values, clamped to Int8 range.
195
+ * Divides two integers using floor division (`⌊a / b⌋`): the result is `a /
196
+ * b` rounded toward negative infinity, as an `Int8`.
206
197
  *
207
- * @param x - The dividend
208
- * @param y - The divisor (cannot be 0)
209
- * @returns `⌊x / y⌋` clamped to [-128, 127]
198
+ * @param a - The dividend
199
+ * @param b - The divisor (must be non-zero)
200
+ * @returns The floored quotient as an `Int8`
210
201
  */
211
202
  div,
212
203
  } as const;
@@ -50,132 +50,134 @@ const random = (min: Uint8, max: Uint8): Uint8 =>
50
50
  castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));
51
51
 
52
52
  /**
53
- * Checks if a number is a Uint8 (8-bit unsigned integer in the range [0, 255]).
53
+ * Type guard that checks if a value is an non-negative integer less than 256.
54
54
  *
55
- * @param value The value to check.
56
- * @returns `true` if the value is a Uint8, `false` otherwise.
55
+ * Returns `true` for an non-negative integer less than 256 — a value with no
56
+ * fractional component.
57
+ *
58
+ * @param value - The value to check
59
+ * @returns `true` if the value is an non-negative integer less than 256, `false` otherwise
57
60
  */
58
61
  export const isUint8 = is;
59
62
 
60
63
  /**
61
- * Casts a number to a Uint8 type. This function validates that the input is
62
- * within the Uint8 range [0, 255] and is an integer, then returns it with the
63
- * Uint8 brand.
64
+ * Casts a `number` to the `Uint8` branded type.
65
+ *
66
+ * Validates that the value is an non-negative integer less than 256 and returns
67
+ * it with the `Uint8` brand. Throws a `TypeError` otherwise.
64
68
  *
65
- * @param value The value to cast.
66
- * @returns The value as a Uint8 type.
67
- * @throws {TypeError} If the value is not a valid 8-bit unsigned integer.
69
+ * @param value - The value to cast
70
+ * @returns The value as an `Uint8`
71
+ * @throws {TypeError} If the value is not an non-negative integer less than 256
68
72
  */
69
73
  export const asUint8 = castType;
70
74
 
71
75
  /**
72
- * Namespace providing type-safe arithmetic operations for 8-bit unsigned
73
- * integers.
76
+ * Namespace providing type-safe operations for the `Uint8` branded type.
74
77
  *
75
- * All operations automatically clamp results to the valid Uint8 range [0, 255].
76
- * This ensures that all arithmetic maintains the 8-bit unsigned integer
77
- * constraint, with negative results clamped to 0 and overflow results clamped
78
- * to MAX_VALUE.
78
+ * The `Uint8` type represents an non-negative integer less than 256. Division
79
+ * (`div`) uses floor division.
79
80
  */
80
81
  export const Uint8 = {
81
82
  /**
82
- * Type guard that checks if a value is an 8-bit unsigned integer.
83
+ * Type guard that checks if a value is an non-negative integer less than 256.
83
84
  *
84
- * @param value The value to check.
85
- * @returns `true` if the value is an 8-bit unsigned integer, `false`
86
- * otherwise.
85
+ * @param value - The value to check
86
+ * @returns `true` if the value is an non-negative integer less than 256, `false` otherwise
87
+ * @see {@link isUint8} for usage examples
87
88
  */
88
89
  is,
89
90
 
90
91
  /**
91
- * The minimum value for an 8-bit unsigned integer.
92
- *
93
- * @readonly
92
+ * The smallest value representable as `Uint8`.
94
93
  */
95
94
  MIN_VALUE,
96
95
 
97
96
  /**
98
- * The maximum value for an 8-bit unsigned integer.
99
- *
100
- * @readonly
97
+ * The largest value representable as `Uint8`.
101
98
  */
102
99
  MAX_VALUE,
103
100
 
104
101
  /**
105
- * Returns the larger of the given Uint8 values.
102
+ * Returns the largest of the given non-negative integers.
106
103
  *
107
- * @param values The Uint8 values to compare.
108
- * @returns The maximum value as a Uint8.
104
+ * @param values - The non-negative integers to compare (at least one required)
105
+ * @returns The largest value as an `Uint8`
109
106
  */
110
107
  max: max_,
111
108
 
112
109
  /**
113
- * Returns the smaller of the given Uint8 values.
110
+ * Returns the smallest of the given non-negative integers.
114
111
  *
115
- * @param values The Uint8 values to compare.
116
- * @returns The minimum value as a Uint8.
112
+ * @param values - The non-negative integers to compare (at least one required)
113
+ * @returns The smallest value as an `Uint8`
117
114
  */
118
115
  min: min_,
119
116
 
120
117
  /**
121
- * Clamps a number to the Uint8 range.
118
+ * Clamps a `number` into the `Uint8` range, rounding to the nearest integer
119
+ * and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
122
120
  *
123
- * @param value The number to clamp.
124
- * @returns The value clamped to [0, 255] as a Uint8.
121
+ * @param value - The value to clamp
122
+ * @returns The clamped value as an `Uint8`
125
123
  */
126
124
  clamp,
127
125
 
128
126
  /**
129
- * Generates a random Uint8 value within the specified range.
127
+ * Generates a random `Uint8` within the given range.
128
+ *
129
+ * The range is inclusive on both ends.
130
130
  *
131
- * @param min The minimum value (inclusive).
132
- * @param max The maximum value (inclusive).
133
- * @returns A random Uint8 between min and max.
131
+ * @param min - The minimum value (inclusive)
132
+ * @param max - The maximum value (inclusive)
133
+ * @returns A random `Uint8` in `[min, max]`
134
134
  */
135
135
  random,
136
136
 
137
137
  /**
138
- * Raises x to the power of y, clamped to Uint8 range.
138
+ * Raises `a` to the power `b`, returning `a ** b` as an `Uint8` (floored to
139
+ * an integer).
139
140
  *
140
- * @param x - The base
141
- * @param y - The exponent
142
- * @returns `x ** y` clamped to [0, 255]
141
+ * @param a - The base non-negative integer
142
+ * @param b - The exponent non-negative integer
143
+ * @returns `a ** b` as an `Uint8`
143
144
  */
144
145
  pow,
145
146
 
146
147
  /**
147
- * Adds two Uint8 values, clamped to Uint8 range.
148
+ * Adds two non-negative integers, returning `a + b` as an `Uint8`.
148
149
  *
149
- * @param x - First operand
150
- * @param y - Second operand
151
- * @returns `x + y` clamped to [0, 255]
150
+ * @param a - The first non-negative integer
151
+ * @param b - The second non-negative integer
152
+ * @returns The sum of `a` and `b` as an `Uint8`
152
153
  */
153
154
  add,
154
155
 
155
156
  /**
156
- * Subtracts two Uint8 values, clamped to Uint8 range.
157
+ * Subtracts two non-negative integers, returning `a - b` as an `Uint8`.
157
158
  *
158
- * @param x - First operand
159
- * @param y - Second operand
160
- * @returns `x - y` clamped to [0, 255]
159
+ * @param a - The first non-negative integer
160
+ * @param b - The second non-negative integer
161
+ * @returns The difference of `a` and `b` as an `Uint8`
161
162
  */
162
163
  sub,
163
164
 
164
165
  /**
165
- * Multiplies two Uint8 values, clamped to Uint8 range.
166
+ * Multiplies two non-negative integers, returning `a * b` as an `Uint8`.
166
167
  *
167
- * @param x - First operand
168
- * @param y - Second operand
169
- * @returns `x * y` clamped to [0, 255]
168
+ * @param a - The first non-negative integer
169
+ * @param b - The second non-negative integer
170
+ * @returns The product of `a` and `b` as an `Uint8`
170
171
  */
171
172
  mul,
172
173
 
173
174
  /**
174
- * Divides two Uint8 values, clamped to Uint8 range.
175
+ * Divides two non-negative integers using floor division (`⌊a / b⌋`): the
176
+ * result is `a / b` rounded toward negative infinity, as an `Uint8`.
175
177
  *
176
- * @param x - The dividend
177
- * @param y - The divisor (cannot be 0)
178
- * @returns `⌊x / y⌋` clamped to [0, 255]
178
+ * @param a - The dividend
179
+ * @param b - The divisor (must be non-zero)
180
+ * @returns The floored quotient as an `Uint8`
179
181
  */
180
182
  div,
181
183
  } as const;
@@ -0,0 +1 @@
1
+ export * from './str.mjs';