ts-data-forge 11.0.0 → 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 (185) hide show
  1. package/README.md +2 -2
  2. package/dist/number/branded-types/finite-number.d.mts +47 -61
  3. package/dist/number/branded-types/finite-number.d.mts.map +1 -1
  4. package/dist/number/branded-types/finite-number.mjs +37 -41
  5. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  6. package/dist/number/branded-types/int.d.mts +40 -46
  7. package/dist/number/branded-types/int.d.mts.map +1 -1
  8. package/dist/number/branded-types/int.mjs +29 -31
  9. package/dist/number/branded-types/int.mjs.map +1 -1
  10. package/dist/number/branded-types/int16.d.mts +71 -59
  11. package/dist/number/branded-types/int16.d.mts.map +1 -1
  12. package/dist/number/branded-types/int16.mjs +56 -47
  13. package/dist/number/branded-types/int16.mjs.map +1 -1
  14. package/dist/number/branded-types/int32.d.mts +71 -59
  15. package/dist/number/branded-types/int32.d.mts.map +1 -1
  16. package/dist/number/branded-types/int32.mjs +56 -47
  17. package/dist/number/branded-types/int32.mjs.map +1 -1
  18. package/dist/number/branded-types/negative-finite-number.d.mts +76 -60
  19. package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
  20. package/dist/number/branded-types/negative-finite-number.mjs +62 -49
  21. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  22. package/dist/number/branded-types/negative-int.d.mts +66 -49
  23. package/dist/number/branded-types/negative-int.d.mts.map +1 -1
  24. package/dist/number/branded-types/negative-int.mjs +48 -39
  25. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  26. package/dist/number/branded-types/negative-safe-int.d.mts +64 -57
  27. package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
  28. package/dist/number/branded-types/negative-safe-int.mjs +49 -44
  29. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  30. package/dist/number/branded-types/non-negative-finite-number.d.mts +80 -65
  31. package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
  32. package/dist/number/branded-types/non-negative-finite-number.mjs +65 -53
  33. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  34. package/dist/number/branded-types/non-negative-int16.d.mts +71 -58
  35. package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
  36. package/dist/number/branded-types/non-negative-int16.mjs +55 -45
  37. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  38. package/dist/number/branded-types/non-negative-int32.d.mts +71 -59
  39. package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
  40. package/dist/number/branded-types/non-negative-int32.mjs +55 -46
  41. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  42. package/dist/number/branded-types/non-positive-finite-number.d.mts +70 -55
  43. package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
  44. package/dist/number/branded-types/non-positive-finite-number.mjs +55 -43
  45. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  46. package/dist/number/branded-types/non-positive-int.d.mts +46 -146
  47. package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
  48. package/dist/number/branded-types/non-positive-int.mjs +33 -108
  49. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  50. package/dist/number/branded-types/non-positive-safe-int.d.mts +62 -54
  51. package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
  52. package/dist/number/branded-types/non-positive-safe-int.mjs +46 -41
  53. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  54. package/dist/number/branded-types/non-zero-finite-number.d.mts +62 -49
  55. package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
  56. package/dist/number/branded-types/non-zero-finite-number.mjs +46 -37
  57. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  58. package/dist/number/branded-types/non-zero-int.d.mts +51 -38
  59. package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
  60. package/dist/number/branded-types/non-zero-int.mjs +31 -27
  61. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  62. package/dist/number/branded-types/non-zero-int16.d.mts +59 -54
  63. package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
  64. package/dist/number/branded-types/non-zero-int16.mjs +44 -41
  65. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  66. package/dist/number/branded-types/non-zero-int32.d.mts +59 -55
  67. package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
  68. package/dist/number/branded-types/non-zero-int32.mjs +44 -42
  69. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  70. package/dist/number/branded-types/non-zero-safe-int.d.mts +60 -55
  71. package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
  72. package/dist/number/branded-types/non-zero-safe-int.mjs +44 -42
  73. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  74. package/dist/number/branded-types/non-zero-uint16.d.mts +59 -54
  75. package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
  76. package/dist/number/branded-types/non-zero-uint16.mjs +43 -41
  77. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  78. package/dist/number/branded-types/non-zero-uint32.d.mts +59 -54
  79. package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
  80. package/dist/number/branded-types/non-zero-uint32.mjs +43 -41
  81. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  82. package/dist/number/branded-types/positive-finite-number.d.mts +82 -64
  83. package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
  84. package/dist/number/branded-types/positive-finite-number.mjs +67 -52
  85. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  86. package/dist/number/branded-types/positive-int.d.mts +53 -70
  87. package/dist/number/branded-types/positive-int.d.mts.map +1 -1
  88. package/dist/number/branded-types/positive-int.mjs +42 -52
  89. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  90. package/dist/number/branded-types/positive-int16.d.mts +68 -58
  91. package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
  92. package/dist/number/branded-types/positive-int16.mjs +52 -45
  93. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  94. package/dist/number/branded-types/positive-int32.d.mts +68 -58
  95. package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
  96. package/dist/number/branded-types/positive-int32.mjs +52 -45
  97. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  98. package/dist/number/branded-types/positive-safe-int.d.mts +72 -61
  99. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
  100. package/dist/number/branded-types/positive-safe-int.mjs +56 -48
  101. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  102. package/dist/number/branded-types/positive-uint16.d.mts +68 -58
  103. package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
  104. package/dist/number/branded-types/positive-uint16.mjs +52 -45
  105. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  106. package/dist/number/branded-types/positive-uint32.d.mts +68 -59
  107. package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
  108. package/dist/number/branded-types/positive-uint32.mjs +52 -46
  109. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  110. package/dist/number/branded-types/safe-int.d.mts +52 -66
  111. package/dist/number/branded-types/safe-int.d.mts.map +1 -1
  112. package/dist/number/branded-types/safe-int.mjs +45 -47
  113. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  114. package/dist/number/branded-types/safe-uint.d.mts +68 -58
  115. package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
  116. package/dist/number/branded-types/safe-uint.mjs +53 -46
  117. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  118. package/dist/number/branded-types/uint.d.mts +72 -55
  119. package/dist/number/branded-types/uint.d.mts.map +1 -1
  120. package/dist/number/branded-types/uint.mjs +52 -45
  121. package/dist/number/branded-types/uint.mjs.map +1 -1
  122. package/dist/number/branded-types/uint16.d.mts +66 -59
  123. package/dist/number/branded-types/uint16.d.mts.map +1 -1
  124. package/dist/number/branded-types/uint16.mjs +51 -45
  125. package/dist/number/branded-types/uint16.mjs.map +1 -1
  126. package/dist/number/branded-types/uint32.d.mts +66 -57
  127. package/dist/number/branded-types/uint32.d.mts.map +1 -1
  128. package/dist/number/branded-types/uint32.mjs +50 -45
  129. package/dist/number/branded-types/uint32.mjs.map +1 -1
  130. package/dist/number/enum/int8.d.mts +62 -66
  131. package/dist/number/enum/int8.d.mts.map +1 -1
  132. package/dist/number/enum/int8.mjs +57 -51
  133. package/dist/number/enum/int8.mjs.map +1 -1
  134. package/dist/number/enum/uint8.d.mts +66 -59
  135. package/dist/number/enum/uint8.d.mts.map +1 -1
  136. package/dist/number/enum/uint8.mjs +57 -51
  137. package/dist/number/enum/uint8.mjs.map +1 -1
  138. package/dist/number/refined-number-utils.d.mts +9 -9
  139. package/dist/number/refined-number-utils.d.mts.map +1 -1
  140. package/dist/number/refined-number-utils.mjs +7 -7
  141. package/dist/number/refined-number-utils.mjs.map +1 -1
  142. package/package.json +2 -1
  143. package/src/number/branded-types/finite-number.mts +47 -61
  144. package/src/number/branded-types/int.mts +40 -46
  145. package/src/number/branded-types/int16.mts +72 -60
  146. package/src/number/branded-types/int32.mts +72 -60
  147. package/src/number/branded-types/negative-finite-number.mts +78 -71
  148. package/src/number/branded-types/negative-finite-number.test.mts +4 -4
  149. package/src/number/branded-types/negative-int.mts +68 -60
  150. package/src/number/branded-types/negative-int.test.mts +5 -5
  151. package/src/number/branded-types/negative-safe-int.mts +66 -68
  152. package/src/number/branded-types/negative-safe-int.test.mts +4 -4
  153. package/src/number/branded-types/non-negative-finite-number.mts +81 -66
  154. package/src/number/branded-types/non-negative-int16.mts +72 -59
  155. package/src/number/branded-types/non-negative-int32.mts +72 -60
  156. package/src/number/branded-types/non-positive-finite-number.mts +71 -56
  157. package/src/number/branded-types/non-positive-finite-number.test.mts +7 -7
  158. package/src/number/branded-types/non-positive-int.mts +47 -147
  159. package/src/number/branded-types/non-positive-int.test.mts +7 -7
  160. package/src/number/branded-types/non-positive-safe-int.mts +63 -55
  161. package/src/number/branded-types/non-positive-safe-int.test.mts +7 -7
  162. package/src/number/branded-types/non-zero-finite-number.mts +62 -51
  163. package/src/number/branded-types/non-zero-int.mts +51 -38
  164. package/src/number/branded-types/non-zero-int16.mts +60 -55
  165. package/src/number/branded-types/non-zero-int32.mts +60 -56
  166. package/src/number/branded-types/non-zero-safe-int.mts +61 -56
  167. package/src/number/branded-types/non-zero-uint16.mts +60 -55
  168. package/src/number/branded-types/non-zero-uint32.mts +60 -55
  169. package/src/number/branded-types/positive-finite-number.mts +83 -65
  170. package/src/number/branded-types/positive-int.mts +54 -71
  171. package/src/number/branded-types/positive-int16.mts +69 -59
  172. package/src/number/branded-types/positive-int32.mts +69 -59
  173. package/src/number/branded-types/positive-safe-int.mts +73 -62
  174. package/src/number/branded-types/positive-uint16.mts +69 -59
  175. package/src/number/branded-types/positive-uint32.mts +69 -60
  176. package/src/number/branded-types/safe-int.mts +53 -67
  177. package/src/number/branded-types/safe-uint.mts +69 -59
  178. package/src/number/branded-types/uint.mts +73 -56
  179. package/src/number/branded-types/uint16.mts +67 -60
  180. package/src/number/branded-types/uint32.mts +67 -58
  181. package/src/number/enum/int8.mts +70 -73
  182. package/src/number/enum/int8.test.mts +7 -4
  183. package/src/number/enum/uint8.mts +74 -66
  184. package/src/number/enum/uint8.test.mts +7 -4
  185. package/src/number/refined-number-utils.mts +22 -19
@@ -1 +1 @@
1
- {"version":3,"file":"int8.mjs","sources":["../../../src/number/enum/int8.mts"],"sourcesContent":["import {\n type AbsoluteValue,\n type Int16,\n type Int8 as TtfImported_Int8,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type Int8 = TtfImported_Int8;\n\nconst typeNameInMessage = 'an integer in [-128, 127]';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n castType: castTypeImpl,\n clamp: clampImpl,\n is: isImpl,\n random: randomImpl,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n Int16,\n -128,\n 127\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: -128,\n MAX_VALUE: 127,\n typeNameInMessage,\n} as const);\n\nconst is = (x: number): x is Int8 => isImpl(x);\n\nconst castType = (x: number): Int8 =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n castTypeImpl(x) as Int8;\n\nconst clamp = (a: number): Int8 => castType(clampImpl(a));\n\nconst abs = <N extends Int8>(x: N): AbsoluteValue<N> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.abs(x) as unknown as AbsoluteValue<N>;\n\nconst min_ = (...values: readonly Int8[]): Int8 =>\n castType(Math.min(...values));\n\nconst max_ = (...values: readonly Int8[]): Int8 =>\n castType(Math.max(...values));\n\nconst pow = (x: Int8, y: Int8): Int8 => clamp(x ** y);\n\nconst add = (x: Int8, y: Int8): Int8 => clamp(x + y);\n\nconst sub = (x: Int8, y: Int8): Int8 => clamp(x - y);\n\nconst mul = (x: Int8, y: Int8): Int8 => clamp(x * y);\n\nconst div = (x: Int8, y: Exclude<Int8, 0>): Int8 => clamp(Math.floor(x / y));\n\nconst random = (min: Int8, max: Int8): Int8 =>\n castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));\n\n/**\n * Type guard that checks if a value is an 8-bit signed integer.\n *\n * An Int8 is a signed integer in the range [-128, 127], representing values\n * that fit in exactly 8 bits of memory.\n *\n * @param value - The value to check\n * @returns `true` if the value is an Int8, `false` otherwise\n */\nexport const isInt8 = is;\n\n/**\n * Casts a number to an Int8 branded type.\n *\n * This function validates that the input is within the Int8 range [-128, 127]\n * and is an integer, then returns it with the Int8 brand.\n *\n * @param value - The value to cast\n * @returns The value as an Int8 branded type\n * @throws {TypeError} If the value is not a valid 8-bit signed integer\n */\nexport const asInt8 = castType;\n\n/**\n * Namespace providing type-safe operations for Int8 (8-bit signed integer)\n * branded types.\n *\n * Int8 represents signed integers in the range [-128, 127], equivalent to a\n * signed byte in many programming languages. All operations automatically clamp\n * results to stay within this range, preventing overflow/underflow issues.\n *\n * This type is useful for:\n *\n * - Binary data processing (signed bytes)\n * - Small integer values with known bounds\n * - Embedded systems programming\n * - Memory-efficient integer storage\n * - Image processing (signed pixel offsets)\n */\nexport const Int8 = {\n /**\n * Type guard that checks if a value is an 8-bit signed integer.\n *\n * @param value - The value to check\n * @returns `true` if the value is in range [-128, 127] and is an integer\n * @see {@link isInt8} for usage examples\n */\n is,\n\n /**\n * The minimum value for an 8-bit signed integer.\n *\n * @readonly\n */\n MIN_VALUE,\n\n /**\n * The maximum value for an 8-bit signed integer.\n *\n * @readonly\n */\n MAX_VALUE,\n\n /**\n * Returns the minimum value from a list of Int8 values.\n *\n * @param values - The Int8 values to compare (at least one required)\n * @returns The smallest value as an Int8\n */\n min: min_,\n\n /**\n * Returns the maximum value from a list of Int8 values.\n *\n * @param values - The Int8 values to compare (at least one required)\n * @returns The largest value as an Int8\n */\n max: max_,\n\n /**\n * Clamps a number to the Int8 range.\n *\n * @param value The number to clamp.\n * @returns The value clamped to [-128, 127] as an Int8.\n */\n clamp,\n\n /**\n * Returns the absolute value of an Int8.\n *\n * @param value The Int8 value.\n * @returns The absolute value as an Int8, clamped to valid range.\n */\n abs,\n\n /**\n * Generates a random Int8 value within the specified range (inclusive).\n *\n * Both bounds are inclusive. If min > max, they are automatically swapped.\n *\n * @param min - The minimum value (inclusive)\n * @param max - The maximum value (inclusive)\n * @returns A random Int8 in the range [min, max]\n */\n random,\n\n /**\n * Raises x to the power of y, clamped to Int8 range.\n *\n * @param x - The base\n * @param y - The exponent\n * @returns `x ** y` clamped to [-128, 127]\n */\n pow,\n\n /**\n * Adds two Int8 values, clamped to Int8 range.\n *\n * @param x - First operand\n * @param y - Second operand\n * @returns `x + y` clamped to [-128, 127]\n */\n add,\n\n /**\n * Subtracts two Int8 values, clamped to Int8 range.\n *\n * @param x - First operand\n * @param y - Second operand\n * @returns `x - y` clamped to [-128, 127]\n */\n sub,\n\n /**\n * Multiplies two Int8 values, clamped to Int8 range.\n *\n * @param x - First operand\n * @param y - Second operand\n * @returns `x * y` clamped to [-128, 127]\n */\n mul,\n\n /**\n * Divides two Int8 values, clamped to Int8 range.\n *\n * @param x - The dividend\n * @param y - The divisor (cannot be 0)\n * @returns `⌊x / y⌋` clamped to [-128, 127]\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof Int8,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n Int16,\n 'int' | 'range'\n >\n>('=');\n"],"names":[],"mappings":";;AAUA,MAAM,iBAAA,GAAoB,2BAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA,EAAU,YAAA;AAAA,EACV,KAAA,EAAO,SAAA;AAAA,EACP,EAAA,EAAI,MAAA;AAAA,EACJ,MAAA,EAAQ;AACV,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,SAAA,EAAW,IAAA;AAAA,EACX,SAAA,EAAW,GAAA;AAAA,EACX;AACF,CAAU,CAAA;AAEV,MAAM,EAAA,GAAK,CAAC,CAAA,KAAyB,MAAA,CAAO,CAAC,CAAA;AAE7C,MAAM,WAAW,CAAC,CAAA;AAAA;AAAA,EAEhB,aAAa,CAAC;AAAA,CAAA;AAEhB,MAAM,QAAQ,CAAC,CAAA,KAAoB,QAAA,CAAS,SAAA,CAAU,CAAC,CAAC,CAAA;AAExD,MAAM,MAAM,CAAiB,CAAA;AAAA;AAAA,EAE3B,IAAA,CAAK,IAAI,CAAC;AAAA,CAAA;AAEZ,MAAM,IAAA,GAAO,IAAI,MAAA,KACf,QAAA,CAAS,KAAK,GAAA,CAAI,GAAG,MAAM,CAAC,CAAA;AAE9B,MAAM,IAAA,GAAO,IAAI,MAAA,KACf,QAAA,CAAS,KAAK,GAAA,CAAI,GAAG,MAAM,CAAC,CAAA;AAE9B,MAAM,MAAM,CAAC,CAAA,EAAS,CA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AAAA;AAAA;AAAA;AAAA,EASA,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":"int8.mjs","sources":["../../../src/number/enum/int8.mts"],"sourcesContent":["import {\n type AbsoluteValue,\n type Int16,\n type Int8 as TtfImported_Int8,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type Int8 = TtfImported_Int8;\n\nconst typeNameInMessage = 'an integer in [-128, 127]';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n castType: castTypeImpl,\n fromNumber: fromNumberImpl,\n is: isImpl,\n random: randomImpl,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n Int16,\n -128,\n 127\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: -128,\n MAX_VALUE: 127,\n typeNameInMessage,\n} as const);\n\nconst is = (x: number): x is Int8 => isImpl(x);\n\nconst castType = (x: number): Int8 =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n castTypeImpl(x) as Int8;\n\nconst fromNumber = (a: number): Int8 => castType(fromNumberImpl(a));\n\nconst abs = <N extends Int8>(x: N): AbsoluteValue<N> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.abs(x) as unknown as AbsoluteValue<N>;\n\nconst min_ = (...values: readonly Int8[]): Int8 =>\n castType(Math.min(...values));\n\nconst max_ = (...values: readonly Int8[]): Int8 =>\n castType(Math.max(...values));\n\nconst pow = (x: Int8, y: Int8): Int8 => fromNumber(x ** y);\n\nconst add = (x: Int8, y: Int8): Int8 => fromNumber(x + y);\n\nconst sub = (x: Int8, y: Int8): Int8 => fromNumber(x - y);\n\nconst mul = (x: Int8, y: Int8): Int8 => fromNumber(x * y);\n\nconst div = (x: Int8, y: Exclude<Int8, 0>): Int8 =>\n fromNumber(Math.floor(x / y));\n\nconst random = (min: Int8, max: Int8): Int8 =>\n castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));\n\n/**\n * Type guard that checks if a value is an integer in [-128, 127].\n *\n * Returns `true` for an integer in [-128, 127] — a value with no fractional\n * component.\n *\n * @param value - The value to check\n * @returns `true` if the value is an integer in [-128, 127], `false` otherwise\n */\nexport const isInt8 = is;\n\n/**\n * Casts a `number` to the `Int8` branded type.\n *\n * Validates that the value is an integer in [-128, 127] and returns it with the\n * `Int8` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as an `Int8`\n * @throws {TypeError} If the value is not an integer in [-128, 127]\n */\nexport const asInt8 = castType;\n\n/**\n * Namespace providing type-safe operations for the `Int8` branded type.\n *\n * The `Int8` type represents an integer in [-128, 127]. Division (`div`) uses\n * floor division.\n */\nexport const Int8 = {\n /**\n * Type guard that checks if a value is an integer in [-128, 127].\n *\n * @param value - The value to check\n * @returns `true` if the value is an integer in [-128, 127], `false` otherwise\n * @see {@link isInt8} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `Int8` (the lower saturation target of\n * `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `Int8` (the upper saturation target of\n * `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given integers.\n *\n * @param values - The integers to compare (at least one required)\n * @returns The smallest value as an `Int8`\n */\n min: min_,\n\n /**\n * Returns the largest of the given integers.\n *\n * @param values - The integers to compare (at least one required)\n * @returns The largest value as an `Int8`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into an `Int8`, rounding to the nearest\n * integer and saturating the result into the range `[MIN_VALUE, MAX_VALUE]`.\n *\n * Unlike `asInt8`, this is total: out-of-range inputs are clamped to the\n * nearest representable `Int8` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as an `Int8`\n */\n fromNumber,\n\n /**\n * Returns the absolute value of an integer in [-128, 127].\n *\n * The result is non-negative and keeps the `Int8` brand.\n *\n * @param a - The integer value\n * @returns The absolute value as a non-negative `Int8`\n */\n abs,\n\n /**\n * Generates a random `Int8` 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 `Int8` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as an `Int8` (floored to an\n * integer).\n *\n * @param a - The base integer\n * @param b - The exponent integer\n * @returns `a ** b` as an `Int8`\n */\n pow,\n\n /**\n * Adds two integers, returning `a + b` as an `Int8`.\n *\n * @param a - The first integer\n * @param b - The second integer\n * @returns The sum of `a` and `b` as an `Int8`\n */\n add,\n\n /**\n * Subtracts two integers, returning `a - b` as an `Int8`.\n *\n * @param a - The first integer\n * @param b - The second integer\n * @returns The difference of `a` and `b` as an `Int8`\n */\n sub,\n\n /**\n * Multiplies two integers, returning `a * b` as an `Int8`.\n *\n * @param a - The first integer\n * @param b - The second integer\n * @returns The product of `a` and `b` as an `Int8`\n */\n mul,\n\n /**\n * Divides two integers using floor division (`⌊a / b⌋`): the result is `a /\n * b` rounded toward negative infinity, as an `Int8`.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as an `Int8`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof Int8,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n Int16,\n 'int' | 'range'\n >\n>('=');\n"],"names":[],"mappings":";;AAUA,MAAM,iBAAA,GAAoB,2BAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA,EAAU,YAAA;AAAA,EACV,UAAA,EAAY,cAAA;AAAA,EACZ,EAAA,EAAI,MAAA;AAAA,EACJ,MAAA,EAAQ;AACV,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,SAAA,EAAW,IAAA;AAAA,EACX,SAA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;AAAA;AAAA,EAQlB,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,EAYL,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;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,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AACF;;;;"}
@@ -1,119 +1,126 @@
1
1
  import { type Uint8 as TtfImported_Uint8 } from 'ts-type-forge';
2
2
  export type Uint8 = TtfImported_Uint8;
3
3
  /**
4
- * Checks if a number is a Uint8 (8-bit unsigned integer in the range [0, 255]).
4
+ * Type guard that checks if a value is an non-negative integer less than 256.
5
5
  *
6
- * @param value The value to check.
7
- * @returns `true` if the value is a Uint8, `false` otherwise.
6
+ * Returns `true` for an non-negative integer less than 256 — a value with no
7
+ * fractional component.
8
+ *
9
+ * @param value - The value to check
10
+ * @returns `true` if the value is an non-negative integer less than 256, `false` otherwise
8
11
  */
9
12
  export declare const isUint8: (x: number) => x is Uint8;
10
13
  /**
11
- * Casts a number to a Uint8 type. This function validates that the input is
12
- * within the Uint8 range [0, 255] and is an integer, then returns it with the
13
- * Uint8 brand.
14
+ * Casts a `number` to the `Uint8` branded type.
15
+ *
16
+ * Validates that the value is an non-negative integer less than 256 and returns
17
+ * it with the `Uint8` brand. Throws a `TypeError` otherwise.
14
18
  *
15
- * @param value The value to cast.
16
- * @returns The value as a Uint8 type.
17
- * @throws {TypeError} If the value is not a valid 8-bit unsigned integer.
19
+ * @param value - The value to cast
20
+ * @returns The value as an `Uint8`
21
+ * @throws {TypeError} If the value is not an non-negative integer less than 256
18
22
  */
19
23
  export declare const asUint8: (x: number) => Uint8;
20
24
  /**
21
- * Namespace providing type-safe arithmetic operations for 8-bit unsigned
22
- * integers.
25
+ * Namespace providing type-safe operations for the `Uint8` branded type.
23
26
  *
24
- * All operations automatically clamp results to the valid Uint8 range [0, 255].
25
- * This ensures that all arithmetic maintains the 8-bit unsigned integer
26
- * constraint, with negative results clamped to 0 and overflow results clamped
27
- * to MAX_VALUE.
27
+ * The `Uint8` type represents an non-negative integer less than 256. Division
28
+ * (`div`) uses floor division.
28
29
  */
29
30
  export declare const Uint8: {
30
31
  /**
31
- * Type guard that checks if a value is an 8-bit unsigned integer.
32
+ * Type guard that checks if a value is an non-negative integer less than 256.
32
33
  *
33
- * @param value The value to check.
34
- * @returns `true` if the value is an 8-bit unsigned integer, `false`
35
- * otherwise.
34
+ * @param value - The value to check
35
+ * @returns `true` if the value is an non-negative integer less than 256, `false` otherwise
36
+ * @see {@link isUint8} for usage examples
36
37
  */
37
38
  readonly is: (x: number) => x is Uint8;
38
39
  /**
39
- * The minimum value for an 8-bit unsigned integer.
40
- *
41
- * @readonly
40
+ * The smallest value representable as `Uint8` (the lower saturation target of
41
+ * `fromNumber`).
42
42
  */
43
43
  readonly MIN_VALUE: 0;
44
44
  /**
45
- * The maximum value for an 8-bit unsigned integer.
46
- *
47
- * @readonly
45
+ * The largest value representable as `Uint8` (the upper saturation target of
46
+ * `fromNumber`).
48
47
  */
49
48
  readonly MAX_VALUE: 255;
50
49
  /**
51
- * Returns the larger of the given Uint8 values.
50
+ * Returns the largest of the given non-negative integers.
52
51
  *
53
- * @param values The Uint8 values to compare.
54
- * @returns The maximum value as a Uint8.
52
+ * @param values - The non-negative integers to compare (at least one required)
53
+ * @returns The largest value as an `Uint8`
55
54
  */
56
55
  readonly max: (...values: readonly Uint8[]) => Uint8;
57
56
  /**
58
- * Returns the smaller of the given Uint8 values.
57
+ * Returns the smallest of the given non-negative integers.
59
58
  *
60
- * @param values The Uint8 values to compare.
61
- * @returns The minimum value as a Uint8.
59
+ * @param values - The non-negative integers to compare (at least one required)
60
+ * @returns The smallest value as an `Uint8`
62
61
  */
63
62
  readonly min: (...values: readonly Uint8[]) => Uint8;
64
63
  /**
65
- * Clamps a number to the Uint8 range.
64
+ * Converts an arbitrary `number` into an `Uint8`, rounding to the nearest
65
+ * integer and saturating the result into the range `[MIN_VALUE, MAX_VALUE]`.
66
+ *
67
+ * Unlike `asUint8`, this is total: out-of-range inputs are clamped to the
68
+ * nearest representable `Uint8` instead of throwing.
66
69
  *
67
- * @param value The number to clamp.
68
- * @returns The value clamped to [0, 255] as a Uint8.
70
+ * @param value - The value to convert
71
+ * @returns The value as an `Uint8`
69
72
  */
70
- readonly clamp: (a: number) => Uint8;
73
+ readonly fromNumber: (a: number) => Uint8;
71
74
  /**
72
- * Generates a random Uint8 value within the specified range.
75
+ * Generates a random `Uint8` within the given range.
76
+ *
77
+ * The range is inclusive on both ends.
73
78
  *
74
- * @param min The minimum value (inclusive).
75
- * @param max The maximum value (inclusive).
76
- * @returns A random Uint8 between min and max.
79
+ * @param min - The minimum value (inclusive)
80
+ * @param max - The maximum value (inclusive)
81
+ * @returns A random `Uint8` in `[min, max]`
77
82
  */
78
83
  readonly random: (min: Uint8, max: Uint8) => Uint8;
79
84
  /**
80
- * Raises x to the power of y, clamped to Uint8 range.
85
+ * Raises `a` to the power `b`, returning `a ** b` as an `Uint8` (floored to
86
+ * an integer).
81
87
  *
82
- * @param x - The base
83
- * @param y - The exponent
84
- * @returns `x ** y` clamped to [0, 255]
88
+ * @param a - The base non-negative integer
89
+ * @param b - The exponent non-negative integer
90
+ * @returns `a ** b` as an `Uint8`
85
91
  */
86
92
  readonly pow: (x: Uint8, y: Uint8) => Uint8;
87
93
  /**
88
- * Adds two Uint8 values, clamped to Uint8 range.
94
+ * Adds two non-negative integers, returning `a + b` as an `Uint8`.
89
95
  *
90
- * @param x - First operand
91
- * @param y - Second operand
92
- * @returns `x + y` clamped to [0, 255]
96
+ * @param a - The first non-negative integer
97
+ * @param b - The second non-negative integer
98
+ * @returns The sum of `a` and `b` as an `Uint8`
93
99
  */
94
100
  readonly add: (x: Uint8, y: Uint8) => Uint8;
95
101
  /**
96
- * Subtracts two Uint8 values, clamped to Uint8 range.
102
+ * Subtracts two non-negative integers, returning `a - b` as an `Uint8`.
97
103
  *
98
- * @param x - First operand
99
- * @param y - Second operand
100
- * @returns `x - y` clamped to [0, 255]
104
+ * @param a - The first non-negative integer
105
+ * @param b - The second non-negative integer
106
+ * @returns The difference of `a` and `b` as an `Uint8`
101
107
  */
102
108
  readonly sub: (x: Uint8, y: Uint8) => Uint8;
103
109
  /**
104
- * Multiplies two Uint8 values, clamped to Uint8 range.
110
+ * Multiplies two non-negative integers, returning `a * b` as an `Uint8`.
105
111
  *
106
- * @param x - First operand
107
- * @param y - Second operand
108
- * @returns `x * y` clamped to [0, 255]
112
+ * @param a - The first non-negative integer
113
+ * @param b - The second non-negative integer
114
+ * @returns The product of `a` and `b` as an `Uint8`
109
115
  */
110
116
  readonly mul: (x: Uint8, y: Uint8) => Uint8;
111
117
  /**
112
- * Divides two Uint8 values, clamped to Uint8 range.
118
+ * Divides two non-negative integers using floor division (`⌊a / b⌋`): the
119
+ * result is `a / b` rounded toward negative infinity, as an `Uint8`.
113
120
  *
114
- * @param x - The dividend
115
- * @param y - The divisor (cannot be 0)
116
- * @returns `⌊x / y⌋` clamped to [0, 255]
121
+ * @param a - The dividend
122
+ * @param b - The divisor (must be non-zero)
123
+ * @returns The floored quotient as an `Uint8`
117
124
  */
118
125
  readonly div: (x: Uint8, y: Exclude<Uint8, 0>) => Uint8;
119
126
  };
@@ -1 +1 @@
1
- {"version":3,"file":"uint8.d.mts","sourceRoot":"","sources":["../../../src/number/enum/uint8.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,IAAI,iBAAiB,EAAe,MAAM,eAAe,CAAC;AAI7E,MAAM,MAAM,KAAK,GAAG,iBAAiB,CAAC;AA+CtC;;;;;GAKG;AACH,eAAO,MAAM,OAAO,MAjCL,MAAM,KAAG,CAAC,IAAI,KAiCJ,CAAC;AAE1B;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,MA1CC,MAAM,KAAG,KA0CC,CAAC;AAEhC;;;;;;;;GAQG;AACH,eAAO,MAAM,KAAK;IAChB;;;;;;OAMG;qBA9DU,MAAM,KAAG,CAAC,IAAI,KAAK;IAiEhC;;;;OAIG;;IAGH;;;;OAIG;;IAGH;;;;;OAKG;8BAzEoB,SAAS,KAAK,EAAE,KAAG,KAAK;IA4E/C;;;;;OAKG;8BApFoB,SAAS,KAAK,EAAE,KAAG,KAAK;IAuF/C;;;;;OAKG;wBA9Fa,MAAM,KAAG,KAAK;IAiG9B;;;;;;OAMG;2BArFgB,KAAK,OAAO,KAAK,KAAG,KAAK;IAwF5C;;;;;;OAMG;sBAxGW,KAAK,KAAK,KAAK,KAAG,KAAK;IA2GrC;;;;;;OAMG;sBA/GW,KAAK,KAAK,KAAK,KAAG,KAAK;IAkHrC;;;;;;OAMG;sBAtHW,KAAK,KAAK,KAAK,KAAG,KAAK;IAyHrC;;;;;;OAMG;sBA7HW,KAAK,KAAK,KAAK,KAAG,KAAK;IAgIrC;;;;;;OAMG;sBApIW,KAAK,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,KAAG,KAAK;CAsIzC,CAAC"}
1
+ {"version":3,"file":"uint8.d.mts","sourceRoot":"","sources":["../../../src/number/enum/uint8.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,IAAI,iBAAiB,EAAe,MAAM,eAAe,CAAC;AAI7E,MAAM,MAAM,KAAK,GAAG,iBAAiB,CAAC;AAgDtC;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,MArCL,MAAM,KAAG,CAAC,IAAI,KAqCJ,CAAC;AAE1B;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,MA/CC,MAAM,KAAG,KA+CC,CAAC;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,KAAK;IAChB;;;;;;OAMG;qBAhEU,MAAM,KAAG,CAAC,IAAI,KAAK;IAmEhC;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;8BAzEoB,SAAS,KAAK,EAAE,KAAG,KAAK;IA4E/C;;;;;OAKG;8BApFoB,SAAS,KAAK,EAAE,KAAG,KAAK;IAuF/C;;;;;;;;;OASG;6BAlGkB,MAAM,KAAG,KAAK;IAqGnC;;;;;;;;OAQG;2BA1FgB,KAAK,OAAO,KAAK,KAAG,KAAK;IA6F5C;;;;;;;OAOG;sBA/GW,KAAK,KAAK,KAAK,KAAG,KAAK;IAkHrC;;;;;;OAMG;sBAtHW,KAAK,KAAK,KAAK,KAAG,KAAK;IAyHrC;;;;;;OAMG;sBA7HW,KAAK,KAAK,KAAK,KAAG,KAAK;IAgIrC;;;;;;OAMG;sBApIW,KAAK,KAAK,KAAK,KAAG,KAAK;IAuIrC;;;;;;;OAOG;sBA5IW,KAAK,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,KAAG,KAAK;CA8IzC,CAAC"}
@@ -5,7 +5,7 @@ const {
5
5
  MAX_VALUE,
6
6
  MIN_VALUE,
7
7
  castType: castTypeImpl,
8
- clamp: clampImpl,
8
+ fromNumber: fromNumberImpl,
9
9
  is: isImpl,
10
10
  random: randomImpl
11
11
  } = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger(
@@ -21,105 +21,111 @@ const castType = (x) => (
21
21
  // eslint-disable-next-line total-functions/no-unsafe-type-assertion
22
22
  castTypeImpl(x)
23
23
  );
24
- const clamp = (a) => castType(clampImpl(a));
24
+ const fromNumber = (a) => castType(fromNumberImpl(a));
25
25
  const min_ = (...values) => castType(Math.min(...values));
26
26
  const max_ = (...values) => castType(Math.max(...values));
27
- const pow = (x, y) => clamp(x ** y);
28
- const add = (x, y) => clamp(x + y);
29
- const sub = (x, y) => clamp(x - y);
30
- const mul = (x, y) => clamp(x * y);
31
- const div = (x, y) => clamp(Math.floor(x / y));
27
+ const pow = (x, y) => fromNumber(x ** y);
28
+ const add = (x, y) => fromNumber(x + y);
29
+ const sub = (x, y) => fromNumber(x - y);
30
+ const mul = (x, y) => fromNumber(x * y);
31
+ const div = (x, y) => fromNumber(Math.floor(x / y));
32
32
  const random = (min, max) => castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));
33
33
  const isUint8 = is;
34
34
  const asUint8 = castType;
35
35
  const Uint8 = {
36
36
  /**
37
- * Type guard that checks if a value is an 8-bit unsigned integer.
37
+ * Type guard that checks if a value is an non-negative integer less than 256.
38
38
  *
39
- * @param value The value to check.
40
- * @returns `true` if the value is an 8-bit unsigned integer, `false`
41
- * otherwise.
39
+ * @param value - The value to check
40
+ * @returns `true` if the value is an non-negative integer less than 256, `false` otherwise
41
+ * @see {@link isUint8} for usage examples
42
42
  */
43
43
  is,
44
44
  /**
45
- * The minimum value for an 8-bit unsigned integer.
46
- *
47
- * @readonly
45
+ * The smallest value representable as `Uint8` (the lower saturation target of
46
+ * `fromNumber`).
48
47
  */
49
48
  MIN_VALUE,
50
49
  /**
51
- * The maximum value for an 8-bit unsigned integer.
52
- *
53
- * @readonly
50
+ * The largest value representable as `Uint8` (the upper saturation target of
51
+ * `fromNumber`).
54
52
  */
55
53
  MAX_VALUE,
56
54
  /**
57
- * Returns the larger of the given Uint8 values.
55
+ * Returns the largest of the given non-negative integers.
58
56
  *
59
- * @param values The Uint8 values to compare.
60
- * @returns The maximum value as a Uint8.
57
+ * @param values - The non-negative integers to compare (at least one required)
58
+ * @returns The largest value as an `Uint8`
61
59
  */
62
60
  max: max_,
63
61
  /**
64
- * Returns the smaller of the given Uint8 values.
62
+ * Returns the smallest of the given non-negative integers.
65
63
  *
66
- * @param values The Uint8 values to compare.
67
- * @returns The minimum value as a Uint8.
64
+ * @param values - The non-negative integers to compare (at least one required)
65
+ * @returns The smallest value as an `Uint8`
68
66
  */
69
67
  min: min_,
70
68
  /**
71
- * Clamps a number to the Uint8 range.
69
+ * Converts an arbitrary `number` into an `Uint8`, rounding to the nearest
70
+ * integer and saturating the result into the range `[MIN_VALUE, MAX_VALUE]`.
72
71
  *
73
- * @param value The number to clamp.
74
- * @returns The value clamped to [0, 255] as a Uint8.
72
+ * Unlike `asUint8`, this is total: out-of-range inputs are clamped to the
73
+ * nearest representable `Uint8` instead of throwing.
74
+ *
75
+ * @param value - The value to convert
76
+ * @returns The value as an `Uint8`
75
77
  */
76
- clamp,
78
+ fromNumber,
77
79
  /**
78
- * Generates a random Uint8 value within the specified range.
80
+ * Generates a random `Uint8` within the given range.
81
+ *
82
+ * The range is inclusive on both ends.
79
83
  *
80
- * @param min The minimum value (inclusive).
81
- * @param max The maximum value (inclusive).
82
- * @returns A random Uint8 between min and max.
84
+ * @param min - The minimum value (inclusive)
85
+ * @param max - The maximum value (inclusive)
86
+ * @returns A random `Uint8` in `[min, max]`
83
87
  */
84
88
  random,
85
89
  /**
86
- * Raises x to the power of y, clamped to Uint8 range.
90
+ * Raises `a` to the power `b`, returning `a ** b` as an `Uint8` (floored to
91
+ * an integer).
87
92
  *
88
- * @param x - The base
89
- * @param y - The exponent
90
- * @returns `x ** y` clamped to [0, 255]
93
+ * @param a - The base non-negative integer
94
+ * @param b - The exponent non-negative integer
95
+ * @returns `a ** b` as an `Uint8`
91
96
  */
92
97
  pow,
93
98
  /**
94
- * Adds two Uint8 values, clamped to Uint8 range.
99
+ * Adds two non-negative integers, returning `a + b` as an `Uint8`.
95
100
  *
96
- * @param x - First operand
97
- * @param y - Second operand
98
- * @returns `x + y` clamped to [0, 255]
101
+ * @param a - The first non-negative integer
102
+ * @param b - The second non-negative integer
103
+ * @returns The sum of `a` and `b` as an `Uint8`
99
104
  */
100
105
  add,
101
106
  /**
102
- * Subtracts two Uint8 values, clamped to Uint8 range.
107
+ * Subtracts two non-negative integers, returning `a - b` as an `Uint8`.
103
108
  *
104
- * @param x - First operand
105
- * @param y - Second operand
106
- * @returns `x - y` clamped to [0, 255]
109
+ * @param a - The first non-negative integer
110
+ * @param b - The second non-negative integer
111
+ * @returns The difference of `a` and `b` as an `Uint8`
107
112
  */
108
113
  sub,
109
114
  /**
110
- * Multiplies two Uint8 values, clamped to Uint8 range.
115
+ * Multiplies two non-negative integers, returning `a * b` as an `Uint8`.
111
116
  *
112
- * @param x - First operand
113
- * @param y - Second operand
114
- * @returns `x * y` clamped to [0, 255]
117
+ * @param a - The first non-negative integer
118
+ * @param b - The second non-negative integer
119
+ * @returns The product of `a` and `b` as an `Uint8`
115
120
  */
116
121
  mul,
117
122
  /**
118
- * Divides two Uint8 values, clamped to Uint8 range.
123
+ * Divides two non-negative integers using floor division (`⌊a / b⌋`): the
124
+ * result is `a / b` rounded toward negative infinity, as an `Uint8`.
119
125
  *
120
- * @param x - The dividend
121
- * @param y - The divisor (cannot be 0)
122
- * @returns `⌊x / y⌋` clamped to [0, 255]
126
+ * @param a - The dividend
127
+ * @param b - The divisor (must be non-zero)
128
+ * @returns The floored quotient as an `Uint8`
123
129
  */
124
130
  div
125
131
  };
@@ -1 +1 @@
1
- {"version":3,"file":"uint8.mjs","sources":["../../../src/number/enum/uint8.mts"],"sourcesContent":["import { type Uint8 as TtfImported_Uint8, type Uint16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type Uint8 = TtfImported_Uint8;\n\nconst typeNameInMessage = 'an non-negative integer less than 256';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n castType: castTypeImpl,\n clamp: clampImpl,\n is: isImpl,\n random: randomImpl,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<Uint16, 0, 255>(\n {\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 0,\n MAX_VALUE: 255,\n typeNameInMessage,\n } as const,\n);\n\nconst is = (x: number): x is Uint8 => isImpl(x);\n\nconst castType = (x: number): Uint8 =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n castTypeImpl(x) as Uint8;\n\nconst clamp = (a: number): Uint8 => castType(clampImpl(a));\n\nconst min_ = (...values: readonly Uint8[]): Uint8 =>\n castType(Math.min(...values));\n\nconst max_ = (...values: readonly Uint8[]): Uint8 =>\n castType(Math.max(...values));\n\nconst pow = (x: Uint8, y: Uint8): Uint8 => clamp(x ** y);\n\nconst add = (x: Uint8, y: Uint8): Uint8 => clamp(x + y);\n\nconst sub = (x: Uint8, y: Uint8): Uint8 => clamp(x - y);\n\nconst mul = (x: Uint8, y: Uint8): Uint8 => clamp(x * y);\n\nconst div = (x: Uint8, y: Exclude<Uint8, 0>): Uint8 => clamp(Math.floor(x / y));\n\nconst random = (min: Uint8, max: Uint8): Uint8 =>\n castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));\n\n/**\n * Checks if a number is a Uint8 (8-bit unsigned integer in the range [0, 255]).\n *\n * @param value The value to check.\n * @returns `true` if the value is a Uint8, `false` otherwise.\n */\nexport const isUint8 = is;\n\n/**\n * Casts a number to a Uint8 type. This function validates that the input is\n * within the Uint8 range [0, 255] and is an integer, then returns it with the\n * Uint8 brand.\n *\n * @param value The value to cast.\n * @returns The value as a Uint8 type.\n * @throws {TypeError} If the value is not a valid 8-bit unsigned integer.\n */\nexport const asUint8 = castType;\n\n/**\n * Namespace providing type-safe arithmetic operations for 8-bit unsigned\n * integers.\n *\n * All operations automatically clamp results to the valid Uint8 range [0, 255].\n * This ensures that all arithmetic maintains the 8-bit unsigned integer\n * constraint, with negative results clamped to 0 and overflow results clamped\n * to MAX_VALUE.\n */\nexport const Uint8 = {\n /**\n * Type guard that checks if a value is an 8-bit unsigned integer.\n *\n * @param value The value to check.\n * @returns `true` if the value is an 8-bit unsigned integer, `false`\n * otherwise.\n */\n is,\n\n /**\n * The minimum value for an 8-bit unsigned integer.\n *\n * @readonly\n */\n MIN_VALUE,\n\n /**\n * The maximum value for an 8-bit unsigned integer.\n *\n * @readonly\n */\n MAX_VALUE,\n\n /**\n * Returns the larger of the given Uint8 values.\n *\n * @param values The Uint8 values to compare.\n * @returns The maximum value as a Uint8.\n */\n max: max_,\n\n /**\n * Returns the smaller of the given Uint8 values.\n *\n * @param values The Uint8 values to compare.\n * @returns The minimum value as a Uint8.\n */\n min: min_,\n\n /**\n * Clamps a number to the Uint8 range.\n *\n * @param value The number to clamp.\n * @returns The value clamped to [0, 255] as a Uint8.\n */\n clamp,\n\n /**\n * Generates a random Uint8 value within the specified range.\n *\n * @param min The minimum value (inclusive).\n * @param max The maximum value (inclusive).\n * @returns A random Uint8 between min and max.\n */\n random,\n\n /**\n * Raises x to the power of y, clamped to Uint8 range.\n *\n * @param x - The base\n * @param y - The exponent\n * @returns `x ** y` clamped to [0, 255]\n */\n pow,\n\n /**\n * Adds two Uint8 values, clamped to Uint8 range.\n *\n * @param x - First operand\n * @param y - Second operand\n * @returns `x + y` clamped to [0, 255]\n */\n add,\n\n /**\n * Subtracts two Uint8 values, clamped to Uint8 range.\n *\n * @param x - First operand\n * @param y - Second operand\n * @returns `x - y` clamped to [0, 255]\n */\n sub,\n\n /**\n * Multiplies two Uint8 values, clamped to Uint8 range.\n *\n * @param x - First operand\n * @param y - Second operand\n * @returns `x * y` clamped to [0, 255]\n */\n mul,\n\n /**\n * Divides two Uint8 values, clamped to Uint8 range.\n *\n * @param x - The dividend\n * @param y - The divisor (cannot be 0)\n * @returns `⌊x / y⌋` clamped to [0, 255]\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof Uint8,\n keyof TsDataForgeInternals.RefinedNumberUtils.Number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C,MAAM,IAAA,CAAK,KAAA,CAAM,CAAA,GAAI,CAAC,CAAC,CAAA;AAE9E,MAAM,MAAA,GAAS,CAAC,GAAA,EAAY,GAAA,KAC1B,QAAA,CAAS,UAAA,CAAW,YAAA,CAAa,GAAG,CAAA,EAAG,YAAA,CAAa,GAAG,CAAC,CAAC,CAAA;AAQpD,MAAM,OAAA,GAAU;AAWhB,MAAM,OAAA,GAAU;AAWhB,MAAM,KAAA,GAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQnB,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,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":"uint8.mjs","sources":["../../../src/number/enum/uint8.mts"],"sourcesContent":["import { type Uint8 as TtfImported_Uint8, type Uint16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type Uint8 = TtfImported_Uint8;\n\nconst typeNameInMessage = 'an non-negative integer less than 256';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n castType: castTypeImpl,\n fromNumber: fromNumberImpl,\n is: isImpl,\n random: randomImpl,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<Uint16, 0, 255>(\n {\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 0,\n MAX_VALUE: 255,\n typeNameInMessage,\n } as const,\n);\n\nconst is = (x: number): x is Uint8 => isImpl(x);\n\nconst castType = (x: number): Uint8 =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n castTypeImpl(x) as Uint8;\n\nconst fromNumber = (a: number): Uint8 => castType(fromNumberImpl(a));\n\nconst min_ = (...values: readonly Uint8[]): Uint8 =>\n castType(Math.min(...values));\n\nconst max_ = (...values: readonly Uint8[]): Uint8 =>\n castType(Math.max(...values));\n\nconst pow = (x: Uint8, y: Uint8): Uint8 => fromNumber(x ** y);\n\nconst add = (x: Uint8, y: Uint8): Uint8 => fromNumber(x + y);\n\nconst sub = (x: Uint8, y: Uint8): Uint8 => fromNumber(x - y);\n\nconst mul = (x: Uint8, y: Uint8): Uint8 => fromNumber(x * y);\n\nconst div = (x: Uint8, y: Exclude<Uint8, 0>): Uint8 =>\n fromNumber(Math.floor(x / y));\n\nconst random = (min: Uint8, max: Uint8): Uint8 =>\n castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));\n\n/**\n * Type guard that checks if a value is an non-negative integer less than 256.\n *\n * Returns `true` for an non-negative integer less than 256 — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is an non-negative integer less than 256, `false` otherwise\n */\nexport const isUint8 = is;\n\n/**\n * Casts a `number` to the `Uint8` branded type.\n *\n * Validates that the value is an non-negative integer less than 256 and returns\n * it with the `Uint8` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as an `Uint8`\n * @throws {TypeError} If the value is not an non-negative integer less than 256\n */\nexport const asUint8 = castType;\n\n/**\n * Namespace providing type-safe operations for the `Uint8` branded type.\n *\n * The `Uint8` type represents an non-negative integer less than 256. Division\n * (`div`) uses floor division.\n */\nexport const Uint8 = {\n /**\n * Type guard that checks if a value is an non-negative integer less than 256.\n *\n * @param value - The value to check\n * @returns `true` if the value is an non-negative integer less than 256, `false` otherwise\n * @see {@link isUint8} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `Uint8` (the lower saturation target of\n * `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `Uint8` (the upper saturation target of\n * `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the largest of the given non-negative integers.\n *\n * @param values - The non-negative integers to compare (at least one required)\n * @returns The largest value as an `Uint8`\n */\n max: max_,\n\n /**\n * Returns the smallest of the given non-negative integers.\n *\n * @param values - The non-negative integers to compare (at least one required)\n * @returns The smallest value as an `Uint8`\n */\n min: min_,\n\n /**\n * Converts an arbitrary `number` into an `Uint8`, rounding to the nearest\n * integer and saturating the result into the range `[MIN_VALUE, MAX_VALUE]`.\n *\n * Unlike `asUint8`, this is total: out-of-range inputs are clamped to the\n * nearest representable `Uint8` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as an `Uint8`\n */\n fromNumber,\n\n /**\n * Generates a random `Uint8` 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 `Uint8` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as an `Uint8` (floored to\n * an integer).\n *\n * @param a - The base non-negative integer\n * @param b - The exponent non-negative integer\n * @returns `a ** b` as an `Uint8`\n */\n pow,\n\n /**\n * Adds two non-negative integers, returning `a + b` as an `Uint8`.\n *\n * @param a - The first non-negative integer\n * @param b - The second non-negative integer\n * @returns The sum of `a` and `b` as an `Uint8`\n */\n add,\n\n /**\n * Subtracts two non-negative integers, returning `a - b` as an `Uint8`.\n *\n * @param a - The first non-negative integer\n * @param b - The second non-negative integer\n * @returns The difference of `a` and `b` as an `Uint8`\n */\n sub,\n\n /**\n * Multiplies two non-negative integers, returning `a * b` as an `Uint8`.\n *\n * @param a - The first non-negative integer\n * @param b - The second non-negative integer\n * @returns The product of `a` and `b` as an `Uint8`\n */\n mul,\n\n /**\n * Divides two non-negative integers using floor division (`⌊a / b⌋`): the\n * result is `a / b` rounded toward negative infinity, as an `Uint8`.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as an `Uint8`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof Uint8,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n Uint16,\n 'int' | 'non-negative' | 'range'\n >\n>('=');\n"],"names":[],"mappings":";;AAMA,MAAM,iBAAA,GAAoB,uCAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA,EAAU,YAAA;AAAA,EACV,UAAA,EAAY,cAAA;AAAA,EACZ,EAAA,EAAI,MAAA;AAAA,EACJ,MAAA,EAAQ;AACV,CAAA,GAAI,qBAAqB,kBAAA,CAAmB,mBAAA;AAAA,EAC1C;AAAA,IACE,oBAAA,EAAsB,aAAA;AAAA,IACtB,SAAA,EAAW,CAAA;AAAA,IACX,SAAA,EAAW,GAAA;AAAA,IACX;AAAA;AAEJ,CAAA;AAEA,MAAM,EAAA,GAAK,CAAC,CAAA,KAA0B,MAAA,CAAO,CAAC,CAAA;AAE9C,MAAM,WAAW,CAAC,CAAA;AAAA;AAAA,EAEhB,aAAa,CAAC;AAAA,CAAA;AAEhB,MAAM,aAAa,CAAC,CAAA,KAAqB,QAAA,CAAS,cAAA,CAAe,CAAC,CAAC,CAAA;AAEnE,MAAM,IAAA,GAAO,IAAI,MAAA,KACf,QAAA,CAAS,KAAK,GAAA,CAAI,GAAG,MAAM,CAAC,CAAA;AAE9B,MAAM,IAAA,GAAO,IAAI,MAAA,KACf,QAAA,CAAS,KAAK,GAAA,CAAI,GAAG,MAAM,CAAC,CAAA;AAE9B,MAAM,MAAM,CA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AA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AACF;;;;"}
@@ -78,16 +78,16 @@ export declare namespace TsDataForgeInternals {
78
78
  round: (x: N, y: N) => ToInt<N>;
79
79
  }>) & ('non-negative' extends classes ? Readonly<{
80
80
  MIN_VALUE: number;
81
- clamp: (a: number) => N;
81
+ fromNumber: (a: number) => N;
82
82
  }> : unknown) & ('non-negative' extends classes ? unknown : 'positive' extends classes ? unknown : Readonly<{
83
83
  abs: (x: N) => ToNonNegative<N>;
84
84
  }>) & ('positive' extends classes ? Readonly<{
85
85
  MIN_VALUE: number;
86
- clamp: (a: number) => N;
86
+ fromNumber: (a: number) => N;
87
87
  }> : unknown) & ('range' extends classes ? Readonly<{
88
88
  MIN_VALUE: number;
89
89
  MAX_VALUE: number;
90
- clamp: (a: number) => N;
90
+ fromNumber: (a: number) => N;
91
91
  }> : unknown) & Pick<Readonly<{
92
92
  add: (x: N, y: N) => N;
93
93
  sub: (x: N, y: N) => N;
@@ -115,7 +115,7 @@ export declare namespace TsDataForgeInternals {
115
115
  random: (min?: ElementTypeWithSmallInt, max?: ElementTypeWithSmallInt) => ElementType;
116
116
  randomNonZero: (min?: ElementTypeWithSmallInt, max?: ElementTypeWithSmallInt) => ElementType;
117
117
  castType: <N extends number>(x: N) => ElementType & N;
118
- clamp: TypeEq<MAX_VALUE | MIN_VALUE, undefined> extends true ? undefined : (x: number) => ElementType;
118
+ fromNumber: TypeEq<MAX_VALUE | MIN_VALUE, undefined> extends true ? undefined : (x: number) => ElementType;
119
119
  }>;
120
120
  /**
121
121
  * Factory function that creates a complete set of type-safe operations for
@@ -157,7 +157,7 @@ export declare namespace TsDataForgeInternals {
157
157
  *
158
158
  * const quotient = intOps.div(six, intOps.castType(2));
159
159
  *
160
- * const roundedClamp = intOps.clamp(1.5);
160
+ * const coerced = intOps.fromNumber(1.5);
161
161
  *
162
162
  * const randomValue = intOps.random();
163
163
  *
@@ -169,7 +169,7 @@ export declare namespace TsDataForgeInternals {
169
169
  *
170
170
  * assert.isTrue(quotient === 3);
171
171
  *
172
- * assert.isTrue(roundedClamp === 2);
172
+ * assert.isTrue(coerced === 2);
173
173
  *
174
174
  * assert.isTrue(Number.isSafeInteger(randomValue));
175
175
  * ```
@@ -210,7 +210,7 @@ export declare namespace TsDataForgeInternals {
210
210
  random: (min?: ElementType, max?: ElementType) => ElementType;
211
211
  randomNonZero: (min?: ElementType, max?: ElementType) => ElementType;
212
212
  castType: <N extends number>(x: N) => ElementType & N;
213
- clamp: TypeEq<MAX_VALUE | MIN_VALUE, undefined> extends true ? undefined : (x: number) => ElementType;
213
+ fromNumber: TypeEq<MAX_VALUE | MIN_VALUE, undefined> extends true ? undefined : (x: number) => ElementType;
214
214
  }>;
215
215
  /**
216
216
  * Factory function that creates a complete set of type-safe operations for
@@ -248,7 +248,7 @@ export declare namespace TsDataForgeInternals {
248
248
  *
249
249
  * const ratio = floatOps.div(sum, floatOps.castType(10));
250
250
  *
251
- * const clamped = floatOps.clamp(0);
251
+ * const coerced = floatOps.fromNumber(0);
252
252
  *
253
253
  * const boundedRandom = floatOps.random(
254
254
  * floatOps.castType(10),
@@ -261,7 +261,7 @@ export declare namespace TsDataForgeInternals {
261
261
  *
262
262
  * assert.isTrue(ratio === 5);
263
263
  *
264
- * assert.isTrue(clamped >= Number.MIN_VALUE);
264
+ * assert.isTrue(coerced >= Number.MIN_VALUE);
265
265
  *
266
266
  * assert.isTrue(boundedRandom >= 10 && boundedRandom <= 20);
267
267
  *
@@ -1 +1 @@
1
- {"version":3,"file":"refined-number-utils.d.mts","sourceRoot":"","sources":["../../src/number/refined-number-utils.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,i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AAS,kBAAkB,EACtC,SAAS,SAAS,MAAM,EACxB,SAAS,SAAS,MAAM,yDAMvB,QAAQ,CAAC;YACV,OAAO,CAAC,EAAE,OAAO,CAAC;YAClB,SAAS,EAAE,SAAS,CAAC;YACrB,SAAS,EAAE,SAAS,CAAC;YACrB,iBAAiB,EAAE,MAAM,CAAC;SAC3B,CAAC,KAAG,iBAAiB,CAAC,WAAW,EAAE,SAAS,EAAE,SAAS,CAoFvD,CAAC;;KACH;CACF"}
1
+ {"version":3,"file":"refined-number-utils.d.mts","sourceRoot":"","sources":["../../src/number/refined-number-utils.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AAKvB,gBAAgB;AAChB,yBAAiB,oBAAoB,CAAC;IACpC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,UAAiB,kBAAkB,CAAC;QAclC,KAAK,kBAAkB,GAAG,eAAe,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAEhE;;;;;WAKG;QACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,kBAAkB,IAAI,cAAc,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAEzE,KAAK,SAAS,CAAC,CAAC,SAAS,kBAAkB,IAAI,cAAc,CAC3D,CAAC,EACD,aAAa,CACd,CAAC;QAMF,KAAK,wBAAwB,CAAC,CAAC,SAAS,GAAG,IAAI,YAAY,CACzD,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CACxB,CAAC;QAEF;;;;;WAKG;QACH,MAAM,MAAM,aAAa,CAAC,CAAC,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,WAAW,CAAC;YAC9D,aAAa,EAAE,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,WAAW,KAAK,WAAW,CAAC;YAErE,QAAQ,EAAE,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,KAAK,WAAW,GAAG,CAAC,CAAC;YAEtD,UAAU,EAAE,MAAM,CAAC,SAAS,GAAG,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,GAC7D,SAAS,GACT,CAAC,CAAC,EAAE,MAAM,KAAK,WAAW,CAAC;SAChC,CAAC,CAAC;QAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAoEG;QACH,MAAM,CAAC,MAAM,iBAAiB,GAC5B,WAAW,SAAS,kBAAkB,EACtC,SAAS,SAAS,MAAM,EACxB,SAAS,SAAS,MAAM,yDAMvB,QAAQ,CAAC;YACV,OAAO,CAAC,EAAE,OAAO,CAAC;YAClB,SAAS,EAAE,SAAS,CAAC;YACrB,SAAS,EAAE,SAAS,CAAC;YACrB,iBAAiB,EAAE,MAAM,CAAC;SAC3B,CAAC,KAAG,iBAAiB,CAAC,WAAW,EAAE,SAAS,EAAE,SAAS,CAuFvD,CAAC;;KACH;CACF"}
@@ -23,12 +23,12 @@ var TsDataForgeInternals;
23
23
  }) => {
24
24
  const is = (a) => (integerOrSafeInteger === "Integer" ? Number.isInteger(a) : Number.isSafeInteger(a)) && (nonZero === true ? a !== 0 : true) && (isFnOrUndefined(MIN_VALUE, MAX_VALUE)?.(a) ?? true);
25
25
  const castType = castTypeImpl(is, typeNameInMessage);
26
- const clamp = pipe(
26
+ const fromNumber = pipe(
27
27
  clampFnOrUndefined(MIN_VALUE, MAX_VALUE)
28
28
  ).mapNullable(
29
29
  (cl) => (x) => castType(Math.round(cl(x)))
30
30
  ).value;
31
- const clampOrCastFn = clamp ?? castType;
31
+ const clampOrCastFn = fromNumber ?? castType;
32
32
  const abs = (x) => (
33
33
  // eslint-disable-next-line total-functions/no-unsafe-type-assertion
34
34
  Math.abs(clampOrCastFn(x))
@@ -68,9 +68,9 @@ var TsDataForgeInternals;
68
68
  random,
69
69
  randomNonZero,
70
70
  castType,
71
- clamp: (
71
+ fromNumber: (
72
72
  // eslint-disable-next-line total-functions/no-unsafe-type-assertion
73
- clamp
73
+ fromNumber
74
74
  )
75
75
  };
76
76
  };
@@ -82,12 +82,12 @@ var TsDataForgeInternals;
82
82
  }) => {
83
83
  const is = (a) => Number.isFinite(a) && (nonZero === true ? a !== 0 : true) && (isFnOrUndefined(MIN_VALUE, MAX_VALUE)?.(a) ?? true);
84
84
  const castType = castTypeImpl(is, typeNameInMessage);
85
- const clamp = pipe(
85
+ const fromNumber = pipe(
86
86
  clampFnOrUndefined(MIN_VALUE, MAX_VALUE)
87
87
  ).mapNullable(
88
88
  (cl) => (x) => castType(cl(x))
89
89
  ).value;
90
- const clampOrCastFn = clamp ?? castType;
90
+ const clampOrCastFn = fromNumber ?? castType;
91
91
  const abs = (x) => (
92
92
  // eslint-disable-next-line total-functions/no-unsafe-type-assertion
93
93
  Math.abs(x)
@@ -126,7 +126,7 @@ var TsDataForgeInternals;
126
126
  randomNonZero,
127
127
  castType,
128
128
  // eslint-disable-next-line total-functions/no-unsafe-type-assertion
129
- clamp
129
+ fromNumber
130
130
  };
131
131
  };
132
132
  })(TsDataForgeInternals2.RefinedNumberUtils || (TsDataForgeInternals2.RefinedNumberUtils = {}));