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.
- package/README.md +2 -2
- package/dist/number/branded-types/finite-number.d.mts +47 -61
- package/dist/number/branded-types/finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/finite-number.mjs +37 -41
- package/dist/number/branded-types/finite-number.mjs.map +1 -1
- package/dist/number/branded-types/int.d.mts +40 -46
- package/dist/number/branded-types/int.d.mts.map +1 -1
- package/dist/number/branded-types/int.mjs +29 -31
- package/dist/number/branded-types/int.mjs.map +1 -1
- package/dist/number/branded-types/int16.d.mts +71 -59
- package/dist/number/branded-types/int16.d.mts.map +1 -1
- package/dist/number/branded-types/int16.mjs +56 -47
- package/dist/number/branded-types/int16.mjs.map +1 -1
- package/dist/number/branded-types/int32.d.mts +71 -59
- package/dist/number/branded-types/int32.d.mts.map +1 -1
- package/dist/number/branded-types/int32.mjs +56 -47
- package/dist/number/branded-types/int32.mjs.map +1 -1
- package/dist/number/branded-types/negative-finite-number.d.mts +76 -60
- package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/negative-finite-number.mjs +62 -49
- package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/negative-int.d.mts +66 -49
- package/dist/number/branded-types/negative-int.d.mts.map +1 -1
- package/dist/number/branded-types/negative-int.mjs +48 -39
- package/dist/number/branded-types/negative-int.mjs.map +1 -1
- package/dist/number/branded-types/negative-safe-int.d.mts +64 -57
- package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/negative-safe-int.mjs +49 -44
- package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.d.mts +80 -65
- package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.mjs +65 -53
- package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int16.d.mts +71 -58
- package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-int16.mjs +55 -45
- package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int32.d.mts +71 -59
- package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-int32.mjs +55 -46
- package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-finite-number.d.mts +70 -55
- package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-finite-number.mjs +55 -43
- package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-int.d.mts +46 -146
- package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-int.mjs +33 -108
- package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-safe-int.d.mts +62 -54
- package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-safe-int.mjs +46 -41
- package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.d.mts +62 -49
- package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.mjs +46 -37
- package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int.d.mts +51 -38
- package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int.mjs +31 -27
- package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int16.d.mts +59 -54
- package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int16.mjs +44 -41
- package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int32.d.mts +59 -55
- package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int32.mjs +44 -42
- package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.d.mts +60 -55
- package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs +44 -42
- package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.d.mts +59 -54
- package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.mjs +43 -41
- package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.d.mts +59 -54
- package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.mjs +43 -41
- package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
- package/dist/number/branded-types/positive-finite-number.d.mts +82 -64
- package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/positive-finite-number.mjs +67 -52
- package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/positive-int.d.mts +53 -70
- package/dist/number/branded-types/positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int.mjs +42 -52
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-int16.d.mts +68 -58
- package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int16.mjs +52 -45
- package/dist/number/branded-types/positive-int16.mjs.map +1 -1
- package/dist/number/branded-types/positive-int32.d.mts +68 -58
- package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int32.mjs +52 -45
- package/dist/number/branded-types/positive-int32.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.d.mts +72 -61
- package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs +56 -48
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint16.d.mts +68 -58
- package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint16.mjs +52 -45
- package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint32.d.mts +68 -59
- package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint32.mjs +52 -46
- package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.d.mts +52 -66
- package/dist/number/branded-types/safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/safe-int.mjs +45 -47
- package/dist/number/branded-types/safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-uint.d.mts +68 -58
- package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
- package/dist/number/branded-types/safe-uint.mjs +53 -46
- package/dist/number/branded-types/safe-uint.mjs.map +1 -1
- package/dist/number/branded-types/uint.d.mts +72 -55
- package/dist/number/branded-types/uint.d.mts.map +1 -1
- package/dist/number/branded-types/uint.mjs +52 -45
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/branded-types/uint16.d.mts +66 -59
- package/dist/number/branded-types/uint16.d.mts.map +1 -1
- package/dist/number/branded-types/uint16.mjs +51 -45
- package/dist/number/branded-types/uint16.mjs.map +1 -1
- package/dist/number/branded-types/uint32.d.mts +66 -57
- package/dist/number/branded-types/uint32.d.mts.map +1 -1
- package/dist/number/branded-types/uint32.mjs +50 -45
- package/dist/number/branded-types/uint32.mjs.map +1 -1
- package/dist/number/enum/int8.d.mts +62 -66
- package/dist/number/enum/int8.d.mts.map +1 -1
- package/dist/number/enum/int8.mjs +57 -51
- package/dist/number/enum/int8.mjs.map +1 -1
- package/dist/number/enum/uint8.d.mts +66 -59
- package/dist/number/enum/uint8.d.mts.map +1 -1
- package/dist/number/enum/uint8.mjs +57 -51
- package/dist/number/enum/uint8.mjs.map +1 -1
- package/dist/number/refined-number-utils.d.mts +9 -9
- package/dist/number/refined-number-utils.d.mts.map +1 -1
- package/dist/number/refined-number-utils.mjs +7 -7
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/package.json +2 -1
- package/src/number/branded-types/finite-number.mts +47 -61
- package/src/number/branded-types/int.mts +40 -46
- package/src/number/branded-types/int16.mts +72 -60
- package/src/number/branded-types/int32.mts +72 -60
- package/src/number/branded-types/negative-finite-number.mts +78 -71
- package/src/number/branded-types/negative-finite-number.test.mts +4 -4
- package/src/number/branded-types/negative-int.mts +68 -60
- package/src/number/branded-types/negative-int.test.mts +5 -5
- package/src/number/branded-types/negative-safe-int.mts +66 -68
- package/src/number/branded-types/negative-safe-int.test.mts +4 -4
- package/src/number/branded-types/non-negative-finite-number.mts +81 -66
- package/src/number/branded-types/non-negative-int16.mts +72 -59
- package/src/number/branded-types/non-negative-int32.mts +72 -60
- package/src/number/branded-types/non-positive-finite-number.mts +71 -56
- package/src/number/branded-types/non-positive-finite-number.test.mts +7 -7
- package/src/number/branded-types/non-positive-int.mts +47 -147
- package/src/number/branded-types/non-positive-int.test.mts +7 -7
- package/src/number/branded-types/non-positive-safe-int.mts +63 -55
- package/src/number/branded-types/non-positive-safe-int.test.mts +7 -7
- package/src/number/branded-types/non-zero-finite-number.mts +62 -51
- package/src/number/branded-types/non-zero-int.mts +51 -38
- package/src/number/branded-types/non-zero-int16.mts +60 -55
- package/src/number/branded-types/non-zero-int32.mts +60 -56
- package/src/number/branded-types/non-zero-safe-int.mts +61 -56
- package/src/number/branded-types/non-zero-uint16.mts +60 -55
- package/src/number/branded-types/non-zero-uint32.mts +60 -55
- package/src/number/branded-types/positive-finite-number.mts +83 -65
- package/src/number/branded-types/positive-int.mts +54 -71
- package/src/number/branded-types/positive-int16.mts +69 -59
- package/src/number/branded-types/positive-int32.mts +69 -59
- package/src/number/branded-types/positive-safe-int.mts +73 -62
- package/src/number/branded-types/positive-uint16.mts +69 -59
- package/src/number/branded-types/positive-uint32.mts +69 -60
- package/src/number/branded-types/safe-int.mts +53 -67
- package/src/number/branded-types/safe-uint.mts +69 -59
- package/src/number/branded-types/uint.mts +73 -56
- package/src/number/branded-types/uint16.mts +67 -60
- package/src/number/branded-types/uint32.mts +67 -58
- package/src/number/enum/int8.mts +70 -73
- package/src/number/enum/int8.test.mts +7 -4
- package/src/number/enum/uint8.mts +74 -66
- package/src/number/enum/uint8.test.mts +7 -4
- 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
|
|
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,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,aAAa,CAAC,CAAA,KAAoB,QAAA,CAAS,cAAA,CAAe,CAAC,CAAC,CAAA;AAElE,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,CAAA,KAAkB,UAAA,CAAW,KAAK,CAAC,CAAA;AAEzD,MAAM,MAAM,CAAC,CAAA,EAA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A;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
|
-
*
|
|
4
|
+
* Type guard that checks if a value is an non-negative integer less than 256.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
|
12
|
-
*
|
|
13
|
-
*
|
|
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
|
|
17
|
-
* @throws {TypeError} If the value is not
|
|
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
|
|
22
|
-
* integers.
|
|
25
|
+
* Namespace providing type-safe operations for the `Uint8` branded type.
|
|
23
26
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
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
|
|
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
|
|
35
|
-
*
|
|
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
|
|
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
|
|
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
|
|
50
|
+
* Returns the largest of the given non-negative integers.
|
|
52
51
|
*
|
|
53
|
-
* @param values The
|
|
54
|
-
* @returns The
|
|
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
|
|
57
|
+
* Returns the smallest of the given non-negative integers.
|
|
59
58
|
*
|
|
60
|
-
* @param values The
|
|
61
|
-
* @returns The
|
|
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
|
-
*
|
|
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
|
|
68
|
-
* @returns The value
|
|
70
|
+
* @param value - The value to convert
|
|
71
|
+
* @returns The value as an `Uint8`
|
|
69
72
|
*/
|
|
70
|
-
readonly
|
|
73
|
+
readonly fromNumber: (a: number) => Uint8;
|
|
71
74
|
/**
|
|
72
|
-
* Generates a random Uint8
|
|
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
|
|
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
|
|
85
|
+
* Raises `a` to the power `b`, returning `a ** b` as an `Uint8` (floored to
|
|
86
|
+
* an integer).
|
|
81
87
|
*
|
|
82
|
-
* @param
|
|
83
|
-
* @param
|
|
84
|
-
* @returns `
|
|
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
|
|
94
|
+
* Adds two non-negative integers, returning `a + b` as an `Uint8`.
|
|
89
95
|
*
|
|
90
|
-
* @param
|
|
91
|
-
* @param
|
|
92
|
-
* @returns `
|
|
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
|
|
102
|
+
* Subtracts two non-negative integers, returning `a - b` as an `Uint8`.
|
|
97
103
|
*
|
|
98
|
-
* @param
|
|
99
|
-
* @param
|
|
100
|
-
* @returns `
|
|
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
|
|
110
|
+
* Multiplies two non-negative integers, returning `a * b` as an `Uint8`.
|
|
105
111
|
*
|
|
106
|
-
* @param
|
|
107
|
-
* @param
|
|
108
|
-
* @returns `
|
|
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
|
|
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
|
|
115
|
-
* @param
|
|
116
|
-
* @returns
|
|
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;
|
|
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
|
-
|
|
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
|
|
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) =>
|
|
28
|
-
const add = (x, y) =>
|
|
29
|
-
const sub = (x, y) =>
|
|
30
|
-
const mul = (x, y) =>
|
|
31
|
-
const div = (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
|
|
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
|
|
41
|
-
*
|
|
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
|
|
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
|
|
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
|
|
55
|
+
* Returns the largest of the given non-negative integers.
|
|
58
56
|
*
|
|
59
|
-
* @param values The
|
|
60
|
-
* @returns The
|
|
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
|
|
62
|
+
* Returns the smallest of the given non-negative integers.
|
|
65
63
|
*
|
|
66
|
-
* @param values The
|
|
67
|
-
* @returns The
|
|
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
|
-
*
|
|
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
|
-
*
|
|
74
|
-
*
|
|
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
|
-
|
|
78
|
+
fromNumber,
|
|
77
79
|
/**
|
|
78
|
-
* Generates a random Uint8
|
|
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
|
|
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
|
|
90
|
+
* Raises `a` to the power `b`, returning `a ** b` as an `Uint8` (floored to
|
|
91
|
+
* an integer).
|
|
87
92
|
*
|
|
88
|
-
* @param
|
|
89
|
-
* @param
|
|
90
|
-
* @returns `
|
|
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
|
|
99
|
+
* Adds two non-negative integers, returning `a + b` as an `Uint8`.
|
|
95
100
|
*
|
|
96
|
-
* @param
|
|
97
|
-
* @param
|
|
98
|
-
* @returns `
|
|
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
|
|
107
|
+
* Subtracts two non-negative integers, returning `a - b` as an `Uint8`.
|
|
103
108
|
*
|
|
104
|
-
* @param
|
|
105
|
-
* @param
|
|
106
|
-
* @returns `
|
|
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
|
|
115
|
+
* Multiplies two non-negative integers, returning `a * b` as an `Uint8`.
|
|
111
116
|
*
|
|
112
|
-
* @param
|
|
113
|
-
* @param
|
|
114
|
-
* @returns `
|
|
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
|
|
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
|
|
121
|
-
* @param
|
|
122
|
-
* @returns
|
|
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
|
|
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,CAAC,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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
|
-
|
|
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
|
-
|
|
86
|
+
fromNumber: (a: number) => N;
|
|
87
87
|
}> : unknown) & ('range' extends classes ? Readonly<{
|
|
88
88
|
MIN_VALUE: number;
|
|
89
89
|
MAX_VALUE: number;
|
|
90
|
-
|
|
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
|
-
|
|
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
|
|
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(
|
|
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
|
-
|
|
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
|
|
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(
|
|
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,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,SAAS,kBAAkB,IACpD,KAAK,SAAS,mBAAmB,CAAC,CAAC,CAAC,GAChC,cAAc,CAAC,CAAC,EAAE,cAAc,CAAC,GACjC,cAAc,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;QAE3C;;;;;;WAMG;QACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,kBAAkB,IAAI,KAAK,CACrE,iBAAiB,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K,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;SACjC,CAAC,CAAC,GACP,CAAC,cAAc,SAAS,OAAO,GAC3B,QAAQ,CAAC;YACP,SAAS,EAAE,MAAM,CAAC;YAClB,
|
|
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,SAAS,kBAAkB,IACpD,KAAK,SAAS,mBAAmB,CAAC,CAAC,CAAC,GAChC,cAAc,CAAC,CAAC,EAAE,cAAc,CAA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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
|
|
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 =
|
|
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
|
-
|
|
71
|
+
fromNumber: (
|
|
72
72
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
73
|
-
|
|
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
|
|
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 =
|
|
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
|
-
|
|
129
|
+
fromNumber
|
|
130
130
|
};
|
|
131
131
|
};
|
|
132
132
|
})(TsDataForgeInternals2.RefinedNumberUtils || (TsDataForgeInternals2.RefinedNumberUtils = {}));
|