ts-data-forge 11.0.1 → 12.0.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 (165) hide show
  1. package/README.md +2 -2
  2. package/dist/number/branded-types/int16.d.mts +12 -7
  3. package/dist/number/branded-types/int16.d.mts.map +1 -1
  4. package/dist/number/branded-types/int16.mjs +13 -8
  5. package/dist/number/branded-types/int16.mjs.map +1 -1
  6. package/dist/number/branded-types/int32.d.mts +12 -7
  7. package/dist/number/branded-types/int32.d.mts.map +1 -1
  8. package/dist/number/branded-types/int32.mjs +13 -8
  9. package/dist/number/branded-types/int32.mjs.map +1 -1
  10. package/dist/number/branded-types/negative-finite-number.d.mts +13 -6
  11. package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
  12. package/dist/number/branded-types/negative-finite-number.mjs +15 -8
  13. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  14. package/dist/number/branded-types/negative-int.d.mts +11 -6
  15. package/dist/number/branded-types/negative-int.d.mts.map +1 -1
  16. package/dist/number/branded-types/negative-int.mjs +13 -8
  17. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  18. package/dist/number/branded-types/negative-safe-int.d.mts +13 -7
  19. package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
  20. package/dist/number/branded-types/negative-safe-int.mjs +15 -9
  21. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  22. package/dist/number/branded-types/non-negative-finite-number.d.mts +11 -6
  23. package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
  24. package/dist/number/branded-types/non-negative-finite-number.mjs +12 -7
  25. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  26. package/dist/number/branded-types/non-negative-int16.d.mts +13 -7
  27. package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
  28. package/dist/number/branded-types/non-negative-int16.mjs +14 -8
  29. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  30. package/dist/number/branded-types/non-negative-int32.d.mts +13 -7
  31. package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
  32. package/dist/number/branded-types/non-negative-int32.mjs +14 -8
  33. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  34. package/dist/number/branded-types/non-positive-finite-number.d.mts +11 -6
  35. package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
  36. package/dist/number/branded-types/non-positive-finite-number.mjs +12 -7
  37. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  38. package/dist/number/branded-types/non-positive-int.d.mts +11 -6
  39. package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
  40. package/dist/number/branded-types/non-positive-int.mjs +12 -7
  41. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  42. package/dist/number/branded-types/non-positive-safe-int.d.mts +14 -7
  43. package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
  44. package/dist/number/branded-types/non-positive-safe-int.mjs +15 -8
  45. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  46. package/dist/number/branded-types/non-zero-int16.d.mts +13 -7
  47. package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
  48. package/dist/number/branded-types/non-zero-int16.mjs +14 -8
  49. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  50. package/dist/number/branded-types/non-zero-int32.d.mts +13 -7
  51. package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
  52. package/dist/number/branded-types/non-zero-int32.mjs +14 -8
  53. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  54. package/dist/number/branded-types/non-zero-safe-int.d.mts +13 -7
  55. package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
  56. package/dist/number/branded-types/non-zero-safe-int.mjs +14 -8
  57. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  58. package/dist/number/branded-types/non-zero-uint16.d.mts +13 -7
  59. package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
  60. package/dist/number/branded-types/non-zero-uint16.mjs +14 -8
  61. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  62. package/dist/number/branded-types/non-zero-uint32.d.mts +13 -7
  63. package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
  64. package/dist/number/branded-types/non-zero-uint32.mjs +14 -8
  65. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  66. package/dist/number/branded-types/positive-finite-number.d.mts +13 -6
  67. package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
  68. package/dist/number/branded-types/positive-finite-number.mjs +14 -7
  69. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  70. package/dist/number/branded-types/positive-int.d.mts +13 -8
  71. package/dist/number/branded-types/positive-int.d.mts.map +1 -1
  72. package/dist/number/branded-types/positive-int.mjs +14 -9
  73. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  74. package/dist/number/branded-types/positive-int16.d.mts +13 -7
  75. package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
  76. package/dist/number/branded-types/positive-int16.mjs +14 -8
  77. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  78. package/dist/number/branded-types/positive-int32.d.mts +13 -7
  79. package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
  80. package/dist/number/branded-types/positive-int32.mjs +14 -8
  81. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  82. package/dist/number/branded-types/positive-safe-int.d.mts +16 -10
  83. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
  84. package/dist/number/branded-types/positive-safe-int.mjs +17 -11
  85. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  86. package/dist/number/branded-types/positive-uint16.d.mts +13 -7
  87. package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
  88. package/dist/number/branded-types/positive-uint16.mjs +14 -8
  89. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  90. package/dist/number/branded-types/positive-uint32.d.mts +13 -7
  91. package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
  92. package/dist/number/branded-types/positive-uint32.mjs +14 -8
  93. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  94. package/dist/number/branded-types/safe-int.d.mts +15 -10
  95. package/dist/number/branded-types/safe-int.d.mts.map +1 -1
  96. package/dist/number/branded-types/safe-int.mjs +16 -11
  97. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  98. package/dist/number/branded-types/safe-uint.d.mts +12 -7
  99. package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
  100. package/dist/number/branded-types/safe-uint.mjs +13 -8
  101. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  102. package/dist/number/branded-types/uint.d.mts +14 -10
  103. package/dist/number/branded-types/uint.d.mts.map +1 -1
  104. package/dist/number/branded-types/uint.mjs +15 -11
  105. package/dist/number/branded-types/uint.mjs.map +1 -1
  106. package/dist/number/branded-types/uint16.d.mts +12 -7
  107. package/dist/number/branded-types/uint16.d.mts.map +1 -1
  108. package/dist/number/branded-types/uint16.mjs +13 -8
  109. package/dist/number/branded-types/uint16.mjs.map +1 -1
  110. package/dist/number/branded-types/uint32.d.mts +12 -7
  111. package/dist/number/branded-types/uint32.d.mts.map +1 -1
  112. package/dist/number/branded-types/uint32.mjs +13 -8
  113. package/dist/number/branded-types/uint32.mjs.map +1 -1
  114. package/dist/number/enum/int8.d.mts +12 -7
  115. package/dist/number/enum/int8.d.mts.map +1 -1
  116. package/dist/number/enum/int8.mjs +19 -14
  117. package/dist/number/enum/int8.mjs.map +1 -1
  118. package/dist/number/enum/uint8.d.mts +12 -7
  119. package/dist/number/enum/uint8.d.mts.map +1 -1
  120. package/dist/number/enum/uint8.mjs +19 -14
  121. package/dist/number/enum/uint8.mjs.map +1 -1
  122. package/dist/number/refined-number-utils.d.mts +9 -9
  123. package/dist/number/refined-number-utils.d.mts.map +1 -1
  124. package/dist/number/refined-number-utils.mjs +7 -7
  125. package/dist/number/refined-number-utils.mjs.map +1 -1
  126. package/package.json +1 -1
  127. package/src/number/branded-types/int16.mts +13 -8
  128. package/src/number/branded-types/int32.mts +13 -8
  129. package/src/number/branded-types/negative-finite-number.mts +15 -8
  130. package/src/number/branded-types/negative-finite-number.test.mts +4 -4
  131. package/src/number/branded-types/negative-int.mts +13 -8
  132. package/src/number/branded-types/negative-int.test.mts +5 -5
  133. package/src/number/branded-types/negative-safe-int.mts +15 -9
  134. package/src/number/branded-types/negative-safe-int.test.mts +4 -4
  135. package/src/number/branded-types/non-negative-finite-number.mts +12 -7
  136. package/src/number/branded-types/non-negative-int16.mts +14 -8
  137. package/src/number/branded-types/non-negative-int32.mts +14 -8
  138. package/src/number/branded-types/non-positive-finite-number.mts +12 -7
  139. package/src/number/branded-types/non-positive-finite-number.test.mts +7 -7
  140. package/src/number/branded-types/non-positive-int.mts +12 -7
  141. package/src/number/branded-types/non-positive-int.test.mts +7 -7
  142. package/src/number/branded-types/non-positive-safe-int.mts +15 -8
  143. package/src/number/branded-types/non-positive-safe-int.test.mts +7 -7
  144. package/src/number/branded-types/non-zero-int16.mts +14 -8
  145. package/src/number/branded-types/non-zero-int32.mts +14 -8
  146. package/src/number/branded-types/non-zero-safe-int.mts +14 -8
  147. package/src/number/branded-types/non-zero-uint16.mts +14 -8
  148. package/src/number/branded-types/non-zero-uint32.mts +14 -8
  149. package/src/number/branded-types/positive-finite-number.mts +14 -7
  150. package/src/number/branded-types/positive-int.mts +14 -9
  151. package/src/number/branded-types/positive-int16.mts +14 -8
  152. package/src/number/branded-types/positive-int32.mts +14 -8
  153. package/src/number/branded-types/positive-safe-int.mts +17 -11
  154. package/src/number/branded-types/positive-uint16.mts +14 -8
  155. package/src/number/branded-types/positive-uint32.mts +14 -8
  156. package/src/number/branded-types/safe-int.mts +16 -11
  157. package/src/number/branded-types/safe-uint.mts +13 -8
  158. package/src/number/branded-types/uint.mts +15 -11
  159. package/src/number/branded-types/uint16.mts +13 -8
  160. package/src/number/branded-types/uint32.mts +13 -8
  161. package/src/number/enum/int8.mts +20 -14
  162. package/src/number/enum/int8.test.mts +7 -4
  163. package/src/number/enum/uint8.mts +20 -14
  164. package/src/number/enum/uint8.test.mts +7 -4
  165. package/src/number/refined-number-utils.mts +22 -19
@@ -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.
@@ -1 +1 @@
1
- {"version":3,"file":"positive-finite-number.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/positive-finite-number.mts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,IAAI,gCAAgC,EAE9D,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,MAAM,oBAAoB,GAAG,gCAAgC,CAAC;AAEpE,KAAK,WAAW,GAAG,oBAAoB,CAAC;AAqExC;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,sDAAK,CAAC;AAEzC;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;MAAW,CAAC;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;IAC/B;;;;;;OAMG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;wBApHA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,qBAAqB,CAC9D,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,CAC3D;IAoHC;;;;;;OAMG;uBAjHA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC;IAmH3D;;;;;;OAMG;wBApHA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,qBAAqB,CAC9D,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,CAC3D;IAoHC;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;;;;;;;;;;;;;CAEK,CAAC"}
1
+ {"version":3,"file":"positive-finite-number.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/positive-finite-number.mts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,IAAI,gCAAgC,EAE9D,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,MAAM,oBAAoB,GAAG,gCAAgC,CAAC;AAEpE,KAAK,WAAW,GAAG,oBAAoB,CAAC;AAqExC;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,sDAAK,CAAC;AAEzC;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;MAAW,CAAC;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;IAC/B;;;;;;OAMG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;OAMG;wBA3HA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,qBAAqB,CAC9D,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,CAC3D;IA2HC;;;;;;OAMG;uBAxHA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC;IA0H3D;;;;;;OAMG;wBA3HA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,qBAAqB,CAC9D,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,CAC3D;IA2HC;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;;;;;;;;;;;;;CAEK,CAAC"}
@@ -5,8 +5,8 @@ const {
5
5
  MIN_VALUE,
6
6
  add,
7
7
  castType,
8
- clamp,
9
8
  div,
9
+ fromNumber,
10
10
  is,
11
11
  max: max_,
12
12
  min: min_,
@@ -47,7 +47,10 @@ const PositiveFiniteNumber = {
47
47
  */
48
48
  is,
49
49
  /**
50
- * The smallest value representable as `PositiveFiniteNumber`.
50
+ * The smallest value representable as `PositiveFiniteNumber` (the lower
51
+ * saturation target of `fromNumber`). The domain is open at `0` (excluded),
52
+ * so this is `Number.MIN_VALUE` — the smallest positive double — rather than
53
+ * `0`.
51
54
  */
52
55
  MIN_VALUE,
53
56
  /**
@@ -65,13 +68,17 @@ const PositiveFiniteNumber = {
65
68
  */
66
69
  max: max_,
67
70
  /**
68
- * Clamps a `number` into the `PositiveFiniteNumber` range `[MIN_VALUE,
69
- * MAX_VALUE]`.
71
+ * Converts an arbitrary `number` into a `PositiveFiniteNumber`, saturating it
72
+ * into the range `[MIN_VALUE, MAX_VALUE]`.
70
73
  *
71
- * @param value - The value to clamp
72
- * @returns The clamped value as a `PositiveFiniteNumber`
74
+ * Unlike `asPositiveFiniteNumber`, this is total: out-of-range inputs are
75
+ * clamped to the nearest representable `PositiveFiniteNumber` instead of
76
+ * throwing.
77
+ *
78
+ * @param value - The value to convert
79
+ * @returns The value as a `PositiveFiniteNumber`
73
80
  */
74
- clamp,
81
+ fromNumber,
75
82
  /**
76
83
  * Returns the greatest integer less than or equal to a positive finite
77
84
  * number.
@@ -1 +1 @@
1
- {"version":3,"file":"positive-finite-number.mjs","sources":["../../../src/number/branded-types/positive-finite-number.mts"],"sourcesContent":["import {\n type PositiveInt,\n type PositiveFiniteNumber as TtfImported_PositiveFiniteNumber,\n type Uint,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type PositiveFiniteNumber = TtfImported_PositiveFiniteNumber;\n\ntype ElementType = PositiveFiniteNumber;\n\nconst typeNameInMessage = 'a positive finite number';\n\nconst {\n MIN_VALUE,\n add,\n castType,\n clamp,\n div,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForFloat<\n ElementType,\n number,\n number\n>({\n MIN_VALUE: Number.MIN_VALUE,\n MAX_VALUE: Number.MAX_VALUE,\n typeNameInMessage,\n} as const);\n\nconst floor = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.floor(\n x,\n ) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\nconst ceil = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.ceil(x) as TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;\n\nconst round = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.round(\n x,\n ) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\nexpectType<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>,\n PositiveInt\n>('=');\n\nexpectType<\n TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >,\n Uint\n>('=');\n\n/**\n * Type guard that checks if a value is a positive finite number.\n *\n * Returns `true` only for a finite value — never `NaN`, `Infinity`, or\n * `-Infinity`.\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive finite number, `false` otherwise\n */\nexport const isPositiveFiniteNumber = is;\n\n/**\n * Casts a `number` to the `PositiveFiniteNumber` branded type.\n *\n * Validates that the value is a positive finite number and returns it with the\n * `PositiveFiniteNumber` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `PositiveFiniteNumber`\n * @throws {TypeError} If the value is not a positive finite number\n */\nexport const asPositiveFiniteNumber = castType;\n\n/**\n * Namespace providing type-safe operations for the `PositiveFiniteNumber`\n * branded type.\n *\n * The `PositiveFiniteNumber` type represents a positive finite number.\n */\nexport const PositiveFiniteNumber = {\n /**\n * Type guard that checks if a value is a positive finite number.\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive finite number, `false` otherwise\n * @see {@link isPositiveFiniteNumber} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `PositiveFiniteNumber`.\n */\n MIN_VALUE,\n\n /**\n * Returns the smallest of the given positive finite numbers.\n *\n * @param values - The positive finite numbers to compare (at least one required)\n * @returns The smallest value as a `PositiveFiniteNumber`\n */\n min: min_,\n\n /**\n * Returns the largest of the given positive finite numbers.\n *\n * @param values - The positive finite numbers to compare (at least one required)\n * @returns The largest value as a `PositiveFiniteNumber`\n */\n max: max_,\n\n /**\n * Clamps a `number` into the `PositiveFiniteNumber` range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * @param value - The value to clamp\n * @returns The clamped value as a `PositiveFiniteNumber`\n */\n clamp,\n\n /**\n * Returns the greatest integer less than or equal to a positive finite\n * number.\n *\n * @param a - The positive finite number value\n * @returns The floored value as an integer\n */\n floor,\n\n /**\n * Returns the smallest integer greater than or equal to a positive finite\n * number.\n *\n * @param a - The positive finite number value\n * @returns The ceiled value as an integer\n */\n ceil,\n\n /**\n * Returns the value of a positive finite number rounded to the nearest\n * integer.\n *\n * @param a - The positive finite number value\n * @returns The rounded value as an integer\n */\n round,\n\n /**\n * Generates a random `PositiveFiniteNumber` 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 `PositiveFiniteNumber` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a\n * `PositiveFiniteNumber`.\n *\n * @param a - The base positive finite number\n * @param b - The exponent positive finite number\n * @returns `a ** b` as a `PositiveFiniteNumber`\n */\n pow,\n\n /**\n * Adds two positive finite numbers, returning `a + b` as a\n * `PositiveFiniteNumber`.\n *\n * @param a - The first positive finite number\n * @param b - The second positive finite number\n * @returns The sum of `a` and `b` as a `PositiveFiniteNumber`\n */\n add,\n\n /**\n * Subtracts two positive finite numbers, returning `a - b` as a\n * `PositiveFiniteNumber`.\n *\n * @param a - The first positive finite number\n * @param b - The second positive finite number\n * @returns The difference of `a` and `b` as a `PositiveFiniteNumber`\n */\n sub,\n\n /**\n * Multiplies two positive finite numbers, returning `a * b` as a\n * `PositiveFiniteNumber`.\n *\n * @param a - The first positive finite number\n * @param b - The second positive finite number\n * @returns The product of `a` and `b` as a `PositiveFiniteNumber`\n */\n mul,\n\n /**\n * Divides two positive finite numbers, returning `a / b` as a\n * `PositiveFiniteNumber`.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns `a / b` as a `PositiveFiniteNumber`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof PositiveFiniteNumber,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'positive'\n >\n>('=');\n\nexpectType<\n typeof PositiveFiniteNumber,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<ElementType, 'positive'>\n>('<=');\n"],"names":[],"mappings":";;AAYA,MAAM,iBAAA,GAAoB,0BAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,GAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,iBAAA,CAI1C;AAAA,EACA,WAAW,MAAA,CAAO,SAAA;AAAA,EAClB,WAAW,MAAA,CAAO,SAAA;AAAA,EAClB;AACF,CAAU,CAAA;AAEV,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAA;AAAA,IACH;AAAA;AACF,CAAA;AAIF,MAAM,OAAO,CACX,CAAA;AAAA;AAAA,EAGA,IAAA,CAAK,KAAK,CAAC;AAAA,CAAA;AAEb,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAA;AAAA,IACH;AAAA;AACF,CAAA;AAyBK,MAAM,sBAAA,GAAyB;AAY/B,MAAM,sBAAA,GAAyB;AAQ/B,MAAM,oBAAA,GAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlC,EAAA;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,EASA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,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,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;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":"positive-finite-number.mjs","sources":["../../../src/number/branded-types/positive-finite-number.mts"],"sourcesContent":["import {\n type PositiveInt,\n type PositiveFiniteNumber as TtfImported_PositiveFiniteNumber,\n type Uint,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type PositiveFiniteNumber = TtfImported_PositiveFiniteNumber;\n\ntype ElementType = PositiveFiniteNumber;\n\nconst typeNameInMessage = 'a positive finite number';\n\nconst {\n MIN_VALUE,\n add,\n castType,\n div,\n fromNumber,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForFloat<\n ElementType,\n number,\n number\n>({\n MIN_VALUE: Number.MIN_VALUE,\n MAX_VALUE: Number.MAX_VALUE,\n typeNameInMessage,\n} as const);\n\nconst floor = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.floor(\n x,\n ) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\nconst ceil = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.ceil(x) as TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;\n\nconst round = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.round(\n x,\n ) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\nexpectType<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>,\n PositiveInt\n>('=');\n\nexpectType<\n TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >,\n Uint\n>('=');\n\n/**\n * Type guard that checks if a value is a positive finite number.\n *\n * Returns `true` only for a finite value — never `NaN`, `Infinity`, or\n * `-Infinity`.\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive finite number, `false` otherwise\n */\nexport const isPositiveFiniteNumber = is;\n\n/**\n * Casts a `number` to the `PositiveFiniteNumber` branded type.\n *\n * Validates that the value is a positive finite number and returns it with the\n * `PositiveFiniteNumber` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `PositiveFiniteNumber`\n * @throws {TypeError} If the value is not a positive finite number\n */\nexport const asPositiveFiniteNumber = castType;\n\n/**\n * Namespace providing type-safe operations for the `PositiveFiniteNumber`\n * branded type.\n *\n * The `PositiveFiniteNumber` type represents a positive finite number.\n */\nexport const PositiveFiniteNumber = {\n /**\n * Type guard that checks if a value is a positive finite number.\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive finite number, `false` otherwise\n * @see {@link isPositiveFiniteNumber} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `PositiveFiniteNumber` (the lower\n * saturation target of `fromNumber`). The domain is open at `0` (excluded),\n * so this is `Number.MIN_VALUE` — the smallest positive double — rather than\n * `0`.\n */\n MIN_VALUE,\n\n /**\n * Returns the smallest of the given positive finite numbers.\n *\n * @param values - The positive finite numbers to compare (at least one required)\n * @returns The smallest value as a `PositiveFiniteNumber`\n */\n min: min_,\n\n /**\n * Returns the largest of the given positive finite numbers.\n *\n * @param values - The positive finite numbers to compare (at least one required)\n * @returns The largest value as a `PositiveFiniteNumber`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `PositiveFiniteNumber`, saturating it\n * into the range `[MIN_VALUE, MAX_VALUE]`.\n *\n * Unlike `asPositiveFiniteNumber`, this is total: out-of-range inputs are\n * clamped to the nearest representable `PositiveFiniteNumber` instead of\n * throwing.\n *\n * @param value - The value to convert\n * @returns The value as a `PositiveFiniteNumber`\n */\n fromNumber,\n\n /**\n * Returns the greatest integer less than or equal to a positive finite\n * number.\n *\n * @param a - The positive finite number value\n * @returns The floored value as an integer\n */\n floor,\n\n /**\n * Returns the smallest integer greater than or equal to a positive finite\n * number.\n *\n * @param a - The positive finite number value\n * @returns The ceiled value as an integer\n */\n ceil,\n\n /**\n * Returns the value of a positive finite number rounded to the nearest\n * integer.\n *\n * @param a - The positive finite number value\n * @returns The rounded value as an integer\n */\n round,\n\n /**\n * Generates a random `PositiveFiniteNumber` 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 `PositiveFiniteNumber` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a\n * `PositiveFiniteNumber`.\n *\n * @param a - The base positive finite number\n * @param b - The exponent positive finite number\n * @returns `a ** b` as a `PositiveFiniteNumber`\n */\n pow,\n\n /**\n * Adds two positive finite numbers, returning `a + b` as a\n * `PositiveFiniteNumber`.\n *\n * @param a - The first positive finite number\n * @param b - The second positive finite number\n * @returns The sum of `a` and `b` as a `PositiveFiniteNumber`\n */\n add,\n\n /**\n * Subtracts two positive finite numbers, returning `a - b` as a\n * `PositiveFiniteNumber`.\n *\n * @param a - The first positive finite number\n * @param b - The second positive finite number\n * @returns The difference of `a` and `b` as a `PositiveFiniteNumber`\n */\n sub,\n\n /**\n * Multiplies two positive finite numbers, returning `a * b` as a\n * `PositiveFiniteNumber`.\n *\n * @param a - The first positive finite number\n * @param b - The second positive finite number\n * @returns The product of `a` and `b` as a `PositiveFiniteNumber`\n */\n mul,\n\n /**\n * Divides two positive finite numbers, returning `a / b` as a\n * `PositiveFiniteNumber`.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns `a / b` as a `PositiveFiniteNumber`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof PositiveFiniteNumber,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'positive'\n >\n>('=');\n\nexpectType<\n typeof PositiveFiniteNumber,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<ElementType, 'positive'>\n>('<=');\n"],"names":[],"mappings":";;AAYA,MAAM,iBAAA,GAAoB,0BAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAA;AAAA,EACA,UAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,iBAAA,CAI1C;AAAA,EACA,WAAW,MAAA,CAAO,SAAA;AAAA,EAClB,WAAW,MAAA,CAAO,SAAA;AAAA,EAClB;AACF,CAAU,CAAA;AAEV,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAA;AAAA,IACH;AAAA;AACF,CAAA;AAIF,MAAM,OAAO,CACX,CAAA;AAAA;AAAA,EAGA,IAAA,CAAK,KAAK,CAAC;AAAA,CAAA;AAEb,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAA;AAAA,IACH;AAAA;AACF,CAAA;AAyBK,MAAM,sBAAA,GAAyB;AAY/B,MAAM,sBAAA,GAAyB;AAQ/B,MAAM,oBAAA,GAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlC,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,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,EASA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,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,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AACF;;;;"}
@@ -84,7 +84,8 @@ export declare const PositiveInt: {
84
84
  */
85
85
  readonly is: (a: number) => a is TtfImported_PositiveInt;
86
86
  /**
87
- * The smallest value representable as `PositiveInt`.
87
+ * The smallest value representable as `PositiveInt` (the lower saturation
88
+ * target of `fromNumber`).
88
89
  */
89
90
  readonly MIN_VALUE: 1;
90
91
  /**
@@ -126,25 +127,29 @@ export declare const PositiveInt: {
126
127
  */
127
128
  readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_PositiveInt>[]) => TtfImported_PositiveInt;
128
129
  /**
129
- * Clamps a `number` into the `PositiveInt` range, rounding to the nearest
130
- * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
130
+ * Converts an arbitrary `number` into a `PositiveInt`, rounding to the
131
+ * nearest integer and saturating the result into the range `[MIN_VALUE,
132
+ * MAX_VALUE]`.
133
+ *
134
+ * Unlike `asPositiveInt`, this is total: out-of-range inputs are clamped to
135
+ * the nearest representable `PositiveInt` instead of throwing.
131
136
  *
132
137
  * @example
133
138
  *
134
139
  * ```ts
135
- * const belowRange = PositiveInt.clamp(0);
140
+ * const belowRange = PositiveInt.fromNumber(0);
136
141
  *
137
- * const withinRange = PositiveInt.clamp(10);
142
+ * const withinRange = PositiveInt.fromNumber(10);
138
143
  *
139
144
  * assert.isTrue(belowRange === 1);
140
145
  *
141
146
  * assert.isTrue(withinRange === 10);
142
147
  * ```
143
148
  *
144
- * @param value - The value to clamp
145
- * @returns The clamped value as a `PositiveInt`
149
+ * @param value - The value to convert
150
+ * @returns The value as a `PositiveInt`
146
151
  */
147
- readonly clamp: (x: number) => TtfImported_PositiveInt;
152
+ readonly fromNumber: (x: number) => TtfImported_PositiveInt;
148
153
  /**
149
154
  * Generates a random `PositiveInt` within the given range.
150
155
  *
@@ -1 +1 @@
1
- {"version":3,"file":"positive-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/positive-int.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,IAAI,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAI5E,MAAM,MAAM,WAAW,GAAG,uBAAuB,CAAC;AA8BlD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,6CAAK,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;MAAW,CAAC;AAEtC;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW;IACtB;;;;;;;;;;;;;;;;OAgBG;;IAGH;;OAEG;;IAGH;;;;;;;;;;;;;;;;;OAiBG;;IAGH;;;;;;;;;;;;;;;;;OAiBG;;IAGH;;;;;;;;;;;;;;;;;;OAkBG;;IAGH;;;;;;;;;;;;;;;;;;;;;;OAsBG;;IAGH;;;;;;;;;;;;;;;;;;;OAmBG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;;;;;;OAmBG;;;;;;;;;;;;;;;CAEK,CAAC"}
1
+ {"version":3,"file":"positive-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/positive-int.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,IAAI,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAI5E,MAAM,MAAM,WAAW,GAAG,uBAAuB,CAAC;AA8BlD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,6CAAK,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;MAAW,CAAC;AAEtC;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW;IACtB;;;;;;;;;;;;;;;;OAgBG;;IAGH;;;OAGG;;IAGH;;;;;;;;;;;;;;;;;OAiBG;;IAGH;;;;;;;;;;;;;;;;;OAiBG;;IAGH;;;;;;;;;;;;;;;;;;;;;;OAsBG;;IAGH;;;;;;;;;;;;;;;;;;;;;;OAsBG;;IAGH;;;;;;;;;;;;;;;;;;;OAmBG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;;;;;;OAmBG;;;;;;;;;;;;;;;CAEK,CAAC"}
@@ -5,8 +5,8 @@ const {
5
5
  MIN_VALUE,
6
6
  add,
7
7
  castType,
8
- clamp,
9
8
  div,
9
+ fromNumber,
10
10
  is,
11
11
  max: max_,
12
12
  min: min_,
@@ -42,7 +42,8 @@ const PositiveInt = {
42
42
  */
43
43
  is,
44
44
  /**
45
- * The smallest value representable as `PositiveInt`.
45
+ * The smallest value representable as `PositiveInt` (the lower saturation
46
+ * target of `fromNumber`).
46
47
  */
47
48
  MIN_VALUE,
48
49
  /**
@@ -84,25 +85,29 @@ const PositiveInt = {
84
85
  */
85
86
  max: max_,
86
87
  /**
87
- * Clamps a `number` into the `PositiveInt` range, rounding to the nearest
88
- * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
88
+ * Converts an arbitrary `number` into a `PositiveInt`, rounding to the
89
+ * nearest integer and saturating the result into the range `[MIN_VALUE,
90
+ * MAX_VALUE]`.
91
+ *
92
+ * Unlike `asPositiveInt`, this is total: out-of-range inputs are clamped to
93
+ * the nearest representable `PositiveInt` instead of throwing.
89
94
  *
90
95
  * @example
91
96
  *
92
97
  * ```ts
93
- * const belowRange = PositiveInt.clamp(0);
98
+ * const belowRange = PositiveInt.fromNumber(0);
94
99
  *
95
- * const withinRange = PositiveInt.clamp(10);
100
+ * const withinRange = PositiveInt.fromNumber(10);
96
101
  *
97
102
  * assert.isTrue(belowRange === 1);
98
103
  *
99
104
  * assert.isTrue(withinRange === 10);
100
105
  * ```
101
106
  *
102
- * @param value - The value to clamp
103
- * @returns The clamped value as a `PositiveInt`
107
+ * @param value - The value to convert
108
+ * @returns The value as a `PositiveInt`
104
109
  */
105
- clamp,
110
+ fromNumber,
106
111
  /**
107
112
  * Generates a random `PositiveInt` within the given range.
108
113
  *
@@ -1 +1 @@
1
- {"version":3,"file":"positive-int.mjs","sources":["../../../src/number/branded-types/positive-int.mts"],"sourcesContent":["import { type PositiveInt as TtfImported_PositiveInt } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type PositiveInt = TtfImported_PositiveInt;\n\ntype ElementType = PositiveInt;\n\nconst typeNameInMessage = 'a positive integer';\n\nconst {\n MIN_VALUE,\n add,\n castType,\n clamp,\n div,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n 1,\n number\n>({\n integerOrSafeInteger: 'Integer',\n MIN_VALUE: 1,\n MAX_VALUE: Number.MAX_VALUE,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a positive integer.\n *\n * Returns `true` for a positive integer — a value with no fractional component,\n * including values outside the safe integer range (unlike `SafeInt`).\n *\n * @example\n *\n * ```ts\n * assert.isTrue(isPositiveInt(5));\n *\n * assert.isFalse(isPositiveInt(0));\n *\n * assert.isTrue(PositiveInt.is(10));\n * ```\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive integer, `false` otherwise\n */\nexport const isPositiveInt = is;\n\n/**\n * Casts a `number` to the `PositiveInt` branded type.\n *\n * Validates that the value is a positive integer and returns it with the\n * `PositiveInt` brand. Throws a `TypeError` otherwise.\n *\n * @example\n *\n * ```ts\n * const branded = asPositiveInt(7);\n *\n * assert.isTrue(branded === 7);\n *\n * assert.isTrue(PositiveInt.is(branded));\n * ```\n *\n * @param value - The value to cast\n * @returns The value as a `PositiveInt`\n * @throws {TypeError} If the value is not a positive integer\n */\nexport const asPositiveInt = castType;\n\n/**\n * Namespace providing type-safe operations for the `PositiveInt` branded type.\n *\n * The `PositiveInt` type represents a positive integer. Division (`div`) uses\n * floor division.\n *\n * Unlike `SafeInt`, `PositiveInt` 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 PositiveInt = {\n /**\n * Type guard that checks if a value is a positive integer.\n *\n * @example\n *\n * ```ts\n * assert.isTrue(isPositiveInt(5));\n *\n * assert.isFalse(isPositiveInt(0));\n *\n * assert.isTrue(PositiveInt.is(10));\n * ```\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive integer, `false` otherwise\n * @see {@link isPositiveInt} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `PositiveInt`.\n */\n MIN_VALUE,\n\n /**\n * Returns the smallest of the given positive integers.\n *\n * @example\n *\n * ```ts\n * const smallest = PositiveInt.min(\n * asPositiveInt(9),\n * asPositiveInt(3),\n * asPositiveInt(12),\n * );\n *\n * assert.isTrue(smallest === 3);\n * ```\n *\n * @param values - The positive integers to compare (at least one required)\n * @returns The smallest value as a `PositiveInt`\n */\n min: min_,\n\n /**\n * Returns the largest of the given positive integers.\n *\n * @example\n *\n * ```ts\n * const largest = PositiveInt.max(\n * asPositiveInt(9),\n * asPositiveInt(3),\n * asPositiveInt(12),\n * );\n *\n * assert.isTrue(largest === 12);\n * ```\n *\n * @param values - The positive integers to compare (at least one required)\n * @returns The largest value as a `PositiveInt`\n */\n max: max_,\n\n /**\n * Clamps a `number` into the `PositiveInt` range, rounding to the nearest\n * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.\n *\n * @example\n *\n * ```ts\n * const belowRange = PositiveInt.clamp(0);\n *\n * const withinRange = PositiveInt.clamp(10);\n *\n * assert.isTrue(belowRange === 1);\n *\n * assert.isTrue(withinRange === 10);\n * ```\n *\n * @param value - The value to clamp\n * @returns The clamped value as a `PositiveInt`\n */\n clamp,\n\n /**\n * Generates a random `PositiveInt` within the given range.\n *\n * The range is inclusive on both ends.\n *\n * @example\n *\n * ```ts\n * const min = asPositiveInt(3);\n *\n * const max = asPositiveInt(6);\n *\n * const randomValue = PositiveInt.random(min, max);\n *\n * assert.isTrue(PositiveInt.is(randomValue));\n *\n * assert.isTrue(randomValue >= 3 && randomValue <= 6);\n * ```\n *\n * @param min - The minimum value (inclusive)\n * @param max - The maximum value (inclusive)\n * @returns A random `PositiveInt` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `PositiveInt` (floored\n * to an integer).\n *\n * @example\n *\n * ```ts\n * const base = asPositiveInt(2);\n *\n * const exponent = asPositiveInt(4);\n *\n * const power = PositiveInt.pow(base, exponent);\n *\n * assert.isTrue(power === 16);\n * ```\n *\n * @param a - The base positive integer\n * @param b - The exponent positive integer\n * @returns `a ** b` as a `PositiveInt`\n */\n pow,\n\n /**\n * Adds two positive integers, returning `a + b` as a `PositiveInt`.\n *\n * @example\n *\n * ```ts\n * const sum = PositiveInt.add(asPositiveInt(4), asPositiveInt(5));\n *\n * assert.isTrue(sum === 9);\n * ```\n *\n * @param a - The first positive integer\n * @param b - The second positive integer\n * @returns The sum of `a` and `b` as a `PositiveInt`\n */\n add,\n\n /**\n * Subtracts two positive integers, returning `a - b` as a `PositiveInt`.\n *\n * @example\n *\n * ```ts\n * const difference = PositiveInt.sub(asPositiveInt(5), asPositiveInt(7));\n *\n * assert.isTrue(difference === 1);\n * ```\n *\n * @param a - The first positive integer\n * @param b - The second positive integer\n * @returns The difference of `a` and `b` as a `PositiveInt`\n */\n sub,\n\n /**\n * Multiplies two positive integers, returning `a * b` as a `PositiveInt`.\n *\n * @example\n *\n * ```ts\n * const product = PositiveInt.mul(asPositiveInt(3), asPositiveInt(7));\n *\n * assert.isTrue(product === 21);\n * ```\n *\n * @param a - The first positive integer\n * @param b - The second positive integer\n * @returns The product of `a` and `b` as a `PositiveInt`\n */\n mul,\n\n /**\n * Divides two positive integers using floor division (`⌊a / b⌋`): the result\n * is `a / b` rounded toward negative infinity, as a `PositiveInt`.\n *\n * @example\n *\n * ```ts\n * const quotient = PositiveInt.div(asPositiveInt(9), asPositiveInt(2));\n *\n * const clamped = PositiveInt.div(asPositiveInt(3), asPositiveInt(10));\n *\n * assert.isTrue(quotient === 4);\n *\n * assert.isTrue(clamped === 1);\n * ```\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as a `PositiveInt`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof PositiveInt,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive'\n >\n>('=');\n\nexpectType<\n typeof PositiveInt,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,oBAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,GAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,SAAA;AAAA,EACtB,SAAA,EAAW,CAAA;AAAA,EACX,WAAW,MAAA,CAAO,SAAA;AAAA,EAClB;AACF,CAAU,CAAA;AAqBH,MAAM,aAAA,GAAgB;AAsBtB,MAAM,aAAA,GAAgB;AAYtB,MAAM,WAAA,GAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBzB,EAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyBA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBA;AACF;;;;"}
1
+ {"version":3,"file":"positive-int.mjs","sources":["../../../src/number/branded-types/positive-int.mts"],"sourcesContent":["import { type PositiveInt as TtfImported_PositiveInt } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type PositiveInt = TtfImported_PositiveInt;\n\ntype ElementType = PositiveInt;\n\nconst typeNameInMessage = 'a positive integer';\n\nconst {\n MIN_VALUE,\n add,\n castType,\n div,\n fromNumber,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n 1,\n number\n>({\n integerOrSafeInteger: 'Integer',\n MIN_VALUE: 1,\n MAX_VALUE: Number.MAX_VALUE,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a positive integer.\n *\n * Returns `true` for a positive integer — a value with no fractional component,\n * including values outside the safe integer range (unlike `SafeInt`).\n *\n * @example\n *\n * ```ts\n * assert.isTrue(isPositiveInt(5));\n *\n * assert.isFalse(isPositiveInt(0));\n *\n * assert.isTrue(PositiveInt.is(10));\n * ```\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive integer, `false` otherwise\n */\nexport const isPositiveInt = is;\n\n/**\n * Casts a `number` to the `PositiveInt` branded type.\n *\n * Validates that the value is a positive integer and returns it with the\n * `PositiveInt` brand. Throws a `TypeError` otherwise.\n *\n * @example\n *\n * ```ts\n * const branded = asPositiveInt(7);\n *\n * assert.isTrue(branded === 7);\n *\n * assert.isTrue(PositiveInt.is(branded));\n * ```\n *\n * @param value - The value to cast\n * @returns The value as a `PositiveInt`\n * @throws {TypeError} If the value is not a positive integer\n */\nexport const asPositiveInt = castType;\n\n/**\n * Namespace providing type-safe operations for the `PositiveInt` branded type.\n *\n * The `PositiveInt` type represents a positive integer. Division (`div`) uses\n * floor division.\n *\n * Unlike `SafeInt`, `PositiveInt` 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 PositiveInt = {\n /**\n * Type guard that checks if a value is a positive integer.\n *\n * @example\n *\n * ```ts\n * assert.isTrue(isPositiveInt(5));\n *\n * assert.isFalse(isPositiveInt(0));\n *\n * assert.isTrue(PositiveInt.is(10));\n * ```\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive integer, `false` otherwise\n * @see {@link isPositiveInt} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `PositiveInt` (the lower saturation\n * target of `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * Returns the smallest of the given positive integers.\n *\n * @example\n *\n * ```ts\n * const smallest = PositiveInt.min(\n * asPositiveInt(9),\n * asPositiveInt(3),\n * asPositiveInt(12),\n * );\n *\n * assert.isTrue(smallest === 3);\n * ```\n *\n * @param values - The positive integers to compare (at least one required)\n * @returns The smallest value as a `PositiveInt`\n */\n min: min_,\n\n /**\n * Returns the largest of the given positive integers.\n *\n * @example\n *\n * ```ts\n * const largest = PositiveInt.max(\n * asPositiveInt(9),\n * asPositiveInt(3),\n * asPositiveInt(12),\n * );\n *\n * assert.isTrue(largest === 12);\n * ```\n *\n * @param values - The positive integers to compare (at least one required)\n * @returns The largest value as a `PositiveInt`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `PositiveInt`, rounding to the\n * nearest integer and saturating the result into the range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * Unlike `asPositiveInt`, this is total: out-of-range inputs are clamped to\n * the nearest representable `PositiveInt` instead of throwing.\n *\n * @example\n *\n * ```ts\n * const belowRange = PositiveInt.fromNumber(0);\n *\n * const withinRange = PositiveInt.fromNumber(10);\n *\n * assert.isTrue(belowRange === 1);\n *\n * assert.isTrue(withinRange === 10);\n * ```\n *\n * @param value - The value to convert\n * @returns The value as a `PositiveInt`\n */\n fromNumber,\n\n /**\n * Generates a random `PositiveInt` within the given range.\n *\n * The range is inclusive on both ends.\n *\n * @example\n *\n * ```ts\n * const min = asPositiveInt(3);\n *\n * const max = asPositiveInt(6);\n *\n * const randomValue = PositiveInt.random(min, max);\n *\n * assert.isTrue(PositiveInt.is(randomValue));\n *\n * assert.isTrue(randomValue >= 3 && randomValue <= 6);\n * ```\n *\n * @param min - The minimum value (inclusive)\n * @param max - The maximum value (inclusive)\n * @returns A random `PositiveInt` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `PositiveInt` (floored\n * to an integer).\n *\n * @example\n *\n * ```ts\n * const base = asPositiveInt(2);\n *\n * const exponent = asPositiveInt(4);\n *\n * const power = PositiveInt.pow(base, exponent);\n *\n * assert.isTrue(power === 16);\n * ```\n *\n * @param a - The base positive integer\n * @param b - The exponent positive integer\n * @returns `a ** b` as a `PositiveInt`\n */\n pow,\n\n /**\n * Adds two positive integers, returning `a + b` as a `PositiveInt`.\n *\n * @example\n *\n * ```ts\n * const sum = PositiveInt.add(asPositiveInt(4), asPositiveInt(5));\n *\n * assert.isTrue(sum === 9);\n * ```\n *\n * @param a - The first positive integer\n * @param b - The second positive integer\n * @returns The sum of `a` and `b` as a `PositiveInt`\n */\n add,\n\n /**\n * Subtracts two positive integers, returning `a - b` as a `PositiveInt`.\n *\n * @example\n *\n * ```ts\n * const difference = PositiveInt.sub(asPositiveInt(5), asPositiveInt(7));\n *\n * assert.isTrue(difference === 1);\n * ```\n *\n * @param a - The first positive integer\n * @param b - The second positive integer\n * @returns The difference of `a` and `b` as a `PositiveInt`\n */\n sub,\n\n /**\n * Multiplies two positive integers, returning `a * b` as a `PositiveInt`.\n *\n * @example\n *\n * ```ts\n * const product = PositiveInt.mul(asPositiveInt(3), asPositiveInt(7));\n *\n * assert.isTrue(product === 21);\n * ```\n *\n * @param a - The first positive integer\n * @param b - The second positive integer\n * @returns The product of `a` and `b` as a `PositiveInt`\n */\n mul,\n\n /**\n * Divides two positive integers using floor division (`⌊a / b⌋`): the result\n * is `a / b` rounded toward negative infinity, as a `PositiveInt`.\n *\n * @example\n *\n * ```ts\n * const quotient = PositiveInt.div(asPositiveInt(9), asPositiveInt(2));\n *\n * const clamped = PositiveInt.div(asPositiveInt(3), asPositiveInt(10));\n *\n * assert.isTrue(quotient === 4);\n *\n * assert.isTrue(clamped === 1);\n * ```\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as a `PositiveInt`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof PositiveInt,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive'\n >\n>('=');\n\nexpectType<\n typeof PositiveInt,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,oBAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAA;AAAA,EACA,UAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,SAAA;AAAA,EACtB,SAAA,EAAW,CAAA;AAAA,EACX,WAAW,MAAA,CAAO,SAAA;AAAA,EAClB;AACF,CAAU,CAAA;AAqBH,MAAM,aAAA,GAAgB;AAsBtB,MAAM,aAAA,GAAgB;AAYtB,MAAM,WAAA,GAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBzB,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyBL,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyBA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBA;AACF;;;;"}
@@ -56,11 +56,13 @@ export declare const PositiveInt16: {
56
56
  */
57
57
  readonly is: (a: number) => a is TtfImported_PositiveInt16;
58
58
  /**
59
- * The smallest value representable as `PositiveInt16`.
59
+ * The smallest value representable as `PositiveInt16` (the lower saturation
60
+ * target of `fromNumber`).
60
61
  */
61
62
  readonly MIN_VALUE: 1;
62
63
  /**
63
- * The largest value representable as `PositiveInt16`.
64
+ * The largest value representable as `PositiveInt16` (the upper saturation
65
+ * target of `fromNumber`).
64
66
  */
65
67
  readonly MAX_VALUE: number;
66
68
  /**
@@ -78,13 +80,17 @@ export declare const PositiveInt16: {
78
80
  */
79
81
  readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_PositiveInt16>[]) => TtfImported_PositiveInt16;
80
82
  /**
81
- * Clamps a `number` into the `PositiveInt16` range, rounding to the nearest
82
- * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
83
+ * Converts an arbitrary `number` into a `PositiveInt16`, rounding to the
84
+ * nearest integer and saturating the result into the range `[MIN_VALUE,
85
+ * MAX_VALUE]`.
83
86
  *
84
- * @param value - The value to clamp
85
- * @returns The clamped value as a `PositiveInt16`
87
+ * Unlike `asPositiveInt16`, this is total: out-of-range inputs are clamped to
88
+ * the nearest representable `PositiveInt16` instead of throwing.
89
+ *
90
+ * @param value - The value to convert
91
+ * @returns The value as a `PositiveInt16`
86
92
  */
87
- readonly clamp: (x: number) => TtfImported_PositiveInt16;
93
+ readonly fromNumber: (x: number) => TtfImported_PositiveInt16;
88
94
  /**
89
95
  * Generates a random `PositiveInt16` within the given range.
90
96
  *
@@ -1 +1 @@
1
- {"version":3,"file":"positive-int16.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/positive-int16.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,IAAI,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAIhF,MAAM,MAAM,aAAa,GAAG,yBAAyB,CAAC;AA+BtD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,+CAAK,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;;IAGH;;;;;;OAMG;;IAGH;;;;;;;OAOG;;;;;;;;;;;;;;;;;;;;CAEK,CAAC"}
1
+ {"version":3,"file":"positive-int16.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/positive-int16.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,IAAI,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAIhF,MAAM,MAAM,aAAa,GAAG,yBAAyB,CAAC;AA+BtD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,+CAAK,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;;IAGH;;;;;;OAMG;;IAGH;;;;;;;OAOG;;;;;;;;;;;;;;;;;;;;CAEK,CAAC"}