ts-data-forge 11.0.1 → 12.1.0

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 (178) hide show
  1. package/README.md +2 -2
  2. package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts +65 -5
  3. package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts.map +1 -1
  4. package/dist/array/impl/array-utils-length-bounded-array-cast.mjs +69 -27
  5. package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -1
  6. package/dist/array/impl/index.mjs +1 -1
  7. package/dist/number/branded-types/int16.d.mts +12 -7
  8. package/dist/number/branded-types/int16.d.mts.map +1 -1
  9. package/dist/number/branded-types/int16.mjs +13 -8
  10. package/dist/number/branded-types/int16.mjs.map +1 -1
  11. package/dist/number/branded-types/int32.d.mts +12 -7
  12. package/dist/number/branded-types/int32.d.mts.map +1 -1
  13. package/dist/number/branded-types/int32.mjs +13 -8
  14. package/dist/number/branded-types/int32.mjs.map +1 -1
  15. package/dist/number/branded-types/negative-finite-number.d.mts +13 -6
  16. package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
  17. package/dist/number/branded-types/negative-finite-number.mjs +15 -8
  18. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  19. package/dist/number/branded-types/negative-int.d.mts +11 -6
  20. package/dist/number/branded-types/negative-int.d.mts.map +1 -1
  21. package/dist/number/branded-types/negative-int.mjs +13 -8
  22. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  23. package/dist/number/branded-types/negative-safe-int.d.mts +13 -7
  24. package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
  25. package/dist/number/branded-types/negative-safe-int.mjs +15 -9
  26. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  27. package/dist/number/branded-types/non-negative-finite-number.d.mts +11 -6
  28. package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
  29. package/dist/number/branded-types/non-negative-finite-number.mjs +12 -7
  30. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  31. package/dist/number/branded-types/non-negative-int16.d.mts +13 -7
  32. package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
  33. package/dist/number/branded-types/non-negative-int16.mjs +14 -8
  34. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  35. package/dist/number/branded-types/non-negative-int32.d.mts +13 -7
  36. package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
  37. package/dist/number/branded-types/non-negative-int32.mjs +14 -8
  38. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  39. package/dist/number/branded-types/non-positive-finite-number.d.mts +11 -6
  40. package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
  41. package/dist/number/branded-types/non-positive-finite-number.mjs +12 -7
  42. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  43. package/dist/number/branded-types/non-positive-int.d.mts +11 -6
  44. package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
  45. package/dist/number/branded-types/non-positive-int.mjs +12 -7
  46. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  47. package/dist/number/branded-types/non-positive-safe-int.d.mts +14 -7
  48. package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
  49. package/dist/number/branded-types/non-positive-safe-int.mjs +15 -8
  50. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  51. package/dist/number/branded-types/non-zero-int16.d.mts +13 -7
  52. package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
  53. package/dist/number/branded-types/non-zero-int16.mjs +14 -8
  54. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  55. package/dist/number/branded-types/non-zero-int32.d.mts +13 -7
  56. package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
  57. package/dist/number/branded-types/non-zero-int32.mjs +14 -8
  58. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  59. package/dist/number/branded-types/non-zero-safe-int.d.mts +13 -7
  60. package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
  61. package/dist/number/branded-types/non-zero-safe-int.mjs +14 -8
  62. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  63. package/dist/number/branded-types/non-zero-uint16.d.mts +13 -7
  64. package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
  65. package/dist/number/branded-types/non-zero-uint16.mjs +14 -8
  66. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  67. package/dist/number/branded-types/non-zero-uint32.d.mts +13 -7
  68. package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
  69. package/dist/number/branded-types/non-zero-uint32.mjs +14 -8
  70. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  71. package/dist/number/branded-types/positive-finite-number.d.mts +13 -6
  72. package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
  73. package/dist/number/branded-types/positive-finite-number.mjs +14 -7
  74. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  75. package/dist/number/branded-types/positive-int.d.mts +13 -8
  76. package/dist/number/branded-types/positive-int.d.mts.map +1 -1
  77. package/dist/number/branded-types/positive-int.mjs +14 -9
  78. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  79. package/dist/number/branded-types/positive-int16.d.mts +13 -7
  80. package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
  81. package/dist/number/branded-types/positive-int16.mjs +14 -8
  82. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  83. package/dist/number/branded-types/positive-int32.d.mts +13 -7
  84. package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
  85. package/dist/number/branded-types/positive-int32.mjs +14 -8
  86. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  87. package/dist/number/branded-types/positive-safe-int.d.mts +16 -10
  88. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
  89. package/dist/number/branded-types/positive-safe-int.mjs +17 -11
  90. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  91. package/dist/number/branded-types/positive-uint16.d.mts +13 -7
  92. package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
  93. package/dist/number/branded-types/positive-uint16.mjs +14 -8
  94. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  95. package/dist/number/branded-types/positive-uint32.d.mts +13 -7
  96. package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
  97. package/dist/number/branded-types/positive-uint32.mjs +14 -8
  98. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  99. package/dist/number/branded-types/safe-int.d.mts +15 -10
  100. package/dist/number/branded-types/safe-int.d.mts.map +1 -1
  101. package/dist/number/branded-types/safe-int.mjs +16 -11
  102. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  103. package/dist/number/branded-types/safe-uint.d.mts +12 -7
  104. package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
  105. package/dist/number/branded-types/safe-uint.mjs +13 -8
  106. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  107. package/dist/number/branded-types/uint.d.mts +14 -10
  108. package/dist/number/branded-types/uint.d.mts.map +1 -1
  109. package/dist/number/branded-types/uint.mjs +15 -11
  110. package/dist/number/branded-types/uint.mjs.map +1 -1
  111. package/dist/number/branded-types/uint16.d.mts +12 -7
  112. package/dist/number/branded-types/uint16.d.mts.map +1 -1
  113. package/dist/number/branded-types/uint16.mjs +13 -8
  114. package/dist/number/branded-types/uint16.mjs.map +1 -1
  115. package/dist/number/branded-types/uint32.d.mts +12 -7
  116. package/dist/number/branded-types/uint32.d.mts.map +1 -1
  117. package/dist/number/branded-types/uint32.mjs +13 -8
  118. package/dist/number/branded-types/uint32.mjs.map +1 -1
  119. package/dist/number/enum/int8.d.mts +12 -7
  120. package/dist/number/enum/int8.d.mts.map +1 -1
  121. package/dist/number/enum/int8.mjs +19 -14
  122. package/dist/number/enum/int8.mjs.map +1 -1
  123. package/dist/number/enum/uint8.d.mts +12 -7
  124. package/dist/number/enum/uint8.d.mts.map +1 -1
  125. package/dist/number/enum/uint8.mjs +19 -14
  126. package/dist/number/enum/uint8.mjs.map +1 -1
  127. package/dist/number/refined-number-utils.d.mts +9 -9
  128. package/dist/number/refined-number-utils.d.mts.map +1 -1
  129. package/dist/number/refined-number-utils.mjs +7 -7
  130. package/dist/number/refined-number-utils.mjs.map +1 -1
  131. package/dist/string/str.d.mts +70 -5
  132. package/dist/string/str.d.mts.map +1 -1
  133. package/dist/string/str.mjs +72 -26
  134. package/dist/string/str.mjs.map +1 -1
  135. package/package.json +1 -1
  136. package/src/array/impl/array-utils-length-bounded-array-cast.mts +204 -39
  137. package/src/array/impl/array-utils-length-bounded-array-cast.test.mts +126 -0
  138. package/src/number/branded-types/int16.mts +13 -8
  139. package/src/number/branded-types/int32.mts +13 -8
  140. package/src/number/branded-types/negative-finite-number.mts +15 -8
  141. package/src/number/branded-types/negative-finite-number.test.mts +4 -4
  142. package/src/number/branded-types/negative-int.mts +13 -8
  143. package/src/number/branded-types/negative-int.test.mts +5 -5
  144. package/src/number/branded-types/negative-safe-int.mts +15 -9
  145. package/src/number/branded-types/negative-safe-int.test.mts +4 -4
  146. package/src/number/branded-types/non-negative-finite-number.mts +12 -7
  147. package/src/number/branded-types/non-negative-int16.mts +14 -8
  148. package/src/number/branded-types/non-negative-int32.mts +14 -8
  149. package/src/number/branded-types/non-positive-finite-number.mts +12 -7
  150. package/src/number/branded-types/non-positive-finite-number.test.mts +7 -7
  151. package/src/number/branded-types/non-positive-int.mts +12 -7
  152. package/src/number/branded-types/non-positive-int.test.mts +7 -7
  153. package/src/number/branded-types/non-positive-safe-int.mts +15 -8
  154. package/src/number/branded-types/non-positive-safe-int.test.mts +7 -7
  155. package/src/number/branded-types/non-zero-int16.mts +14 -8
  156. package/src/number/branded-types/non-zero-int32.mts +14 -8
  157. package/src/number/branded-types/non-zero-safe-int.mts +14 -8
  158. package/src/number/branded-types/non-zero-uint16.mts +14 -8
  159. package/src/number/branded-types/non-zero-uint32.mts +14 -8
  160. package/src/number/branded-types/positive-finite-number.mts +14 -7
  161. package/src/number/branded-types/positive-int.mts +14 -9
  162. package/src/number/branded-types/positive-int16.mts +14 -8
  163. package/src/number/branded-types/positive-int32.mts +14 -8
  164. package/src/number/branded-types/positive-safe-int.mts +17 -11
  165. package/src/number/branded-types/positive-uint16.mts +14 -8
  166. package/src/number/branded-types/positive-uint32.mts +14 -8
  167. package/src/number/branded-types/safe-int.mts +16 -11
  168. package/src/number/branded-types/safe-uint.mts +13 -8
  169. package/src/number/branded-types/uint.mts +15 -11
  170. package/src/number/branded-types/uint16.mts +13 -8
  171. package/src/number/branded-types/uint32.mts +13 -8
  172. package/src/number/enum/int8.mts +20 -14
  173. package/src/number/enum/int8.test.mts +7 -4
  174. package/src/number/enum/uint8.mts +20 -14
  175. package/src/number/enum/uint8.test.mts +7 -4
  176. package/src/number/refined-number-utils.mts +22 -19
  177. package/src/string/str.mts +201 -39
  178. package/src/string/str.test.mts +76 -0
@@ -6,7 +6,7 @@ const {
6
6
  MIN_VALUE,
7
7
  abs,
8
8
  castType,
9
- clamp,
9
+ fromNumber,
10
10
  is,
11
11
  max: max_,
12
12
  min: min_,
@@ -32,11 +32,13 @@ const NonZeroInt16 = {
32
32
  */
33
33
  is,
34
34
  /**
35
- * The smallest value representable as `NonZeroInt16`.
35
+ * The smallest value representable as `NonZeroInt16` (the lower saturation
36
+ * target of `fromNumber`).
36
37
  */
37
38
  MIN_VALUE,
38
39
  /**
39
- * The largest value representable as `NonZeroInt16`.
40
+ * The largest value representable as `NonZeroInt16` (the upper saturation
41
+ * target of `fromNumber`).
40
42
  */
41
43
  MAX_VALUE,
42
44
  /**
@@ -63,13 +65,17 @@ const NonZeroInt16 = {
63
65
  */
64
66
  max: max_,
65
67
  /**
66
- * Clamps a `number` into the `NonZeroInt16` range, rounding to the nearest
67
- * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
68
+ * Converts an arbitrary `number` into a `NonZeroInt16`, rounding to the
69
+ * nearest integer and saturating the result into the range `[MIN_VALUE,
70
+ * MAX_VALUE]`.
68
71
  *
69
- * @param value - The value to clamp
70
- * @returns The clamped value as a `NonZeroInt16`
72
+ * Unlike `asNonZeroInt16`, this is total: out-of-range inputs are clamped to
73
+ * the nearest representable `NonZeroInt16` instead of throwing.
74
+ *
75
+ * @param value - The value to convert
76
+ * @returns The value as a `NonZeroInt16`
71
77
  */
72
- clamp,
78
+ fromNumber,
73
79
  /**
74
80
  * Generates a random `NonZeroInt16` within the given range.
75
81
  *
@@ -1 +1 @@
1
- {"version":3,"file":"non-zero-int16.mjs","sources":["../../../src/number/branded-types/non-zero-int16.mts"],"sourcesContent":["import { type NonZeroInt16 as TtfImported_NonZeroInt16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonZeroInt16 = TtfImported_NonZeroInt16;\n\ntype ElementType = NonZeroInt16;\n\nconst typeNameInMessage = 'a non-zero integer in [-2^15, 2^15)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n abs,\n castType,\n clamp,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n randomNonZero: random,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n number,\n number\n>({\n integerOrSafeInteger: 'SafeInteger',\n nonZero: true,\n MIN_VALUE: -(2 ** 15),\n MAX_VALUE: 2 ** 15 - 1,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a non-zero integer in [-2^15, 2^15).\n *\n * Returns `true` for a non-zero integer in [-2^15, 2^15) — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [-2^15, 2^15), `false` otherwise\n */\nexport const isNonZeroInt16 = is;\n\n/**\n * Casts a `number` to the `NonZeroInt16` branded type.\n *\n * Validates that the value is a non-zero integer in [-2^15, 2^15) and returns\n * it with the `NonZeroInt16` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonZeroInt16`\n * @throws {TypeError} If the value is not a non-zero integer in [-2^15, 2^15)\n */\nexport const asNonZeroInt16 = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonZeroInt16` branded type.\n *\n * The `NonZeroInt16` type represents a non-zero integer in [-2^15, 2^15).\n * Division (`div`) uses floor division.\n */\nexport const NonZeroInt16 = {\n /**\n * Type guard that checks if a value is a non-zero integer in [-2^15, 2^15).\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [-2^15, 2^15), `false` otherwise\n * @see {@link isNonZeroInt16} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `NonZeroInt16`.\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `NonZeroInt16`.\n */\n MAX_VALUE,\n\n /**\n * Returns the absolute value of a non-zero integer in [-2^15, 2^15).\n *\n * The result is non-negative and keeps the `NonZeroInt16` brand.\n *\n * @param a - The non-zero integer value\n * @returns The absolute value as a non-negative `NonZeroInt16`\n */\n abs,\n\n /**\n * Returns the smallest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The smallest value as a `NonZeroInt16`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The largest value as a `NonZeroInt16`\n */\n max: max_,\n\n /**\n * Clamps a `number` into the `NonZeroInt16` 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 `NonZeroInt16`\n */\n clamp,\n\n /**\n * Generates a random `NonZeroInt16` 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 `NonZeroInt16` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroInt16`\n * (floored to an integer).\n *\n * @param a - The base non-zero integer\n * @param b - The exponent non-zero integer\n * @returns `a ** b` as a `NonZeroInt16`\n */\n pow,\n\n /**\n * Multiplies two non-zero integers, returning `a * b` as a `NonZeroInt16`.\n *\n * @param a - The first non-zero integer\n * @param b - The second non-zero integer\n * @returns The product of `a` and `b` as a `NonZeroInt16`\n */\n mul,\n} as const;\n\nexpectType<\n keyof typeof NonZeroInt16,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'range',\n 'mul'\n >\n>('=');\n\nexpectType<\n typeof NonZeroInt16,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'range',\n 'mul'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,qCAAA;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,GAAA;AAAA,EACA,aAAA,EAAe;AACjB,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA,EACT,SAAA,EAAW,MAAO;AAAA,EAClB,SAAA,EAAW,KAAK,EAAA,GAAK,CAAA;AAAA,EACrB;AACF,CAAU,CAAA;AAWH,MAAM,cAAA,GAAiB;AAYvB,MAAM,cAAA,GAAiB;AAQvB,MAAM,YAAA,GAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ1B,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;AACF;;;;"}
1
+ {"version":3,"file":"non-zero-int16.mjs","sources":["../../../src/number/branded-types/non-zero-int16.mts"],"sourcesContent":["import { type NonZeroInt16 as TtfImported_NonZeroInt16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonZeroInt16 = TtfImported_NonZeroInt16;\n\ntype ElementType = NonZeroInt16;\n\nconst typeNameInMessage = 'a non-zero integer in [-2^15, 2^15)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n abs,\n castType,\n fromNumber,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n randomNonZero: random,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n number,\n number\n>({\n integerOrSafeInteger: 'SafeInteger',\n nonZero: true,\n MIN_VALUE: -(2 ** 15),\n MAX_VALUE: 2 ** 15 - 1,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a non-zero integer in [-2^15, 2^15).\n *\n * Returns `true` for a non-zero integer in [-2^15, 2^15) — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [-2^15, 2^15), `false` otherwise\n */\nexport const isNonZeroInt16 = is;\n\n/**\n * Casts a `number` to the `NonZeroInt16` branded type.\n *\n * Validates that the value is a non-zero integer in [-2^15, 2^15) and returns\n * it with the `NonZeroInt16` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonZeroInt16`\n * @throws {TypeError} If the value is not a non-zero integer in [-2^15, 2^15)\n */\nexport const asNonZeroInt16 = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonZeroInt16` branded type.\n *\n * The `NonZeroInt16` type represents a non-zero integer in [-2^15, 2^15).\n * Division (`div`) uses floor division.\n */\nexport const NonZeroInt16 = {\n /**\n * Type guard that checks if a value is a non-zero integer in [-2^15, 2^15).\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [-2^15, 2^15), `false` otherwise\n * @see {@link isNonZeroInt16} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `NonZeroInt16` (the lower saturation\n * target of `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `NonZeroInt16` (the upper saturation\n * target of `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the absolute value of a non-zero integer in [-2^15, 2^15).\n *\n * The result is non-negative and keeps the `NonZeroInt16` brand.\n *\n * @param a - The non-zero integer value\n * @returns The absolute value as a non-negative `NonZeroInt16`\n */\n abs,\n\n /**\n * Returns the smallest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The smallest value as a `NonZeroInt16`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The largest value as a `NonZeroInt16`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `NonZeroInt16`, rounding to the\n * nearest integer and saturating the result into the range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * Unlike `asNonZeroInt16`, this is total: out-of-range inputs are clamped to\n * the nearest representable `NonZeroInt16` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as a `NonZeroInt16`\n */\n fromNumber,\n\n /**\n * Generates a random `NonZeroInt16` 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 `NonZeroInt16` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroInt16`\n * (floored to an integer).\n *\n * @param a - The base non-zero integer\n * @param b - The exponent non-zero integer\n * @returns `a ** b` as a `NonZeroInt16`\n */\n pow,\n\n /**\n * Multiplies two non-zero integers, returning `a * b` as a `NonZeroInt16`.\n *\n * @param a - The first non-zero integer\n * @param b - The second non-zero integer\n * @returns The product of `a` and `b` as a `NonZeroInt16`\n */\n mul,\n} as const;\n\nexpectType<\n keyof typeof NonZeroInt16,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'range',\n 'mul'\n >\n>('=');\n\nexpectType<\n typeof NonZeroInt16,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'range',\n 'mul'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,qCAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,aAAA,EAAe;AACjB,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA,EACT,SAAA,EAAW,MAAO;AAAA,EAClB,SAAA,EAAW,KAAK,EAAA,GAAK,CAAA;AAAA,EACrB;AACF,CAAU,CAAA;AAWH,MAAM,cAAA,GAAiB;AAYvB,MAAM,cAAA,GAAiB;AAQvB,MAAM,YAAA,GAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ1B,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,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;AAAA;AAAA;AAAA;AAAA,EAaL,UAAA;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;AACF;;;;"}
@@ -49,11 +49,13 @@ export declare const NonZeroInt32: {
49
49
  */
50
50
  readonly is: (a: number) => a is TtfImported_NonZeroInt32;
51
51
  /**
52
- * The smallest value representable as `NonZeroInt32`.
52
+ * The smallest value representable as `NonZeroInt32` (the lower saturation
53
+ * target of `fromNumber`).
53
54
  */
54
55
  readonly MIN_VALUE: number;
55
56
  /**
56
- * The largest value representable as `NonZeroInt32`.
57
+ * The largest value representable as `NonZeroInt32` (the upper saturation
58
+ * target of `fromNumber`).
57
59
  */
58
60
  readonly MAX_VALUE: number;
59
61
  /**
@@ -80,13 +82,17 @@ export declare const NonZeroInt32: {
80
82
  */
81
83
  readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_NonZeroInt32>[]) => TtfImported_NonZeroInt32;
82
84
  /**
83
- * Clamps a `number` into the `NonZeroInt32` range, rounding to the nearest
84
- * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
85
+ * Converts an arbitrary `number` into a `NonZeroInt32`, rounding to the
86
+ * nearest integer and saturating the result into the range `[MIN_VALUE,
87
+ * MAX_VALUE]`.
85
88
  *
86
- * @param value - The value to clamp
87
- * @returns The clamped value as a `NonZeroInt32`
89
+ * Unlike `asNonZeroInt32`, this is total: out-of-range inputs are clamped to
90
+ * the nearest representable `NonZeroInt32` instead of throwing.
91
+ *
92
+ * @param value - The value to convert
93
+ * @returns The value as a `NonZeroInt32`
88
94
  */
89
- readonly clamp: (x: number) => TtfImported_NonZeroInt32;
95
+ readonly fromNumber: (x: number) => TtfImported_NonZeroInt32;
90
96
  /**
91
97
  * Generates a random `NonZeroInt32` within the given range.
92
98
  *
@@ -1 +1 @@
1
- {"version":3,"file":"non-zero-int32.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-zero-int32.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,IAAI,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAI9E,MAAM,MAAM,YAAY,GAAG,wBAAwB,CAAC;AA8BpD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,8CAAK,CAAC;AAEjC;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;MAAW,CAAC;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,YAAY;IACvB;;;;;;OAMG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;;;OAOG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;CAEK,CAAC"}
1
+ {"version":3,"file":"non-zero-int32.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-zero-int32.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,IAAI,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAI9E,MAAM,MAAM,YAAY,GAAG,wBAAwB,CAAC;AA8BpD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,8CAAK,CAAC;AAEjC;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;MAAW,CAAC;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,YAAY;IACvB;;;;;;OAMG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;;;;OAOG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;CAEK,CAAC"}
@@ -6,7 +6,7 @@ const {
6
6
  MIN_VALUE,
7
7
  abs,
8
8
  castType,
9
- clamp,
9
+ fromNumber,
10
10
  is,
11
11
  max: max_,
12
12
  min: min_,
@@ -32,11 +32,13 @@ const NonZeroInt32 = {
32
32
  */
33
33
  is,
34
34
  /**
35
- * The smallest value representable as `NonZeroInt32`.
35
+ * The smallest value representable as `NonZeroInt32` (the lower saturation
36
+ * target of `fromNumber`).
36
37
  */
37
38
  MIN_VALUE,
38
39
  /**
39
- * The largest value representable as `NonZeroInt32`.
40
+ * The largest value representable as `NonZeroInt32` (the upper saturation
41
+ * target of `fromNumber`).
40
42
  */
41
43
  MAX_VALUE,
42
44
  /**
@@ -63,13 +65,17 @@ const NonZeroInt32 = {
63
65
  */
64
66
  max: max_,
65
67
  /**
66
- * Clamps a `number` into the `NonZeroInt32` range, rounding to the nearest
67
- * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
68
+ * Converts an arbitrary `number` into a `NonZeroInt32`, rounding to the
69
+ * nearest integer and saturating the result into the range `[MIN_VALUE,
70
+ * MAX_VALUE]`.
68
71
  *
69
- * @param value - The value to clamp
70
- * @returns The clamped value as a `NonZeroInt32`
72
+ * Unlike `asNonZeroInt32`, this is total: out-of-range inputs are clamped to
73
+ * the nearest representable `NonZeroInt32` instead of throwing.
74
+ *
75
+ * @param value - The value to convert
76
+ * @returns The value as a `NonZeroInt32`
71
77
  */
72
- clamp,
78
+ fromNumber,
73
79
  /**
74
80
  * Generates a random `NonZeroInt32` within the given range.
75
81
  *
@@ -1 +1 @@
1
- {"version":3,"file":"non-zero-int32.mjs","sources":["../../../src/number/branded-types/non-zero-int32.mts"],"sourcesContent":["import { type NonZeroInt32 as TtfImported_NonZeroInt32 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonZeroInt32 = TtfImported_NonZeroInt32;\n\ntype ElementType = NonZeroInt32;\n\nconst typeNameInMessage = 'a non-zero integer in [-2^31, 2^31)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n abs,\n castType,\n clamp,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n randomNonZero: random,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n number,\n number\n>({\n integerOrSafeInteger: 'SafeInteger',\n nonZero: true,\n MIN_VALUE: -(2 ** 31),\n MAX_VALUE: 2 ** 31 - 1,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a non-zero integer in [-2^31, 2^31).\n *\n * Returns `true` for a non-zero integer in [-2^31, 2^31) — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [-2^31, 2^31), `false` otherwise\n */\nexport const isNonZeroInt32 = is;\n\n/**\n * Casts a `number` to the `NonZeroInt32` branded type.\n *\n * Validates that the value is a non-zero integer in [-2^31, 2^31) and returns\n * it with the `NonZeroInt32` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonZeroInt32`\n * @throws {TypeError} If the value is not a non-zero integer in [-2^31, 2^31)\n */\nexport const asNonZeroInt32 = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonZeroInt32` branded type.\n *\n * The `NonZeroInt32` type represents a non-zero integer in [-2^31, 2^31).\n * Division (`div`) uses floor division.\n */\nexport const NonZeroInt32 = {\n /**\n * Type guard that checks if a value is a non-zero integer in [-2^31, 2^31).\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [-2^31, 2^31), `false` otherwise\n * @see {@link isNonZeroInt32} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `NonZeroInt32`.\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `NonZeroInt32`.\n */\n MAX_VALUE,\n\n /**\n * Returns the absolute value of a non-zero integer in [-2^31, 2^31).\n *\n * The result is non-negative and keeps the `NonZeroInt32` brand.\n *\n * @param a - The non-zero integer value\n * @returns The absolute value as a non-negative `NonZeroInt32`\n */\n abs,\n\n /**\n * Returns the smallest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The smallest value as a `NonZeroInt32`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The largest value as a `NonZeroInt32`\n */\n max: max_,\n\n /**\n * Clamps a `number` into the `NonZeroInt32` 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 `NonZeroInt32`\n */\n clamp,\n\n /**\n * Generates a random `NonZeroInt32` 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 `NonZeroInt32` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroInt32`\n * (floored to an integer).\n *\n * @param a - The base non-zero integer\n * @param b - The exponent non-zero integer\n * @returns `a ** b` as a `NonZeroInt32`\n */\n pow,\n\n /**\n * Multiplies two non-zero integers, returning `a * b` as a `NonZeroInt32`.\n *\n * @param a - The first non-zero integer\n * @param b - The second non-zero integer\n * @returns The product of `a` and `b` as a `NonZeroInt32`\n */\n mul,\n} as const;\n\nexpectType<\n keyof typeof NonZeroInt32,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'range',\n 'mul'\n >\n>('=');\n\nexpectType<\n typeof NonZeroInt32,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'range',\n 'mul'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,qCAAA;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,GAAA;AAAA,EACA,aAAA,EAAe;AACjB,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA,EACT,SAAA,EAAW,WAAO;AAAA,EAClB,SAAA,EAAW,KAAK,EAAA,GAAK,CAAA;AAAA,EACrB;AACF,CAAU,CAAA;AAWH,MAAM,cAAA,GAAiB;AAYvB,MAAM,cAAA,GAAiB;AAQvB,MAAM,YAAA,GAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ1B,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;AACF;;;;"}
1
+ {"version":3,"file":"non-zero-int32.mjs","sources":["../../../src/number/branded-types/non-zero-int32.mts"],"sourcesContent":["import { type NonZeroInt32 as TtfImported_NonZeroInt32 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonZeroInt32 = TtfImported_NonZeroInt32;\n\ntype ElementType = NonZeroInt32;\n\nconst typeNameInMessage = 'a non-zero integer in [-2^31, 2^31)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n abs,\n castType,\n fromNumber,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n randomNonZero: random,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n number,\n number\n>({\n integerOrSafeInteger: 'SafeInteger',\n nonZero: true,\n MIN_VALUE: -(2 ** 31),\n MAX_VALUE: 2 ** 31 - 1,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a non-zero integer in [-2^31, 2^31).\n *\n * Returns `true` for a non-zero integer in [-2^31, 2^31) — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [-2^31, 2^31), `false` otherwise\n */\nexport const isNonZeroInt32 = is;\n\n/**\n * Casts a `number` to the `NonZeroInt32` branded type.\n *\n * Validates that the value is a non-zero integer in [-2^31, 2^31) and returns\n * it with the `NonZeroInt32` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonZeroInt32`\n * @throws {TypeError} If the value is not a non-zero integer in [-2^31, 2^31)\n */\nexport const asNonZeroInt32 = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonZeroInt32` branded type.\n *\n * The `NonZeroInt32` type represents a non-zero integer in [-2^31, 2^31).\n * Division (`div`) uses floor division.\n */\nexport const NonZeroInt32 = {\n /**\n * Type guard that checks if a value is a non-zero integer in [-2^31, 2^31).\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [-2^31, 2^31), `false` otherwise\n * @see {@link isNonZeroInt32} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `NonZeroInt32` (the lower saturation\n * target of `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `NonZeroInt32` (the upper saturation\n * target of `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the absolute value of a non-zero integer in [-2^31, 2^31).\n *\n * The result is non-negative and keeps the `NonZeroInt32` brand.\n *\n * @param a - The non-zero integer value\n * @returns The absolute value as a non-negative `NonZeroInt32`\n */\n abs,\n\n /**\n * Returns the smallest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The smallest value as a `NonZeroInt32`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The largest value as a `NonZeroInt32`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `NonZeroInt32`, rounding to the\n * nearest integer and saturating the result into the range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * Unlike `asNonZeroInt32`, this is total: out-of-range inputs are clamped to\n * the nearest representable `NonZeroInt32` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as a `NonZeroInt32`\n */\n fromNumber,\n\n /**\n * Generates a random `NonZeroInt32` 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 `NonZeroInt32` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroInt32`\n * (floored to an integer).\n *\n * @param a - The base non-zero integer\n * @param b - The exponent non-zero integer\n * @returns `a ** b` as a `NonZeroInt32`\n */\n pow,\n\n /**\n * Multiplies two non-zero integers, returning `a * b` as a `NonZeroInt32`.\n *\n * @param a - The first non-zero integer\n * @param b - The second non-zero integer\n * @returns The product of `a` and `b` as a `NonZeroInt32`\n */\n mul,\n} as const;\n\nexpectType<\n keyof typeof NonZeroInt32,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'range',\n 'mul'\n >\n>('=');\n\nexpectType<\n typeof NonZeroInt32,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'range',\n 'mul'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,qCAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,aAAA,EAAe;AACjB,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA,EACT,SAAA,EAAW,WAAO;AAAA,EAClB,SAAA,EAAW,KAAK,EAAA,GAAK,CAAA;AAAA,EACrB;AACF,CAAU,CAAA;AAWH,MAAM,cAAA,GAAiB;AAYvB,MAAM,cAAA,GAAiB;AAQvB,MAAM,YAAA,GAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ1B,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,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;AAAA;AAAA;AAAA;AAAA,EAaL,UAAA;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;AACF;;;;"}
@@ -46,11 +46,13 @@ export declare const NonZeroSafeInt: {
46
46
  */
47
47
  readonly is: (a: number) => a is TtfImported_NonZeroSafeInt;
48
48
  /**
49
- * The smallest value representable as `NonZeroSafeInt`.
49
+ * The smallest value representable as `NonZeroSafeInt` (the lower saturation
50
+ * target of `fromNumber`).
50
51
  */
51
52
  readonly MIN_VALUE: SafeInt;
52
53
  /**
53
- * The largest value representable as `NonZeroSafeInt`.
54
+ * The largest value representable as `NonZeroSafeInt` (the upper saturation
55
+ * target of `fromNumber`).
54
56
  */
55
57
  readonly MAX_VALUE: SafeUint;
56
58
  /**
@@ -77,13 +79,17 @@ export declare const NonZeroSafeInt: {
77
79
  */
78
80
  readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_NonZeroSafeInt>[]) => TtfImported_NonZeroSafeInt;
79
81
  /**
80
- * Clamps a `number` into the `NonZeroSafeInt` range, rounding to the nearest
81
- * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
82
+ * Converts an arbitrary `number` into a `NonZeroSafeInt`, rounding to the
83
+ * nearest integer and saturating the result into the range `[MIN_VALUE,
84
+ * MAX_VALUE]`.
82
85
  *
83
- * @param value - The value to clamp
84
- * @returns The clamped value as a `NonZeroSafeInt`
86
+ * Unlike `asNonZeroSafeInt`, this is total: out-of-range inputs are clamped
87
+ * to the nearest representable `NonZeroSafeInt` instead of throwing.
88
+ *
89
+ * @param value - The value to convert
90
+ * @returns The value as a `NonZeroSafeInt`
85
91
  */
86
- readonly clamp: (x: number) => TtfImported_NonZeroSafeInt;
92
+ readonly fromNumber: (x: number) => TtfImported_NonZeroSafeInt;
87
93
  /**
88
94
  * Generates a random `NonZeroSafeInt` within the given range.
89
95
  *
@@ -1 +1 @@
1
- {"version":3,"file":"non-zero-safe-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-zero-safe-int.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,cAAc,IAAI,0BAA0B,EAClD,MAAM,eAAe,CAAC;AAIvB,MAAM,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAgCxD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,gDAAK,CAAC;AAEnC;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;MAAW,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;IACzB;;;;;;OAMG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;;;OAOG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;CAEK,CAAC"}
1
+ {"version":3,"file":"non-zero-safe-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-zero-safe-int.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,cAAc,IAAI,0BAA0B,EAClD,MAAM,eAAe,CAAC;AAIvB,MAAM,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAgCxD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,gDAAK,CAAC;AAEnC;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;MAAW,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;IACzB;;;;;;OAMG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;;;;OAOG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;CAEK,CAAC"}
@@ -6,7 +6,7 @@ const {
6
6
  MIN_VALUE,
7
7
  abs,
8
8
  castType,
9
- clamp,
9
+ fromNumber,
10
10
  is,
11
11
  max: max_,
12
12
  min: min_,
@@ -34,11 +34,13 @@ const NonZeroSafeInt = {
34
34
  */
35
35
  is,
36
36
  /**
37
- * The smallest value representable as `NonZeroSafeInt`.
37
+ * The smallest value representable as `NonZeroSafeInt` (the lower saturation
38
+ * target of `fromNumber`).
38
39
  */
39
40
  MIN_VALUE,
40
41
  /**
41
- * The largest value representable as `NonZeroSafeInt`.
42
+ * The largest value representable as `NonZeroSafeInt` (the upper saturation
43
+ * target of `fromNumber`).
42
44
  */
43
45
  MAX_VALUE,
44
46
  /**
@@ -65,13 +67,17 @@ const NonZeroSafeInt = {
65
67
  */
66
68
  max: max_,
67
69
  /**
68
- * Clamps a `number` into the `NonZeroSafeInt` range, rounding to the nearest
69
- * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
70
+ * Converts an arbitrary `number` into a `NonZeroSafeInt`, rounding to the
71
+ * nearest integer and saturating the result into the range `[MIN_VALUE,
72
+ * MAX_VALUE]`.
70
73
  *
71
- * @param value - The value to clamp
72
- * @returns The clamped value as a `NonZeroSafeInt`
74
+ * Unlike `asNonZeroSafeInt`, this is total: out-of-range inputs are clamped
75
+ * to the nearest representable `NonZeroSafeInt` instead of throwing.
76
+ *
77
+ * @param value - The value to convert
78
+ * @returns The value as a `NonZeroSafeInt`
73
79
  */
74
- clamp,
80
+ fromNumber,
75
81
  /**
76
82
  * Generates a random `NonZeroSafeInt` within the given range.
77
83
  *
@@ -1 +1 @@
1
- {"version":3,"file":"non-zero-safe-int.mjs","sources":["../../../src/number/branded-types/non-zero-safe-int.mts"],"sourcesContent":["import {\n type SafeInt,\n type SafeUint,\n type NonZeroSafeInt as TtfImported_NonZeroSafeInt,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonZeroSafeInt = TtfImported_NonZeroSafeInt;\n\ntype ElementType = NonZeroSafeInt;\n\nconst typeNameInMessage = 'a non-zero safe integer';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n abs,\n castType,\n clamp,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n randomNonZero: random,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n SafeInt,\n SafeUint\n>({\n integerOrSafeInteger: 'SafeInteger',\n nonZero: true,\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-min-safe-integer\n MIN_VALUE: Number.MIN_SAFE_INTEGER as SafeInt,\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer\n MAX_VALUE: Number.MAX_SAFE_INTEGER as SafeUint,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a non-zero safe integer.\n *\n * Returns `true` for a non-zero 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 non-zero safe integer, `false` otherwise\n */\nexport const isNonZeroSafeInt = is;\n\n/**\n * Casts a `number` to the `NonZeroSafeInt` branded type.\n *\n * Validates that the value is a non-zero safe integer and returns it with the\n * `NonZeroSafeInt` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonZeroSafeInt`\n * @throws {TypeError} If the value is not a non-zero safe integer\n */\nexport const asNonZeroSafeInt = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonZeroSafeInt` branded\n * type.\n *\n * The `NonZeroSafeInt` type represents a non-zero safe integer. Division\n * (`div`) uses floor division.\n */\nexport const NonZeroSafeInt = {\n /**\n * Type guard that checks if a value is a non-zero safe integer.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero safe integer, `false` otherwise\n * @see {@link isNonZeroSafeInt} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `NonZeroSafeInt`.\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `NonZeroSafeInt`.\n */\n MAX_VALUE,\n\n /**\n * Returns the absolute value of a non-zero safe integer.\n *\n * The result is non-negative and keeps the `NonZeroSafeInt` brand.\n *\n * @param a - The non-zero safe integer value\n * @returns The absolute value as a non-negative `NonZeroSafeInt`\n */\n abs,\n\n /**\n * Returns the smallest of the given non-zero safe integers.\n *\n * @param values - The non-zero safe integers to compare (at least one required)\n * @returns The smallest value as a `NonZeroSafeInt`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-zero safe integers.\n *\n * @param values - The non-zero safe integers to compare (at least one required)\n * @returns The largest value as a `NonZeroSafeInt`\n */\n max: max_,\n\n /**\n * Clamps a `number` into the `NonZeroSafeInt` 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 `NonZeroSafeInt`\n */\n clamp,\n\n /**\n * Generates a random `NonZeroSafeInt` 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 `NonZeroSafeInt` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroSafeInt`\n * (floored to an integer).\n *\n * @param a - The base non-zero safe integer\n * @param b - The exponent non-zero safe integer\n * @returns `a ** b` as a `NonZeroSafeInt`\n */\n pow,\n\n /**\n * Multiplies two non-zero safe integers, returning `a * b` as a\n * `NonZeroSafeInt`.\n *\n * @param a - The first non-zero safe integer\n * @param b - The second non-zero safe integer\n * @returns The product of `a` and `b` as a `NonZeroSafeInt`\n */\n mul,\n} as const;\n\nexpectType<\n keyof typeof NonZeroSafeInt,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'range',\n 'mul'\n >\n>('=');\n\nexpectType<\n typeof NonZeroSafeInt,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'range',\n 'mul'\n >\n>('<=');\n"],"names":[],"mappings":";;AAYA,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,GAAA;AAAA,EACA,aAAA,EAAe;AACjB,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA;AAAA,EAET,WAAW,MAAA,CAAO,gBAAA;AAAA;AAAA,EAElB,WAAW,MAAA,CAAO,gBAAA;AAAA,EAClB;AACF,CAAU,CAAA;AAWH,MAAM,gBAAA,GAAmB;AAYzB,MAAM,gBAAA,GAAmB;AASzB,MAAM,cAAA,GAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5B,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;AAAA,EAUA;AACF;;;;"}
1
+ {"version":3,"file":"non-zero-safe-int.mjs","sources":["../../../src/number/branded-types/non-zero-safe-int.mts"],"sourcesContent":["import {\n type SafeInt,\n type SafeUint,\n type NonZeroSafeInt as TtfImported_NonZeroSafeInt,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonZeroSafeInt = TtfImported_NonZeroSafeInt;\n\ntype ElementType = NonZeroSafeInt;\n\nconst typeNameInMessage = 'a non-zero safe integer';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n abs,\n castType,\n fromNumber,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n randomNonZero: random,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n SafeInt,\n SafeUint\n>({\n integerOrSafeInteger: 'SafeInteger',\n nonZero: true,\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-min-safe-integer\n MIN_VALUE: Number.MIN_SAFE_INTEGER as SafeInt,\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer\n MAX_VALUE: Number.MAX_SAFE_INTEGER as SafeUint,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a non-zero safe integer.\n *\n * Returns `true` for a non-zero 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 non-zero safe integer, `false` otherwise\n */\nexport const isNonZeroSafeInt = is;\n\n/**\n * Casts a `number` to the `NonZeroSafeInt` branded type.\n *\n * Validates that the value is a non-zero safe integer and returns it with the\n * `NonZeroSafeInt` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonZeroSafeInt`\n * @throws {TypeError} If the value is not a non-zero safe integer\n */\nexport const asNonZeroSafeInt = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonZeroSafeInt` branded\n * type.\n *\n * The `NonZeroSafeInt` type represents a non-zero safe integer. Division\n * (`div`) uses floor division.\n */\nexport const NonZeroSafeInt = {\n /**\n * Type guard that checks if a value is a non-zero safe integer.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero safe integer, `false` otherwise\n * @see {@link isNonZeroSafeInt} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `NonZeroSafeInt` (the lower saturation\n * target of `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `NonZeroSafeInt` (the upper saturation\n * target of `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the absolute value of a non-zero safe integer.\n *\n * The result is non-negative and keeps the `NonZeroSafeInt` brand.\n *\n * @param a - The non-zero safe integer value\n * @returns The absolute value as a non-negative `NonZeroSafeInt`\n */\n abs,\n\n /**\n * Returns the smallest of the given non-zero safe integers.\n *\n * @param values - The non-zero safe integers to compare (at least one required)\n * @returns The smallest value as a `NonZeroSafeInt`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-zero safe integers.\n *\n * @param values - The non-zero safe integers to compare (at least one required)\n * @returns The largest value as a `NonZeroSafeInt`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `NonZeroSafeInt`, rounding to the\n * nearest integer and saturating the result into the range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * Unlike `asNonZeroSafeInt`, this is total: out-of-range inputs are clamped\n * to the nearest representable `NonZeroSafeInt` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as a `NonZeroSafeInt`\n */\n fromNumber,\n\n /**\n * Generates a random `NonZeroSafeInt` 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 `NonZeroSafeInt` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroSafeInt`\n * (floored to an integer).\n *\n * @param a - The base non-zero safe integer\n * @param b - The exponent non-zero safe integer\n * @returns `a ** b` as a `NonZeroSafeInt`\n */\n pow,\n\n /**\n * Multiplies two non-zero safe integers, returning `a * b` as a\n * `NonZeroSafeInt`.\n *\n * @param a - The first non-zero safe integer\n * @param b - The second non-zero safe integer\n * @returns The product of `a` and `b` as a `NonZeroSafeInt`\n */\n mul,\n} as const;\n\nexpectType<\n keyof typeof NonZeroSafeInt,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'range',\n 'mul'\n >\n>('=');\n\nexpectType<\n typeof NonZeroSafeInt,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'range',\n 'mul'\n >\n>('<=');\n"],"names":[],"mappings":";;AAYA,MAAM,iBAAA,GAAoB,yBAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,aAAA,EAAe;AACjB,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA;AAAA,EAET,WAAW,MAAA,CAAO,gBAAA;AAAA;AAAA,EAElB,WAAW,MAAA,CAAO,gBAAA;AAAA,EAClB;AACF,CAAU,CAAA;AAWH,MAAM,gBAAA,GAAmB;AAYzB,MAAM,gBAAA,GAAmB;AASzB,MAAM,cAAA,GAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5B,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,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;AAAA;AAAA;AAAA;AAAA,EAaL,UAAA;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;AAAA,EAUA;AACF;;;;"}
@@ -55,11 +55,13 @@ export declare const NonZeroUint16: {
55
55
  */
56
56
  readonly is: (a: number) => a is import("ts-type-forge").PositiveUint16;
57
57
  /**
58
- * The smallest value representable as `NonZeroUint16`.
58
+ * The smallest value representable as `NonZeroUint16` (the lower saturation
59
+ * target of `fromNumber`).
59
60
  */
60
61
  readonly MIN_VALUE: 1;
61
62
  /**
62
- * The largest value representable as `NonZeroUint16`.
63
+ * The largest value representable as `NonZeroUint16` (the upper saturation
64
+ * target of `fromNumber`).
63
65
  */
64
66
  readonly MAX_VALUE: number;
65
67
  /**
@@ -77,13 +79,17 @@ export declare const NonZeroUint16: {
77
79
  */
78
80
  readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<import("ts-type-forge").PositiveUint16>[]) => import("ts-type-forge").PositiveUint16;
79
81
  /**
80
- * Clamps a `number` into the `NonZeroUint16` range, rounding to the nearest
81
- * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
82
+ * Converts an arbitrary `number` into a `NonZeroUint16`, rounding to the
83
+ * nearest integer and saturating the result into the range `[MIN_VALUE,
84
+ * MAX_VALUE]`.
82
85
  *
83
- * @param value - The value to clamp
84
- * @returns The clamped value as a `NonZeroUint16`
86
+ * Unlike `asNonZeroUint16`, this is total: out-of-range inputs are clamped to
87
+ * the nearest representable `NonZeroUint16` instead of throwing.
88
+ *
89
+ * @param value - The value to convert
90
+ * @returns The value as a `NonZeroUint16`
85
91
  */
86
- readonly clamp: (x: number) => import("ts-type-forge").PositiveUint16;
92
+ readonly fromNumber: (x: number) => import("ts-type-forge").PositiveUint16;
87
93
  /**
88
94
  * Generates a random `NonZeroUint16` within the given range.
89
95
  *
@@ -1 +1 @@
1
- {"version":3,"file":"non-zero-uint16.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-zero-uint16.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,IAAI,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAIhF,MAAM,MAAM,aAAa,GAAG,yBAAyB,CAAC;AA8BtD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,4DAAK,CAAC;AAElC;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;MAAW,CAAC;AAExC;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;IACxB;;;;;;OAMG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;CAEK,CAAC"}
1
+ {"version":3,"file":"non-zero-uint16.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-zero-uint16.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,IAAI,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAIhF,MAAM,MAAM,aAAa,GAAG,yBAAyB,CAAC;AA8BtD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,4DAAK,CAAC;AAElC;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;MAAW,CAAC;AAExC;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;IACxB;;;;;;OAMG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;CAEK,CAAC"}
@@ -6,7 +6,7 @@ const {
6
6
  MIN_VALUE,
7
7
  add,
8
8
  castType,
9
- clamp,
9
+ fromNumber,
10
10
  is,
11
11
  max: max_,
12
12
  min: min_,
@@ -32,11 +32,13 @@ const NonZeroUint16 = {
32
32
  */
33
33
  is,
34
34
  /**
35
- * The smallest value representable as `NonZeroUint16`.
35
+ * The smallest value representable as `NonZeroUint16` (the lower saturation
36
+ * target of `fromNumber`).
36
37
  */
37
38
  MIN_VALUE,
38
39
  /**
39
- * The largest value representable as `NonZeroUint16`.
40
+ * The largest value representable as `NonZeroUint16` (the upper saturation
41
+ * target of `fromNumber`).
40
42
  */
41
43
  MAX_VALUE,
42
44
  /**
@@ -54,13 +56,17 @@ const NonZeroUint16 = {
54
56
  */
55
57
  max: max_,
56
58
  /**
57
- * Clamps a `number` into the `NonZeroUint16` range, rounding to the nearest
58
- * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
59
+ * Converts an arbitrary `number` into a `NonZeroUint16`, rounding to the
60
+ * nearest integer and saturating the result into the range `[MIN_VALUE,
61
+ * MAX_VALUE]`.
59
62
  *
60
- * @param value - The value to clamp
61
- * @returns The clamped value as a `NonZeroUint16`
63
+ * Unlike `asNonZeroUint16`, this is total: out-of-range inputs are clamped to
64
+ * the nearest representable `NonZeroUint16` instead of throwing.
65
+ *
66
+ * @param value - The value to convert
67
+ * @returns The value as a `NonZeroUint16`
62
68
  */
63
- clamp,
69
+ fromNumber,
64
70
  /**
65
71
  * Generates a random `NonZeroUint16` within the given range.
66
72
  *
@@ -1 +1 @@
1
- {"version":3,"file":"non-zero-uint16.mjs","sources":["../../../src/number/branded-types/non-zero-uint16.mts"],"sourcesContent":["import { type NonZeroUint16 as TtfImported_NonZeroUint16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonZeroUint16 = TtfImported_NonZeroUint16;\n\ntype ElementType = NonZeroUint16;\n\nconst typeNameInMessage = 'a non-zero integer in [1, 2^16)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n clamp,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n randomNonZero: random,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n 1,\n number\n>({\n integerOrSafeInteger: 'SafeInteger',\n nonZero: true,\n MIN_VALUE: 1,\n MAX_VALUE: 2 ** 16 - 1,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a non-zero integer in [1, 2^16).\n *\n * Returns `true` for a non-zero integer in [1, 2^16) — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [1, 2^16), `false` otherwise\n */\nexport const isNonZeroUint16 = is;\n\n/**\n * Casts a `number` to the `NonZeroUint16` branded type.\n *\n * Validates that the value is a non-zero integer in [1, 2^16) and returns it\n * with the `NonZeroUint16` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonZeroUint16`\n * @throws {TypeError} If the value is not a non-zero integer in [1, 2^16)\n */\nexport const asNonZeroUint16 = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonZeroUint16` branded\n * type.\n *\n * The `NonZeroUint16` type represents a non-zero integer in [1, 2^16). Division\n * (`div`) uses floor division.\n */\nexport const NonZeroUint16 = {\n /**\n * Type guard that checks if a value is a non-zero integer in [1, 2^16).\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [1, 2^16), `false` otherwise\n * @see {@link isNonZeroUint16} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `NonZeroUint16`.\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `NonZeroUint16`.\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The smallest value as a `NonZeroUint16`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The largest value as a `NonZeroUint16`\n */\n max: max_,\n\n /**\n * Clamps a `number` into the `NonZeroUint16` 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 `NonZeroUint16`\n */\n clamp,\n\n /**\n * Generates a random `NonZeroUint16` 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 `NonZeroUint16` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroUint16`\n * (floored to an integer).\n *\n * @param a - The base non-zero integer\n * @param b - The exponent non-zero integer\n * @returns `a ** b` as a `NonZeroUint16`\n */\n pow,\n\n /**\n * Adds two non-zero integers, returning `a + b` as a `NonZeroUint16`.\n *\n * @param a - The first non-zero integer\n * @param b - The second non-zero integer\n * @returns The sum of `a` and `b` as a `NonZeroUint16`\n */\n add,\n\n /**\n * Multiplies two non-zero integers, returning `a * b` as a `NonZeroUint16`.\n *\n * @param a - The first non-zero integer\n * @param b - The second non-zero integer\n * @returns The product of `a` and `b` as a `NonZeroUint16`\n */\n mul,\n} as const;\n\nexpectType<\n keyof typeof NonZeroUint16,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range',\n 'add' | 'mul'\n >\n>('=');\n\nexpectType<\n typeof NonZeroUint16,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range',\n 'add' | 'mul'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,iCAAA;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,GAAA;AAAA,EACA,aAAA,EAAe;AACjB,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA,EACT,SAAA,EAAW,CAAA;AAAA,EACX,SAAA,EAAW,KAAK,EAAA,GAAK,CAAA;AAAA,EACrB;AACF,CAAU,CAAA;AAWH,MAAM,eAAA,GAAkB;AAYxB,MAAM,eAAA,GAAkB;AASxB,MAAM,aAAA,GAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ3B,EAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;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;;;;"}
1
+ {"version":3,"file":"non-zero-uint16.mjs","sources":["../../../src/number/branded-types/non-zero-uint16.mts"],"sourcesContent":["import { type NonZeroUint16 as TtfImported_NonZeroUint16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonZeroUint16 = TtfImported_NonZeroUint16;\n\ntype ElementType = NonZeroUint16;\n\nconst typeNameInMessage = 'a non-zero integer in [1, 2^16)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n fromNumber,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n randomNonZero: random,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n 1,\n number\n>({\n integerOrSafeInteger: 'SafeInteger',\n nonZero: true,\n MIN_VALUE: 1,\n MAX_VALUE: 2 ** 16 - 1,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a non-zero integer in [1, 2^16).\n *\n * Returns `true` for a non-zero integer in [1, 2^16) — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [1, 2^16), `false` otherwise\n */\nexport const isNonZeroUint16 = is;\n\n/**\n * Casts a `number` to the `NonZeroUint16` branded type.\n *\n * Validates that the value is a non-zero integer in [1, 2^16) and returns it\n * with the `NonZeroUint16` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonZeroUint16`\n * @throws {TypeError} If the value is not a non-zero integer in [1, 2^16)\n */\nexport const asNonZeroUint16 = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonZeroUint16` branded\n * type.\n *\n * The `NonZeroUint16` type represents a non-zero integer in [1, 2^16). Division\n * (`div`) uses floor division.\n */\nexport const NonZeroUint16 = {\n /**\n * Type guard that checks if a value is a non-zero integer in [1, 2^16).\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [1, 2^16), `false` otherwise\n * @see {@link isNonZeroUint16} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `NonZeroUint16` (the lower saturation\n * target of `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `NonZeroUint16` (the upper saturation\n * target of `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The smallest value as a `NonZeroUint16`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The largest value as a `NonZeroUint16`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `NonZeroUint16`, rounding to the\n * nearest integer and saturating the result into the range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * Unlike `asNonZeroUint16`, this is total: out-of-range inputs are clamped to\n * the nearest representable `NonZeroUint16` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as a `NonZeroUint16`\n */\n fromNumber,\n\n /**\n * Generates a random `NonZeroUint16` 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 `NonZeroUint16` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroUint16`\n * (floored to an integer).\n *\n * @param a - The base non-zero integer\n * @param b - The exponent non-zero integer\n * @returns `a ** b` as a `NonZeroUint16`\n */\n pow,\n\n /**\n * Adds two non-zero integers, returning `a + b` as a `NonZeroUint16`.\n *\n * @param a - The first non-zero integer\n * @param b - The second non-zero integer\n * @returns The sum of `a` and `b` as a `NonZeroUint16`\n */\n add,\n\n /**\n * Multiplies two non-zero integers, returning `a * b` as a `NonZeroUint16`.\n *\n * @param a - The first non-zero integer\n * @param b - The second non-zero integer\n * @returns The product of `a` and `b` as a `NonZeroUint16`\n */\n mul,\n} as const;\n\nexpectType<\n keyof typeof NonZeroUint16,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range',\n 'add' | 'mul'\n >\n>('=');\n\nexpectType<\n typeof NonZeroUint16,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range',\n 'add' | 'mul'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,iCAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,aAAA,EAAe;AACjB,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA,EACT,SAAA,EAAW,CAAA;AAAA,EACX,SAAA,EAAW,KAAK,EAAA,GAAK,CAAA;AAAA,EACrB;AACF,CAAU,CAAA;AAWH,MAAM,eAAA,GAAkB;AAYxB,MAAM,eAAA,GAAkB;AASxB,MAAM,aAAA,GAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ3B,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;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;AAAA;AAAA;AAAA;AAAA,EAaL,UAAA;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;;;;"}
@@ -53,11 +53,13 @@ export declare const NonZeroUint32: {
53
53
  */
54
54
  readonly is: (a: number) => a is import("ts-type-forge").PositiveUint32;
55
55
  /**
56
- * The smallest value representable as `NonZeroUint32`.
56
+ * The smallest value representable as `NonZeroUint32` (the lower saturation
57
+ * target of `fromNumber`).
57
58
  */
58
59
  readonly MIN_VALUE: 1;
59
60
  /**
60
- * The largest value representable as `NonZeroUint32`.
61
+ * The largest value representable as `NonZeroUint32` (the upper saturation
62
+ * target of `fromNumber`).
61
63
  */
62
64
  readonly MAX_VALUE: number;
63
65
  /**
@@ -75,13 +77,17 @@ export declare const NonZeroUint32: {
75
77
  */
76
78
  readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<import("ts-type-forge").PositiveUint32>[]) => import("ts-type-forge").PositiveUint32;
77
79
  /**
78
- * Clamps a `number` into the `NonZeroUint32` range, rounding to the nearest
79
- * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
80
+ * Converts an arbitrary `number` into a `NonZeroUint32`, rounding to the
81
+ * nearest integer and saturating the result into the range `[MIN_VALUE,
82
+ * MAX_VALUE]`.
80
83
  *
81
- * @param value - The value to clamp
82
- * @returns The clamped value as a `NonZeroUint32`
84
+ * Unlike `asNonZeroUint32`, this is total: out-of-range inputs are clamped to
85
+ * the nearest representable `NonZeroUint32` instead of throwing.
86
+ *
87
+ * @param value - The value to convert
88
+ * @returns The value as a `NonZeroUint32`
83
89
  */
84
- readonly clamp: (x: number) => import("ts-type-forge").PositiveUint32;
90
+ readonly fromNumber: (x: number) => import("ts-type-forge").PositiveUint32;
85
91
  /**
86
92
  * Generates a random `NonZeroUint32` within the given range.
87
93
  *
@@ -1 +1 @@
1
- {"version":3,"file":"non-zero-uint32.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-zero-uint32.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,IAAI,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAIhF,MAAM,MAAM,aAAa,GAAG,yBAAyB,CAAC;AA8BtD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,4DAAK,CAAC;AAElC;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;MAAW,CAAC;AAExC;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;IACxB;;;;;;OAMG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;CAEK,CAAC"}
1
+ {"version":3,"file":"non-zero-uint32.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-zero-uint32.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,IAAI,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAIhF,MAAM,MAAM,aAAa,GAAG,yBAAyB,CAAC;AA8BtD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,4DAAK,CAAC;AAElC;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;MAAW,CAAC;AAExC;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;IACxB;;;;;;OAMG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;CAEK,CAAC"}
@@ -6,7 +6,7 @@ const {
6
6
  MIN_VALUE,
7
7
  add,
8
8
  castType,
9
- clamp,
9
+ fromNumber,
10
10
  is,
11
11
  max: max_,
12
12
  min: min_,
@@ -32,11 +32,13 @@ const NonZeroUint32 = {
32
32
  */
33
33
  is,
34
34
  /**
35
- * The smallest value representable as `NonZeroUint32`.
35
+ * The smallest value representable as `NonZeroUint32` (the lower saturation
36
+ * target of `fromNumber`).
36
37
  */
37
38
  MIN_VALUE,
38
39
  /**
39
- * The largest value representable as `NonZeroUint32`.
40
+ * The largest value representable as `NonZeroUint32` (the upper saturation
41
+ * target of `fromNumber`).
40
42
  */
41
43
  MAX_VALUE,
42
44
  /**
@@ -54,13 +56,17 @@ const NonZeroUint32 = {
54
56
  */
55
57
  max: max_,
56
58
  /**
57
- * Clamps a `number` into the `NonZeroUint32` range, rounding to the nearest
58
- * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
59
+ * Converts an arbitrary `number` into a `NonZeroUint32`, rounding to the
60
+ * nearest integer and saturating the result into the range `[MIN_VALUE,
61
+ * MAX_VALUE]`.
59
62
  *
60
- * @param value - The value to clamp
61
- * @returns The clamped value as a `NonZeroUint32`
63
+ * Unlike `asNonZeroUint32`, this is total: out-of-range inputs are clamped to
64
+ * the nearest representable `NonZeroUint32` instead of throwing.
65
+ *
66
+ * @param value - The value to convert
67
+ * @returns The value as a `NonZeroUint32`
62
68
  */
63
- clamp,
69
+ fromNumber,
64
70
  /**
65
71
  * Generates a random `NonZeroUint32` within the given range.
66
72
  *
@@ -1 +1 @@
1
- {"version":3,"file":"non-zero-uint32.mjs","sources":["../../../src/number/branded-types/non-zero-uint32.mts"],"sourcesContent":["import { type NonZeroUint32 as TtfImported_NonZeroUint32 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonZeroUint32 = TtfImported_NonZeroUint32;\n\ntype ElementType = NonZeroUint32;\n\nconst typeNameInMessage = 'a non-zero integer in [1, 2^32)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n clamp,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n randomNonZero: random,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n 1,\n number\n>({\n integerOrSafeInteger: 'SafeInteger',\n nonZero: true,\n MIN_VALUE: 1,\n MAX_VALUE: 2 ** 32 - 1,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a non-zero integer in [1, 2^32).\n *\n * Returns `true` for a non-zero integer in [1, 2^32) — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [1, 2^32), `false` otherwise\n */\nexport const isNonZeroUint32 = is;\n\n/**\n * Casts a `number` to the `NonZeroUint32` branded type.\n *\n * Validates that the value is a non-zero integer in [1, 2^32) and returns it\n * with the `NonZeroUint32` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonZeroUint32`\n * @throws {TypeError} If the value is not a non-zero integer in [1, 2^32)\n */\nexport const asNonZeroUint32 = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonZeroUint32` branded\n * type.\n *\n * The `NonZeroUint32` type represents a non-zero integer in [1, 2^32). Division\n * (`div`) uses floor division.\n */\nexport const NonZeroUint32 = {\n /**\n * Type guard that checks if a value is a non-zero integer in [1, 2^32).\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [1, 2^32), `false` otherwise\n * @see {@link isNonZeroUint32} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `NonZeroUint32`.\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `NonZeroUint32`.\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The smallest value as a `NonZeroUint32`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The largest value as a `NonZeroUint32`\n */\n max: max_,\n\n /**\n * Clamps a `number` into the `NonZeroUint32` 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 `NonZeroUint32`\n */\n clamp,\n\n /**\n * Generates a random `NonZeroUint32` 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 `NonZeroUint32` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroUint32`\n * (floored to an integer).\n *\n * @param a - The base non-zero integer\n * @param b - The exponent non-zero integer\n * @returns `a ** b` as a `NonZeroUint32`\n */\n pow,\n\n /**\n * Adds two non-zero integers, returning `a + b` as a `NonZeroUint32`.\n *\n * @param a - The first non-zero integer\n * @param b - The second non-zero integer\n * @returns The sum of `a` and `b` as a `NonZeroUint32`\n */\n add,\n\n /**\n * Multiplies two non-zero integers, returning `a * b` as a `NonZeroUint32`.\n *\n * @param a - The first non-zero integer\n * @param b - The second non-zero integer\n * @returns The product of `a` and `b` as a `NonZeroUint32`\n */\n mul,\n} as const;\n\nexpectType<\n keyof typeof NonZeroUint32,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range',\n 'add' | 'mul'\n >\n>('=');\n\nexpectType<\n typeof NonZeroUint32,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range',\n 'add' | 'mul'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,iCAAA;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,GAAA;AAAA,EACA,aAAA,EAAe;AACjB,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA,EACT,SAAA,EAAW,CAAA;AAAA,EACX,SAAA,EAAW,KAAK,EAAA,GAAK,CAAA;AAAA,EACrB;AACF,CAAU,CAAA;AAWH,MAAM,eAAA,GAAkB;AAYxB,MAAM,eAAA,GAAkB;AASxB,MAAM,aAAA,GAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ3B,EAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;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;;;;"}
1
+ {"version":3,"file":"non-zero-uint32.mjs","sources":["../../../src/number/branded-types/non-zero-uint32.mts"],"sourcesContent":["import { type NonZeroUint32 as TtfImported_NonZeroUint32 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonZeroUint32 = TtfImported_NonZeroUint32;\n\ntype ElementType = NonZeroUint32;\n\nconst typeNameInMessage = 'a non-zero integer in [1, 2^32)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n fromNumber,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n randomNonZero: random,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n 1,\n number\n>({\n integerOrSafeInteger: 'SafeInteger',\n nonZero: true,\n MIN_VALUE: 1,\n MAX_VALUE: 2 ** 32 - 1,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a non-zero integer in [1, 2^32).\n *\n * Returns `true` for a non-zero integer in [1, 2^32) — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [1, 2^32), `false` otherwise\n */\nexport const isNonZeroUint32 = is;\n\n/**\n * Casts a `number` to the `NonZeroUint32` branded type.\n *\n * Validates that the value is a non-zero integer in [1, 2^32) and returns it\n * with the `NonZeroUint32` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonZeroUint32`\n * @throws {TypeError} If the value is not a non-zero integer in [1, 2^32)\n */\nexport const asNonZeroUint32 = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonZeroUint32` branded\n * type.\n *\n * The `NonZeroUint32` type represents a non-zero integer in [1, 2^32). Division\n * (`div`) uses floor division.\n */\nexport const NonZeroUint32 = {\n /**\n * Type guard that checks if a value is a non-zero integer in [1, 2^32).\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-zero integer in [1, 2^32), `false` otherwise\n * @see {@link isNonZeroUint32} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `NonZeroUint32` (the lower saturation\n * target of `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `NonZeroUint32` (the upper saturation\n * target of `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The smallest value as a `NonZeroUint32`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-zero integers.\n *\n * @param values - The non-zero integers to compare (at least one required)\n * @returns The largest value as a `NonZeroUint32`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `NonZeroUint32`, rounding to the\n * nearest integer and saturating the result into the range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * Unlike `asNonZeroUint32`, this is total: out-of-range inputs are clamped to\n * the nearest representable `NonZeroUint32` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as a `NonZeroUint32`\n */\n fromNumber,\n\n /**\n * Generates a random `NonZeroUint32` 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 `NonZeroUint32` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroUint32`\n * (floored to an integer).\n *\n * @param a - The base non-zero integer\n * @param b - The exponent non-zero integer\n * @returns `a ** b` as a `NonZeroUint32`\n */\n pow,\n\n /**\n * Adds two non-zero integers, returning `a + b` as a `NonZeroUint32`.\n *\n * @param a - The first non-zero integer\n * @param b - The second non-zero integer\n * @returns The sum of `a` and `b` as a `NonZeroUint32`\n */\n add,\n\n /**\n * Multiplies two non-zero integers, returning `a * b` as a `NonZeroUint32`.\n *\n * @param a - The first non-zero integer\n * @param b - The second non-zero integer\n * @returns The product of `a` and `b` as a `NonZeroUint32`\n */\n mul,\n} as const;\n\nexpectType<\n keyof typeof NonZeroUint32,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range',\n 'add' | 'mul'\n >\n>('=');\n\nexpectType<\n typeof NonZeroUint32,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range',\n 'add' | 'mul'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,iCAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,aAAA,EAAe;AACjB,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,OAAA,EAAS,IAAA;AAAA,EACT,SAAA,EAAW,CAAA;AAAA,EACX,SAAA,EAAW,KAAK,EAAA,GAAK,CAAA;AAAA,EACrB;AACF,CAAU,CAAA;AAWH,MAAM,eAAA,GAAkB;AAYxB,MAAM,eAAA,GAAkB;AASxB,MAAM,aAAA,GAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ3B,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;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;AAAA;AAAA;AAAA;AAAA,EAaL,UAAA;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;;;;"}
@@ -51,7 +51,10 @@ export declare const PositiveFiniteNumber: {
51
51
  */
52
52
  readonly is: (a: number) => a is TtfImported_PositiveFiniteNumber;
53
53
  /**
54
- * The smallest value representable as `PositiveFiniteNumber`.
54
+ * The smallest value representable as `PositiveFiniteNumber` (the lower
55
+ * saturation target of `fromNumber`). The domain is open at `0` (excluded),
56
+ * so this is `Number.MIN_VALUE` — the smallest positive double — rather than
57
+ * `0`.
55
58
  */
56
59
  readonly MIN_VALUE: number;
57
60
  /**
@@ -69,13 +72,17 @@ export declare const PositiveFiniteNumber: {
69
72
  */
70
73
  readonly max: (...values: readonly TtfImported_PositiveFiniteNumber[]) => TtfImported_PositiveFiniteNumber;
71
74
  /**
72
- * Clamps a `number` into the `PositiveFiniteNumber` range `[MIN_VALUE,
73
- * MAX_VALUE]`.
75
+ * Converts an arbitrary `number` into a `PositiveFiniteNumber`, saturating it
76
+ * into the range `[MIN_VALUE, MAX_VALUE]`.
74
77
  *
75
- * @param value - The value to clamp
76
- * @returns The clamped value as a `PositiveFiniteNumber`
78
+ * Unlike `asPositiveFiniteNumber`, this is total: out-of-range inputs are
79
+ * clamped to the nearest representable `PositiveFiniteNumber` instead of
80
+ * throwing.
81
+ *
82
+ * @param value - The value to convert
83
+ * @returns The value as a `PositiveFiniteNumber`
77
84
  */
78
- readonly clamp: (x: number) => TtfImported_PositiveFiniteNumber;
85
+ readonly fromNumber: (x: number) => TtfImported_PositiveFiniteNumber;
79
86
  /**
80
87
  * Returns the greatest integer less than or equal to a positive finite
81
88
  * number.