ts-data-forge 10.0.0 → 11.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/dist/array/impl/array-utils-creation.d.mts +3 -3
  2. package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
  3. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  4. package/dist/array/impl/array-utils-element-access.d.mts +4 -4
  5. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  6. package/dist/{guard/as-length-bounded-array.d.mts → array/impl/array-utils-length-bounded-array-cast.d.mts} +9 -9
  7. package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts.map +1 -0
  8. package/dist/{guard/as-length-bounded-array.mjs → array/impl/array-utils-length-bounded-array-cast.mjs} +2 -2
  9. package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -0
  10. package/dist/{guard/is-length-bounded-array.d.mts → array/impl/array-utils-length-bounded-array-guard.d.mts} +13 -13
  11. package/dist/array/impl/array-utils-length-bounded-array-guard.d.mts.map +1 -0
  12. package/dist/{guard/is-length-bounded-array.mjs → array/impl/array-utils-length-bounded-array-guard.mjs} +1 -1
  13. package/dist/array/impl/array-utils-length-bounded-array-guard.mjs.map +1 -0
  14. package/dist/array/impl/array-utils-modification.d.mts +9 -9
  15. package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
  16. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  17. package/dist/array/impl/array-utils-reducing-value.d.mts +9 -9
  18. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  19. package/dist/array/impl/array-utils-size.d.mts +3 -3
  20. package/dist/array/impl/array-utils-size.mjs.map +1 -1
  21. package/dist/array/impl/array-utils-slicing.d.mts +9 -9
  22. package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
  23. package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
  24. package/dist/array/impl/array-utils-transformation.d.mts +16 -10
  25. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
  26. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  27. package/dist/array/impl/index.d.mts +2 -0
  28. package/dist/array/impl/index.d.mts.map +1 -1
  29. package/dist/array/impl/index.mjs +2 -0
  30. package/dist/array/impl/index.mjs.map +1 -1
  31. package/dist/entry-point.mjs +1 -3
  32. package/dist/entry-point.mjs.map +1 -1
  33. package/dist/guard/index.d.mts +0 -3
  34. package/dist/guard/index.d.mts.map +1 -1
  35. package/dist/guard/index.mjs +0 -3
  36. package/dist/guard/index.mjs.map +1 -1
  37. package/dist/index.d.mts +1 -0
  38. package/dist/index.d.mts.map +1 -1
  39. package/dist/index.mjs +1 -3
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/number/branded-types/finite-number.d.mts +47 -61
  42. package/dist/number/branded-types/finite-number.d.mts.map +1 -1
  43. package/dist/number/branded-types/finite-number.mjs +37 -41
  44. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  45. package/dist/number/branded-types/int.d.mts +40 -46
  46. package/dist/number/branded-types/int.d.mts.map +1 -1
  47. package/dist/number/branded-types/int.mjs +29 -31
  48. package/dist/number/branded-types/int.mjs.map +1 -1
  49. package/dist/number/branded-types/int16.d.mts +65 -58
  50. package/dist/number/branded-types/int16.d.mts.map +1 -1
  51. package/dist/number/branded-types/int16.mjs +49 -45
  52. package/dist/number/branded-types/int16.mjs.map +1 -1
  53. package/dist/number/branded-types/int32.d.mts +65 -58
  54. package/dist/number/branded-types/int32.d.mts.map +1 -1
  55. package/dist/number/branded-types/int32.mjs +49 -45
  56. package/dist/number/branded-types/int32.mjs.map +1 -1
  57. package/dist/number/branded-types/negative-finite-number.d.mts +68 -59
  58. package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
  59. package/dist/number/branded-types/negative-finite-number.mjs +52 -46
  60. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  61. package/dist/number/branded-types/negative-int.d.mts +60 -48
  62. package/dist/number/branded-types/negative-int.d.mts.map +1 -1
  63. package/dist/number/branded-types/negative-int.mjs +40 -36
  64. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  65. package/dist/number/branded-types/negative-safe-int.d.mts +57 -56
  66. package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
  67. package/dist/number/branded-types/negative-safe-int.mjs +40 -41
  68. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  69. package/dist/number/branded-types/non-negative-finite-number.d.mts +74 -64
  70. package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
  71. package/dist/number/branded-types/non-negative-finite-number.mjs +58 -51
  72. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  73. package/dist/number/branded-types/non-negative-int16.d.mts +64 -57
  74. package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
  75. package/dist/number/branded-types/non-negative-int16.mjs +47 -43
  76. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  77. package/dist/number/branded-types/non-negative-int32.d.mts +64 -58
  78. package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
  79. package/dist/number/branded-types/non-negative-int32.mjs +47 -44
  80. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  81. package/dist/number/branded-types/non-positive-finite-number.d.mts +64 -54
  82. package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
  83. package/dist/number/branded-types/non-positive-finite-number.mjs +48 -41
  84. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  85. package/dist/number/branded-types/non-positive-int.d.mts +41 -146
  86. package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
  87. package/dist/number/branded-types/non-positive-int.mjs +27 -107
  88. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  89. package/dist/number/branded-types/non-positive-safe-int.d.mts +54 -53
  90. package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
  91. package/dist/number/branded-types/non-positive-safe-int.mjs +37 -39
  92. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  93. package/dist/number/branded-types/non-zero-finite-number.d.mts +62 -49
  94. package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
  95. package/dist/number/branded-types/non-zero-finite-number.mjs +46 -37
  96. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  97. package/dist/number/branded-types/non-zero-int.d.mts +51 -38
  98. package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
  99. package/dist/number/branded-types/non-zero-int.mjs +31 -27
  100. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  101. package/dist/number/branded-types/non-zero-int16.d.mts +52 -53
  102. package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
  103. package/dist/number/branded-types/non-zero-int16.mjs +36 -39
  104. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  105. package/dist/number/branded-types/non-zero-int32.d.mts +52 -54
  106. package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
  107. package/dist/number/branded-types/non-zero-int32.mjs +36 -40
  108. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  109. package/dist/number/branded-types/non-zero-safe-int.d.mts +53 -54
  110. package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
  111. package/dist/number/branded-types/non-zero-safe-int.mjs +36 -40
  112. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  113. package/dist/number/branded-types/non-zero-uint16.d.mts +52 -53
  114. package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
  115. package/dist/number/branded-types/non-zero-uint16.mjs +35 -39
  116. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  117. package/dist/number/branded-types/non-zero-uint32.d.mts +52 -53
  118. package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
  119. package/dist/number/branded-types/non-zero-uint32.mjs +35 -39
  120. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  121. package/dist/number/branded-types/positive-finite-number.d.mts +74 -63
  122. package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
  123. package/dist/number/branded-types/positive-finite-number.mjs +58 -50
  124. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  125. package/dist/number/branded-types/positive-int.d.mts +46 -68
  126. package/dist/number/branded-types/positive-int.d.mts.map +1 -1
  127. package/dist/number/branded-types/positive-int.mjs +34 -49
  128. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  129. package/dist/number/branded-types/positive-int16.d.mts +61 -57
  130. package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
  131. package/dist/number/branded-types/positive-int16.mjs +44 -43
  132. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  133. package/dist/number/branded-types/positive-int32.d.mts +61 -57
  134. package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
  135. package/dist/number/branded-types/positive-int32.mjs +44 -43
  136. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  137. package/dist/number/branded-types/positive-safe-int.d.mts +62 -57
  138. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
  139. package/dist/number/branded-types/positive-safe-int.mjs +45 -43
  140. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  141. package/dist/number/branded-types/positive-uint16.d.mts +61 -57
  142. package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
  143. package/dist/number/branded-types/positive-uint16.mjs +44 -43
  144. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  145. package/dist/number/branded-types/positive-uint32.d.mts +61 -58
  146. package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
  147. package/dist/number/branded-types/positive-uint32.mjs +44 -44
  148. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  149. package/dist/number/branded-types/safe-int.d.mts +43 -62
  150. package/dist/number/branded-types/safe-int.d.mts.map +1 -1
  151. package/dist/number/branded-types/safe-int.mjs +35 -42
  152. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  153. package/dist/number/branded-types/safe-uint.d.mts +62 -57
  154. package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
  155. package/dist/number/branded-types/safe-uint.mjs +46 -44
  156. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  157. package/dist/number/branded-types/uint.d.mts +63 -50
  158. package/dist/number/branded-types/uint.d.mts.map +1 -1
  159. package/dist/number/branded-types/uint.mjs +42 -39
  160. package/dist/number/branded-types/uint.mjs.map +1 -1
  161. package/dist/number/branded-types/uint16.d.mts +60 -58
  162. package/dist/number/branded-types/uint16.d.mts.map +1 -1
  163. package/dist/number/branded-types/uint16.mjs +44 -43
  164. package/dist/number/branded-types/uint16.mjs.map +1 -1
  165. package/dist/number/branded-types/uint32.d.mts +59 -55
  166. package/dist/number/branded-types/uint32.d.mts.map +1 -1
  167. package/dist/number/branded-types/uint32.mjs +42 -42
  168. package/dist/number/branded-types/uint32.mjs.map +1 -1
  169. package/dist/number/enum/int8.d.mts +56 -65
  170. package/dist/number/enum/int8.d.mts.map +1 -1
  171. package/dist/number/enum/int8.mjs +44 -43
  172. package/dist/number/enum/int8.mjs.map +1 -1
  173. package/dist/number/enum/uint8.d.mts +60 -58
  174. package/dist/number/enum/uint8.d.mts.map +1 -1
  175. package/dist/number/enum/uint8.mjs +44 -43
  176. package/dist/number/enum/uint8.mjs.map +1 -1
  177. package/dist/string/index.d.mts +2 -0
  178. package/dist/string/index.d.mts.map +1 -0
  179. package/dist/string/index.mjs +2 -0
  180. package/dist/string/index.mjs.map +1 -0
  181. package/dist/string/str.d.mts +273 -0
  182. package/dist/string/str.d.mts.map +1 -0
  183. package/dist/string/str.mjs +42 -0
  184. package/dist/string/str.mjs.map +1 -0
  185. package/package.json +31 -92
  186. package/src/array/impl/array-utils-creation.mts +2 -1
  187. package/src/array/impl/array-utils-element-access.mts +3 -3
  188. package/src/array/impl/array-utils-element-access.test.mts +3 -3
  189. package/src/{guard/as-length-bounded-array.mts → array/impl/array-utils-length-bounded-array-cast.mts} +9 -9
  190. package/src/{guard/as-length-bounded-array.test.mts → array/impl/array-utils-length-bounded-array-cast.test.mts} +2 -2
  191. package/src/{guard/is-length-bounded-array.mts → array/impl/array-utils-length-bounded-array-guard.mts} +12 -12
  192. package/src/{guard/is-length-bounded-array.test.mts → array/impl/array-utils-length-bounded-array-guard.test.mts} +2 -2
  193. package/src/array/impl/array-utils-modification.mts +9 -8
  194. package/src/array/impl/array-utils-modification.test.mts +6 -1
  195. package/src/array/impl/array-utils-reducing-value.mts +9 -9
  196. package/src/array/impl/array-utils-size.mts +2 -2
  197. package/src/array/impl/array-utils-slicing.mts +24 -13
  198. package/src/array/impl/array-utils-transformation.mts +18 -12
  199. package/src/array/impl/array-utils-transformation.test.mts +12 -12
  200. package/src/array/impl/index.mts +2 -0
  201. package/src/guard/index.mts +0 -3
  202. package/src/index.mts +1 -0
  203. package/src/number/branded-types/finite-number.mts +47 -61
  204. package/src/number/branded-types/int.mts +40 -46
  205. package/src/number/branded-types/int16.mts +65 -58
  206. package/src/number/branded-types/int32.mts +65 -58
  207. package/src/number/branded-types/negative-finite-number.mts +68 -68
  208. package/src/number/branded-types/negative-int.mts +60 -57
  209. package/src/number/branded-types/negative-safe-int.mts +57 -65
  210. package/src/number/branded-types/non-negative-finite-number.mts +74 -64
  211. package/src/number/branded-types/non-negative-int16.mts +64 -57
  212. package/src/number/branded-types/non-negative-int32.mts +64 -58
  213. package/src/number/branded-types/non-positive-finite-number.mts +64 -54
  214. package/src/number/branded-types/non-positive-int.mts +41 -146
  215. package/src/number/branded-types/non-positive-safe-int.mts +54 -53
  216. package/src/number/branded-types/non-zero-finite-number.mts +62 -51
  217. package/src/number/branded-types/non-zero-int.mts +51 -38
  218. package/src/number/branded-types/non-zero-int16.mts +52 -53
  219. package/src/number/branded-types/non-zero-int32.mts +52 -54
  220. package/src/number/branded-types/non-zero-safe-int.mts +53 -54
  221. package/src/number/branded-types/non-zero-uint16.mts +52 -53
  222. package/src/number/branded-types/non-zero-uint32.mts +52 -53
  223. package/src/number/branded-types/positive-finite-number.mts +74 -63
  224. package/src/number/branded-types/positive-int.mts +46 -68
  225. package/src/number/branded-types/positive-int16.mts +61 -57
  226. package/src/number/branded-types/positive-int32.mts +61 -57
  227. package/src/number/branded-types/positive-safe-int.mts +62 -57
  228. package/src/number/branded-types/positive-uint16.mts +61 -57
  229. package/src/number/branded-types/positive-uint32.mts +61 -58
  230. package/src/number/branded-types/safe-int.mts +43 -62
  231. package/src/number/branded-types/safe-uint.mts +62 -57
  232. package/src/number/branded-types/uint.mts +63 -50
  233. package/src/number/branded-types/uint16.mts +60 -58
  234. package/src/number/branded-types/uint32.mts +59 -55
  235. package/src/number/enum/int8.mts +56 -65
  236. package/src/number/enum/uint8.mts +60 -58
  237. package/src/string/index.mts +1 -0
  238. package/src/string/str.mts +371 -0
  239. package/src/string/str.test.mts +215 -0
  240. package/dist/guard/as-length-bounded-array.d.mts.map +0 -1
  241. package/dist/guard/as-length-bounded-array.mjs.map +0 -1
  242. package/dist/guard/is-length-bounded-array.d.mts.map +0 -1
  243. package/dist/guard/is-length-bounded-array.mjs.map +0 -1
  244. package/dist/guard/is-length-bounded-string.d.mts +0 -163
  245. package/dist/guard/is-length-bounded-string.d.mts.map +0 -1
  246. package/dist/guard/is-length-bounded-string.mjs +0 -7
  247. package/dist/guard/is-length-bounded-string.mjs.map +0 -1
  248. package/src/guard/is-length-bounded-string.mts +0 -199
  249. package/src/guard/is-length-bounded-string.test.mts +0 -170
@@ -25,79 +25,83 @@ const isNegativeInt = is;
25
25
  const asNegativeInt = castType;
26
26
  const NegativeInt = {
27
27
  /**
28
- * Type guard to check if a value is a NegativeInt.
28
+ * Type guard that checks if a value is a negative integer.
29
29
  *
30
- * @param value The value to check.
31
- * @returns `true` if the value is a negative integer, `false` otherwise.
30
+ * @param value - The value to check
31
+ * @returns `true` if the value is a negative integer, `false` otherwise
32
+ * @see {@link isNegativeInt} for usage examples
32
33
  */
33
34
  is,
34
35
  /**
35
- * The maximum value for a negative integer.
36
- *
37
- * @readonly
36
+ * The largest value representable as `NegativeInt`.
38
37
  */
39
38
  MAX_VALUE,
40
39
  /**
41
40
  * Returns the absolute value of a negative integer.
42
41
  *
43
- * @param a The negative integer.
44
- * @returns The absolute value as a PositiveInt.
42
+ * The result is non-negative and keeps the `NegativeInt` brand. Note that
43
+ * `Math.abs(Number.MIN_SAFE_INTEGER)` exceeds `Number.MAX_SAFE_INTEGER`, so
44
+ * use `SafeInt` for guaranteed precision.
45
+ *
46
+ * @param a - The negative integer value
47
+ * @returns The absolute value as a non-negative `NegativeInt`
45
48
  */
46
49
  abs,
47
50
  /**
48
- * Returns the smaller of two negative integers.
51
+ * Returns the smallest of the given negative integers.
49
52
  *
50
- * @param a The first negative integer.
51
- * @param b The second negative integer.
52
- * @returns The minimum value as a NegativeInt.
53
+ * @param values - The negative integers to compare (at least one required)
54
+ * @returns The smallest value as a `NegativeInt`
53
55
  */
54
56
  min: min_,
55
57
  /**
56
- * Returns the larger of two negative integers.
58
+ * Returns the largest of the given negative integers.
57
59
  *
58
- * @param a The first negative integer.
59
- * @param b The second negative integer.
60
- * @returns The maximum value as a NegativeInt.
60
+ * @param values - The negative integers to compare (at least one required)
61
+ * @returns The largest value as a `NegativeInt`
61
62
  */
62
63
  max: max_,
63
64
  /**
64
- * Clamps a number to the negative integer range.
65
+ * Clamps a `number` into the `NegativeInt` range, rounding to the nearest
66
+ * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
65
67
  *
66
- * @param value The number to clamp.
67
- * @returns The value clamped to `[-∞, -1]` as a NegativeInt.
68
+ * @param value - The value to clamp
69
+ * @returns The clamped value as a `NegativeInt`
68
70
  */
69
71
  clamp,
70
72
  /**
71
- * Generates a random NegativeInt value within the valid range.
73
+ * Generates a random `NegativeInt` within the given range.
72
74
  *
73
- * @returns A random negative integer.
75
+ * The range is inclusive on both ends.
76
+ *
77
+ * @param min - The minimum value (inclusive)
78
+ * @param max - The maximum value (inclusive)
79
+ * @returns A random `NegativeInt` in `[min, max]`
74
80
  */
75
81
  random,
76
82
  /**
77
- * Raises a negative integer to the power of another negative integer.
83
+ * Raises `a` to the power `b`, returning `a ** b` as a `NegativeInt` (floored
84
+ * to an integer).
78
85
  *
79
- * @param a The base negative integer.
80
- * @param b The exponent negative integer.
81
- * @returns `a ** b` clamped to the negative integer range.
86
+ * @param a - The base negative integer
87
+ * @param b - The exponent negative integer
88
+ * @returns `a ** b` as a `NegativeInt`
82
89
  */
83
90
  pow,
84
91
  /**
85
- * Adds two negative integers.
92
+ * Adds two negative integers, returning `a + b` as a `NegativeInt`.
86
93
  *
87
- * @param a The first negative integer.
88
- * @param b The second negative integer.
89
- * @returns `a + b` as a NegativeInt.
94
+ * @param a - The first negative integer
95
+ * @param b - The second negative integer
96
+ * @returns The sum of `a` and `b` as a `NegativeInt`
90
97
  */
91
98
  add,
92
99
  /**
93
- * Subtracts one negative integer from another.
94
- *
95
- * The mathematical result can be positive, so it is clamped to the negative
96
- * integer range (maximum `-1`).
100
+ * Subtracts two negative integers, returning `a - b` as a `NegativeInt`.
97
101
  *
98
- * @param a The minuend negative integer.
99
- * @param b The subtrahend negative integer.
100
- * @returns `a - b` clamped to the negative integer range.
102
+ * @param a - The first negative integer
103
+ * @param b - The second negative integer
104
+ * @returns The difference of `a` and `b` as a `NegativeInt`
101
105
  */
102
106
  sub
103
107
  };
@@ -1 +1 @@
1
- {"version":3,"file":"negative-int.mjs","sources":["../../../src/number/branded-types/negative-int.mts"],"sourcesContent":["import {\n type NegativeInt as TtfImported_NegativeInt,\n type WithSmallInt,\n} from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\nimport { PositiveInt } from './positive-int.mjs';\n\nexport type NegativeInt = TtfImported_NegativeInt;\n\ntype ElementType = NegativeInt;\n\nconst typeNameInMessage = 'a negative integer';\n\nconst {\n MAX_VALUE,\n add,\n castType,\n clamp,\n is,\n max: max_,\n min: min_,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n number,\n -1\n>({\n integerOrSafeInteger: 'Integer',\n nonZero: true,\n MIN_VALUE: -Number.MAX_VALUE,\n MAX_VALUE: -1,\n typeNameInMessage,\n} as const);\n\n/**\n * Returns the absolute value of a negative integer.\n *\n * The absolute value of a negative integer is always a positive integer\n * (`>= 1`), so the result is typed as a {@link PositiveInt}.\n *\n * @param x - The negative integer.\n * @returns `|x|` as a PositiveInt.\n */\nconst abs = (x: WithSmallInt<ElementType>): PositiveInt =>\n PositiveInt.clamp(Math.abs(x));\n\n/**\n * Checks if a number is a NegativeInt (a negative integer `<= -1`).\n *\n * @param value The value to check.\n * @returns `true` if the value is a NegativeInt, `false` otherwise.\n */\nexport const isNegativeInt = is;\n\n/**\n * Casts a number to a NegativeInt type.\n *\n * @param value The value to cast.\n * @returns The value as a NegativeInt type.\n * @throws {TypeError} If the value is not a negative integer.\n */\nexport const asNegativeInt = castType;\n\n/**\n * Namespace providing type-safe arithmetic operations for negative integers.\n *\n * NegativeInt represents integers that are strictly less than zero (`<= -1`).\n * Operations that stay within the negative integers (such as `add`) clamp their\n * results to the valid range, while operations whose result leaves the set\n * (`mul`, `div`, `abs`) are typed to reflect the actual sign of the result.\n */\nexport const NegativeInt = {\n /**\n * Type guard to check if a value is a NegativeInt.\n *\n * @param value The value to check.\n * @returns `true` if the value is a negative integer, `false` otherwise.\n */\n is,\n\n /**\n * The maximum value for a negative integer.\n *\n * @readonly\n */\n MAX_VALUE,\n\n /**\n * Returns the absolute value of a negative integer.\n *\n * @param a The negative integer.\n * @returns The absolute value as a PositiveInt.\n */\n abs,\n\n /**\n * Returns the smaller of two negative integers.\n *\n * @param a The first negative integer.\n * @param b The second negative integer.\n * @returns The minimum value as a NegativeInt.\n */\n min: min_,\n\n /**\n * Returns the larger of two negative integers.\n *\n * @param a The first negative integer.\n * @param b The second negative integer.\n * @returns The maximum value as a NegativeInt.\n */\n max: max_,\n\n /**\n * Clamps a number to the negative integer range.\n *\n * @param value The number to clamp.\n * @returns The value clamped to `[-∞, -1]` as a NegativeInt.\n */\n clamp,\n\n /**\n * Generates a random NegativeInt value within the valid range.\n *\n * @returns A random negative integer.\n */\n random,\n\n /**\n * Raises a negative integer to the power of another negative integer.\n *\n * @param a The base negative integer.\n * @param b The exponent negative integer.\n * @returns `a ** b` clamped to the negative integer range.\n */\n pow,\n\n /**\n * Adds two negative integers.\n *\n * @param a The first negative integer.\n * @param b The second negative integer.\n * @returns `a + b` as a NegativeInt.\n */\n add,\n\n /**\n * Subtracts one negative integer from another.\n *\n * The mathematical result can be positive, so it is clamped to the negative\n * integer range (maximum `-1`).\n *\n * @param a The minuend negative integer.\n * @param b The subtrahend negative integer.\n * @returns `a - b` clamped to the negative integer range.\n */\n sub,\n} as const;\n"],"names":[],"mappings":";;;AAWA,MAAM,iBAAA,GAAoB,oBAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,SAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA,EACT,SAAA,EAAW,CAAC,MAAA,CAAO,SAAA;AAAA,EACnB,SAAA,EAAW,EAAA;AAAA,EACX;AACF,CAAU,CAAA;AAWV,MAAM,GAAA,GAAM,CAAC,CAAA,KACX,WAAA,CAAY,MAAM,IAAA,CAAK,GAAA,CAAI,CAAC,CAAC,CAAA;AAQxB,MAAM,aAAA,GAAgB;AAStB,MAAM,aAAA,GAAgB;AAUtB,MAAM,WAAA,GAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOzB,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA;AACF;;;;"}
1
+ {"version":3,"file":"negative-int.mjs","sources":["../../../src/number/branded-types/negative-int.mts"],"sourcesContent":["import {\n type NegativeInt as TtfImported_NegativeInt,\n type WithSmallInt,\n} from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\nimport { PositiveInt } from './positive-int.mjs';\n\nexport type NegativeInt = TtfImported_NegativeInt;\n\ntype ElementType = NegativeInt;\n\nconst typeNameInMessage = 'a negative integer';\n\nconst {\n MAX_VALUE,\n add,\n castType,\n clamp,\n is,\n max: max_,\n min: min_,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n number,\n -1\n>({\n integerOrSafeInteger: 'Integer',\n nonZero: true,\n MIN_VALUE: -Number.MAX_VALUE,\n MAX_VALUE: -1,\n typeNameInMessage,\n} as const);\n\nconst abs = (x: WithSmallInt<ElementType>): PositiveInt =>\n PositiveInt.clamp(Math.abs(x));\n\n/**\n * Type guard that checks if a value is a negative integer.\n *\n * Returns `true` for a negative integer — a value with no fractional component,\n * including values outside the safe integer range (unlike `SafeInt`).\n *\n * @param value - The value to check\n * @returns `true` if the value is a negative integer, `false` otherwise\n */\nexport const isNegativeInt = is;\n\n/**\n * Casts a `number` to the `NegativeInt` branded type.\n *\n * Validates that the value is a negative integer and returns it with the\n * `NegativeInt` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NegativeInt`\n * @throws {TypeError} If the value is not a negative integer\n */\nexport const asNegativeInt = castType;\n\n/**\n * Namespace providing type-safe operations for the `NegativeInt` branded type.\n *\n * The `NegativeInt` type represents a negative integer. Division (`div`) uses\n * floor division.\n *\n * Unlike `SafeInt`, `NegativeInt` allows values outside the safe integer range\n * (±2^53 − 1), so very large magnitudes may lose precision in JavaScript's\n * `number` type.\n */\nexport const NegativeInt = {\n /**\n * Type guard that checks if a value is a negative integer.\n *\n * @param value - The value to check\n * @returns `true` if the value is a negative integer, `false` otherwise\n * @see {@link isNegativeInt} for usage examples\n */\n is,\n\n /**\n * The largest value representable as `NegativeInt`.\n */\n MAX_VALUE,\n\n /**\n * Returns the absolute value of a negative integer.\n *\n * The result is non-negative and keeps the `NegativeInt` brand. Note that\n * `Math.abs(Number.MIN_SAFE_INTEGER)` exceeds `Number.MAX_SAFE_INTEGER`, so\n * use `SafeInt` for guaranteed precision.\n *\n * @param a - The negative integer value\n * @returns The absolute value as a non-negative `NegativeInt`\n */\n abs,\n\n /**\n * Returns the smallest of the given negative integers.\n *\n * @param values - The negative integers to compare (at least one required)\n * @returns The smallest value as a `NegativeInt`\n */\n min: min_,\n\n /**\n * Returns the largest of the given negative integers.\n *\n * @param values - The negative integers to compare (at least one required)\n * @returns The largest value as a `NegativeInt`\n */\n max: max_,\n\n /**\n * Clamps a `number` into the `NegativeInt` range, rounding to the nearest\n * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.\n *\n * @param value - The value to clamp\n * @returns The clamped value as a `NegativeInt`\n */\n clamp,\n\n /**\n * Generates a random `NegativeInt` within the given range.\n *\n * The range is inclusive on both ends.\n *\n * @param min - The minimum value (inclusive)\n * @param max - The maximum value (inclusive)\n * @returns A random `NegativeInt` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NegativeInt` (floored\n * to an integer).\n *\n * @param a - The base negative integer\n * @param b - The exponent negative integer\n * @returns `a ** b` as a `NegativeInt`\n */\n pow,\n\n /**\n * Adds two negative integers, returning `a + b` as a `NegativeInt`.\n *\n * @param a - The first negative integer\n * @param b - The second negative integer\n * @returns The sum of `a` and `b` as a `NegativeInt`\n */\n add,\n\n /**\n * Subtracts two negative integers, returning `a - b` as a `NegativeInt`.\n *\n * @param a - The first negative integer\n * @param b - The second negative integer\n * @returns The difference of `a` and `b` as a `NegativeInt`\n */\n sub,\n} as const;\n"],"names":[],"mappings":";;;AAWA,MAAM,iBAAA,GAAoB,oBAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,SAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA,EACT,SAAA,EAAW,CAAC,MAAA,CAAO,SAAA;AAAA,EACnB,SAAA,EAAW,EAAA;AAAA,EACX;AACF,CAAU,CAAA;AAEV,MAAM,GAAA,GAAM,CAAC,CAAA,KACX,WAAA,CAAY,MAAM,IAAA,CAAK,GAAA,CAAI,CAAC,CAAC,CAAA;AAWxB,MAAM,aAAA,GAAgB;AAYtB,MAAM,aAAA,GAAgB;AAYtB,MAAM,WAAA,GAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQzB,EAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA;AACF;;;;"}
@@ -3,19 +3,24 @@ import { PositiveSafeInt } from './positive-safe-int.mjs';
3
3
  export type NegativeSafeInt = TtfImported_NegativeSafeInt;
4
4
  type ElementType = NegativeSafeInt;
5
5
  /**
6
- * Checks if a number is a NegativeSafeInt (a negative safe integer in the range
7
- * `[Number.MIN_SAFE_INTEGER, -1]`).
6
+ * Type guard that checks if a value is a negative safe integer.
8
7
  *
9
- * @param value The value to check.
10
- * @returns `true` if the value is a NegativeSafeInt, `false` otherwise.
8
+ * Returns `true` for a negative safe integer — a value with no fractional
9
+ * component.
10
+ *
11
+ * @param value - The value to check
12
+ * @returns `true` if the value is a negative safe integer, `false` otherwise
11
13
  */
12
14
  export declare const isNegativeSafeInt: (a: number) => a is TtfImported_NegativeSafeInt;
13
15
  /**
14
- * Casts a number to a NegativeSafeInt type.
16
+ * Casts a `number` to the `NegativeSafeInt` branded type.
17
+ *
18
+ * Validates that the value is a negative safe integer and returns it with the
19
+ * `NegativeSafeInt` brand. Throws a `TypeError` otherwise.
15
20
  *
16
- * @param value The value to cast.
17
- * @returns The value as a NegativeSafeInt type.
18
- * @throws {TypeError} If the value is not a negative safe integer.
21
+ * @param value - The value to cast
22
+ * @returns The value as a `NegativeSafeInt`
23
+ * @throws {TypeError} If the value is not a negative safe integer
19
24
  */
20
25
  export declare const asNegativeSafeInt: <N extends number>(x: N) => number & {
21
26
  readonly "!=0": true;
@@ -33,98 +38,94 @@ export declare const asNegativeSafeInt: <N extends number>(x: N) => number & {
33
38
  'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
34
39
  }> & N;
35
40
  /**
36
- * Namespace providing type-safe arithmetic operations for negative safe
37
- * integers.
41
+ * Namespace providing type-safe operations for the `NegativeSafeInt` branded
42
+ * type.
38
43
  *
39
- * NegativeSafeInt represents safe integers that are strictly less than zero
40
- * (`[Number.MIN_SAFE_INTEGER, -1]`). Operations that stay within the negative
41
- * safe integers clamp their results to the valid range, while operations whose
42
- * result leaves the set (`mul`, `div`, `abs`) are typed to reflect the actual
43
- * sign of the result.
44
+ * The `NegativeSafeInt` type represents a negative safe integer. Division
45
+ * (`div`) uses floor division.
44
46
  */
45
47
  export declare const NegativeSafeInt: {
46
48
  /**
47
- * Type guard to check if a value is a NegativeSafeInt.
49
+ * Type guard that checks if a value is a negative safe integer.
48
50
  *
49
- * @param value The value to check.
50
- * @returns `true` if the value is a negative safe integer, `false` otherwise.
51
+ * @param value - The value to check
52
+ * @returns `true` if the value is a negative safe integer, `false` otherwise
53
+ * @see {@link isNegativeSafeInt} for usage examples
51
54
  */
52
55
  readonly is: (a: number) => a is TtfImported_NegativeSafeInt;
53
56
  /**
54
- * The minimum value for a negative safe integer.
55
- *
56
- * @readonly
57
+ * The smallest value representable as `NegativeSafeInt`.
57
58
  */
58
59
  readonly MIN_VALUE: number;
59
60
  /**
60
- * The maximum value for a negative safe integer.
61
- *
62
- * @readonly
61
+ * The largest value representable as `NegativeSafeInt`.
63
62
  */
64
63
  readonly MAX_VALUE: -1;
65
64
  /**
66
65
  * Returns the absolute value of a negative safe integer.
67
66
  *
68
- * @param a The negative safe integer.
69
- * @returns The absolute value as a PositiveSafeInt.
67
+ * The result is non-negative and keeps the `NegativeSafeInt` brand.
68
+ *
69
+ * @param a - The negative safe integer value
70
+ * @returns The absolute value as a non-negative `NegativeSafeInt`
70
71
  */
71
72
  readonly abs: (x: WithSmallInt<ElementType>) => PositiveSafeInt;
72
73
  /**
73
- * Returns the smaller of two negative safe integers.
74
+ * Returns the smallest of the given negative safe integers.
74
75
  *
75
- * @param a The first negative safe integer.
76
- * @param b The second negative safe integer.
77
- * @returns The minimum value as a NegativeSafeInt.
76
+ * @param values - The negative safe integers to compare (at least one required)
77
+ * @returns The smallest value as a `NegativeSafeInt`
78
78
  */
79
79
  readonly min: (...values: readonly WithSmallInt<TtfImported_NegativeSafeInt>[]) => TtfImported_NegativeSafeInt;
80
80
  /**
81
- * Returns the larger of two negative safe integers.
81
+ * Returns the largest of the given negative safe integers.
82
82
  *
83
- * @param a The first negative safe integer.
84
- * @param b The second negative safe integer.
85
- * @returns The maximum value as a NegativeSafeInt.
83
+ * @param values - The negative safe integers to compare (at least one required)
84
+ * @returns The largest value as a `NegativeSafeInt`
86
85
  */
87
86
  readonly max: (...values: readonly WithSmallInt<TtfImported_NegativeSafeInt>[]) => TtfImported_NegativeSafeInt;
88
87
  /**
89
- * Clamps a number to the NegativeSafeInt range.
88
+ * Clamps a `number` into the `NegativeSafeInt` range, rounding to the nearest
89
+ * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
90
90
  *
91
- * @param value The number to clamp.
92
- * @returns The value clamped to `[Number.MIN_SAFE_INTEGER, -1]` as a
93
- * NegativeSafeInt.
91
+ * @param value - The value to clamp
92
+ * @returns The clamped value as a `NegativeSafeInt`
94
93
  */
95
94
  readonly clamp: (x: number) => TtfImported_NegativeSafeInt;
96
95
  /**
97
- * Generates a random NegativeSafeInt value within the valid range.
96
+ * Generates a random `NegativeSafeInt` within the given range.
97
+ *
98
+ * The range is inclusive on both ends.
98
99
  *
99
- * @returns A random NegativeSafeInt between Number.MIN_SAFE_INTEGER and -1.
100
+ * @param min - The minimum value (inclusive)
101
+ * @param max - The maximum value (inclusive)
102
+ * @returns A random `NegativeSafeInt` in `[min, max]`
100
103
  */
101
104
  readonly random: (min?: WithSmallInt<TtfImported_NegativeSafeInt> | undefined, max?: WithSmallInt<TtfImported_NegativeSafeInt> | undefined) => TtfImported_NegativeSafeInt;
102
105
  /**
103
- * Raises a negative safe integer to the power of another negative safe
104
- * integer.
106
+ * Raises `a` to the power `b`, returning `a ** b` as a `NegativeSafeInt`
107
+ * (floored to an integer).
105
108
  *
106
- * @param a The base negative safe integer.
107
- * @param b The exponent negative safe integer.
108
- * @returns `a ** b` clamped to the NegativeSafeInt range.
109
+ * @param a - The base negative safe integer
110
+ * @param b - The exponent negative safe integer
111
+ * @returns `a ** b` as a `NegativeSafeInt`
109
112
  */
110
113
  readonly pow: (x: WithSmallInt<TtfImported_NegativeSafeInt>, y: WithSmallInt<TtfImported_NegativeSafeInt>) => TtfImported_NegativeSafeInt;
111
114
  /**
112
- * Adds two negative safe integers.
115
+ * Adds two negative safe integers, returning `a + b` as a `NegativeSafeInt`.
113
116
  *
114
- * @param a The first negative safe integer.
115
- * @param b The second negative safe integer.
116
- * @returns `a + b` clamped to the NegativeSafeInt range.
117
+ * @param a - The first negative safe integer
118
+ * @param b - The second negative safe integer
119
+ * @returns The sum of `a` and `b` as a `NegativeSafeInt`
117
120
  */
118
121
  readonly add: (x: WithSmallInt<TtfImported_NegativeSafeInt>, y: WithSmallInt<TtfImported_NegativeSafeInt>) => TtfImported_NegativeSafeInt;
119
122
  /**
120
- * Subtracts one negative safe integer from another.
121
- *
122
- * The mathematical result can be positive, so it is clamped to the
123
- * NegativeSafeInt range (maximum `-1`).
123
+ * Subtracts two negative safe integers, returning `a - b` as a
124
+ * `NegativeSafeInt`.
124
125
  *
125
- * @param a The minuend negative safe integer.
126
- * @param b The subtrahend negative safe integer.
127
- * @returns `a - b` clamped to the NegativeSafeInt range.
126
+ * @param a - The first negative safe integer
127
+ * @param b - The second negative safe integer
128
+ * @returns The difference of `a` and `b` as a `NegativeSafeInt`
128
129
  */
129
130
  readonly sub: (x: WithSmallInt<TtfImported_NegativeSafeInt>, y: WithSmallInt<TtfImported_NegativeSafeInt>) => TtfImported_NegativeSafeInt;
130
131
  };
@@ -1 +1 @@
1
- {"version":3,"file":"negative-safe-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/negative-safe-int.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,IAAI,2BAA2B,EACnD,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAE1D,KAAK,WAAW,GAAG,eAAe,CAAC;AAwCnC;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,iDAAK,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;MAAW,CAAC;AAE1C;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;IAC1B;;;;;OAKG;;IAGH;;;;OAIG;;IAGH;;;;OAIG;;IAGH;;;;;OAKG;sBA3DW,YAAY,CAAC,WAAW,CAAC,KAAG,eAAe;IA8DzD;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;OAIG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;;;OASG;;CAEK,CAAC"}
1
+ {"version":3,"file":"negative-safe-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/negative-safe-int.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,IAAI,2BAA2B,EACnD,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAE1D,KAAK,WAAW,GAAG,eAAe,CAAC;AA+BnC;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,iDAAK,CAAC;AAEpC;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;MAAW,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;IAC1B;;;;;;OAMG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;;;OAOG;sBA5DW,YAAY,CAAC,WAAW,CAAC,KAAG,eAAe;IA+DzD;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;OAOG;;CAEK,CAAC"}
@@ -26,87 +26,86 @@ const isNegativeSafeInt = is;
26
26
  const asNegativeSafeInt = castType;
27
27
  const NegativeSafeInt = {
28
28
  /**
29
- * Type guard to check if a value is a NegativeSafeInt.
29
+ * Type guard that checks if a value is a negative safe integer.
30
30
  *
31
- * @param value The value to check.
32
- * @returns `true` if the value is a negative safe integer, `false` otherwise.
31
+ * @param value - The value to check
32
+ * @returns `true` if the value is a negative safe integer, `false` otherwise
33
+ * @see {@link isNegativeSafeInt} for usage examples
33
34
  */
34
35
  is,
35
36
  /**
36
- * The minimum value for a negative safe integer.
37
- *
38
- * @readonly
37
+ * The smallest value representable as `NegativeSafeInt`.
39
38
  */
40
39
  MIN_VALUE,
41
40
  /**
42
- * The maximum value for a negative safe integer.
43
- *
44
- * @readonly
41
+ * The largest value representable as `NegativeSafeInt`.
45
42
  */
46
43
  MAX_VALUE,
47
44
  /**
48
45
  * Returns the absolute value of a negative safe integer.
49
46
  *
50
- * @param a The negative safe integer.
51
- * @returns The absolute value as a PositiveSafeInt.
47
+ * The result is non-negative and keeps the `NegativeSafeInt` brand.
48
+ *
49
+ * @param a - The negative safe integer value
50
+ * @returns The absolute value as a non-negative `NegativeSafeInt`
52
51
  */
53
52
  abs,
54
53
  /**
55
- * Returns the smaller of two negative safe integers.
54
+ * Returns the smallest of the given negative safe integers.
56
55
  *
57
- * @param a The first negative safe integer.
58
- * @param b The second negative safe integer.
59
- * @returns The minimum value as a NegativeSafeInt.
56
+ * @param values - The negative safe integers to compare (at least one required)
57
+ * @returns The smallest value as a `NegativeSafeInt`
60
58
  */
61
59
  min: min_,
62
60
  /**
63
- * Returns the larger of two negative safe integers.
61
+ * Returns the largest of the given negative safe integers.
64
62
  *
65
- * @param a The first negative safe integer.
66
- * @param b The second negative safe integer.
67
- * @returns The maximum value as a NegativeSafeInt.
63
+ * @param values - The negative safe integers to compare (at least one required)
64
+ * @returns The largest value as a `NegativeSafeInt`
68
65
  */
69
66
  max: max_,
70
67
  /**
71
- * Clamps a number to the NegativeSafeInt range.
68
+ * Clamps a `number` into the `NegativeSafeInt` range, rounding to the nearest
69
+ * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
72
70
  *
73
- * @param value The number to clamp.
74
- * @returns The value clamped to `[Number.MIN_SAFE_INTEGER, -1]` as a
75
- * NegativeSafeInt.
71
+ * @param value - The value to clamp
72
+ * @returns The clamped value as a `NegativeSafeInt`
76
73
  */
77
74
  clamp,
78
75
  /**
79
- * Generates a random NegativeSafeInt value within the valid range.
76
+ * Generates a random `NegativeSafeInt` within the given range.
80
77
  *
81
- * @returns A random NegativeSafeInt between Number.MIN_SAFE_INTEGER and -1.
78
+ * The range is inclusive on both ends.
79
+ *
80
+ * @param min - The minimum value (inclusive)
81
+ * @param max - The maximum value (inclusive)
82
+ * @returns A random `NegativeSafeInt` in `[min, max]`
82
83
  */
83
84
  random,
84
85
  /**
85
- * Raises a negative safe integer to the power of another negative safe
86
- * integer.
86
+ * Raises `a` to the power `b`, returning `a ** b` as a `NegativeSafeInt`
87
+ * (floored to an integer).
87
88
  *
88
- * @param a The base negative safe integer.
89
- * @param b The exponent negative safe integer.
90
- * @returns `a ** b` clamped to the NegativeSafeInt range.
89
+ * @param a - The base negative safe integer
90
+ * @param b - The exponent negative safe integer
91
+ * @returns `a ** b` as a `NegativeSafeInt`
91
92
  */
92
93
  pow,
93
94
  /**
94
- * Adds two negative safe integers.
95
+ * Adds two negative safe integers, returning `a + b` as a `NegativeSafeInt`.
95
96
  *
96
- * @param a The first negative safe integer.
97
- * @param b The second negative safe integer.
98
- * @returns `a + b` clamped to the NegativeSafeInt range.
97
+ * @param a - The first negative safe integer
98
+ * @param b - The second negative safe integer
99
+ * @returns The sum of `a` and `b` as a `NegativeSafeInt`
99
100
  */
100
101
  add,
101
102
  /**
102
- * Subtracts one negative safe integer from another.
103
- *
104
- * The mathematical result can be positive, so it is clamped to the
105
- * NegativeSafeInt range (maximum `-1`).
103
+ * Subtracts two negative safe integers, returning `a - b` as a
104
+ * `NegativeSafeInt`.
106
105
  *
107
- * @param a The minuend negative safe integer.
108
- * @param b The subtrahend negative safe integer.
109
- * @returns `a - b` clamped to the NegativeSafeInt range.
106
+ * @param a - The first negative safe integer
107
+ * @param b - The second negative safe integer
108
+ * @returns The difference of `a` and `b` as a `NegativeSafeInt`
110
109
  */
111
110
  sub
112
111
  };
@@ -1 +1 @@
1
- {"version":3,"file":"negative-safe-int.mjs","sources":["../../../src/number/branded-types/negative-safe-int.mts"],"sourcesContent":["import {\n type NegativeSafeInt as TtfImported_NegativeSafeInt,\n type WithSmallInt,\n} from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\nimport { PositiveSafeInt } from './positive-safe-int.mjs';\n\nexport type NegativeSafeInt = TtfImported_NegativeSafeInt;\n\ntype ElementType = NegativeSafeInt;\n\nconst typeNameInMessage = 'a negative safe integer';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n clamp,\n is,\n max: max_,\n min: min_,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n number,\n -1\n>({\n integerOrSafeInteger: 'SafeInteger',\n nonZero: true,\n MIN_VALUE: Number.MIN_SAFE_INTEGER,\n MAX_VALUE: -1,\n typeNameInMessage,\n} as const);\n\n/**\n * Returns the absolute value of a negative safe integer.\n *\n * The absolute value of a negative safe integer is always a positive safe\n * integer (`>= 1`), so the result is typed as a {@link PositiveSafeInt}.\n *\n * @param x - The negative safe integer.\n * @returns `|x|` as a PositiveSafeInt.\n */\nconst abs = (x: WithSmallInt<ElementType>): PositiveSafeInt =>\n PositiveSafeInt.clamp(Math.abs(x));\n\n/**\n * Checks if a number is a NegativeSafeInt (a negative safe integer in the range\n * `[Number.MIN_SAFE_INTEGER, -1]`).\n *\n * @param value The value to check.\n * @returns `true` if the value is a NegativeSafeInt, `false` otherwise.\n */\nexport const isNegativeSafeInt = is;\n\n/**\n * Casts a number to a NegativeSafeInt type.\n *\n * @param value The value to cast.\n * @returns The value as a NegativeSafeInt type.\n * @throws {TypeError} If the value is not a negative safe integer.\n */\nexport const asNegativeSafeInt = castType;\n\n/**\n * Namespace providing type-safe arithmetic operations for negative safe\n * integers.\n *\n * NegativeSafeInt represents safe integers that are strictly less than zero\n * (`[Number.MIN_SAFE_INTEGER, -1]`). Operations that stay within the negative\n * safe integers clamp their results to the valid range, while operations whose\n * result leaves the set (`mul`, `div`, `abs`) are typed to reflect the actual\n * sign of the result.\n */\nexport const NegativeSafeInt = {\n /**\n * Type guard to check if a value is a NegativeSafeInt.\n *\n * @param value The value to check.\n * @returns `true` if the value is a negative safe integer, `false` otherwise.\n */\n is,\n\n /**\n * The minimum value for a negative safe integer.\n *\n * @readonly\n */\n MIN_VALUE,\n\n /**\n * The maximum value for a negative safe integer.\n *\n * @readonly\n */\n MAX_VALUE,\n\n /**\n * Returns the absolute value of a negative safe integer.\n *\n * @param a The negative safe integer.\n * @returns The absolute value as a PositiveSafeInt.\n */\n abs,\n\n /**\n * Returns the smaller of two negative safe integers.\n *\n * @param a The first negative safe integer.\n * @param b The second negative safe integer.\n * @returns The minimum value as a NegativeSafeInt.\n */\n min: min_,\n\n /**\n * Returns the larger of two negative safe integers.\n *\n * @param a The first negative safe integer.\n * @param b The second negative safe integer.\n * @returns The maximum value as a NegativeSafeInt.\n */\n max: max_,\n\n /**\n * Clamps a number to the NegativeSafeInt range.\n *\n * @param value The number to clamp.\n * @returns The value clamped to `[Number.MIN_SAFE_INTEGER, -1]` as a\n * NegativeSafeInt.\n */\n clamp,\n\n /**\n * Generates a random NegativeSafeInt value within the valid range.\n *\n * @returns A random NegativeSafeInt between Number.MIN_SAFE_INTEGER and -1.\n */\n random,\n\n /**\n * Raises a negative safe integer to the power of another negative safe\n * integer.\n *\n * @param a The base negative safe integer.\n * @param b The exponent negative safe integer.\n * @returns `a ** b` clamped to the NegativeSafeInt range.\n */\n pow,\n\n /**\n * Adds two negative safe integers.\n *\n * @param a The first negative safe integer.\n * @param b The second negative safe integer.\n * @returns `a + b` clamped to the NegativeSafeInt range.\n */\n add,\n\n /**\n * Subtracts one negative safe integer from another.\n *\n * The mathematical result can be positive, so it is clamped to the\n * NegativeSafeInt range (maximum `-1`).\n *\n * @param a The minuend negative safe integer.\n * @param b The subtrahend negative safe integer.\n * @returns `a - b` clamped to the NegativeSafeInt range.\n */\n sub,\n} as const;\n"],"names":[],"mappings":";;;AAWA,MAAM,iBAAA,GAAoB,yBAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA,EACT,WAAW,MAAA,CAAO,gBAAA;AAAA,EAClB,SAAA,EAAW,EAAA;AAAA,EACX;AACF,CAAU,CAAA;AAWV,MAAM,GAAA,GAAM,CAAC,CAAA,KACX,eAAA,CAAgB,MAAM,IAAA,CAAK,GAAA,CAAI,CAAC,CAAC,CAAA;AAS5B,MAAM,iBAAA,GAAoB;AAS1B,MAAM,iBAAA,GAAoB;AAY1B,MAAM,eAAA,GAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO7B,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA;AACF;;;;"}
1
+ {"version":3,"file":"negative-safe-int.mjs","sources":["../../../src/number/branded-types/negative-safe-int.mts"],"sourcesContent":["import {\n type NegativeSafeInt as TtfImported_NegativeSafeInt,\n type WithSmallInt,\n} from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\nimport { PositiveSafeInt } from './positive-safe-int.mjs';\n\nexport type NegativeSafeInt = TtfImported_NegativeSafeInt;\n\ntype ElementType = NegativeSafeInt;\n\nconst typeNameInMessage = 'a negative safe integer';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n clamp,\n is,\n max: max_,\n min: min_,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n number,\n -1\n>({\n integerOrSafeInteger: 'SafeInteger',\n nonZero: true,\n MIN_VALUE: Number.MIN_SAFE_INTEGER,\n MAX_VALUE: -1,\n typeNameInMessage,\n} as const);\n\nconst abs = (x: WithSmallInt<ElementType>): PositiveSafeInt =>\n PositiveSafeInt.clamp(Math.abs(x));\n\n/**\n * Type guard that checks if a value is a negative safe integer.\n *\n * Returns `true` for a negative safe integer — a value with no fractional\n * component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a negative safe integer, `false` otherwise\n */\nexport const isNegativeSafeInt = is;\n\n/**\n * Casts a `number` to the `NegativeSafeInt` branded type.\n *\n * Validates that the value is a negative safe integer and returns it with the\n * `NegativeSafeInt` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NegativeSafeInt`\n * @throws {TypeError} If the value is not a negative safe integer\n */\nexport const asNegativeSafeInt = castType;\n\n/**\n * Namespace providing type-safe operations for the `NegativeSafeInt` branded\n * type.\n *\n * The `NegativeSafeInt` type represents a negative safe integer. Division\n * (`div`) uses floor division.\n */\nexport const NegativeSafeInt = {\n /**\n * Type guard that checks if a value is a negative safe integer.\n *\n * @param value - The value to check\n * @returns `true` if the value is a negative safe integer, `false` otherwise\n * @see {@link isNegativeSafeInt} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `NegativeSafeInt`.\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `NegativeSafeInt`.\n */\n MAX_VALUE,\n\n /**\n * Returns the absolute value of a negative safe integer.\n *\n * The result is non-negative and keeps the `NegativeSafeInt` brand.\n *\n * @param a - The negative safe integer value\n * @returns The absolute value as a non-negative `NegativeSafeInt`\n */\n abs,\n\n /**\n * Returns the smallest of the given negative safe integers.\n *\n * @param values - The negative safe integers to compare (at least one required)\n * @returns The smallest value as a `NegativeSafeInt`\n */\n min: min_,\n\n /**\n * Returns the largest of the given negative safe integers.\n *\n * @param values - The negative safe integers to compare (at least one required)\n * @returns The largest value as a `NegativeSafeInt`\n */\n max: max_,\n\n /**\n * Clamps a `number` into the `NegativeSafeInt` range, rounding to the nearest\n * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.\n *\n * @param value - The value to clamp\n * @returns The clamped value as a `NegativeSafeInt`\n */\n clamp,\n\n /**\n * Generates a random `NegativeSafeInt` within the given range.\n *\n * The range is inclusive on both ends.\n *\n * @param min - The minimum value (inclusive)\n * @param max - The maximum value (inclusive)\n * @returns A random `NegativeSafeInt` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NegativeSafeInt`\n * (floored to an integer).\n *\n * @param a - The base negative safe integer\n * @param b - The exponent negative safe integer\n * @returns `a ** b` as a `NegativeSafeInt`\n */\n pow,\n\n /**\n * Adds two negative safe integers, returning `a + b` as a `NegativeSafeInt`.\n *\n * @param a - The first negative safe integer\n * @param b - The second negative safe integer\n * @returns The sum of `a` and `b` as a `NegativeSafeInt`\n */\n add,\n\n /**\n * Subtracts two negative safe integers, returning `a - b` as a\n * `NegativeSafeInt`.\n *\n * @param a - The first negative safe integer\n * @param b - The second negative safe integer\n * @returns The difference of `a` and `b` as a `NegativeSafeInt`\n */\n sub,\n} as const;\n"],"names":[],"mappings":";;;AAWA,MAAM,iBAAA,GAAoB,yBAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA,EACT,WAAW,MAAA,CAAO,gBAAA;AAAA,EAClB,SAAA,EAAW,EAAA;AAAA,EACX;AACF,CAAU,CAAA;AAEV,MAAM,GAAA,GAAM,CAAC,CAAA,KACX,eAAA,CAAgB,MAAM,IAAA,CAAK,GAAA,CAAI,CAAC,CAAC,CAAA;AAW5B,MAAM,iBAAA,GAAoB;AAY1B,MAAM,iBAAA,GAAoB;AAS1B,MAAM,eAAA,GAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,EAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AACF;;;;"}