ts-data-forge 1.0.0 → 1.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 (292) hide show
  1. package/README.md +1 -1
  2. package/dist/array/array-utils.d.mts +2617 -0
  3. package/dist/array/array-utils.d.mts.map +1 -0
  4. package/dist/array/array-utils.mjs +2915 -0
  5. package/dist/array/array-utils.mjs.map +1 -0
  6. package/dist/array/index.d.mts +3 -0
  7. package/dist/array/index.d.mts.map +1 -0
  8. package/dist/array/index.mjs +3 -0
  9. package/dist/array/index.mjs.map +1 -0
  10. package/dist/array/tuple-utils.d.mts +421 -0
  11. package/dist/array/tuple-utils.d.mts.map +1 -0
  12. package/dist/array/tuple-utils.mjs +391 -0
  13. package/dist/array/tuple-utils.mjs.map +1 -0
  14. package/dist/collections/imap-mapped.d.mts +445 -0
  15. package/dist/collections/imap-mapped.d.mts.map +1 -0
  16. package/dist/collections/imap-mapped.mjs +424 -0
  17. package/dist/collections/imap-mapped.mjs.map +1 -0
  18. package/dist/collections/imap.d.mts +359 -0
  19. package/dist/collections/imap.d.mts.map +1 -0
  20. package/dist/collections/imap.mjs +338 -0
  21. package/dist/collections/imap.mjs.map +1 -0
  22. package/dist/collections/index.d.mts +7 -0
  23. package/dist/collections/index.d.mts.map +1 -0
  24. package/dist/collections/index.mjs +7 -0
  25. package/dist/collections/index.mjs.map +1 -0
  26. package/dist/collections/iset-mapped.d.mts +576 -0
  27. package/dist/collections/iset-mapped.d.mts.map +1 -0
  28. package/dist/collections/iset-mapped.mjs +522 -0
  29. package/dist/collections/iset-mapped.mjs.map +1 -0
  30. package/dist/collections/iset.d.mts +426 -0
  31. package/dist/collections/iset.d.mts.map +1 -0
  32. package/dist/collections/iset.mjs +437 -0
  33. package/dist/collections/iset.mjs.map +1 -0
  34. package/dist/collections/queue.d.mts +190 -0
  35. package/dist/collections/queue.d.mts.map +1 -0
  36. package/dist/collections/queue.mjs +317 -0
  37. package/dist/collections/queue.mjs.map +1 -0
  38. package/dist/collections/stack.d.mts +210 -0
  39. package/dist/collections/stack.d.mts.map +1 -0
  40. package/dist/collections/stack.mjs +353 -0
  41. package/dist/collections/stack.mjs.map +1 -0
  42. package/dist/expect-type.d.mts +199 -0
  43. package/dist/expect-type.d.mts.map +1 -0
  44. package/dist/expect-type.mjs +201 -0
  45. package/dist/expect-type.mjs.map +1 -0
  46. package/dist/functional/index.d.mts +5 -0
  47. package/dist/functional/index.d.mts.map +1 -0
  48. package/dist/functional/index.mjs +5 -0
  49. package/dist/functional/index.mjs.map +1 -0
  50. package/dist/functional/match.d.mts +215 -0
  51. package/dist/functional/match.d.mts.map +1 -0
  52. package/dist/functional/match.mjs +139 -0
  53. package/dist/functional/match.mjs.map +1 -0
  54. package/dist/functional/optional.d.mts +517 -0
  55. package/dist/functional/optional.d.mts.map +1 -0
  56. package/dist/functional/optional.mjs +532 -0
  57. package/dist/functional/optional.mjs.map +1 -0
  58. package/dist/functional/pipe.d.mts +185 -0
  59. package/dist/functional/pipe.d.mts.map +1 -0
  60. package/dist/functional/pipe.mjs +129 -0
  61. package/dist/functional/pipe.mjs.map +1 -0
  62. package/dist/functional/result.d.mts +796 -0
  63. package/dist/functional/result.d.mts.map +1 -0
  64. package/dist/functional/result.mjs +844 -0
  65. package/dist/functional/result.mjs.map +1 -0
  66. package/dist/globals.d.mts +38 -0
  67. package/dist/guard/has-key.d.mts +100 -0
  68. package/dist/guard/has-key.d.mts.map +1 -0
  69. package/dist/guard/has-key.mjs +94 -0
  70. package/dist/guard/has-key.mjs.map +1 -0
  71. package/dist/guard/index.d.mts +8 -0
  72. package/dist/guard/index.d.mts.map +1 -0
  73. package/dist/guard/index.mjs +8 -0
  74. package/dist/guard/index.mjs.map +1 -0
  75. package/dist/guard/is-non-empty-string.d.mts +106 -0
  76. package/dist/guard/is-non-empty-string.d.mts.map +1 -0
  77. package/dist/guard/is-non-empty-string.mjs +108 -0
  78. package/dist/guard/is-non-empty-string.mjs.map +1 -0
  79. package/dist/guard/is-non-null-object.d.mts +105 -0
  80. package/dist/guard/is-non-null-object.d.mts.map +1 -0
  81. package/dist/guard/is-non-null-object.mjs +108 -0
  82. package/dist/guard/is-non-null-object.mjs.map +1 -0
  83. package/dist/guard/is-primitive.d.mts +146 -0
  84. package/dist/guard/is-primitive.d.mts.map +1 -0
  85. package/dist/guard/is-primitive.mjs +161 -0
  86. package/dist/guard/is-primitive.mjs.map +1 -0
  87. package/dist/guard/is-record.d.mts +151 -0
  88. package/dist/guard/is-record.d.mts.map +1 -0
  89. package/dist/guard/is-record.mjs +155 -0
  90. package/dist/guard/is-record.mjs.map +1 -0
  91. package/dist/guard/is-type.d.mts +430 -0
  92. package/dist/guard/is-type.d.mts.map +1 -0
  93. package/dist/guard/is-type.mjs +432 -0
  94. package/dist/guard/is-type.mjs.map +1 -0
  95. package/dist/guard/key-is-in.d.mts +158 -0
  96. package/dist/guard/key-is-in.d.mts.map +1 -0
  97. package/dist/guard/key-is-in.mjs +160 -0
  98. package/dist/guard/key-is-in.mjs.map +1 -0
  99. package/dist/index.d.mts +11 -0
  100. package/dist/index.d.mts.map +1 -0
  101. package/dist/index.mjs +61 -0
  102. package/dist/index.mjs.map +1 -0
  103. package/dist/iterator/index.d.mts +2 -0
  104. package/dist/iterator/index.d.mts.map +1 -0
  105. package/dist/iterator/index.mjs +2 -0
  106. package/dist/iterator/index.mjs.map +1 -0
  107. package/dist/iterator/range.d.mts +97 -0
  108. package/dist/iterator/range.d.mts.map +1 -0
  109. package/dist/iterator/range.mjs +130 -0
  110. package/dist/iterator/range.mjs.map +1 -0
  111. package/dist/json/index.d.mts +2 -0
  112. package/dist/json/index.d.mts.map +1 -0
  113. package/dist/json/index.mjs +2 -0
  114. package/dist/json/index.mjs.map +1 -0
  115. package/dist/json/json.d.mts +597 -0
  116. package/dist/json/json.d.mts.map +1 -0
  117. package/dist/json/json.mjs +687 -0
  118. package/dist/json/json.mjs.map +1 -0
  119. package/dist/number/branded-types/finite-number.d.mts +291 -0
  120. package/dist/number/branded-types/finite-number.d.mts.map +1 -0
  121. package/dist/number/branded-types/finite-number.mjs +296 -0
  122. package/dist/number/branded-types/finite-number.mjs.map +1 -0
  123. package/dist/number/branded-types/index.d.mts +27 -0
  124. package/dist/number/branded-types/index.d.mts.map +1 -0
  125. package/dist/number/branded-types/index.mjs +27 -0
  126. package/dist/number/branded-types/index.mjs.map +1 -0
  127. package/dist/number/branded-types/int.d.mts +242 -0
  128. package/dist/number/branded-types/int.d.mts.map +1 -0
  129. package/dist/number/branded-types/int.mjs +239 -0
  130. package/dist/number/branded-types/int.mjs.map +1 -0
  131. package/dist/number/branded-types/int16.d.mts +162 -0
  132. package/dist/number/branded-types/int16.d.mts.map +1 -0
  133. package/dist/number/branded-types/int16.mjs +141 -0
  134. package/dist/number/branded-types/int16.mjs.map +1 -0
  135. package/dist/number/branded-types/int32.d.mts +155 -0
  136. package/dist/number/branded-types/int32.d.mts.map +1 -0
  137. package/dist/number/branded-types/int32.mjs +142 -0
  138. package/dist/number/branded-types/int32.mjs.map +1 -0
  139. package/dist/number/branded-types/non-negative-finite-number.d.mts +165 -0
  140. package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -0
  141. package/dist/number/branded-types/non-negative-finite-number.mjs +160 -0
  142. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -0
  143. package/dist/number/branded-types/non-negative-int16.d.mts +160 -0
  144. package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -0
  145. package/dist/number/branded-types/non-negative-int16.mjs +138 -0
  146. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -0
  147. package/dist/number/branded-types/non-negative-int32.d.mts +156 -0
  148. package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -0
  149. package/dist/number/branded-types/non-negative-int32.mjs +138 -0
  150. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -0
  151. package/dist/number/branded-types/non-zero-finite-number.d.mts +154 -0
  152. package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -0
  153. package/dist/number/branded-types/non-zero-finite-number.mjs +160 -0
  154. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -0
  155. package/dist/number/branded-types/non-zero-int.d.mts +131 -0
  156. package/dist/number/branded-types/non-zero-int.d.mts.map +1 -0
  157. package/dist/number/branded-types/non-zero-int.mjs +128 -0
  158. package/dist/number/branded-types/non-zero-int.mjs.map +1 -0
  159. package/dist/number/branded-types/non-zero-int16.d.mts +166 -0
  160. package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -0
  161. package/dist/number/branded-types/non-zero-int16.mjs +145 -0
  162. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -0
  163. package/dist/number/branded-types/non-zero-int32.d.mts +158 -0
  164. package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -0
  165. package/dist/number/branded-types/non-zero-int32.mjs +145 -0
  166. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -0
  167. package/dist/number/branded-types/non-zero-safe-int.d.mts +148 -0
  168. package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -0
  169. package/dist/number/branded-types/non-zero-safe-int.mjs +145 -0
  170. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -0
  171. package/dist/number/branded-types/non-zero-uint16.d.mts +160 -0
  172. package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -0
  173. package/dist/number/branded-types/non-zero-uint16.mjs +140 -0
  174. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -0
  175. package/dist/number/branded-types/non-zero-uint32.d.mts +156 -0
  176. package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -0
  177. package/dist/number/branded-types/non-zero-uint32.mjs +140 -0
  178. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -0
  179. package/dist/number/branded-types/positive-finite-number.d.mts +171 -0
  180. package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -0
  181. package/dist/number/branded-types/positive-finite-number.mjs +165 -0
  182. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -0
  183. package/dist/number/branded-types/positive-int.d.mts +270 -0
  184. package/dist/number/branded-types/positive-int.d.mts.map +1 -0
  185. package/dist/number/branded-types/positive-int.mjs +257 -0
  186. package/dist/number/branded-types/positive-int.mjs.map +1 -0
  187. package/dist/number/branded-types/positive-int16.d.mts +162 -0
  188. package/dist/number/branded-types/positive-int16.d.mts.map +1 -0
  189. package/dist/number/branded-types/positive-int16.mjs +139 -0
  190. package/dist/number/branded-types/positive-int16.mjs.map +1 -0
  191. package/dist/number/branded-types/positive-int32.d.mts +158 -0
  192. package/dist/number/branded-types/positive-int32.d.mts.map +1 -0
  193. package/dist/number/branded-types/positive-int32.mjs +139 -0
  194. package/dist/number/branded-types/positive-int32.mjs.map +1 -0
  195. package/dist/number/branded-types/positive-safe-int.d.mts +152 -0
  196. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -0
  197. package/dist/number/branded-types/positive-safe-int.mjs +138 -0
  198. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -0
  199. package/dist/number/branded-types/positive-uint16.d.mts +160 -0
  200. package/dist/number/branded-types/positive-uint16.d.mts.map +1 -0
  201. package/dist/number/branded-types/positive-uint16.mjs +139 -0
  202. package/dist/number/branded-types/positive-uint16.mjs.map +1 -0
  203. package/dist/number/branded-types/positive-uint32.d.mts +156 -0
  204. package/dist/number/branded-types/positive-uint32.d.mts.map +1 -0
  205. package/dist/number/branded-types/positive-uint32.mjs +139 -0
  206. package/dist/number/branded-types/positive-uint32.mjs.map +1 -0
  207. package/dist/number/branded-types/safe-int.d.mts +243 -0
  208. package/dist/number/branded-types/safe-int.d.mts.map +1 -0
  209. package/dist/number/branded-types/safe-int.mjs +240 -0
  210. package/dist/number/branded-types/safe-int.mjs.map +1 -0
  211. package/dist/number/branded-types/safe-uint.d.mts +151 -0
  212. package/dist/number/branded-types/safe-uint.d.mts.map +1 -0
  213. package/dist/number/branded-types/safe-uint.mjs +138 -0
  214. package/dist/number/branded-types/safe-uint.mjs.map +1 -0
  215. package/dist/number/branded-types/uint.d.mts +144 -0
  216. package/dist/number/branded-types/uint.d.mts.map +1 -0
  217. package/dist/number/branded-types/uint.mjs +132 -0
  218. package/dist/number/branded-types/uint.mjs.map +1 -0
  219. package/dist/number/branded-types/uint16.d.mts +157 -0
  220. package/dist/number/branded-types/uint16.d.mts.map +1 -0
  221. package/dist/number/branded-types/uint16.mjs +137 -0
  222. package/dist/number/branded-types/uint16.mjs.map +1 -0
  223. package/dist/number/branded-types/uint32.d.mts +185 -0
  224. package/dist/number/branded-types/uint32.d.mts.map +1 -0
  225. package/dist/number/branded-types/uint32.mjs +169 -0
  226. package/dist/number/branded-types/uint32.mjs.map +1 -0
  227. package/dist/number/enum/index.d.mts +3 -0
  228. package/dist/number/enum/index.d.mts.map +1 -0
  229. package/dist/number/enum/index.mjs +3 -0
  230. package/dist/number/enum/index.mjs.map +1 -0
  231. package/dist/number/enum/int8.d.mts +202 -0
  232. package/dist/number/enum/int8.d.mts.map +1 -0
  233. package/dist/number/enum/int8.mjs +296 -0
  234. package/dist/number/enum/int8.mjs.map +1 -0
  235. package/dist/number/enum/uint8.d.mts +128 -0
  236. package/dist/number/enum/uint8.d.mts.map +1 -0
  237. package/dist/number/enum/uint8.mjs +251 -0
  238. package/dist/number/enum/uint8.mjs.map +1 -0
  239. package/dist/number/index.d.mts +5 -0
  240. package/dist/number/index.d.mts.map +1 -0
  241. package/dist/number/index.mjs +31 -0
  242. package/dist/number/index.mjs.map +1 -0
  243. package/dist/number/num.d.mts +515 -0
  244. package/dist/number/num.d.mts.map +1 -0
  245. package/dist/number/num.mjs +513 -0
  246. package/dist/number/num.mjs.map +1 -0
  247. package/dist/number/refined-number-utils.d.mts +191 -0
  248. package/dist/number/refined-number-utils.d.mts.map +1 -0
  249. package/dist/number/refined-number-utils.mjs +179 -0
  250. package/dist/number/refined-number-utils.mjs.map +1 -0
  251. package/dist/object/index.d.mts +2 -0
  252. package/dist/object/index.d.mts.map +1 -0
  253. package/dist/object/index.mjs +2 -0
  254. package/dist/object/index.mjs.map +1 -0
  255. package/dist/object/object.d.mts +296 -0
  256. package/dist/object/object.d.mts.map +1 -0
  257. package/dist/object/object.mjs +295 -0
  258. package/dist/object/object.mjs.map +1 -0
  259. package/dist/others/cast-mutable.d.mts +110 -0
  260. package/dist/others/cast-mutable.d.mts.map +1 -0
  261. package/dist/others/cast-mutable.mjs +114 -0
  262. package/dist/others/cast-mutable.mjs.map +1 -0
  263. package/dist/others/cast-readonly.d.mts +189 -0
  264. package/dist/others/cast-readonly.d.mts.map +1 -0
  265. package/dist/others/cast-readonly.mjs +193 -0
  266. package/dist/others/cast-readonly.mjs.map +1 -0
  267. package/dist/others/if-then.d.mts +98 -0
  268. package/dist/others/if-then.d.mts.map +1 -0
  269. package/dist/others/if-then.mjs +100 -0
  270. package/dist/others/if-then.mjs.map +1 -0
  271. package/dist/others/index.d.mts +8 -0
  272. package/dist/others/index.d.mts.map +1 -0
  273. package/dist/others/index.mjs +8 -0
  274. package/dist/others/index.mjs.map +1 -0
  275. package/dist/others/map-nullable.d.mts +151 -0
  276. package/dist/others/map-nullable.d.mts.map +1 -0
  277. package/dist/others/map-nullable.mjs +159 -0
  278. package/dist/others/map-nullable.mjs.map +1 -0
  279. package/dist/others/memoize-function.d.mts +173 -0
  280. package/dist/others/memoize-function.d.mts.map +1 -0
  281. package/dist/others/memoize-function.mjs +189 -0
  282. package/dist/others/memoize-function.mjs.map +1 -0
  283. package/dist/others/tuple.d.mts +159 -0
  284. package/dist/others/tuple.d.mts.map +1 -0
  285. package/dist/others/tuple.mjs +161 -0
  286. package/dist/others/tuple.mjs.map +1 -0
  287. package/dist/others/unknown-to-string.d.mts +180 -0
  288. package/dist/others/unknown-to-string.d.mts.map +1 -0
  289. package/dist/others/unknown-to-string.mjs +211 -0
  290. package/dist/others/unknown-to-string.mjs.map +1 -0
  291. package/dist/tsconfig.json +1 -0
  292. package/package.json +16 -14
@@ -0,0 +1,251 @@
1
+ import { TsVerifiedInternals } from '../refined-number-utils.mjs';
2
+
3
+ const typeNameInMessage = 'an non-negative integer less than 256';
4
+ const { MIN_VALUE, MAX_VALUE, random: randomImpl, is: isImpl, castType: castTypeImpl, clamp: clampImpl, } = TsVerifiedInternals.RefinedNumberUtils.operatorsForInteger({
5
+ integerOrSafeInteger: 'SafeInteger',
6
+ MIN_VALUE: 0,
7
+ MAX_VALUE: 255,
8
+ typeNameInMessage,
9
+ });
10
+ /**
11
+ * Type guard that checks if a value is an 8-bit unsigned integer.
12
+ *
13
+ * A Uint8 is an unsigned integer in the range [0, 255], representing
14
+ * values that fit in exactly 8 bits of memory (1 byte).
15
+ *
16
+ * @param x - The number to check
17
+ * @returns `true` if x is a valid Uint8, `false` otherwise
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * is(100); // true
22
+ * is(0); // true (minimum value)
23
+ * is(255); // true (maximum value)
24
+ * is(256); // false (exceeds max)
25
+ * is(-1); // false (negative)
26
+ * is(5.5); // false (not integer)
27
+ * ```
28
+ */
29
+ const is = (x) => isImpl(x);
30
+ /**
31
+ * Casts a number to a Uint8 branded type.
32
+ *
33
+ * This function validates that the input is within the Uint8 range [0, 255]
34
+ * and is an integer, then returns it with the Uint8 brand.
35
+ *
36
+ * @param x - The number to convert
37
+ * @returns The number as a Uint8 branded type
38
+ * @throws {TypeError} If x is not a valid 8-bit unsigned integer
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const byte = castType(200); // Uint8
43
+ * const zero = castType(0); // Uint8 (minimum)
44
+ * const max = castType(255); // Uint8 (maximum)
45
+ *
46
+ * // These throw TypeError:
47
+ * // castType(256); // Exceeds maximum
48
+ * // castType(-1); // Negative value
49
+ * // castType(1.5); // Not an integer
50
+ * ```
51
+ */
52
+ const castType = (x) =>
53
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
54
+ castTypeImpl(x);
55
+ /**
56
+ * Clamps a number to the Uint8 range [0, 255].
57
+ * @param a - The number to clamp
58
+ * @returns The clamped value as Uint8
59
+ */
60
+ const clamp = (a) => castType(clampImpl(a));
61
+ /**
62
+ * Returns the minimum value from a list of Uint8 values.
63
+ *
64
+ * @param values - The Uint8 values to compare (at least one required)
65
+ * @returns The smallest value as a Uint8
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * min_(asUint8(50), asUint8(30), asUint8(100)); // Uint8 (30)
70
+ * min_(asUint8(0), asUint8(255)); // Uint8 (0)
71
+ * ```
72
+ */
73
+ const min_ = (...values) => castType(Math.min(...values));
74
+ /**
75
+ * Returns the maximum of the given Uint8 values.
76
+ * @param values - The Uint8 values to compare
77
+ * @returns The maximum value
78
+ */
79
+ const max_ = (...values) => castType(Math.max(...values));
80
+ /**
81
+ * Raises x to the power of y, clamped to Uint8 range.
82
+ * @param x - The base
83
+ * @param y - The exponent
84
+ * @returns x^y clamped to [0, 255]
85
+ */
86
+ const pow = (x, y) => clamp(x ** y);
87
+ /**
88
+ * Adds two Uint8 values, clamped to Uint8 range.
89
+ * @param x - First operand
90
+ * @param y - Second operand
91
+ * @returns x + y clamped to [0, 255]
92
+ */
93
+ const add = (x, y) => clamp(x + y);
94
+ /**
95
+ * Subtracts two Uint8 values, clamped to Uint8 range.
96
+ * @param x - First operand
97
+ * @param y - Second operand
98
+ * @returns x - y clamped to [0, 255]
99
+ */
100
+ const sub = (x, y) => clamp(x - y);
101
+ /**
102
+ * Multiplies two Uint8 values, clamped to Uint8 range.
103
+ * @param x - First operand
104
+ * @param y - Second operand
105
+ * @returns x * y clamped to [0, 255]
106
+ */
107
+ const mul = (x, y) => clamp(x * y);
108
+ /**
109
+ * Divides two Uint8 values, clamped to Uint8 range.
110
+ * @param x - The dividend
111
+ * @param y - The divisor (cannot be 0)
112
+ * @returns ⌊x / y⌋ clamped to [0, 255]
113
+ */
114
+ const div = (x, y) => clamp(Math.floor(x / y));
115
+ /**
116
+ * Generates a random Uint8 value within the specified range.
117
+ * @param min - The minimum value (inclusive)
118
+ * @param max - The maximum value (inclusive)
119
+ * @returns A random Uint8 between min and max
120
+ */
121
+ const random = (min, max) => castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));
122
+ /**
123
+ * Checks if a number is a Uint8 (8-bit unsigned integer in the range [0, 255]).
124
+ * @param value The value to check.
125
+ * @returns `true` if the value is a Uint8, `false` otherwise.
126
+ */
127
+ const isUint8 = is;
128
+ /**
129
+ * Casts a number to a Uint8 type.
130
+ * @param value The value to cast.
131
+ * @returns The value as a Uint8 type.
132
+ * @throws {TypeError} If the value is not a valid 8-bit unsigned integer.
133
+ * @example
134
+ * ```typescript
135
+ * const x = asUint8(255); // Uint8
136
+ * const y = asUint8(0); // Uint8
137
+ * // asUint8(-1); // throws TypeError
138
+ * // asUint8(256); // throws TypeError
139
+ * // asUint8(1.5); // throws TypeError
140
+ * ```
141
+ */
142
+ const asUint8 = castType;
143
+ /**
144
+ * Namespace providing type-safe arithmetic operations for 8-bit unsigned integers.
145
+ *
146
+ * All operations automatically clamp results to the valid Uint8 range [0, 255].
147
+ * This ensures that all arithmetic maintains the 8-bit unsigned integer constraint,
148
+ * with negative results clamped to 0 and overflow results clamped to MAX_VALUE.
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * const a = asUint8(200);
153
+ * const b = asUint8(100);
154
+ *
155
+ * // Arithmetic operations with automatic clamping
156
+ * const sum = Uint8.add(a, b); // Uint8 (255 - clamped to MAX_VALUE)
157
+ * const diff = Uint8.sub(a, b); // Uint8 (100)
158
+ * const reverseDiff = Uint8.sub(b, a); // Uint8 (0 - clamped to MIN_VALUE)
159
+ * const product = Uint8.mul(a, b); // Uint8 (255 - clamped due to overflow)
160
+ *
161
+ * // Range operations
162
+ * const clamped = Uint8.clamp(-10); // Uint8 (0)
163
+ * const minimum = Uint8.min(a, b); // Uint8 (100)
164
+ * const maximum = Uint8.max(a, b); // Uint8 (200)
165
+ *
166
+ * // Utility operations
167
+ * const random = Uint8.random(asUint8(50), asUint8(150)); // Uint8 (random value in [50, 150])
168
+ * const power = Uint8.pow(asUint8(2), asUint8(7)); // Uint8 (128)
169
+ * ```
170
+ */
171
+ const Uint8 = {
172
+ /**
173
+ * Type guard to check if a value is a Uint8.
174
+ * @param value The value to check.
175
+ * @returns `true` if the value is an 8-bit unsigned integer, `false` otherwise.
176
+ */
177
+ is,
178
+ /**
179
+ * The minimum value for an 8-bit unsigned integer.
180
+ * @readonly
181
+ */
182
+ MIN_VALUE,
183
+ /**
184
+ * The maximum value for an 8-bit unsigned integer.
185
+ * @readonly
186
+ */
187
+ MAX_VALUE,
188
+ /**
189
+ * Returns the larger of the given Uint8 values.
190
+ * @param values The Uint8 values to compare.
191
+ * @returns The maximum value as a Uint8.
192
+ */
193
+ max: max_,
194
+ /**
195
+ * Returns the smaller of the given Uint8 values.
196
+ * @param values The Uint8 values to compare.
197
+ * @returns The minimum value as a Uint8.
198
+ */
199
+ min: min_,
200
+ /**
201
+ * Clamps a number to the Uint8 range.
202
+ * @param value The number to clamp.
203
+ * @returns The value clamped to [0, 255] as a Uint8.
204
+ */
205
+ clamp,
206
+ /**
207
+ * Generates a random Uint8 value within the specified range.
208
+ * @param min The minimum value (inclusive).
209
+ * @param max The maximum value (inclusive).
210
+ * @returns A random Uint8 between min and max.
211
+ */
212
+ random,
213
+ /**
214
+ * Raises a Uint8 to the power of another Uint8.
215
+ * @param a The base Uint8.
216
+ * @param b The exponent Uint8.
217
+ * @returns `a ** b` clamped to [0, 255] as a Uint8.
218
+ */
219
+ pow,
220
+ /**
221
+ * Adds two Uint8 values.
222
+ * @param a The first Uint8.
223
+ * @param b The second Uint8.
224
+ * @returns `a + b` clamped to [0, 255] as a Uint8.
225
+ */
226
+ add,
227
+ /**
228
+ * Subtracts one Uint8 from another.
229
+ * @param a The minuend Uint8.
230
+ * @param b The subtrahend Uint8.
231
+ * @returns `a - b` clamped to [0, 255] as a Uint8 (minimum 0).
232
+ */
233
+ sub,
234
+ /**
235
+ * Multiplies two Uint8 values.
236
+ * @param a The first Uint8.
237
+ * @param b The second Uint8.
238
+ * @returns `a * b` clamped to [0, 255] as a Uint8.
239
+ */
240
+ mul,
241
+ /**
242
+ * Divides one Uint8 by another using floor division.
243
+ * @param a The dividend Uint8.
244
+ * @param b The divisor Uint8 (cannot be 0).
245
+ * @returns `⌊a / b⌋` clamped to [0, 255] as a Uint8.
246
+ */
247
+ div,
248
+ };
249
+
250
+ export { Uint8, asUint8, isUint8 };
251
+ //# sourceMappingURL=uint8.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uint8.mjs","sources":["../../../src/number/enum/uint8.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA,MAAM,iBAAiB,GAAG,uCAAuC;AAEjE,MAAM,EACJ,SAAS,EACT,SAAS,EACT,MAAM,EAAE,UAAU,EAClB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,SAAS,GACjB,GAAG,mBAAmB,CAAC,kBAAkB,CAAC,mBAAmB,CAAiB;AAC7E,IAAA,oBAAoB,EAAE,aAAa;AACnC,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,SAAS,EAAE,GAAG;IACd,iBAAiB;AACT,CAAA,CAAC;AAEX;;;;;;;;;;;;;;;;;;AAkBG;AACH,MAAM,EAAE,GAAG,CAAC,CAAS,KAAiB,MAAM,CAAC,CAAC,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;AAqBG;AACH,MAAM,QAAQ,GAAG,CAAC,CAAS;AACzB;AACA,YAAY,CAAC,CAAC,CAAU;AAE1B;;;;AAIG;AACH,MAAM,KAAK,GAAG,CAAC,CAAS,KAAY,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAE1D;;;;;;;;;;;AAWG;AACH,MAAM,IAAI,GAAG,CAAC,GAAG,MAAwB,KACvC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;AAE/B;;;;AAIG;AACH,MAAM,IAAI,GAAG,CAAC,GAAG,MAAwB,KACvC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;AAE/B;;;;;AAKG;AACH,MAAM,GAAG,GAAG,CAAC,CAAQ,EAAE,CAAQ,KAAY,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;AAExD;;;;;AAKG;AACH,MAAM,GAAG,GAAG,CAAC,CAAQ,EAAE,CAAQ,KAAY,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;AAEvD;;;;;AAKG;AACH,MAAM,GAAG,GAAG,CAAC,CAAQ,EAAE,CAAQ,KAAY,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;AAEvD;;;;;AAKG;AACH,MAAM,GAAG,GAAG,CAAC,CAAQ,EAAE,CAAQ,KAAY,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;AAEvD;;;;;AAKG;AACH,MAAM,GAAG,GAAG,CAAC,CAAQ,EAAE,CAAoB,KAAY,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/E;;;;;AAKG;AACH,MAAM,MAAM,GAAG,CAAC,GAAU,EAAE,GAAU,KACpC,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;AAE5D;;;;AAIG;AACI,MAAM,OAAO,GAAG;AAEvB;;;;;;;;;;;;;AAaG;AACI,MAAM,OAAO,GAAG;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACI,MAAM,KAAK,GAAG;AACnB;;;;AAIG;IACH,EAAE;AAEF;;;AAGG;IACH,SAAS;AAET;;;AAGG;IACH,SAAS;AAET;;;;AAIG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;AAIG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;AAIG;IACH,KAAK;AAEL;;;;;AAKG;IACH,MAAM;AAEN;;;;;AAKG;IACH,GAAG;AAEH;;;;;AAKG;IACH,GAAG;AAEH;;;;;AAKG;IACH,GAAG;AAEH;;;;;AAKG;IACH,GAAG;AAEH;;;;;AAKG;IACH,GAAG;;;;;"}
@@ -0,0 +1,5 @@
1
+ export * from './branded-types/index.mjs';
2
+ export * from './enum/index.mjs';
3
+ export * from './num.mjs';
4
+ export * from './refined-number-utils.mjs';
5
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/number/index.mts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,31 @@
1
+ export { FiniteNumber, asFiniteNumber, isFiniteNumber } from './branded-types/finite-number.mjs';
2
+ export { Int, asInt, isInt } from './branded-types/int.mjs';
3
+ export { Int16, asInt16, isInt16 } from './branded-types/int16.mjs';
4
+ export { Int32, asInt32, isInt32 } from './branded-types/int32.mjs';
5
+ export { NonNegativeFiniteNumber, asNonNegativeFiniteNumber, isNonNegativeFiniteNumber } from './branded-types/non-negative-finite-number.mjs';
6
+ export { NonNegativeInt16, asNonNegativeInt16, isNonNegativeInt16 } from './branded-types/non-negative-int16.mjs';
7
+ export { NonNegativeInt32, asNonNegativeInt32, isNonNegativeInt32 } from './branded-types/non-negative-int32.mjs';
8
+ export { NonZeroFiniteNumber, asNonZeroFiniteNumber, isNonZeroFiniteNumber } from './branded-types/non-zero-finite-number.mjs';
9
+ export { NonZeroInt, asNonZeroInt, isNonZeroInt } from './branded-types/non-zero-int.mjs';
10
+ export { NonZeroInt16, asNonZeroInt16, isNonZeroInt16 } from './branded-types/non-zero-int16.mjs';
11
+ export { NonZeroInt32, asNonZeroInt32, isNonZeroInt32 } from './branded-types/non-zero-int32.mjs';
12
+ export { NonZeroSafeInt, asNonZeroSafeInt, isNonZeroSafeInt } from './branded-types/non-zero-safe-int.mjs';
13
+ export { NonZeroUint16, asNonZeroUint16, isNonZeroUint16 } from './branded-types/non-zero-uint16.mjs';
14
+ export { NonZeroUint32, asNonZeroUint32, isNonZeroUint32 } from './branded-types/non-zero-uint32.mjs';
15
+ export { PositiveFiniteNumber, asPositiveFiniteNumber, isPositiveFiniteNumber } from './branded-types/positive-finite-number.mjs';
16
+ export { PositiveInt, asPositiveInt, isPositiveInt } from './branded-types/positive-int.mjs';
17
+ export { PositiveInt16, asPositiveInt16, isPositiveInt16 } from './branded-types/positive-int16.mjs';
18
+ export { PositiveInt32, asPositiveInt32, isPositiveInt32 } from './branded-types/positive-int32.mjs';
19
+ export { PositiveSafeInt, asPositiveSafeInt, isPositiveSafeInt } from './branded-types/positive-safe-int.mjs';
20
+ export { PositiveUint16, asPositiveUint16, isPositiveUint16 } from './branded-types/positive-uint16.mjs';
21
+ export { PositiveUint32, asPositiveUint32, isPositiveUint32 } from './branded-types/positive-uint32.mjs';
22
+ export { SafeInt, asSafeInt, isSafeInt } from './branded-types/safe-int.mjs';
23
+ export { SafeUint, asSafeUint, isSafeUint } from './branded-types/safe-uint.mjs';
24
+ export { Uint, asUint, isUint } from './branded-types/uint.mjs';
25
+ export { Uint16, asUint16, isUint16 } from './branded-types/uint16.mjs';
26
+ export { Uint32, asUint32, isUint32 } from './branded-types/uint32.mjs';
27
+ export { Int8, asInt8, isInt8 } from './enum/int8.mjs';
28
+ export { Uint8, asUint8, isUint8 } from './enum/uint8.mjs';
29
+ export { Num } from './num.mjs';
30
+ export { TsVerifiedInternals } from './refined-number-utils.mjs';
31
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}