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,145 @@
1
+ import { TsVerifiedInternals } from '../refined-number-utils.mjs';
2
+
3
+ const typeNameInMessage = 'a non-zero integer in [-2^31, 2^31)';
4
+ const { MIN_VALUE, MAX_VALUE, abs, 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: -2147483648,
8
+ MAX_VALUE: 2 ** 31 - 1,
9
+ typeNameInMessage,
10
+ });
11
+ /**
12
+ * Checks if a number is a NonZeroInt32 (32-bit non-zero signed integer in the range [-2^31, 2^31) excluding 0).
13
+ * @param value The value to check.
14
+ * @returns `true` if the value is a NonZeroInt32, `false` otherwise.
15
+ */
16
+ const isNonZeroInt32 = is;
17
+ /**
18
+ * Casts a number to a NonZeroInt32 type.
19
+ * @param value The value to cast.
20
+ * @returns The value as a NonZeroInt32 type.
21
+ * @throws {TypeError} If the value is not a non-zero integer in [-2^31, 2^31).
22
+ * @example
23
+ * ```typescript
24
+ * const x = asNonZeroInt32(1000); // NonZeroInt32
25
+ * const y = asNonZeroInt32(-1000); // NonZeroInt32
26
+ * // asNonZeroInt32(0); // throws TypeError
27
+ * // asNonZeroInt32(2147483648); // throws TypeError
28
+ * ```
29
+ */
30
+ const asNonZeroInt32 = castType;
31
+ /**
32
+ * Namespace providing type-safe arithmetic operations for 32-bit non-zero signed integers.
33
+ *
34
+ * All operations automatically clamp results to the valid NonZeroInt32 range [-2147483648, 2147483647]
35
+ * excluding 0. This ensures that all arithmetic maintains the 32-bit non-zero signed integer
36
+ * constraint, preventing zero results and overflow.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const a = asNonZeroInt32(2000000000);
41
+ * const b = asNonZeroInt32(-500000000);
42
+ *
43
+ * // Arithmetic operations with automatic clamping and non-zero constraint
44
+ * const sum = NonZeroInt32.add(a, b); // NonZeroInt32 (1500000000)
45
+ * const diff = NonZeroInt32.sub(a, b); // NonZeroInt32 (2147483647 - clamped to MAX_VALUE)
46
+ * const product = NonZeroInt32.mul(a, b); // NonZeroInt32 (-2147483648 - clamped to MIN_VALUE)
47
+ *
48
+ * // Utility operations
49
+ * const absolute = NonZeroInt32.abs(b); // NonZeroInt32 (500000000)
50
+ * const minimum = NonZeroInt32.min(a, b); // NonZeroInt32 (-500000000)
51
+ * const maximum = NonZeroInt32.max(a, b); // NonZeroInt32 (2000000000)
52
+ *
53
+ * // Range operations (avoiding zero)
54
+ * const clamped = NonZeroInt32.clamp(0); // NonZeroInt32 (1 or -1, avoiding zero)
55
+ * const random = NonZeroInt32.random(); // NonZeroInt32 (random non-zero value in range)
56
+ * const power = NonZeroInt32.pow(asNonZeroInt32(2), asNonZeroInt32(20)); // NonZeroInt32 (1048576)
57
+ * ```
58
+ */
59
+ const NonZeroInt32 = {
60
+ /**
61
+ * Type guard to check if a value is a NonZeroInt32.
62
+ * @param value The value to check.
63
+ * @returns `true` if the value is a 32-bit non-zero signed integer, `false` otherwise.
64
+ */
65
+ is,
66
+ /**
67
+ * The minimum value for a 32-bit non-zero signed integer.
68
+ * @readonly
69
+ */
70
+ MIN_VALUE,
71
+ /**
72
+ * The maximum value for a 32-bit non-zero signed integer.
73
+ * @readonly
74
+ */
75
+ MAX_VALUE,
76
+ /**
77
+ * Returns the absolute value of a 32-bit non-zero signed integer.
78
+ * @param a The NonZeroInt32 value.
79
+ * @returns The absolute value as a NonZeroInt32, clamped to valid range.
80
+ */
81
+ abs,
82
+ /**
83
+ * Returns the smaller of two NonZeroInt32 values.
84
+ * @param a The first NonZeroInt32.
85
+ * @param b The second NonZeroInt32.
86
+ * @returns The minimum value as a NonZeroInt32.
87
+ */
88
+ min: min_,
89
+ /**
90
+ * Returns the larger of two NonZeroInt32 values.
91
+ * @param a The first NonZeroInt32.
92
+ * @param b The second NonZeroInt32.
93
+ * @returns The maximum value as a NonZeroInt32.
94
+ */
95
+ max: max_,
96
+ /**
97
+ * Clamps a number to the NonZeroInt32 range (avoiding zero).
98
+ * @param value The number to clamp.
99
+ * @returns The value clamped to [-2147483648, 2147483647] \ {0} as a NonZeroInt32.
100
+ */
101
+ clamp,
102
+ /**
103
+ * Generates a random NonZeroInt32 value within the valid range.
104
+ * @returns A random NonZeroInt32 between MIN_VALUE and MAX_VALUE (excluding 0).
105
+ */
106
+ random,
107
+ /**
108
+ * Raises a NonZeroInt32 to the power of another NonZeroInt32.
109
+ * @param a The base NonZeroInt32.
110
+ * @param b The exponent NonZeroInt32.
111
+ * @returns `a ** b` clamped to [-2147483648, 2147483647] as a NonZeroInt32.
112
+ */
113
+ pow,
114
+ /**
115
+ * Adds two NonZeroInt32 values.
116
+ * @param a The first NonZeroInt32.
117
+ * @param b The second NonZeroInt32.
118
+ * @returns `a + b` clamped to [-2147483648, 2147483647] as a NonZeroInt32.
119
+ */
120
+ add,
121
+ /**
122
+ * Subtracts one NonZeroInt32 from another.
123
+ * @param a The minuend NonZeroInt32.
124
+ * @param b The subtrahend NonZeroInt32.
125
+ * @returns `a - b` clamped to [-2147483648, 2147483647] as a NonZeroInt32.
126
+ */
127
+ sub,
128
+ /**
129
+ * Multiplies two NonZeroInt32 values.
130
+ * @param a The first NonZeroInt32.
131
+ * @param b The second NonZeroInt32.
132
+ * @returns `a * b` clamped to [-2147483648, 2147483647] as a NonZeroInt32.
133
+ */
134
+ mul,
135
+ /**
136
+ * Divides one NonZeroInt32 by another using floor division.
137
+ * @param a The dividend NonZeroInt32.
138
+ * @param b The divisor NonZeroInt32.
139
+ * @returns `⌊a / b⌋` clamped to [-2147483648, 2147483647] as a NonZeroInt32.
140
+ */
141
+ div,
142
+ };
143
+
144
+ export { NonZeroInt32, asNonZeroInt32, isNonZeroInt32 };
145
+ //# sourceMappingURL=non-zero-int32.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"non-zero-int32.mjs","sources":["../../../src/number/branded-types/non-zero-int32.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA,MAAM,iBAAiB,GAAG,qCAAqC;AAE/D,MAAM,EACJ,SAAS,EACT,SAAS,EACT,GAAG,EACH,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,WAAU;AACrB,IAAA,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC;IACtB,iBAAiB;AACT,CAAA,CAAC;AAEX;;;;AAIG;AACI,MAAM,cAAc,GAAG;AAE9B;;;;;;;;;;;;AAYG;AACI,MAAM,cAAc,GAAG;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACI,MAAM,YAAY,GAAG;AAC1B;;;;AAIG;IACH,EAAE;AAEF;;;AAGG;IACH,SAAS;AAET;;;AAGG;IACH,SAAS;AAET;;;;AAIG;IACH,GAAG;AAEH;;;;;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,148 @@
1
+ import { TsVerifiedInternals } from '../refined-number-utils.mjs';
2
+ /**
3
+ * Checks if a number is a NonZeroSafeInt (a non-zero safe integer in the range [MIN_SAFE_INTEGER, MAX_SAFE_INTEGER] excluding 0).
4
+ * @param value The value to check.
5
+ * @returns `true` if the value is a NonZeroSafeInt, `false` otherwise.
6
+ */
7
+ export declare const isNonZeroSafeInt: (a: number) => a is NonZeroSafeInt;
8
+ /**
9
+ * Casts a number to a NonZeroSafeInt type.
10
+ * @param value The value to cast.
11
+ * @returns The value as a NonZeroSafeInt type.
12
+ * @throws {TypeError} If the value is not a non-zero safe integer.
13
+ * @example
14
+ * ```typescript
15
+ * const x = asNonZeroSafeInt(5); // NonZeroSafeInt
16
+ * const y = asNonZeroSafeInt(-1000); // NonZeroSafeInt
17
+ * // asNonZeroSafeInt(0); // throws TypeError
18
+ * // asNonZeroSafeInt(1.5); // throws TypeError
19
+ * ```
20
+ */
21
+ export declare const asNonZeroSafeInt: <N extends number>(x: N) => number & {
22
+ readonly NaNValue: false;
23
+ readonly "!=0": true;
24
+ readonly Finite: true;
25
+ readonly Int: true;
26
+ readonly SafeInt: true;
27
+ } & Readonly<{
28
+ 'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
29
+ }> & N;
30
+ /**
31
+ * Namespace providing type-safe arithmetic operations for non-zero safe integers.
32
+ *
33
+ * All operations automatically clamp results to the non-zero safe integer range, excluding zero.
34
+ * This ensures that all arithmetic maintains both the non-zero constraint and IEEE 754 precision guarantees,
35
+ * preventing precision loss while ensuring results are never zero.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const a = asNonZeroSafeInt(9007199254740000); // Near MAX_SAFE_INTEGER
40
+ * const b = asNonZeroSafeInt(-1000);
41
+ *
42
+ * // Arithmetic operations with non-zero safe range clamping
43
+ * const sum = NonZeroSafeInt.add(a, b); // NonZeroSafeInt (9007199254739000)
44
+ * const diff = NonZeroSafeInt.sub(a, b); // NonZeroSafeInt (clamped to MAX_SAFE_INTEGER)
45
+ * const product = NonZeroSafeInt.mul(a, b); // NonZeroSafeInt (clamped to MIN_SAFE_INTEGER)
46
+ *
47
+ * // Utility operations
48
+ * const absolute = NonZeroSafeInt.abs(b); // NonZeroSafeInt (1000)
49
+ * const minimum = NonZeroSafeInt.min(a, b); // NonZeroSafeInt (-1000)
50
+ * const maximum = NonZeroSafeInt.max(a, b); // NonZeroSafeInt (a)
51
+ *
52
+ * // Random generation
53
+ * const random = NonZeroSafeInt.random(); // NonZeroSafeInt (random non-zero safe integer)
54
+ * ```
55
+ */
56
+ export declare const NonZeroSafeInt: {
57
+ /**
58
+ * Type guard to check if a value is a NonZeroSafeInt.
59
+ * @param value The value to check.
60
+ * @returns `true` if the value is a non-zero safe integer, `false` otherwise.
61
+ */
62
+ readonly is: (a: number) => a is NonZeroSafeInt;
63
+ /**
64
+ * The minimum safe integer value (-(2^53 - 1)).
65
+ * @readonly
66
+ */
67
+ readonly MIN_VALUE: SafeInt;
68
+ /**
69
+ * The maximum safe integer value (2^53 - 1).
70
+ * @readonly
71
+ */
72
+ readonly MAX_VALUE: SafeUint;
73
+ /**
74
+ * Returns the absolute value of a non-zero safe integer.
75
+ * @param a The NonZeroSafeInt value.
76
+ * @returns The absolute value as a NonZeroSafeInt, clamped to safe range.
77
+ */
78
+ readonly abs: (x: WithSmallInt<NonZeroSafeInt, 40>) => TsVerifiedInternals.RefinedNumberUtils.ToNonNegative<NonZeroSafeInt>;
79
+ /**
80
+ * Returns the smaller of two NonZeroSafeInt values.
81
+ * @param a The first NonZeroSafeInt.
82
+ * @param b The second NonZeroSafeInt.
83
+ * @returns The minimum value as a NonZeroSafeInt.
84
+ */
85
+ readonly min: (...values: readonly WithSmallInt<NonZeroSafeInt, 40>[]) => NonZeroSafeInt;
86
+ /**
87
+ * Returns the larger of two NonZeroSafeInt values.
88
+ * @param a The first NonZeroSafeInt.
89
+ * @param b The second NonZeroSafeInt.
90
+ * @returns The maximum value as a NonZeroSafeInt.
91
+ */
92
+ readonly max: (...values: readonly WithSmallInt<NonZeroSafeInt, 40>[]) => NonZeroSafeInt;
93
+ /**
94
+ * Clamps a number to the non-zero safe integer range.
95
+ * @param value The number to clamp.
96
+ * @returns The value clamped to [MIN_SAFE_INTEGER, MAX_SAFE_INTEGER] \ {0} as a NonZeroSafeInt.
97
+ */
98
+ readonly clamp: (x: number) => NonZeroSafeInt;
99
+ /**
100
+ * Generates a random NonZeroSafeInt value within the valid range.
101
+ * @returns A random non-zero safe integer between MIN_SAFE_INTEGER and MAX_SAFE_INTEGER.
102
+ */
103
+ readonly random: (min: WithSmallInt<NonZeroSafeInt, 40>, max: WithSmallInt<NonZeroSafeInt, 40>) => NonZeroSafeInt;
104
+ /**
105
+ * Raises a NonZeroSafeInt to the power of another NonZeroSafeInt.
106
+ * @param a The base NonZeroSafeInt.
107
+ * @param b The exponent NonZeroSafeInt.
108
+ * @returns `a ** b` clamped to non-zero safe integer range as a NonZeroSafeInt.
109
+ */
110
+ readonly pow: (x: WithSmallInt<NonZeroSafeInt, 40>, y: WithSmallInt<NonZeroSafeInt, 40>) => NonZeroSafeInt;
111
+ /**
112
+ * Adds two NonZeroSafeInt values.
113
+ * @param a The first NonZeroSafeInt.
114
+ * @param b The second NonZeroSafeInt.
115
+ * @returns `a + b` clamped to non-zero safe integer range as a NonZeroSafeInt.
116
+ */
117
+ readonly add: (x: WithSmallInt<NonZeroSafeInt, 40>, y: WithSmallInt<NonZeroSafeInt, 40>) => NonZeroSafeInt;
118
+ /**
119
+ * Subtracts one NonZeroSafeInt from another.
120
+ * @param a The minuend NonZeroSafeInt.
121
+ * @param b The subtrahend NonZeroSafeInt.
122
+ * @returns `a - b` clamped to non-zero safe integer range as a NonZeroSafeInt.
123
+ */
124
+ readonly sub: (x: WithSmallInt<NonZeroSafeInt, 40>, y: WithSmallInt<NonZeroSafeInt, 40>) => NonZeroSafeInt;
125
+ /**
126
+ * Multiplies two NonZeroSafeInt values.
127
+ * @param a The first NonZeroSafeInt.
128
+ * @param b The second NonZeroSafeInt.
129
+ * @returns `a * b` clamped to non-zero safe integer range as a NonZeroSafeInt.
130
+ */
131
+ readonly mul: (x: WithSmallInt<NonZeroSafeInt, 40>, y: WithSmallInt<NonZeroSafeInt, 40>) => NonZeroSafeInt;
132
+ /**
133
+ * Divides one NonZeroSafeInt by another using floor division.
134
+ * @param a The dividend NonZeroSafeInt.
135
+ * @param b The divisor NonZeroSafeInt.
136
+ * @returns `⌊a / b⌋` clamped to non-zero safe integer range as a NonZeroSafeInt.
137
+ */
138
+ readonly div: (x: WithSmallInt<NonZeroSafeInt, 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 | -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 | -40 | NormalizeBrandUnion<number & {
139
+ readonly NaNValue: false;
140
+ readonly "!=0": true;
141
+ readonly Finite: true;
142
+ readonly Int: true;
143
+ readonly SafeInt: true;
144
+ } & Readonly<{
145
+ 'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
146
+ }>>) => NonZeroSafeInt;
147
+ };
148
+ //# sourceMappingURL=non-zero-safe-int.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"non-zero-safe-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-zero-safe-int.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAmClE;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,oCAAK,CAAC;AAEnC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;MAAW,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,cAAc;IACzB;;;;OAIG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;OAIG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;OAIG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;;;;;;;;;CAEK,CAAC"}
@@ -0,0 +1,145 @@
1
+ import { TsVerifiedInternals } from '../refined-number-utils.mjs';
2
+
3
+ const typeNameInMessage = 'a non-zero safe integer';
4
+ const { MIN_VALUE, MAX_VALUE, abs, min: min_, max: max_, pow, add, sub, mul, div, randomNonZero: random, is, castType, clamp, } = TsVerifiedInternals.RefinedNumberUtils.operatorsForInteger({
5
+ integerOrSafeInteger: 'SafeInteger',
6
+ nonZero: true,
7
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
8
+ MIN_VALUE: Number.MIN_SAFE_INTEGER,
9
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
10
+ MAX_VALUE: Number.MAX_SAFE_INTEGER,
11
+ typeNameInMessage,
12
+ });
13
+ /**
14
+ * Checks if a number is a NonZeroSafeInt (a non-zero safe integer in the range [MIN_SAFE_INTEGER, MAX_SAFE_INTEGER] excluding 0).
15
+ * @param value The value to check.
16
+ * @returns `true` if the value is a NonZeroSafeInt, `false` otherwise.
17
+ */
18
+ const isNonZeroSafeInt = is;
19
+ /**
20
+ * Casts a number to a NonZeroSafeInt type.
21
+ * @param value The value to cast.
22
+ * @returns The value as a NonZeroSafeInt type.
23
+ * @throws {TypeError} If the value is not a non-zero safe integer.
24
+ * @example
25
+ * ```typescript
26
+ * const x = asNonZeroSafeInt(5); // NonZeroSafeInt
27
+ * const y = asNonZeroSafeInt(-1000); // NonZeroSafeInt
28
+ * // asNonZeroSafeInt(0); // throws TypeError
29
+ * // asNonZeroSafeInt(1.5); // throws TypeError
30
+ * ```
31
+ */
32
+ const asNonZeroSafeInt = castType;
33
+ /**
34
+ * Namespace providing type-safe arithmetic operations for non-zero safe integers.
35
+ *
36
+ * All operations automatically clamp results to the non-zero safe integer range, excluding zero.
37
+ * This ensures that all arithmetic maintains both the non-zero constraint and IEEE 754 precision guarantees,
38
+ * preventing precision loss while ensuring results are never zero.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const a = asNonZeroSafeInt(9007199254740000); // Near MAX_SAFE_INTEGER
43
+ * const b = asNonZeroSafeInt(-1000);
44
+ *
45
+ * // Arithmetic operations with non-zero safe range clamping
46
+ * const sum = NonZeroSafeInt.add(a, b); // NonZeroSafeInt (9007199254739000)
47
+ * const diff = NonZeroSafeInt.sub(a, b); // NonZeroSafeInt (clamped to MAX_SAFE_INTEGER)
48
+ * const product = NonZeroSafeInt.mul(a, b); // NonZeroSafeInt (clamped to MIN_SAFE_INTEGER)
49
+ *
50
+ * // Utility operations
51
+ * const absolute = NonZeroSafeInt.abs(b); // NonZeroSafeInt (1000)
52
+ * const minimum = NonZeroSafeInt.min(a, b); // NonZeroSafeInt (-1000)
53
+ * const maximum = NonZeroSafeInt.max(a, b); // NonZeroSafeInt (a)
54
+ *
55
+ * // Random generation
56
+ * const random = NonZeroSafeInt.random(); // NonZeroSafeInt (random non-zero safe integer)
57
+ * ```
58
+ */
59
+ const NonZeroSafeInt = {
60
+ /**
61
+ * Type guard to check if a value is a NonZeroSafeInt.
62
+ * @param value The value to check.
63
+ * @returns `true` if the value is a non-zero safe integer, `false` otherwise.
64
+ */
65
+ is,
66
+ /**
67
+ * The minimum safe integer value (-(2^53 - 1)).
68
+ * @readonly
69
+ */
70
+ MIN_VALUE,
71
+ /**
72
+ * The maximum safe integer value (2^53 - 1).
73
+ * @readonly
74
+ */
75
+ MAX_VALUE,
76
+ /**
77
+ * Returns the absolute value of a non-zero safe integer.
78
+ * @param a The NonZeroSafeInt value.
79
+ * @returns The absolute value as a NonZeroSafeInt, clamped to safe range.
80
+ */
81
+ abs,
82
+ /**
83
+ * Returns the smaller of two NonZeroSafeInt values.
84
+ * @param a The first NonZeroSafeInt.
85
+ * @param b The second NonZeroSafeInt.
86
+ * @returns The minimum value as a NonZeroSafeInt.
87
+ */
88
+ min: min_,
89
+ /**
90
+ * Returns the larger of two NonZeroSafeInt values.
91
+ * @param a The first NonZeroSafeInt.
92
+ * @param b The second NonZeroSafeInt.
93
+ * @returns The maximum value as a NonZeroSafeInt.
94
+ */
95
+ max: max_,
96
+ /**
97
+ * Clamps a number to the non-zero safe integer range.
98
+ * @param value The number to clamp.
99
+ * @returns The value clamped to [MIN_SAFE_INTEGER, MAX_SAFE_INTEGER] \ {0} as a NonZeroSafeInt.
100
+ */
101
+ clamp,
102
+ /**
103
+ * Generates a random NonZeroSafeInt value within the valid range.
104
+ * @returns A random non-zero safe integer between MIN_SAFE_INTEGER and MAX_SAFE_INTEGER.
105
+ */
106
+ random,
107
+ /**
108
+ * Raises a NonZeroSafeInt to the power of another NonZeroSafeInt.
109
+ * @param a The base NonZeroSafeInt.
110
+ * @param b The exponent NonZeroSafeInt.
111
+ * @returns `a ** b` clamped to non-zero safe integer range as a NonZeroSafeInt.
112
+ */
113
+ pow,
114
+ /**
115
+ * Adds two NonZeroSafeInt values.
116
+ * @param a The first NonZeroSafeInt.
117
+ * @param b The second NonZeroSafeInt.
118
+ * @returns `a + b` clamped to non-zero safe integer range as a NonZeroSafeInt.
119
+ */
120
+ add,
121
+ /**
122
+ * Subtracts one NonZeroSafeInt from another.
123
+ * @param a The minuend NonZeroSafeInt.
124
+ * @param b The subtrahend NonZeroSafeInt.
125
+ * @returns `a - b` clamped to non-zero safe integer range as a NonZeroSafeInt.
126
+ */
127
+ sub,
128
+ /**
129
+ * Multiplies two NonZeroSafeInt values.
130
+ * @param a The first NonZeroSafeInt.
131
+ * @param b The second NonZeroSafeInt.
132
+ * @returns `a * b` clamped to non-zero safe integer range as a NonZeroSafeInt.
133
+ */
134
+ mul,
135
+ /**
136
+ * Divides one NonZeroSafeInt by another using floor division.
137
+ * @param a The dividend NonZeroSafeInt.
138
+ * @param b The divisor NonZeroSafeInt.
139
+ * @returns `⌊a / b⌋` clamped to non-zero safe integer range as a NonZeroSafeInt.
140
+ */
141
+ div,
142
+ };
143
+
144
+ export { NonZeroSafeInt, asNonZeroSafeInt, isNonZeroSafeInt };
145
+ //# sourceMappingURL=non-zero-safe-int.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"non-zero-safe-int.mjs","sources":["../../../src/number/branded-types/non-zero-safe-int.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA,MAAM,iBAAiB,GAAG,yBAAyB;AAEnD,MAAM,EACJ,SAAS,EACT,SAAS,EACT,GAAG,EACH,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;;IAEb,SAAS,EAAE,MAAM,CAAC,gBAA2B;;IAE7C,SAAS,EAAE,MAAM,CAAC,gBAA4B;IAC9C,iBAAiB;AACT,CAAA,CAAC;AAEX;;;;AAIG;AACI,MAAM,gBAAgB,GAAG;AAEhC;;;;;;;;;;;;AAYG;AACI,MAAM,gBAAgB,GAAG;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;AACI,MAAM,cAAc,GAAG;AAC5B;;;;AAIG;IACH,EAAE;AAEF;;;AAGG;IACH,SAAS;AAET;;;AAGG;IACH,SAAS;AAET;;;;AAIG;IACH,GAAG;AAEH;;;;;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,160 @@
1
+ /**
2
+ * Checks if a number is a NonZeroUint16 (16-bit non-zero unsigned integer in the range [1, 2^16)).
3
+ * @param value The value to check.
4
+ * @returns `true` if the value is a NonZeroUint16, `false` otherwise.
5
+ */
6
+ export declare const isNonZeroUint16: (a: number) => a is PositiveUint16;
7
+ /**
8
+ * Casts a number to a NonZeroUint16 type.
9
+ * @param value The value to cast.
10
+ * @returns The value as a NonZeroUint16 type.
11
+ * @throws {TypeError} If the value is not a non-zero integer in [1, 2^16).
12
+ * @example
13
+ * ```typescript
14
+ * const x = asNonZeroUint16(1000); // NonZeroUint16
15
+ * const y = asNonZeroUint16(65535); // NonZeroUint16
16
+ * // asNonZeroUint16(0); // throws TypeError
17
+ * // asNonZeroUint16(-1); // throws TypeError
18
+ * // asNonZeroUint16(65536); // throws TypeError
19
+ * ```
20
+ */
21
+ export declare const asNonZeroUint16: <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^16": true;
30
+ readonly "< 2^31": true;
31
+ readonly "< 2^32": true;
32
+ readonly Finite: true;
33
+ readonly Int: true;
34
+ readonly SafeInt: true;
35
+ } & Readonly<{
36
+ 'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
37
+ }> & N;
38
+ /**
39
+ * Namespace providing type-safe arithmetic operations for 16-bit non-zero unsigned integers.
40
+ *
41
+ * All operations automatically clamp results to the valid NonZeroUint16 range [1, 65535].
42
+ * This ensures that all arithmetic maintains the 16-bit non-zero unsigned integer constraint,
43
+ * with results below 1 clamped to MIN_VALUE and overflow results clamped to MAX_VALUE.
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const a = asNonZeroUint16(60000);
48
+ * const b = asNonZeroUint16(10000);
49
+ *
50
+ * // Arithmetic operations with automatic clamping and non-zero constraint
51
+ * const sum = NonZeroUint16.add(a, b); // NonZeroUint16 (65535 - clamped to MAX_VALUE)
52
+ * const diff = NonZeroUint16.sub(a, b); // NonZeroUint16 (50000)
53
+ * const reverseDiff = NonZeroUint16.sub(b, a); // NonZeroUint16 (1 - clamped to MIN_VALUE)
54
+ * const product = NonZeroUint16.mul(a, b); // NonZeroUint16 (65535 - clamped due to overflow)
55
+ *
56
+ * // Range operations (maintaining non-zero constraint)
57
+ * const clamped = NonZeroUint16.clamp(-100); // NonZeroUint16 (1)
58
+ * const minimum = NonZeroUint16.min(a, b); // NonZeroUint16 (10000)
59
+ * const maximum = NonZeroUint16.max(a, b); // NonZeroUint16 (60000)
60
+ *
61
+ * // Utility operations
62
+ * const random = NonZeroUint16.random(); // NonZeroUint16 (random value in [1, 65535])
63
+ * const power = NonZeroUint16.pow(asNonZeroUint16(2), asNonZeroUint16(10)); // NonZeroUint16 (1024)
64
+ * ```
65
+ */
66
+ export declare const NonZeroUint16: {
67
+ /**
68
+ * Type guard to check if a value is a NonZeroUint16.
69
+ * @param value The value to check.
70
+ * @returns `true` if the value is a 16-bit non-zero unsigned integer, `false` otherwise.
71
+ */
72
+ readonly is: (a: number) => a is PositiveUint16;
73
+ /**
74
+ * The minimum value for a 16-bit non-zero unsigned integer.
75
+ * @readonly
76
+ */
77
+ readonly MIN_VALUE: 1;
78
+ /**
79
+ * The maximum value for a 16-bit non-zero unsigned integer.
80
+ * @readonly
81
+ */
82
+ readonly MAX_VALUE: number;
83
+ /**
84
+ * Returns the smaller of two NonZeroUint16 values.
85
+ * @param a The first NonZeroUint16.
86
+ * @param b The second NonZeroUint16.
87
+ * @returns The minimum value as a NonZeroUint16.
88
+ */
89
+ readonly min: (...values: readonly WithSmallInt<PositiveUint16, 40>[]) => PositiveUint16;
90
+ /**
91
+ * Returns the larger of two NonZeroUint16 values.
92
+ * @param a The first NonZeroUint16.
93
+ * @param b The second NonZeroUint16.
94
+ * @returns The maximum value as a NonZeroUint16.
95
+ */
96
+ readonly max: (...values: readonly WithSmallInt<PositiveUint16, 40>[]) => PositiveUint16;
97
+ /**
98
+ * Clamps a number to the NonZeroUint16 range.
99
+ * @param value The number to clamp.
100
+ * @returns The value clamped to [1, 65535] as a NonZeroUint16.
101
+ */
102
+ readonly clamp: (x: number) => PositiveUint16;
103
+ /**
104
+ * Generates a random NonZeroUint16 value within the valid range.
105
+ * @returns A random NonZeroUint16 between 1 and 65535.
106
+ */
107
+ readonly random: (min: WithSmallInt<PositiveUint16, 40>, max: WithSmallInt<PositiveUint16, 40>) => PositiveUint16;
108
+ /**
109
+ * Raises a NonZeroUint16 to the power of another NonZeroUint16.
110
+ * @param a The base NonZeroUint16.
111
+ * @param b The exponent NonZeroUint16.
112
+ * @returns `a ** b` clamped to [1, 65535] as a NonZeroUint16.
113
+ */
114
+ readonly pow: (x: WithSmallInt<PositiveUint16, 40>, y: WithSmallInt<PositiveUint16, 40>) => PositiveUint16;
115
+ /**
116
+ * Adds two NonZeroUint16 values.
117
+ * @param a The first NonZeroUint16.
118
+ * @param b The second NonZeroUint16.
119
+ * @returns `a + b` clamped to [1, 65535] as a NonZeroUint16.
120
+ */
121
+ readonly add: (x: WithSmallInt<PositiveUint16, 40>, y: WithSmallInt<PositiveUint16, 40>) => PositiveUint16;
122
+ /**
123
+ * Subtracts one NonZeroUint16 from another.
124
+ * @param a The minuend NonZeroUint16.
125
+ * @param b The subtrahend NonZeroUint16.
126
+ * @returns `a - b` clamped to [1, 65535] as a NonZeroUint16 (minimum 1).
127
+ */
128
+ readonly sub: (x: WithSmallInt<PositiveUint16, 40>, y: WithSmallInt<PositiveUint16, 40>) => PositiveUint16;
129
+ /**
130
+ * Multiplies two NonZeroUint16 values.
131
+ * @param a The first NonZeroUint16.
132
+ * @param b The second NonZeroUint16.
133
+ * @returns `a * b` clamped to [1, 65535] as a NonZeroUint16.
134
+ */
135
+ readonly mul: (x: WithSmallInt<PositiveUint16, 40>, y: WithSmallInt<PositiveUint16, 40>) => PositiveUint16;
136
+ /**
137
+ * Divides one NonZeroUint16 by another using floor division.
138
+ * @param a The dividend NonZeroUint16.
139
+ * @param b The divisor NonZeroUint16.
140
+ * @returns `⌊a / b⌋` clamped to [1, 65535] as a NonZeroUint16.
141
+ */
142
+ readonly div: (x: WithSmallInt<PositiveUint16, 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 & {
143
+ readonly NaNValue: false;
144
+ readonly "!=0": true;
145
+ readonly "> -2^16": true;
146
+ readonly "> -2^32": true;
147
+ readonly ">= -2^15": true;
148
+ readonly ">= -2^31": true;
149
+ readonly ">=0": true;
150
+ readonly "< 2^16": true;
151
+ readonly "< 2^31": true;
152
+ readonly "< 2^32": true;
153
+ readonly Finite: true;
154
+ readonly Int: true;
155
+ readonly SafeInt: true;
156
+ } & Readonly<{
157
+ 'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
158
+ }>>) => PositiveUint16;
159
+ };
160
+ //# sourceMappingURL=non-zero-uint16.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"non-zero-uint16.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-zero-uint16.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"}