ts-data-forge 1.0.0 → 1.0.2

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 +18 -16
@@ -0,0 +1,140 @@
1
+ import { TsVerifiedInternals } from '../refined-number-utils.mjs';
2
+
3
+ const typeNameInMessage = 'a non-zero integer in [1, 2^16)';
4
+ const { MIN_VALUE, MAX_VALUE, min: min_, max: max_, pow, add, sub, mul, div, randomNonZero: random, is, castType, clamp, } = TsVerifiedInternals.RefinedNumberUtils.operatorsForInteger({
5
+ integerOrSafeInteger: 'SafeInteger',
6
+ nonZero: true,
7
+ MIN_VALUE: 1,
8
+ MAX_VALUE: 2 ** 16 - 1,
9
+ typeNameInMessage,
10
+ });
11
+ /**
12
+ * Checks if a number is a NonZeroUint16 (16-bit non-zero unsigned integer in the range [1, 2^16)).
13
+ * @param value The value to check.
14
+ * @returns `true` if the value is a NonZeroUint16, `false` otherwise.
15
+ */
16
+ const isNonZeroUint16 = is;
17
+ /**
18
+ * Casts a number to a NonZeroUint16 type.
19
+ * @param value The value to cast.
20
+ * @returns The value as a NonZeroUint16 type.
21
+ * @throws {TypeError} If the value is not a non-zero integer in [1, 2^16).
22
+ * @example
23
+ * ```typescript
24
+ * const x = asNonZeroUint16(1000); // NonZeroUint16
25
+ * const y = asNonZeroUint16(65535); // NonZeroUint16
26
+ * // asNonZeroUint16(0); // throws TypeError
27
+ * // asNonZeroUint16(-1); // throws TypeError
28
+ * // asNonZeroUint16(65536); // throws TypeError
29
+ * ```
30
+ */
31
+ const asNonZeroUint16 = castType;
32
+ /**
33
+ * Namespace providing type-safe arithmetic operations for 16-bit non-zero unsigned integers.
34
+ *
35
+ * All operations automatically clamp results to the valid NonZeroUint16 range [1, 65535].
36
+ * This ensures that all arithmetic maintains the 16-bit non-zero unsigned integer constraint,
37
+ * with results below 1 clamped to MIN_VALUE and overflow results clamped to MAX_VALUE.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const a = asNonZeroUint16(60000);
42
+ * const b = asNonZeroUint16(10000);
43
+ *
44
+ * // Arithmetic operations with automatic clamping and non-zero constraint
45
+ * const sum = NonZeroUint16.add(a, b); // NonZeroUint16 (65535 - clamped to MAX_VALUE)
46
+ * const diff = NonZeroUint16.sub(a, b); // NonZeroUint16 (50000)
47
+ * const reverseDiff = NonZeroUint16.sub(b, a); // NonZeroUint16 (1 - clamped to MIN_VALUE)
48
+ * const product = NonZeroUint16.mul(a, b); // NonZeroUint16 (65535 - clamped due to overflow)
49
+ *
50
+ * // Range operations (maintaining non-zero constraint)
51
+ * const clamped = NonZeroUint16.clamp(-100); // NonZeroUint16 (1)
52
+ * const minimum = NonZeroUint16.min(a, b); // NonZeroUint16 (10000)
53
+ * const maximum = NonZeroUint16.max(a, b); // NonZeroUint16 (60000)
54
+ *
55
+ * // Utility operations
56
+ * const random = NonZeroUint16.random(); // NonZeroUint16 (random value in [1, 65535])
57
+ * const power = NonZeroUint16.pow(asNonZeroUint16(2), asNonZeroUint16(10)); // NonZeroUint16 (1024)
58
+ * ```
59
+ */
60
+ const NonZeroUint16 = {
61
+ /**
62
+ * Type guard to check if a value is a NonZeroUint16.
63
+ * @param value The value to check.
64
+ * @returns `true` if the value is a 16-bit non-zero unsigned integer, `false` otherwise.
65
+ */
66
+ is,
67
+ /**
68
+ * The minimum value for a 16-bit non-zero unsigned integer.
69
+ * @readonly
70
+ */
71
+ MIN_VALUE,
72
+ /**
73
+ * The maximum value for a 16-bit non-zero unsigned integer.
74
+ * @readonly
75
+ */
76
+ MAX_VALUE,
77
+ /**
78
+ * Returns the smaller of two NonZeroUint16 values.
79
+ * @param a The first NonZeroUint16.
80
+ * @param b The second NonZeroUint16.
81
+ * @returns The minimum value as a NonZeroUint16.
82
+ */
83
+ min: min_,
84
+ /**
85
+ * Returns the larger of two NonZeroUint16 values.
86
+ * @param a The first NonZeroUint16.
87
+ * @param b The second NonZeroUint16.
88
+ * @returns The maximum value as a NonZeroUint16.
89
+ */
90
+ max: max_,
91
+ /**
92
+ * Clamps a number to the NonZeroUint16 range.
93
+ * @param value The number to clamp.
94
+ * @returns The value clamped to [1, 65535] as a NonZeroUint16.
95
+ */
96
+ clamp,
97
+ /**
98
+ * Generates a random NonZeroUint16 value within the valid range.
99
+ * @returns A random NonZeroUint16 between 1 and 65535.
100
+ */
101
+ random,
102
+ /**
103
+ * Raises a NonZeroUint16 to the power of another NonZeroUint16.
104
+ * @param a The base NonZeroUint16.
105
+ * @param b The exponent NonZeroUint16.
106
+ * @returns `a ** b` clamped to [1, 65535] as a NonZeroUint16.
107
+ */
108
+ pow,
109
+ /**
110
+ * Adds two NonZeroUint16 values.
111
+ * @param a The first NonZeroUint16.
112
+ * @param b The second NonZeroUint16.
113
+ * @returns `a + b` clamped to [1, 65535] as a NonZeroUint16.
114
+ */
115
+ add,
116
+ /**
117
+ * Subtracts one NonZeroUint16 from another.
118
+ * @param a The minuend NonZeroUint16.
119
+ * @param b The subtrahend NonZeroUint16.
120
+ * @returns `a - b` clamped to [1, 65535] as a NonZeroUint16 (minimum 1).
121
+ */
122
+ sub,
123
+ /**
124
+ * Multiplies two NonZeroUint16 values.
125
+ * @param a The first NonZeroUint16.
126
+ * @param b The second NonZeroUint16.
127
+ * @returns `a * b` clamped to [1, 65535] as a NonZeroUint16.
128
+ */
129
+ mul,
130
+ /**
131
+ * Divides one NonZeroUint16 by another using floor division.
132
+ * @param a The dividend NonZeroUint16.
133
+ * @param b The divisor NonZeroUint16.
134
+ * @returns `⌊a / b⌋` clamped to [1, 65535] as a NonZeroUint16.
135
+ */
136
+ div,
137
+ };
138
+
139
+ export { NonZeroUint16, asNonZeroUint16, isNonZeroUint16 };
140
+ //# sourceMappingURL=non-zero-uint16.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"non-zero-uint16.mjs","sources":["../../../src/number/branded-types/non-zero-uint16.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA,MAAM,iBAAiB,GAAG,iCAAiC;AAE3D,MAAM,EACJ,SAAS,EACT,SAAS,EACT,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,IAAI,EACT,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,aAAa,EAAE,MAAM,EACrB,EAAE,EACF,QAAQ,EACR,KAAK,GACN,GAAG,mBAAmB,CAAC,kBAAkB,CAAC,mBAAmB,CAI5D;AACA,IAAA,oBAAoB,EAAE,aAAa;AACnC,IAAA,OAAO,EAAE,IAAI;AACb,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC;IACtB,iBAAiB;AACT,CAAA,CAAC;AAEX;;;;AAIG;AACI,MAAM,eAAe,GAAG;AAE/B;;;;;;;;;;;;;AAaG;AACI,MAAM,eAAe,GAAG;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACI,MAAM,aAAa,GAAG;AAC3B;;;;AAIG;IACH,EAAE;AAEF;;;AAGG;IACH,SAAS;AAET;;;AAGG;IACH,SAAS;AAET;;;;;AAKG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;AAKG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;AAIG;IACH,KAAK;AAEL;;;AAGG;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,156 @@
1
+ /**
2
+ * Checks if a number is a NonZeroUint32 (32-bit non-zero unsigned integer in the range [1, 2^32)).
3
+ * @param value The value to check.
4
+ * @returns `true` if the value is a NonZeroUint32, `false` otherwise.
5
+ */
6
+ export declare const isNonZeroUint32: (a: number) => a is PositiveUint32;
7
+ /**
8
+ * Casts a number to a NonZeroUint32 type.
9
+ * @param value The value to cast.
10
+ * @returns The value as a NonZeroUint32 type.
11
+ * @throws {TypeError} If the value is not a non-zero integer in [1, 2^32).
12
+ * @example
13
+ * ```typescript
14
+ * const x = asNonZeroUint32(1000); // NonZeroUint32
15
+ * const y = asNonZeroUint32(4294967295); // NonZeroUint32
16
+ * // asNonZeroUint32(0); // throws TypeError
17
+ * // asNonZeroUint32(-1); // throws TypeError
18
+ * // asNonZeroUint32(4294967296); // throws TypeError
19
+ * ```
20
+ */
21
+ export declare const asNonZeroUint32: <N extends number>(x: N) => number & {
22
+ readonly NaNValue: false;
23
+ readonly "!=0": true;
24
+ readonly "> -2^16": true;
25
+ readonly "> -2^32": true;
26
+ readonly ">= -2^15": true;
27
+ readonly ">= -2^31": true;
28
+ readonly ">=0": true;
29
+ readonly "< 2^32": true;
30
+ readonly Finite: true;
31
+ readonly Int: true;
32
+ readonly SafeInt: true;
33
+ } & Readonly<{
34
+ 'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
35
+ }> & N;
36
+ /**
37
+ * Namespace providing type-safe arithmetic operations for 32-bit non-zero unsigned integers.
38
+ *
39
+ * All operations automatically clamp results to the valid NonZeroUint32 range [1, 4294967295].
40
+ * This ensures that all arithmetic maintains the 32-bit non-zero unsigned integer constraint,
41
+ * with results below 1 clamped to MIN_VALUE and overflow results clamped to MAX_VALUE.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const a = asNonZeroUint32(4000000000);
46
+ * const b = asNonZeroUint32(1000000000);
47
+ *
48
+ * // Arithmetic operations with automatic clamping and non-zero constraint
49
+ * const sum = NonZeroUint32.add(a, b); // NonZeroUint32 (4294967295 - clamped to MAX_VALUE)
50
+ * const diff = NonZeroUint32.sub(a, b); // NonZeroUint32 (3000000000)
51
+ * const reverseDiff = NonZeroUint32.sub(b, a); // NonZeroUint32 (1 - clamped to MIN_VALUE)
52
+ * const product = NonZeroUint32.mul(a, b); // NonZeroUint32 (4294967295 - clamped due to overflow)
53
+ *
54
+ * // Range operations (maintaining non-zero constraint)
55
+ * const clamped = NonZeroUint32.clamp(-100); // NonZeroUint32 (1)
56
+ * const minimum = NonZeroUint32.min(a, b); // NonZeroUint32 (1000000000)
57
+ * const maximum = NonZeroUint32.max(a, b); // NonZeroUint32 (4000000000)
58
+ *
59
+ * // Utility operations
60
+ * const random = NonZeroUint32.random(); // NonZeroUint32 (random value in [1, 4294967295])
61
+ * const power = NonZeroUint32.pow(asNonZeroUint32(2), asNonZeroUint32(20)); // NonZeroUint32 (1048576)
62
+ * ```
63
+ */
64
+ export declare const NonZeroUint32: {
65
+ /**
66
+ * Type guard to check if a value is a NonZeroUint32.
67
+ * @param value The value to check.
68
+ * @returns `true` if the value is a 32-bit non-zero unsigned integer, `false` otherwise.
69
+ */
70
+ readonly is: (a: number) => a is PositiveUint32;
71
+ /**
72
+ * The minimum value for a 32-bit non-zero unsigned integer.
73
+ * @readonly
74
+ */
75
+ readonly MIN_VALUE: 1;
76
+ /**
77
+ * The maximum value for a 32-bit non-zero unsigned integer.
78
+ * @readonly
79
+ */
80
+ readonly MAX_VALUE: number;
81
+ /**
82
+ * Returns the smaller of two NonZeroUint32 values.
83
+ * @param a The first NonZeroUint32.
84
+ * @param b The second NonZeroUint32.
85
+ * @returns The minimum value as a NonZeroUint32.
86
+ */
87
+ readonly min: (...values: readonly WithSmallInt<PositiveUint32, 40>[]) => PositiveUint32;
88
+ /**
89
+ * Returns the larger of two NonZeroUint32 values.
90
+ * @param a The first NonZeroUint32.
91
+ * @param b The second NonZeroUint32.
92
+ * @returns The maximum value as a NonZeroUint32.
93
+ */
94
+ readonly max: (...values: readonly WithSmallInt<PositiveUint32, 40>[]) => PositiveUint32;
95
+ /**
96
+ * Clamps a number to the NonZeroUint32 range.
97
+ * @param value The number to clamp.
98
+ * @returns The value clamped to [1, 4294967295] as a NonZeroUint32.
99
+ */
100
+ readonly clamp: (x: number) => PositiveUint32;
101
+ /**
102
+ * Generates a random NonZeroUint32 value within the valid range.
103
+ * @returns A random NonZeroUint32 between 1 and 4294967295.
104
+ */
105
+ readonly random: (min: WithSmallInt<PositiveUint32, 40>, max: WithSmallInt<PositiveUint32, 40>) => PositiveUint32;
106
+ /**
107
+ * Raises a NonZeroUint32 to the power of another NonZeroUint32.
108
+ * @param a The base NonZeroUint32.
109
+ * @param b The exponent NonZeroUint32.
110
+ * @returns `a ** b` clamped to [1, 4294967295] as a NonZeroUint32.
111
+ */
112
+ readonly pow: (x: WithSmallInt<PositiveUint32, 40>, y: WithSmallInt<PositiveUint32, 40>) => PositiveUint32;
113
+ /**
114
+ * Adds two NonZeroUint32 values.
115
+ * @param a The first NonZeroUint32.
116
+ * @param b The second NonZeroUint32.
117
+ * @returns `a + b` clamped to [1, 4294967295] as a NonZeroUint32.
118
+ */
119
+ readonly add: (x: WithSmallInt<PositiveUint32, 40>, y: WithSmallInt<PositiveUint32, 40>) => PositiveUint32;
120
+ /**
121
+ * Subtracts one NonZeroUint32 from another.
122
+ * @param a The minuend NonZeroUint32.
123
+ * @param b The subtrahend NonZeroUint32.
124
+ * @returns `a - b` clamped to [1, 4294967295] as a NonZeroUint32 (minimum 1).
125
+ */
126
+ readonly sub: (x: WithSmallInt<PositiveUint32, 40>, y: WithSmallInt<PositiveUint32, 40>) => PositiveUint32;
127
+ /**
128
+ * Multiplies two NonZeroUint32 values.
129
+ * @param a The first NonZeroUint32.
130
+ * @param b The second NonZeroUint32.
131
+ * @returns `a * b` clamped to [1, 4294967295] as a NonZeroUint32.
132
+ */
133
+ readonly mul: (x: WithSmallInt<PositiveUint32, 40>, y: WithSmallInt<PositiveUint32, 40>) => PositiveUint32;
134
+ /**
135
+ * Divides one NonZeroUint32 by another using floor division.
136
+ * @param a The dividend NonZeroUint32.
137
+ * @param b The divisor NonZeroUint32.
138
+ * @returns `⌊a / b⌋` clamped to [1, 4294967295] as a NonZeroUint32.
139
+ */
140
+ readonly div: (x: WithSmallInt<PositiveUint32, 40>, y: 1 | 2 | 3 | 32 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | 10 | 24 | 14 | 34 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 35 | 36 | 37 | 38 | 39 | NormalizeBrandUnion<number & {
141
+ readonly NaNValue: false;
142
+ readonly "!=0": true;
143
+ readonly "> -2^16": true;
144
+ readonly "> -2^32": true;
145
+ readonly ">= -2^15": true;
146
+ readonly ">= -2^31": true;
147
+ readonly ">=0": true;
148
+ readonly "< 2^32": true;
149
+ readonly Finite: true;
150
+ readonly Int: true;
151
+ readonly SafeInt: true;
152
+ } & Readonly<{
153
+ 'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
154
+ }>>) => PositiveUint32;
155
+ };
156
+ //# sourceMappingURL=non-zero-uint32.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"non-zero-uint32.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-zero-uint32.mts"],"names":[],"mappings":"AAiCA;;;;GAIG;AACH,eAAO,MAAM,eAAe,oCAAK,CAAC;AAElC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;MAAW,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,aAAa;IACxB;;;;OAIG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;OAIG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;;;;;;;;;;;;;;;CAEK,CAAC"}
@@ -0,0 +1,140 @@
1
+ import { TsVerifiedInternals } from '../refined-number-utils.mjs';
2
+
3
+ const typeNameInMessage = 'a non-zero integer in [1, 2^32)';
4
+ const { MIN_VALUE, MAX_VALUE, min: min_, max: max_, pow, add, sub, mul, div, randomNonZero: random, is, castType, clamp, } = TsVerifiedInternals.RefinedNumberUtils.operatorsForInteger({
5
+ integerOrSafeInteger: 'SafeInteger',
6
+ nonZero: true,
7
+ MIN_VALUE: 1,
8
+ MAX_VALUE: 2 ** 32 - 1,
9
+ typeNameInMessage,
10
+ });
11
+ /**
12
+ * Checks if a number is a NonZeroUint32 (32-bit non-zero unsigned integer in the range [1, 2^32)).
13
+ * @param value The value to check.
14
+ * @returns `true` if the value is a NonZeroUint32, `false` otherwise.
15
+ */
16
+ const isNonZeroUint32 = is;
17
+ /**
18
+ * Casts a number to a NonZeroUint32 type.
19
+ * @param value The value to cast.
20
+ * @returns The value as a NonZeroUint32 type.
21
+ * @throws {TypeError} If the value is not a non-zero integer in [1, 2^32).
22
+ * @example
23
+ * ```typescript
24
+ * const x = asNonZeroUint32(1000); // NonZeroUint32
25
+ * const y = asNonZeroUint32(4294967295); // NonZeroUint32
26
+ * // asNonZeroUint32(0); // throws TypeError
27
+ * // asNonZeroUint32(-1); // throws TypeError
28
+ * // asNonZeroUint32(4294967296); // throws TypeError
29
+ * ```
30
+ */
31
+ const asNonZeroUint32 = castType;
32
+ /**
33
+ * Namespace providing type-safe arithmetic operations for 32-bit non-zero unsigned integers.
34
+ *
35
+ * All operations automatically clamp results to the valid NonZeroUint32 range [1, 4294967295].
36
+ * This ensures that all arithmetic maintains the 32-bit non-zero unsigned integer constraint,
37
+ * with results below 1 clamped to MIN_VALUE and overflow results clamped to MAX_VALUE.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const a = asNonZeroUint32(4000000000);
42
+ * const b = asNonZeroUint32(1000000000);
43
+ *
44
+ * // Arithmetic operations with automatic clamping and non-zero constraint
45
+ * const sum = NonZeroUint32.add(a, b); // NonZeroUint32 (4294967295 - clamped to MAX_VALUE)
46
+ * const diff = NonZeroUint32.sub(a, b); // NonZeroUint32 (3000000000)
47
+ * const reverseDiff = NonZeroUint32.sub(b, a); // NonZeroUint32 (1 - clamped to MIN_VALUE)
48
+ * const product = NonZeroUint32.mul(a, b); // NonZeroUint32 (4294967295 - clamped due to overflow)
49
+ *
50
+ * // Range operations (maintaining non-zero constraint)
51
+ * const clamped = NonZeroUint32.clamp(-100); // NonZeroUint32 (1)
52
+ * const minimum = NonZeroUint32.min(a, b); // NonZeroUint32 (1000000000)
53
+ * const maximum = NonZeroUint32.max(a, b); // NonZeroUint32 (4000000000)
54
+ *
55
+ * // Utility operations
56
+ * const random = NonZeroUint32.random(); // NonZeroUint32 (random value in [1, 4294967295])
57
+ * const power = NonZeroUint32.pow(asNonZeroUint32(2), asNonZeroUint32(20)); // NonZeroUint32 (1048576)
58
+ * ```
59
+ */
60
+ const NonZeroUint32 = {
61
+ /**
62
+ * Type guard to check if a value is a NonZeroUint32.
63
+ * @param value The value to check.
64
+ * @returns `true` if the value is a 32-bit non-zero unsigned integer, `false` otherwise.
65
+ */
66
+ is,
67
+ /**
68
+ * The minimum value for a 32-bit non-zero unsigned integer.
69
+ * @readonly
70
+ */
71
+ MIN_VALUE,
72
+ /**
73
+ * The maximum value for a 32-bit non-zero unsigned integer.
74
+ * @readonly
75
+ */
76
+ MAX_VALUE,
77
+ /**
78
+ * Returns the smaller of two NonZeroUint32 values.
79
+ * @param a The first NonZeroUint32.
80
+ * @param b The second NonZeroUint32.
81
+ * @returns The minimum value as a NonZeroUint32.
82
+ */
83
+ min: min_,
84
+ /**
85
+ * Returns the larger of two NonZeroUint32 values.
86
+ * @param a The first NonZeroUint32.
87
+ * @param b The second NonZeroUint32.
88
+ * @returns The maximum value as a NonZeroUint32.
89
+ */
90
+ max: max_,
91
+ /**
92
+ * Clamps a number to the NonZeroUint32 range.
93
+ * @param value The number to clamp.
94
+ * @returns The value clamped to [1, 4294967295] as a NonZeroUint32.
95
+ */
96
+ clamp,
97
+ /**
98
+ * Generates a random NonZeroUint32 value within the valid range.
99
+ * @returns A random NonZeroUint32 between 1 and 4294967295.
100
+ */
101
+ random,
102
+ /**
103
+ * Raises a NonZeroUint32 to the power of another NonZeroUint32.
104
+ * @param a The base NonZeroUint32.
105
+ * @param b The exponent NonZeroUint32.
106
+ * @returns `a ** b` clamped to [1, 4294967295] as a NonZeroUint32.
107
+ */
108
+ pow,
109
+ /**
110
+ * Adds two NonZeroUint32 values.
111
+ * @param a The first NonZeroUint32.
112
+ * @param b The second NonZeroUint32.
113
+ * @returns `a + b` clamped to [1, 4294967295] as a NonZeroUint32.
114
+ */
115
+ add,
116
+ /**
117
+ * Subtracts one NonZeroUint32 from another.
118
+ * @param a The minuend NonZeroUint32.
119
+ * @param b The subtrahend NonZeroUint32.
120
+ * @returns `a - b` clamped to [1, 4294967295] as a NonZeroUint32 (minimum 1).
121
+ */
122
+ sub,
123
+ /**
124
+ * Multiplies two NonZeroUint32 values.
125
+ * @param a The first NonZeroUint32.
126
+ * @param b The second NonZeroUint32.
127
+ * @returns `a * b` clamped to [1, 4294967295] as a NonZeroUint32.
128
+ */
129
+ mul,
130
+ /**
131
+ * Divides one NonZeroUint32 by another using floor division.
132
+ * @param a The dividend NonZeroUint32.
133
+ * @param b The divisor NonZeroUint32.
134
+ * @returns `⌊a / b⌋` clamped to [1, 4294967295] as a NonZeroUint32.
135
+ */
136
+ div,
137
+ };
138
+
139
+ export { NonZeroUint32, asNonZeroUint32, isNonZeroUint32 };
140
+ //# sourceMappingURL=non-zero-uint32.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"non-zero-uint32.mjs","sources":["../../../src/number/branded-types/non-zero-uint32.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA,MAAM,iBAAiB,GAAG,iCAAiC;AAE3D,MAAM,EACJ,SAAS,EACT,SAAS,EACT,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,IAAI,EACT,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,aAAa,EAAE,MAAM,EACrB,EAAE,EACF,QAAQ,EACR,KAAK,GACN,GAAG,mBAAmB,CAAC,kBAAkB,CAAC,mBAAmB,CAI5D;AACA,IAAA,oBAAoB,EAAE,aAAa;AACnC,IAAA,OAAO,EAAE,IAAI;AACb,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC;IACtB,iBAAiB;AACT,CAAA,CAAC;AAEX;;;;AAIG;AACI,MAAM,eAAe,GAAG;AAE/B;;;;;;;;;;;;;AAaG;AACI,MAAM,eAAe,GAAG;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACI,MAAM,aAAa,GAAG;AAC3B;;;;AAIG;IACH,EAAE;AAEF;;;AAGG;IACH,SAAS;AAET;;;AAGG;IACH,SAAS;AAET;;;;;AAKG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;AAKG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;AAIG;IACH,KAAK;AAEL;;;AAGG;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,171 @@
1
+ import { TsVerifiedInternals } from '../refined-number-utils.mjs';
2
+ type ElementType = PositiveFiniteNumber;
3
+ /**
4
+ * Checks if a number is a PositiveFiniteNumber (a finite number > 0).
5
+ * @param value The value to check.
6
+ * @returns `true` if the value is a PositiveFiniteNumber, `false` otherwise.
7
+ */
8
+ export declare const isPositiveFiniteNumber: (a: number) => a is PositiveFiniteNumber;
9
+ /**
10
+ * Casts a number to a PositiveFiniteNumber type.
11
+ * @param value The value to cast.
12
+ * @returns The value as a PositiveFiniteNumber type.
13
+ * @throws {TypeError} If the value is not a positive finite number.
14
+ * @example
15
+ * ```typescript
16
+ * const x = asPositiveFiniteNumber(5.5); // PositiveFiniteNumber
17
+ * const y = asPositiveFiniteNumber(0.001); // PositiveFiniteNumber
18
+ * // asPositiveFiniteNumber(0); // throws TypeError
19
+ * // asPositiveFiniteNumber(-1); // throws TypeError
20
+ * ```
21
+ */
22
+ export declare const asPositiveFiniteNumber: <N extends number>(x: N) => number & {
23
+ readonly NaNValue: false;
24
+ readonly "!=0": true;
25
+ readonly "> -2^16": true;
26
+ readonly "> -2^32": true;
27
+ readonly ">= -2^15": true;
28
+ readonly ">= -2^31": true;
29
+ readonly ">=0": true;
30
+ readonly Finite: true;
31
+ } & Readonly<{
32
+ 'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
33
+ }> & N;
34
+ /**
35
+ * Namespace providing type-safe arithmetic operations for positive finite numbers.
36
+ *
37
+ * All operations maintain the positive constraint by clamping non-positive results to MIN_VALUE,
38
+ * while ensuring results remain finite (excluding NaN and Infinity). This type is useful
39
+ * for representing quantities that must always be positive, such as probabilities, magnitudes,
40
+ * and physical measurements.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const probability = asPositiveFiniteNumber(0.75);
45
+ * const rate = asPositiveFiniteNumber(1.25);
46
+ *
47
+ * // Arithmetic operations with positive clamping
48
+ * const combined = PositiveFiniteNumber.add(probability, rate); // PositiveFiniteNumber (2.0)
49
+ * const difference = PositiveFiniteNumber.sub(rate, probability); // PositiveFiniteNumber (0.5)
50
+ * const scaled = PositiveFiniteNumber.mul(probability, rate); // PositiveFiniteNumber (0.9375)
51
+ * const ratio = PositiveFiniteNumber.div(rate, probability); // PositiveFiniteNumber (1.666...)
52
+ *
53
+ * // Range operations
54
+ * const clamped = PositiveFiniteNumber.clamp(-10.5); // PositiveFiniteNumber (MIN_VALUE)
55
+ * const minimum = PositiveFiniteNumber.min(probability, rate); // PositiveFiniteNumber (0.75)
56
+ * const maximum = PositiveFiniteNumber.max(probability, rate); // PositiveFiniteNumber (1.25)
57
+ *
58
+ * // Rounding operations (different return types based on operation)
59
+ * const ceiled = PositiveFiniteNumber.ceil(probability); // PositiveInt (1)
60
+ * const floored = PositiveFiniteNumber.floor(rate); // Uint (1)
61
+ * const rounded = PositiveFiniteNumber.round(rate); // Uint (1)
62
+ *
63
+ * // Utility operations
64
+ * const random = PositiveFiniteNumber.random(); // PositiveFiniteNumber (random positive value)
65
+ * const power = PositiveFiniteNumber.pow(rate, probability); // PositiveFiniteNumber (1.18...)
66
+ * ```
67
+ */
68
+ export declare const PositiveFiniteNumber: {
69
+ /**
70
+ * Type guard to check if a value is a PositiveFiniteNumber.
71
+ * @param value The value to check.
72
+ * @returns `true` if the value is a positive finite number, `false` otherwise.
73
+ */
74
+ readonly is: (a: number) => a is PositiveFiniteNumber;
75
+ /**
76
+ * The minimum value for a positive finite number.
77
+ * @readonly
78
+ */
79
+ readonly MIN_VALUE: number;
80
+ /**
81
+ * Returns the smaller of two PositiveFiniteNumber values.
82
+ * @param a The first PositiveFiniteNumber.
83
+ * @param b The second PositiveFiniteNumber.
84
+ * @returns The minimum value as a PositiveFiniteNumber.
85
+ */
86
+ readonly min: (...values: readonly PositiveFiniteNumber[]) => PositiveFiniteNumber;
87
+ /**
88
+ * Returns the larger of two PositiveFiniteNumber values.
89
+ * @param a The first PositiveFiniteNumber.
90
+ * @param b The second PositiveFiniteNumber.
91
+ * @returns The maximum value as a PositiveFiniteNumber.
92
+ */
93
+ readonly max: (...values: readonly PositiveFiniteNumber[]) => PositiveFiniteNumber;
94
+ /**
95
+ * Clamps a number to the positive finite range.
96
+ * @param value The number to clamp.
97
+ * @returns The value clamped to (0, +∞) as a PositiveFiniteNumber.
98
+ */
99
+ readonly clamp: (x: number) => PositiveFiniteNumber;
100
+ /**
101
+ * Rounds down a PositiveFiniteNumber to the nearest integer.
102
+ * @param x The PositiveFiniteNumber to round down.
103
+ * @returns The floor value as a Uint (can be 0).
104
+ */
105
+ readonly floor: (x: ElementType) => TsVerifiedInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<TsVerifiedInternals.RefinedNumberUtils.ToInt<ElementType>>;
106
+ /**
107
+ * Rounds up a PositiveFiniteNumber to the nearest integer.
108
+ * @param x The PositiveFiniteNumber to round up.
109
+ * @returns The ceiling value as a PositiveInt (always >= 1).
110
+ */
111
+ readonly ceil: (x: ElementType) => TsVerifiedInternals.RefinedNumberUtils.ToInt<ElementType>;
112
+ /**
113
+ * Rounds a PositiveFiniteNumber to the nearest integer.
114
+ * @param x The PositiveFiniteNumber to round.
115
+ * @returns The rounded value as a Uint (can be 0 if x < 0.5).
116
+ */
117
+ readonly round: (x: ElementType) => TsVerifiedInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<TsVerifiedInternals.RefinedNumberUtils.ToInt<ElementType>>;
118
+ /**
119
+ * Generates a random PositiveFiniteNumber value.
120
+ * @returns A random positive finite number.
121
+ */
122
+ readonly random: (min: PositiveFiniteNumber, max: PositiveFiniteNumber) => PositiveFiniteNumber;
123
+ /**
124
+ * Raises a PositiveFiniteNumber to the power of another PositiveFiniteNumber.
125
+ * @param a The base PositiveFiniteNumber.
126
+ * @param b The exponent PositiveFiniteNumber.
127
+ * @returns `a ** b` clamped to (0, +∞) as a PositiveFiniteNumber.
128
+ */
129
+ readonly pow: (x: PositiveFiniteNumber, y: PositiveFiniteNumber) => PositiveFiniteNumber;
130
+ /**
131
+ * Adds two PositiveFiniteNumber values.
132
+ * @param a The first PositiveFiniteNumber.
133
+ * @param b The second PositiveFiniteNumber.
134
+ * @returns `a + b` clamped to (0, +∞) as a PositiveFiniteNumber.
135
+ */
136
+ readonly add: (x: PositiveFiniteNumber, y: PositiveFiniteNumber) => PositiveFiniteNumber;
137
+ /**
138
+ * Subtracts one PositiveFiniteNumber from another.
139
+ * @param a The minuend PositiveFiniteNumber.
140
+ * @param b The subtrahend PositiveFiniteNumber.
141
+ * @returns `a - b` clamped to (0, +∞) as a PositiveFiniteNumber (minimum MIN_VALUE).
142
+ */
143
+ readonly sub: (x: PositiveFiniteNumber, y: PositiveFiniteNumber) => PositiveFiniteNumber;
144
+ /**
145
+ * Multiplies two PositiveFiniteNumber values.
146
+ * @param a The first PositiveFiniteNumber.
147
+ * @param b The second PositiveFiniteNumber.
148
+ * @returns `a * b` clamped to (0, +∞) as a PositiveFiniteNumber.
149
+ */
150
+ readonly mul: (x: PositiveFiniteNumber, y: PositiveFiniteNumber) => PositiveFiniteNumber;
151
+ /**
152
+ * Divides one PositiveFiniteNumber by another.
153
+ * @param a The dividend PositiveFiniteNumber.
154
+ * @param b The divisor PositiveFiniteNumber.
155
+ * @returns `a / b` clamped to (0, +∞) as a PositiveFiniteNumber.
156
+ */
157
+ readonly div: (x: PositiveFiniteNumber, y: number & {
158
+ readonly NaNValue: false;
159
+ readonly "!=0": true;
160
+ readonly "> -2^16": true;
161
+ readonly "> -2^32": true;
162
+ readonly ">= -2^15": true;
163
+ readonly ">= -2^31": true;
164
+ readonly ">=0": true;
165
+ readonly Finite: true;
166
+ } & Readonly<{
167
+ 'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
168
+ }>) => PositiveFiniteNumber;
169
+ };
170
+ export {};
171
+ //# sourceMappingURL=positive-finite-number.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"positive-finite-number.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/positive-finite-number.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,KAAK,WAAW,GAAG,oBAAoB,CAAC;AAiExC;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,0CAAK,CAAC;AAEzC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;MAAW,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,oBAAoB;IAC/B;;;;OAIG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;OAIG;;IAGH;;;;OAIG;wBAtIA,WAAW,KACb,mBAAmB,CAAC,kBAAkB,CAAC,qBAAqB,CAC7D,mBAAmB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,CAC1D;IAsIC;;;;OAIG;uBAnIA,WAAW,KACb,mBAAmB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC;IAqI1D;;;;OAIG;wBApIA,WAAW,KACb,mBAAmB,CAAC,kBAAkB,CAAC,qBAAqB,CAC7D,mBAAmB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,CAC1D;IAoIC;;;OAGG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;;;;;;;;;;;;CAEK,CAAC"}