ts-data-forge 11.0.1 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/number/branded-types/int16.d.mts +12 -7
- package/dist/number/branded-types/int16.d.mts.map +1 -1
- package/dist/number/branded-types/int16.mjs +13 -8
- package/dist/number/branded-types/int16.mjs.map +1 -1
- package/dist/number/branded-types/int32.d.mts +12 -7
- package/dist/number/branded-types/int32.d.mts.map +1 -1
- package/dist/number/branded-types/int32.mjs +13 -8
- package/dist/number/branded-types/int32.mjs.map +1 -1
- package/dist/number/branded-types/negative-finite-number.d.mts +13 -6
- package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/negative-finite-number.mjs +15 -8
- package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/negative-int.d.mts +11 -6
- package/dist/number/branded-types/negative-int.d.mts.map +1 -1
- package/dist/number/branded-types/negative-int.mjs +13 -8
- package/dist/number/branded-types/negative-int.mjs.map +1 -1
- package/dist/number/branded-types/negative-safe-int.d.mts +13 -7
- package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/negative-safe-int.mjs +15 -9
- package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.d.mts +11 -6
- package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.mjs +12 -7
- package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int16.d.mts +13 -7
- package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-int16.mjs +14 -8
- package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int32.d.mts +13 -7
- package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-int32.mjs +14 -8
- package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-finite-number.d.mts +11 -6
- package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-finite-number.mjs +12 -7
- package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-int.d.mts +11 -6
- package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-int.mjs +12 -7
- package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-safe-int.d.mts +14 -7
- package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-safe-int.mjs +15 -8
- package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int16.d.mts +13 -7
- package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int16.mjs +14 -8
- package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int32.d.mts +13 -7
- package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int32.mjs +14 -8
- package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.d.mts +13 -7
- package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs +14 -8
- package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.d.mts +13 -7
- package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.mjs +14 -8
- package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.d.mts +13 -7
- package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.mjs +14 -8
- package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
- package/dist/number/branded-types/positive-finite-number.d.mts +13 -6
- package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/positive-finite-number.mjs +14 -7
- package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/positive-int.d.mts +13 -8
- package/dist/number/branded-types/positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int.mjs +14 -9
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-int16.d.mts +13 -7
- package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int16.mjs +14 -8
- package/dist/number/branded-types/positive-int16.mjs.map +1 -1
- package/dist/number/branded-types/positive-int32.d.mts +13 -7
- package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int32.mjs +14 -8
- package/dist/number/branded-types/positive-int32.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.d.mts +16 -10
- package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs +17 -11
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint16.d.mts +13 -7
- package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint16.mjs +14 -8
- package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint32.d.mts +13 -7
- package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint32.mjs +14 -8
- package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.d.mts +15 -10
- package/dist/number/branded-types/safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/safe-int.mjs +16 -11
- package/dist/number/branded-types/safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-uint.d.mts +12 -7
- package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
- package/dist/number/branded-types/safe-uint.mjs +13 -8
- package/dist/number/branded-types/safe-uint.mjs.map +1 -1
- package/dist/number/branded-types/uint.d.mts +14 -10
- package/dist/number/branded-types/uint.d.mts.map +1 -1
- package/dist/number/branded-types/uint.mjs +15 -11
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/branded-types/uint16.d.mts +12 -7
- package/dist/number/branded-types/uint16.d.mts.map +1 -1
- package/dist/number/branded-types/uint16.mjs +13 -8
- package/dist/number/branded-types/uint16.mjs.map +1 -1
- package/dist/number/branded-types/uint32.d.mts +12 -7
- package/dist/number/branded-types/uint32.d.mts.map +1 -1
- package/dist/number/branded-types/uint32.mjs +13 -8
- package/dist/number/branded-types/uint32.mjs.map +1 -1
- package/dist/number/enum/int8.d.mts +12 -7
- package/dist/number/enum/int8.d.mts.map +1 -1
- package/dist/number/enum/int8.mjs +19 -14
- package/dist/number/enum/int8.mjs.map +1 -1
- package/dist/number/enum/uint8.d.mts +12 -7
- package/dist/number/enum/uint8.d.mts.map +1 -1
- package/dist/number/enum/uint8.mjs +19 -14
- 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 +1 -1
- package/src/number/branded-types/int16.mts +13 -8
- package/src/number/branded-types/int32.mts +13 -8
- package/src/number/branded-types/negative-finite-number.mts +15 -8
- package/src/number/branded-types/negative-finite-number.test.mts +4 -4
- package/src/number/branded-types/negative-int.mts +13 -8
- package/src/number/branded-types/negative-int.test.mts +5 -5
- package/src/number/branded-types/negative-safe-int.mts +15 -9
- package/src/number/branded-types/negative-safe-int.test.mts +4 -4
- package/src/number/branded-types/non-negative-finite-number.mts +12 -7
- package/src/number/branded-types/non-negative-int16.mts +14 -8
- package/src/number/branded-types/non-negative-int32.mts +14 -8
- package/src/number/branded-types/non-positive-finite-number.mts +12 -7
- package/src/number/branded-types/non-positive-finite-number.test.mts +7 -7
- package/src/number/branded-types/non-positive-int.mts +12 -7
- package/src/number/branded-types/non-positive-int.test.mts +7 -7
- package/src/number/branded-types/non-positive-safe-int.mts +15 -8
- package/src/number/branded-types/non-positive-safe-int.test.mts +7 -7
- package/src/number/branded-types/non-zero-int16.mts +14 -8
- package/src/number/branded-types/non-zero-int32.mts +14 -8
- package/src/number/branded-types/non-zero-safe-int.mts +14 -8
- package/src/number/branded-types/non-zero-uint16.mts +14 -8
- package/src/number/branded-types/non-zero-uint32.mts +14 -8
- package/src/number/branded-types/positive-finite-number.mts +14 -7
- package/src/number/branded-types/positive-int.mts +14 -9
- package/src/number/branded-types/positive-int16.mts +14 -8
- package/src/number/branded-types/positive-int32.mts +14 -8
- package/src/number/branded-types/positive-safe-int.mts +17 -11
- package/src/number/branded-types/positive-uint16.mts +14 -8
- package/src/number/branded-types/positive-uint32.mts +14 -8
- package/src/number/branded-types/safe-int.mts +16 -11
- package/src/number/branded-types/safe-uint.mts +13 -8
- package/src/number/branded-types/uint.mts +15 -11
- package/src/number/branded-types/uint16.mts +13 -8
- package/src/number/branded-types/uint32.mts +13 -8
- package/src/number/enum/int8.mts +20 -14
- package/src/number/enum/int8.test.mts +7 -4
- package/src/number/enum/uint8.mts +20 -14
- package/src/number/enum/uint8.test.mts +7 -4
- package/src/number/refined-number-utils.mts +22 -19
|
@@ -6,8 +6,8 @@ const {
|
|
|
6
6
|
MIN_VALUE,
|
|
7
7
|
add,
|
|
8
8
|
castType,
|
|
9
|
-
clamp,
|
|
10
9
|
div,
|
|
10
|
+
fromNumber,
|
|
11
11
|
is,
|
|
12
12
|
max: max_,
|
|
13
13
|
min: min_,
|
|
@@ -33,11 +33,13 @@ const PositiveInt16 = {
|
|
|
33
33
|
*/
|
|
34
34
|
is,
|
|
35
35
|
/**
|
|
36
|
-
* The smallest value representable as `PositiveInt16
|
|
36
|
+
* The smallest value representable as `PositiveInt16` (the lower saturation
|
|
37
|
+
* target of `fromNumber`).
|
|
37
38
|
*/
|
|
38
39
|
MIN_VALUE,
|
|
39
40
|
/**
|
|
40
|
-
* The largest value representable as `PositiveInt16
|
|
41
|
+
* The largest value representable as `PositiveInt16` (the upper saturation
|
|
42
|
+
* target of `fromNumber`).
|
|
41
43
|
*/
|
|
42
44
|
MAX_VALUE,
|
|
43
45
|
/**
|
|
@@ -55,13 +57,17 @@ const PositiveInt16 = {
|
|
|
55
57
|
*/
|
|
56
58
|
max: max_,
|
|
57
59
|
/**
|
|
58
|
-
*
|
|
59
|
-
* integer and
|
|
60
|
+
* Converts an arbitrary `number` into a `PositiveInt16`, rounding to the
|
|
61
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
62
|
+
* MAX_VALUE]`.
|
|
60
63
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
64
|
+
* Unlike `asPositiveInt16`, this is total: out-of-range inputs are clamped to
|
|
65
|
+
* the nearest representable `PositiveInt16` instead of throwing.
|
|
66
|
+
*
|
|
67
|
+
* @param value - The value to convert
|
|
68
|
+
* @returns The value as a `PositiveInt16`
|
|
63
69
|
*/
|
|
64
|
-
|
|
70
|
+
fromNumber,
|
|
65
71
|
/**
|
|
66
72
|
* Generates a random `PositiveInt16` within the given range.
|
|
67
73
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positive-int16.mjs","sources":["../../../src/number/branded-types/positive-int16.mts"],"sourcesContent":["import { type PositiveInt16 as TtfImported_PositiveInt16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type PositiveInt16 = TtfImported_PositiveInt16;\n\ntype ElementType = PositiveInt16;\n\nconst typeNameInMessage = 'a positive integer in [1, 2^15)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n
|
|
1
|
+
{"version":3,"file":"positive-int16.mjs","sources":["../../../src/number/branded-types/positive-int16.mts"],"sourcesContent":["import { type PositiveInt16 as TtfImported_PositiveInt16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type PositiveInt16 = TtfImported_PositiveInt16;\n\ntype ElementType = PositiveInt16;\n\nconst typeNameInMessage = 'a positive integer in [1, 2^15)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n div,\n fromNumber,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n 1,\n number\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 1,\n MAX_VALUE: 2 ** 15 - 1,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a positive integer in [1, 2^15).\n *\n * Returns `true` for a positive integer in [1, 2^15) — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive integer in [1, 2^15), `false` otherwise\n */\nexport const isPositiveInt16 = is;\n\n/**\n * Casts a `number` to the `PositiveInt16` branded type.\n *\n * Validates that the value is a positive integer in [1, 2^15) and returns it\n * with the `PositiveInt16` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `PositiveInt16`\n * @throws {TypeError} If the value is not a positive integer in [1, 2^15)\n */\nexport const asPositiveInt16 = castType;\n\n/**\n * Namespace providing type-safe operations for the `PositiveInt16` branded\n * type.\n *\n * The `PositiveInt16` type represents a positive integer in [1, 2^15). Division\n * (`div`) uses floor division.\n */\nexport const PositiveInt16 = {\n /**\n * Type guard that checks if a value is a positive integer in [1, 2^15).\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive integer in [1, 2^15), `false` otherwise\n * @see {@link isPositiveInt16} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `PositiveInt16` (the lower saturation\n * target of `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `PositiveInt16` (the upper saturation\n * target of `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given positive integers.\n *\n * @param values - The positive integers to compare (at least one required)\n * @returns The smallest value as a `PositiveInt16`\n */\n min: min_,\n\n /**\n * Returns the largest of the given positive integers.\n *\n * @param values - The positive integers to compare (at least one required)\n * @returns The largest value as a `PositiveInt16`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `PositiveInt16`, rounding to the\n * nearest integer and saturating the result into the range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * Unlike `asPositiveInt16`, this is total: out-of-range inputs are clamped to\n * the nearest representable `PositiveInt16` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as a `PositiveInt16`\n */\n fromNumber,\n\n /**\n * Generates a random `PositiveInt16` 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 `PositiveInt16` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `PositiveInt16`\n * (floored to an integer).\n *\n * @param a - The base positive integer\n * @param b - The exponent positive integer\n * @returns `a ** b` as a `PositiveInt16`\n */\n pow,\n\n /**\n * Adds two positive integers, returning `a + b` as a `PositiveInt16`.\n *\n * @param a - The first positive integer\n * @param b - The second positive integer\n * @returns The sum of `a` and `b` as a `PositiveInt16`\n */\n add,\n\n /**\n * Subtracts two positive integers, returning `a - b` as a `PositiveInt16`.\n *\n * @param a - The first positive integer\n * @param b - The second positive integer\n * @returns The difference of `a` and `b` as a `PositiveInt16`\n */\n sub,\n\n /**\n * Multiplies two positive integers, returning `a * b` as a `PositiveInt16`.\n *\n * @param a - The first positive integer\n * @param b - The second positive integer\n * @returns The product of `a` and `b` as a `PositiveInt16`\n */\n mul,\n\n /**\n * Divides two positive integers using floor division (`⌊a / b⌋`): the result\n * is `a / b` rounded toward negative infinity, as a `PositiveInt16`.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as a `PositiveInt16`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof PositiveInt16,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range'\n >\n>('=');\n\nexpectType<\n typeof PositiveInt16,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,iCAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAA;AAAA,EACA,UAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,SAAA,EAAW,CAAA;AAAA,EACX,SAAA,EAAW,KAAK,EAAA,GAAK,CAAA;AAAA,EACrB;AACF,CAAU,CAAA;AAWH,MAAM,eAAA,GAAkB;AAYxB,MAAM,eAAA,GAAkB;AASxB,MAAM,aAAA,GAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ3B,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaL,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AACF;;;;"}
|
|
@@ -54,11 +54,13 @@ export declare const PositiveInt32: {
|
|
|
54
54
|
*/
|
|
55
55
|
readonly is: (a: number) => a is TtfImported_PositiveInt32;
|
|
56
56
|
/**
|
|
57
|
-
* The smallest value representable as `PositiveInt32
|
|
57
|
+
* The smallest value representable as `PositiveInt32` (the lower saturation
|
|
58
|
+
* target of `fromNumber`).
|
|
58
59
|
*/
|
|
59
60
|
readonly MIN_VALUE: 1;
|
|
60
61
|
/**
|
|
61
|
-
* The largest value representable as `PositiveInt32
|
|
62
|
+
* The largest value representable as `PositiveInt32` (the upper saturation
|
|
63
|
+
* target of `fromNumber`).
|
|
62
64
|
*/
|
|
63
65
|
readonly MAX_VALUE: number;
|
|
64
66
|
/**
|
|
@@ -76,13 +78,17 @@ export declare const PositiveInt32: {
|
|
|
76
78
|
*/
|
|
77
79
|
readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_PositiveInt32>[]) => TtfImported_PositiveInt32;
|
|
78
80
|
/**
|
|
79
|
-
*
|
|
80
|
-
* integer and
|
|
81
|
+
* Converts an arbitrary `number` into a `PositiveInt32`, rounding to the
|
|
82
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
83
|
+
* MAX_VALUE]`.
|
|
81
84
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
85
|
+
* Unlike `asPositiveInt32`, this is total: out-of-range inputs are clamped to
|
|
86
|
+
* the nearest representable `PositiveInt32` instead of throwing.
|
|
87
|
+
*
|
|
88
|
+
* @param value - The value to convert
|
|
89
|
+
* @returns The value as a `PositiveInt32`
|
|
84
90
|
*/
|
|
85
|
-
readonly
|
|
91
|
+
readonly fromNumber: (x: number) => TtfImported_PositiveInt32;
|
|
86
92
|
/**
|
|
87
93
|
* Generates a random `PositiveInt32` within the given range.
|
|
88
94
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positive-int32.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/positive-int32.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,IAAI,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAIhF,MAAM,MAAM,aAAa,GAAG,yBAAyB,CAAC;AA+BtD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,+CAAK,CAAC;AAElC;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;MAAW,CAAC;AAExC;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;IACxB;;;;;;OAMG;;IAGH;;
|
|
1
|
+
{"version":3,"file":"positive-int32.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/positive-int32.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,IAAI,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAIhF,MAAM,MAAM,aAAa,GAAG,yBAAyB,CAAC;AA+BtD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,+CAAK,CAAC;AAElC;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;MAAW,CAAC;AAExC;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;IACxB;;;;;;OAMG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;OAOG;;;;;;;;;;;;;;;;;;CAEK,CAAC"}
|
|
@@ -6,8 +6,8 @@ const {
|
|
|
6
6
|
MIN_VALUE,
|
|
7
7
|
add,
|
|
8
8
|
castType,
|
|
9
|
-
clamp,
|
|
10
9
|
div,
|
|
10
|
+
fromNumber,
|
|
11
11
|
is,
|
|
12
12
|
max: max_,
|
|
13
13
|
min: min_,
|
|
@@ -33,11 +33,13 @@ const PositiveInt32 = {
|
|
|
33
33
|
*/
|
|
34
34
|
is,
|
|
35
35
|
/**
|
|
36
|
-
* The smallest value representable as `PositiveInt32
|
|
36
|
+
* The smallest value representable as `PositiveInt32` (the lower saturation
|
|
37
|
+
* target of `fromNumber`).
|
|
37
38
|
*/
|
|
38
39
|
MIN_VALUE,
|
|
39
40
|
/**
|
|
40
|
-
* The largest value representable as `PositiveInt32
|
|
41
|
+
* The largest value representable as `PositiveInt32` (the upper saturation
|
|
42
|
+
* target of `fromNumber`).
|
|
41
43
|
*/
|
|
42
44
|
MAX_VALUE,
|
|
43
45
|
/**
|
|
@@ -55,13 +57,17 @@ const PositiveInt32 = {
|
|
|
55
57
|
*/
|
|
56
58
|
max: max_,
|
|
57
59
|
/**
|
|
58
|
-
*
|
|
59
|
-
* integer and
|
|
60
|
+
* Converts an arbitrary `number` into a `PositiveInt32`, rounding to the
|
|
61
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
62
|
+
* MAX_VALUE]`.
|
|
60
63
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
64
|
+
* Unlike `asPositiveInt32`, this is total: out-of-range inputs are clamped to
|
|
65
|
+
* the nearest representable `PositiveInt32` instead of throwing.
|
|
66
|
+
*
|
|
67
|
+
* @param value - The value to convert
|
|
68
|
+
* @returns The value as a `PositiveInt32`
|
|
63
69
|
*/
|
|
64
|
-
|
|
70
|
+
fromNumber,
|
|
65
71
|
/**
|
|
66
72
|
* Generates a random `PositiveInt32` within the given range.
|
|
67
73
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positive-int32.mjs","sources":["../../../src/number/branded-types/positive-int32.mts"],"sourcesContent":["import { type PositiveInt32 as TtfImported_PositiveInt32 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type PositiveInt32 = TtfImported_PositiveInt32;\n\ntype ElementType = PositiveInt32;\n\nconst typeNameInMessage = 'a positive integer in [1, 2^31)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n
|
|
1
|
+
{"version":3,"file":"positive-int32.mjs","sources":["../../../src/number/branded-types/positive-int32.mts"],"sourcesContent":["import { type PositiveInt32 as TtfImported_PositiveInt32 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type PositiveInt32 = TtfImported_PositiveInt32;\n\ntype ElementType = PositiveInt32;\n\nconst typeNameInMessage = 'a positive integer in [1, 2^31)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n div,\n fromNumber,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n 1,\n number\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 1,\n MAX_VALUE: 2 ** 31 - 1,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a positive integer in [1, 2^31).\n *\n * Returns `true` for a positive integer in [1, 2^31) — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive integer in [1, 2^31), `false` otherwise\n */\nexport const isPositiveInt32 = is;\n\n/**\n * Casts a `number` to the `PositiveInt32` branded type.\n *\n * Validates that the value is a positive integer in [1, 2^31) and returns it\n * with the `PositiveInt32` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `PositiveInt32`\n * @throws {TypeError} If the value is not a positive integer in [1, 2^31)\n */\nexport const asPositiveInt32 = castType;\n\n/**\n * Namespace providing type-safe operations for the `PositiveInt32` branded\n * type.\n *\n * The `PositiveInt32` type represents a positive integer in [1, 2^31). Division\n * (`div`) uses floor division.\n */\nexport const PositiveInt32 = {\n /**\n * Type guard that checks if a value is a positive integer in [1, 2^31).\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive integer in [1, 2^31), `false` otherwise\n * @see {@link isPositiveInt32} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `PositiveInt32` (the lower saturation\n * target of `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `PositiveInt32` (the upper saturation\n * target of `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given positive integers.\n *\n * @param values - The positive integers to compare (at least one required)\n * @returns The smallest value as a `PositiveInt32`\n */\n min: min_,\n\n /**\n * Returns the largest of the given positive integers.\n *\n * @param values - The positive integers to compare (at least one required)\n * @returns The largest value as a `PositiveInt32`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `PositiveInt32`, rounding to the\n * nearest integer and saturating the result into the range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * Unlike `asPositiveInt32`, this is total: out-of-range inputs are clamped to\n * the nearest representable `PositiveInt32` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as a `PositiveInt32`\n */\n fromNumber,\n\n /**\n * Generates a random `PositiveInt32` 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 `PositiveInt32` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `PositiveInt32`\n * (floored to an integer).\n *\n * @param a - The base positive integer\n * @param b - The exponent positive integer\n * @returns `a ** b` as a `PositiveInt32`\n */\n pow,\n\n /**\n * Adds two positive integers, returning `a + b` as a `PositiveInt32`.\n *\n * @param a - The first positive integer\n * @param b - The second positive integer\n * @returns The sum of `a` and `b` as a `PositiveInt32`\n */\n add,\n\n /**\n * Subtracts two positive integers, returning `a - b` as a `PositiveInt32`.\n *\n * @param a - The first positive integer\n * @param b - The second positive integer\n * @returns The difference of `a` and `b` as a `PositiveInt32`\n */\n sub,\n\n /**\n * Multiplies two positive integers, returning `a * b` as a `PositiveInt32`.\n *\n * @param a - The first positive integer\n * @param b - The second positive integer\n * @returns The product of `a` and `b` as a `PositiveInt32`\n */\n mul,\n\n /**\n * Divides two positive integers using floor division (`⌊a / b⌋`): the result\n * is `a / b` rounded toward negative infinity, as a `PositiveInt32`.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as a `PositiveInt32`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof PositiveInt32,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range'\n >\n>('=');\n\nexpectType<\n typeof PositiveInt32,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,iCAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAA;AAAA,EACA,UAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,SAAA,EAAW,CAAA;AAAA,EACX,SAAA,EAAW,KAAK,EAAA,GAAK,CAAA;AAAA,EACrB;AACF,CAAU,CAAA;AAWH,MAAM,eAAA,GAAkB;AAYxB,MAAM,eAAA,GAAkB;AASxB,MAAM,aAAA,GAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ3B,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaL,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AACF;;;;"}
|
|
@@ -86,11 +86,13 @@ export declare const PositiveSafeInt: {
|
|
|
86
86
|
*/
|
|
87
87
|
readonly is: (a: number) => a is TtfImported_PositiveSafeInt;
|
|
88
88
|
/**
|
|
89
|
-
* The smallest value representable as `PositiveSafeInt
|
|
89
|
+
* The smallest value representable as `PositiveSafeInt` (the lower saturation
|
|
90
|
+
* target of `fromNumber`).
|
|
90
91
|
*/
|
|
91
92
|
readonly MIN_VALUE: 1;
|
|
92
93
|
/**
|
|
93
|
-
* The largest value representable as `PositiveSafeInt
|
|
94
|
+
* The largest value representable as `PositiveSafeInt` (the upper saturation
|
|
95
|
+
* target of `fromNumber`).
|
|
94
96
|
*/
|
|
95
97
|
readonly MAX_VALUE: SafeUint;
|
|
96
98
|
/**
|
|
@@ -130,17 +132,21 @@ export declare const PositiveSafeInt: {
|
|
|
130
132
|
*/
|
|
131
133
|
readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_PositiveSafeInt>[]) => TtfImported_PositiveSafeInt;
|
|
132
134
|
/**
|
|
133
|
-
*
|
|
134
|
-
* integer and
|
|
135
|
+
* Converts an arbitrary `number` into a `PositiveSafeInt`, rounding to the
|
|
136
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
137
|
+
* MAX_VALUE]`.
|
|
138
|
+
*
|
|
139
|
+
* Unlike `asPositiveSafeInt`, this is total: out-of-range inputs are clamped
|
|
140
|
+
* to the nearest representable `PositiveSafeInt` instead of throwing.
|
|
135
141
|
*
|
|
136
142
|
* @example
|
|
137
143
|
*
|
|
138
144
|
* ```ts
|
|
139
|
-
* const belowRange = PositiveSafeInt.
|
|
145
|
+
* const belowRange = PositiveSafeInt.fromNumber(0);
|
|
140
146
|
*
|
|
141
|
-
* const withinRange = PositiveSafeInt.
|
|
147
|
+
* const withinRange = PositiveSafeInt.fromNumber(123);
|
|
142
148
|
*
|
|
143
|
-
* const aboveRange = PositiveSafeInt.
|
|
149
|
+
* const aboveRange = PositiveSafeInt.fromNumber(Number.MAX_SAFE_INTEGER + 10);
|
|
144
150
|
*
|
|
145
151
|
* assert.isTrue(belowRange === 1);
|
|
146
152
|
*
|
|
@@ -149,10 +155,10 @@ export declare const PositiveSafeInt: {
|
|
|
149
155
|
* assert.isTrue(aboveRange === Number.MAX_SAFE_INTEGER);
|
|
150
156
|
* ```
|
|
151
157
|
*
|
|
152
|
-
* @param value - The value to
|
|
153
|
-
* @returns The
|
|
158
|
+
* @param value - The value to convert
|
|
159
|
+
* @returns The value as a `PositiveSafeInt`
|
|
154
160
|
*/
|
|
155
|
-
readonly
|
|
161
|
+
readonly fromNumber: (x: number) => TtfImported_PositiveSafeInt;
|
|
156
162
|
/**
|
|
157
163
|
* Generates a random `PositiveSafeInt` within the given range.
|
|
158
164
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positive-safe-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/positive-safe-int.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,eAAe,IAAI,2BAA2B,EACpD,MAAM,eAAe,CAAC;AAIvB,MAAM,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAgC1D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iBAAiB,iDAAK,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;MAAW,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;IAC1B;;;;;;;;;;;;;;;;;;OAkBG;;IAGH;;
|
|
1
|
+
{"version":3,"file":"positive-safe-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/positive-safe-int.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,eAAe,IAAI,2BAA2B,EACpD,MAAM,eAAe,CAAC;AAIvB,MAAM,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAgC1D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iBAAiB,iDAAK,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;MAAW,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;IAC1B;;;;;;;;;;;;;;;;;;OAkBG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;;;;;;;;;;;;;OAgBG;;IAGH;;;;;;;;;;;;;;;;OAgBG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;;IAGH;;;;;;;;;;;;;;;;;;;;;;OAsBG;;IAGH;;;;;;;;;;;;;;;;;;;OAmBG;;IAGH;;;;;;;;;;;;;;;;;;;OAmBG;;IAGH;;;;;;;;;;;;;;;;;;;;OAoBG;;IAGH;;;;;;;;;;;;;;;;;;;;OAoBG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;;;;;;;;;;;;;;;;CAEK,CAAC"}
|
|
@@ -6,8 +6,8 @@ const {
|
|
|
6
6
|
MIN_VALUE,
|
|
7
7
|
add,
|
|
8
8
|
castType,
|
|
9
|
-
clamp,
|
|
10
9
|
div,
|
|
10
|
+
fromNumber,
|
|
11
11
|
is,
|
|
12
12
|
max: max_,
|
|
13
13
|
min: min_,
|
|
@@ -46,11 +46,13 @@ const PositiveSafeInt = {
|
|
|
46
46
|
*/
|
|
47
47
|
is,
|
|
48
48
|
/**
|
|
49
|
-
* The smallest value representable as `PositiveSafeInt
|
|
49
|
+
* The smallest value representable as `PositiveSafeInt` (the lower saturation
|
|
50
|
+
* target of `fromNumber`).
|
|
50
51
|
*/
|
|
51
52
|
MIN_VALUE,
|
|
52
53
|
/**
|
|
53
|
-
* The largest value representable as `PositiveSafeInt
|
|
54
|
+
* The largest value representable as `PositiveSafeInt` (the upper saturation
|
|
55
|
+
* target of `fromNumber`).
|
|
54
56
|
*/
|
|
55
57
|
MAX_VALUE,
|
|
56
58
|
/**
|
|
@@ -90,17 +92,21 @@ const PositiveSafeInt = {
|
|
|
90
92
|
*/
|
|
91
93
|
max: max_,
|
|
92
94
|
/**
|
|
93
|
-
*
|
|
94
|
-
* integer and
|
|
95
|
+
* Converts an arbitrary `number` into a `PositiveSafeInt`, rounding to the
|
|
96
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
97
|
+
* MAX_VALUE]`.
|
|
98
|
+
*
|
|
99
|
+
* Unlike `asPositiveSafeInt`, this is total: out-of-range inputs are clamped
|
|
100
|
+
* to the nearest representable `PositiveSafeInt` instead of throwing.
|
|
95
101
|
*
|
|
96
102
|
* @example
|
|
97
103
|
*
|
|
98
104
|
* ```ts
|
|
99
|
-
* const belowRange = PositiveSafeInt.
|
|
105
|
+
* const belowRange = PositiveSafeInt.fromNumber(0);
|
|
100
106
|
*
|
|
101
|
-
* const withinRange = PositiveSafeInt.
|
|
107
|
+
* const withinRange = PositiveSafeInt.fromNumber(123);
|
|
102
108
|
*
|
|
103
|
-
* const aboveRange = PositiveSafeInt.
|
|
109
|
+
* const aboveRange = PositiveSafeInt.fromNumber(Number.MAX_SAFE_INTEGER + 10);
|
|
104
110
|
*
|
|
105
111
|
* assert.isTrue(belowRange === 1);
|
|
106
112
|
*
|
|
@@ -109,10 +115,10 @@ const PositiveSafeInt = {
|
|
|
109
115
|
* assert.isTrue(aboveRange === Number.MAX_SAFE_INTEGER);
|
|
110
116
|
* ```
|
|
111
117
|
*
|
|
112
|
-
* @param value - The value to
|
|
113
|
-
* @returns The
|
|
118
|
+
* @param value - The value to convert
|
|
119
|
+
* @returns The value as a `PositiveSafeInt`
|
|
114
120
|
*/
|
|
115
|
-
|
|
121
|
+
fromNumber,
|
|
116
122
|
/**
|
|
117
123
|
* Generates a random `PositiveSafeInt` within the given range.
|
|
118
124
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positive-safe-int.mjs","sources":["../../../src/number/branded-types/positive-safe-int.mts"],"sourcesContent":["import {\n type SafeUint,\n type PositiveSafeInt as TtfImported_PositiveSafeInt,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type PositiveSafeInt = TtfImported_PositiveSafeInt;\n\ntype ElementType = PositiveSafeInt;\n\nconst typeNameInMessage = 'a positive safe integer';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n clamp,\n div,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n 1,\n SafeUint\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 1,\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer\n MAX_VALUE: Number.MAX_SAFE_INTEGER as SafeUint,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a positive safe integer.\n *\n * Returns `true` for a positive safe integer — a value with no fractional\n * component.\n *\n * @example\n *\n * ```ts\n * assert.isTrue(isPositiveSafeInt(1));\n *\n * assert.isTrue(isPositiveSafeInt(Number.MAX_SAFE_INTEGER));\n *\n * assert.isFalse(isPositiveSafeInt(0));\n *\n * assert.isTrue(PositiveSafeInt.is(42));\n * ```\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive safe integer, `false` otherwise\n */\nexport const isPositiveSafeInt = is;\n\n/**\n * Casts a `number` to the `PositiveSafeInt` branded type.\n *\n * Validates that the value is a positive safe integer and returns it with the\n * `PositiveSafeInt` brand. Throws a `TypeError` otherwise.\n *\n * @example\n *\n * ```ts\n * const branded = asPositiveSafeInt(128);\n *\n * assert.isTrue(branded === 128);\n *\n * assert.isTrue(PositiveSafeInt.is(branded));\n * ```\n *\n * @param value - The value to cast\n * @returns The value as a `PositiveSafeInt`\n * @throws {TypeError} If the value is not a positive safe integer\n */\nexport const asPositiveSafeInt = castType;\n\n/**\n * Namespace providing type-safe operations for the `PositiveSafeInt` branded\n * type.\n *\n * The `PositiveSafeInt` type represents a positive safe integer. Division\n * (`div`) uses floor division.\n */\nexport const PositiveSafeInt = {\n /**\n * Type guard that checks if a value is a positive safe integer.\n *\n * @example\n *\n * ```ts\n * assert.isTrue(isPositiveSafeInt(1));\n *\n * assert.isTrue(isPositiveSafeInt(Number.MAX_SAFE_INTEGER));\n *\n * assert.isFalse(isPositiveSafeInt(0));\n *\n * assert.isTrue(PositiveSafeInt.is(42));\n * ```\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive safe integer, `false` otherwise\n * @see {@link isPositiveSafeInt} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `PositiveSafeInt`.\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `PositiveSafeInt`.\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given positive safe integers.\n *\n * @example\n *\n * ```ts\n * const smallest = PositiveSafeInt.min(\n * asPositiveSafeInt(10),\n * asPositiveSafeInt(5),\n * );\n *\n * assert.isTrue(smallest === 5);\n * ```\n *\n * @param values - The positive safe integers to compare (at least one required)\n * @returns The smallest value as a `PositiveSafeInt`\n */\n min: min_,\n\n /**\n * Returns the largest of the given positive safe integers.\n *\n * @example\n *\n * ```ts\n * const largest = PositiveSafeInt.max(\n * asPositiveSafeInt(10),\n * asPositiveSafeInt(5),\n * );\n *\n * assert.isTrue(largest === 10);\n * ```\n *\n * @param values - The positive safe integers to compare (at least one required)\n * @returns The largest value as a `PositiveSafeInt`\n */\n max: max_,\n\n /**\n * Clamps a `number` into the `PositiveSafeInt` range, rounding to the nearest\n * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.\n *\n * @example\n *\n * ```ts\n * const belowRange = PositiveSafeInt.clamp(0);\n *\n * const withinRange = PositiveSafeInt.clamp(123);\n *\n * const aboveRange = PositiveSafeInt.clamp(Number.MAX_SAFE_INTEGER + 10);\n *\n * assert.isTrue(belowRange === 1);\n *\n * assert.isTrue(withinRange === 123);\n *\n * assert.isTrue(aboveRange === Number.MAX_SAFE_INTEGER);\n * ```\n *\n * @param value - The value to clamp\n * @returns The clamped value as a `PositiveSafeInt`\n */\n clamp,\n\n /**\n * Generates a random `PositiveSafeInt` within the given range.\n *\n * The range is inclusive on both ends.\n *\n * @example\n *\n * ```ts\n * const min = asPositiveSafeInt(1);\n *\n * const max = asPositiveSafeInt(6);\n *\n * const randomValue = PositiveSafeInt.random(min, max);\n *\n * assert.isTrue(PositiveSafeInt.is(randomValue));\n *\n * assert.isTrue(randomValue >= 1 && randomValue <= 6);\n * ```\n *\n * @param min - The minimum value (inclusive)\n * @param max - The maximum value (inclusive)\n * @returns A random `PositiveSafeInt` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `PositiveSafeInt`\n * (floored to an integer).\n *\n * @example\n *\n * ```ts\n * const base = asPositiveSafeInt(3);\n *\n * const exponent = asPositiveSafeInt(3);\n *\n * const power = PositiveSafeInt.pow(base, exponent);\n *\n * assert.isTrue(power === 27);\n * ```\n *\n * @param a - The base positive safe integer\n * @param b - The exponent positive safe integer\n * @returns `a ** b` as a `PositiveSafeInt`\n */\n pow,\n\n /**\n * Adds two positive safe integers, returning `a + b` as a `PositiveSafeInt`.\n *\n * @example\n *\n * ```ts\n * const sum = PositiveSafeInt.add(\n * asPositiveSafeInt(1000),\n * asPositiveSafeInt(2048),\n * );\n *\n * assert.isTrue(sum === 3048);\n *\n * assert.isTrue(PositiveSafeInt.is(sum));\n * ```\n *\n * @param a - The first positive safe integer\n * @param b - The second positive safe integer\n * @returns The sum of `a` and `b` as a `PositiveSafeInt`\n */\n add,\n\n /**\n * Subtracts two positive safe integers, returning `a - b` as a\n * `PositiveSafeInt`.\n *\n * @example\n *\n * ```ts\n * const difference = PositiveSafeInt.sub(\n * asPositiveSafeInt(10),\n * asPositiveSafeInt(20),\n * );\n *\n * assert.isTrue(difference === 1);\n *\n * assert.isTrue(PositiveSafeInt.is(difference));\n * ```\n *\n * @param a - The first positive safe integer\n * @param b - The second positive safe integer\n * @returns The difference of `a` and `b` as a `PositiveSafeInt`\n */\n sub,\n\n /**\n * Multiplies two positive safe integers, returning `a * b` as a\n * `PositiveSafeInt`.\n *\n * @example\n *\n * ```ts\n * const product = PositiveSafeInt.mul(\n * asPositiveSafeInt(50),\n * asPositiveSafeInt(20),\n * );\n *\n * assert.isTrue(product === 1000);\n *\n * assert.isTrue(PositiveSafeInt.is(product));\n * ```\n *\n * @param a - The first positive safe integer\n * @param b - The second positive safe integer\n * @returns The product of `a` and `b` as a `PositiveSafeInt`\n */\n mul,\n\n /**\n * Divides two positive safe integers using floor division (`⌊a / b⌋`): the\n * result is `a / b` rounded toward negative infinity, as a `PositiveSafeInt`.\n *\n * @example\n *\n * ```ts\n * const quotient = PositiveSafeInt.div(\n * asPositiveSafeInt(25),\n * asPositiveSafeInt(4),\n * );\n *\n * const clamped = PositiveSafeInt.div(\n * asPositiveSafeInt(5),\n * asPositiveSafeInt(50),\n * );\n *\n * assert.isTrue(quotient === 6);\n *\n * assert.isTrue(clamped === 1);\n * ```\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as a `PositiveSafeInt`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof PositiveSafeInt,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range'\n >\n>('=');\n\nexpectType<\n typeof PositiveSafeInt,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range'\n >\n>('<=');\n"],"names":[],"mappings":";;AAWA,MAAM,iBAAA,GAAoB,yBAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,GAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,SAAA,EAAW,CAAA;AAAA;AAAA,EAEX,WAAW,MAAA,CAAO,gBAAA;AAAA,EAClB;AACF,CAAU,CAAA;AAuBH,MAAM,iBAAA,GAAoB;AAsB1B,MAAM,iBAAA,GAAoB;AAS1B,MAAM,eAAA,GAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoB7B,EAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyBL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyBA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4BA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"positive-safe-int.mjs","sources":["../../../src/number/branded-types/positive-safe-int.mts"],"sourcesContent":["import {\n type SafeUint,\n type PositiveSafeInt as TtfImported_PositiveSafeInt,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type PositiveSafeInt = TtfImported_PositiveSafeInt;\n\ntype ElementType = PositiveSafeInt;\n\nconst typeNameInMessage = 'a positive safe integer';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n div,\n fromNumber,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n 1,\n SafeUint\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 1,\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer\n MAX_VALUE: Number.MAX_SAFE_INTEGER as SafeUint,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a positive safe integer.\n *\n * Returns `true` for a positive safe integer — a value with no fractional\n * component.\n *\n * @example\n *\n * ```ts\n * assert.isTrue(isPositiveSafeInt(1));\n *\n * assert.isTrue(isPositiveSafeInt(Number.MAX_SAFE_INTEGER));\n *\n * assert.isFalse(isPositiveSafeInt(0));\n *\n * assert.isTrue(PositiveSafeInt.is(42));\n * ```\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive safe integer, `false` otherwise\n */\nexport const isPositiveSafeInt = is;\n\n/**\n * Casts a `number` to the `PositiveSafeInt` branded type.\n *\n * Validates that the value is a positive safe integer and returns it with the\n * `PositiveSafeInt` brand. Throws a `TypeError` otherwise.\n *\n * @example\n *\n * ```ts\n * const branded = asPositiveSafeInt(128);\n *\n * assert.isTrue(branded === 128);\n *\n * assert.isTrue(PositiveSafeInt.is(branded));\n * ```\n *\n * @param value - The value to cast\n * @returns The value as a `PositiveSafeInt`\n * @throws {TypeError} If the value is not a positive safe integer\n */\nexport const asPositiveSafeInt = castType;\n\n/**\n * Namespace providing type-safe operations for the `PositiveSafeInt` branded\n * type.\n *\n * The `PositiveSafeInt` type represents a positive safe integer. Division\n * (`div`) uses floor division.\n */\nexport const PositiveSafeInt = {\n /**\n * Type guard that checks if a value is a positive safe integer.\n *\n * @example\n *\n * ```ts\n * assert.isTrue(isPositiveSafeInt(1));\n *\n * assert.isTrue(isPositiveSafeInt(Number.MAX_SAFE_INTEGER));\n *\n * assert.isFalse(isPositiveSafeInt(0));\n *\n * assert.isTrue(PositiveSafeInt.is(42));\n * ```\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive safe integer, `false` otherwise\n * @see {@link isPositiveSafeInt} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `PositiveSafeInt` (the lower saturation\n * target of `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `PositiveSafeInt` (the upper saturation\n * target of `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given positive safe integers.\n *\n * @example\n *\n * ```ts\n * const smallest = PositiveSafeInt.min(\n * asPositiveSafeInt(10),\n * asPositiveSafeInt(5),\n * );\n *\n * assert.isTrue(smallest === 5);\n * ```\n *\n * @param values - The positive safe integers to compare (at least one required)\n * @returns The smallest value as a `PositiveSafeInt`\n */\n min: min_,\n\n /**\n * Returns the largest of the given positive safe integers.\n *\n * @example\n *\n * ```ts\n * const largest = PositiveSafeInt.max(\n * asPositiveSafeInt(10),\n * asPositiveSafeInt(5),\n * );\n *\n * assert.isTrue(largest === 10);\n * ```\n *\n * @param values - The positive safe integers to compare (at least one required)\n * @returns The largest value as a `PositiveSafeInt`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `PositiveSafeInt`, rounding to the\n * nearest integer and saturating the result into the range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * Unlike `asPositiveSafeInt`, this is total: out-of-range inputs are clamped\n * to the nearest representable `PositiveSafeInt` instead of throwing.\n *\n * @example\n *\n * ```ts\n * const belowRange = PositiveSafeInt.fromNumber(0);\n *\n * const withinRange = PositiveSafeInt.fromNumber(123);\n *\n * const aboveRange = PositiveSafeInt.fromNumber(Number.MAX_SAFE_INTEGER + 10);\n *\n * assert.isTrue(belowRange === 1);\n *\n * assert.isTrue(withinRange === 123);\n *\n * assert.isTrue(aboveRange === Number.MAX_SAFE_INTEGER);\n * ```\n *\n * @param value - The value to convert\n * @returns The value as a `PositiveSafeInt`\n */\n fromNumber,\n\n /**\n * Generates a random `PositiveSafeInt` within the given range.\n *\n * The range is inclusive on both ends.\n *\n * @example\n *\n * ```ts\n * const min = asPositiveSafeInt(1);\n *\n * const max = asPositiveSafeInt(6);\n *\n * const randomValue = PositiveSafeInt.random(min, max);\n *\n * assert.isTrue(PositiveSafeInt.is(randomValue));\n *\n * assert.isTrue(randomValue >= 1 && randomValue <= 6);\n * ```\n *\n * @param min - The minimum value (inclusive)\n * @param max - The maximum value (inclusive)\n * @returns A random `PositiveSafeInt` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `PositiveSafeInt`\n * (floored to an integer).\n *\n * @example\n *\n * ```ts\n * const base = asPositiveSafeInt(3);\n *\n * const exponent = asPositiveSafeInt(3);\n *\n * const power = PositiveSafeInt.pow(base, exponent);\n *\n * assert.isTrue(power === 27);\n * ```\n *\n * @param a - The base positive safe integer\n * @param b - The exponent positive safe integer\n * @returns `a ** b` as a `PositiveSafeInt`\n */\n pow,\n\n /**\n * Adds two positive safe integers, returning `a + b` as a `PositiveSafeInt`.\n *\n * @example\n *\n * ```ts\n * const sum = PositiveSafeInt.add(\n * asPositiveSafeInt(1000),\n * asPositiveSafeInt(2048),\n * );\n *\n * assert.isTrue(sum === 3048);\n *\n * assert.isTrue(PositiveSafeInt.is(sum));\n * ```\n *\n * @param a - The first positive safe integer\n * @param b - The second positive safe integer\n * @returns The sum of `a` and `b` as a `PositiveSafeInt`\n */\n add,\n\n /**\n * Subtracts two positive safe integers, returning `a - b` as a\n * `PositiveSafeInt`.\n *\n * @example\n *\n * ```ts\n * const difference = PositiveSafeInt.sub(\n * asPositiveSafeInt(10),\n * asPositiveSafeInt(20),\n * );\n *\n * assert.isTrue(difference === 1);\n *\n * assert.isTrue(PositiveSafeInt.is(difference));\n * ```\n *\n * @param a - The first positive safe integer\n * @param b - The second positive safe integer\n * @returns The difference of `a` and `b` as a `PositiveSafeInt`\n */\n sub,\n\n /**\n * Multiplies two positive safe integers, returning `a * b` as a\n * `PositiveSafeInt`.\n *\n * @example\n *\n * ```ts\n * const product = PositiveSafeInt.mul(\n * asPositiveSafeInt(50),\n * asPositiveSafeInt(20),\n * );\n *\n * assert.isTrue(product === 1000);\n *\n * assert.isTrue(PositiveSafeInt.is(product));\n * ```\n *\n * @param a - The first positive safe integer\n * @param b - The second positive safe integer\n * @returns The product of `a` and `b` as a `PositiveSafeInt`\n */\n mul,\n\n /**\n * Divides two positive safe integers using floor division (`⌊a / b⌋`): the\n * result is `a / b` rounded toward negative infinity, as a `PositiveSafeInt`.\n *\n * @example\n *\n * ```ts\n * const quotient = PositiveSafeInt.div(\n * asPositiveSafeInt(25),\n * asPositiveSafeInt(4),\n * );\n *\n * const clamped = PositiveSafeInt.div(\n * asPositiveSafeInt(5),\n * asPositiveSafeInt(50),\n * );\n *\n * assert.isTrue(quotient === 6);\n *\n * assert.isTrue(clamped === 1);\n * ```\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as a `PositiveSafeInt`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof PositiveSafeInt,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range'\n >\n>('=');\n\nexpectType<\n typeof PositiveSafeInt,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range'\n >\n>('<=');\n"],"names":[],"mappings":";;AAWA,MAAM,iBAAA,GAAoB,yBAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAA;AAAA,EACA,UAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,SAAA,EAAW,CAAA;AAAA;AAAA,EAEX,WAAW,MAAA,CAAO,gBAAA;AAAA,EAClB;AACF,CAAU,CAAA;AAuBH,MAAM,iBAAA,GAAoB;AAsB1B,MAAM,iBAAA,GAAoB;AAS1B,MAAM,eAAA,GAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoB7B,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6BL,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyBA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4BA;AACF;;;;"}
|
|
@@ -55,11 +55,13 @@ export declare const PositiveUint16: {
|
|
|
55
55
|
*/
|
|
56
56
|
readonly is: (a: number) => a is TtfImported_PositiveUint16;
|
|
57
57
|
/**
|
|
58
|
-
* The smallest value representable as `PositiveUint16
|
|
58
|
+
* The smallest value representable as `PositiveUint16` (the lower saturation
|
|
59
|
+
* target of `fromNumber`).
|
|
59
60
|
*/
|
|
60
61
|
readonly MIN_VALUE: 1;
|
|
61
62
|
/**
|
|
62
|
-
* The largest value representable as `PositiveUint16
|
|
63
|
+
* The largest value representable as `PositiveUint16` (the upper saturation
|
|
64
|
+
* target of `fromNumber`).
|
|
63
65
|
*/
|
|
64
66
|
readonly MAX_VALUE: number;
|
|
65
67
|
/**
|
|
@@ -77,13 +79,17 @@ export declare const PositiveUint16: {
|
|
|
77
79
|
*/
|
|
78
80
|
readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_PositiveUint16>[]) => TtfImported_PositiveUint16;
|
|
79
81
|
/**
|
|
80
|
-
*
|
|
81
|
-
* integer and
|
|
82
|
+
* Converts an arbitrary `number` into a `PositiveUint16`, rounding to the
|
|
83
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
84
|
+
* MAX_VALUE]`.
|
|
82
85
|
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
86
|
+
* Unlike `asPositiveUint16`, this is total: out-of-range inputs are clamped
|
|
87
|
+
* to the nearest representable `PositiveUint16` instead of throwing.
|
|
88
|
+
*
|
|
89
|
+
* @param value - The value to convert
|
|
90
|
+
* @returns The value as a `PositiveUint16`
|
|
85
91
|
*/
|
|
86
|
-
readonly
|
|
92
|
+
readonly fromNumber: (x: number) => TtfImported_PositiveUint16;
|
|
87
93
|
/**
|
|
88
94
|
* Generates a random `PositiveUint16` within the given range.
|
|
89
95
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positive-uint16.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/positive-uint16.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,IAAI,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAIlF,MAAM,MAAM,cAAc,GAAG,0BAA0B,CAAC;AA+BxD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,gDAAK,CAAC;AAEnC;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;MAAW,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;IACzB;;;;;;OAMG;;IAGH;;
|
|
1
|
+
{"version":3,"file":"positive-uint16.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/positive-uint16.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,IAAI,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAIlF,MAAM,MAAM,cAAc,GAAG,0BAA0B,CAAC;AA+BxD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,gDAAK,CAAC;AAEnC;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;MAAW,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;IACzB;;;;;;OAMG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;OAOG;;;;;;;;;;;;;;;;;;;CAEK,CAAC"}
|
|
@@ -6,8 +6,8 @@ const {
|
|
|
6
6
|
MIN_VALUE,
|
|
7
7
|
add,
|
|
8
8
|
castType,
|
|
9
|
-
clamp,
|
|
10
9
|
div,
|
|
10
|
+
fromNumber,
|
|
11
11
|
is,
|
|
12
12
|
max: max_,
|
|
13
13
|
min: min_,
|
|
@@ -33,11 +33,13 @@ const PositiveUint16 = {
|
|
|
33
33
|
*/
|
|
34
34
|
is,
|
|
35
35
|
/**
|
|
36
|
-
* The smallest value representable as `PositiveUint16
|
|
36
|
+
* The smallest value representable as `PositiveUint16` (the lower saturation
|
|
37
|
+
* target of `fromNumber`).
|
|
37
38
|
*/
|
|
38
39
|
MIN_VALUE,
|
|
39
40
|
/**
|
|
40
|
-
* The largest value representable as `PositiveUint16
|
|
41
|
+
* The largest value representable as `PositiveUint16` (the upper saturation
|
|
42
|
+
* target of `fromNumber`).
|
|
41
43
|
*/
|
|
42
44
|
MAX_VALUE,
|
|
43
45
|
/**
|
|
@@ -55,13 +57,17 @@ const PositiveUint16 = {
|
|
|
55
57
|
*/
|
|
56
58
|
max: max_,
|
|
57
59
|
/**
|
|
58
|
-
*
|
|
59
|
-
* integer and
|
|
60
|
+
* Converts an arbitrary `number` into a `PositiveUint16`, rounding to the
|
|
61
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
62
|
+
* MAX_VALUE]`.
|
|
60
63
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
64
|
+
* Unlike `asPositiveUint16`, this is total: out-of-range inputs are clamped
|
|
65
|
+
* to the nearest representable `PositiveUint16` instead of throwing.
|
|
66
|
+
*
|
|
67
|
+
* @param value - The value to convert
|
|
68
|
+
* @returns The value as a `PositiveUint16`
|
|
63
69
|
*/
|
|
64
|
-
|
|
70
|
+
fromNumber,
|
|
65
71
|
/**
|
|
66
72
|
* Generates a random `PositiveUint16` within the given range.
|
|
67
73
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positive-uint16.mjs","sources":["../../../src/number/branded-types/positive-uint16.mts"],"sourcesContent":["import { type PositiveUint16 as TtfImported_PositiveUint16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type PositiveUint16 = TtfImported_PositiveUint16;\n\ntype ElementType = PositiveUint16;\n\nconst typeNameInMessage = 'a positive integer in [1, 2^16)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n
|
|
1
|
+
{"version":3,"file":"positive-uint16.mjs","sources":["../../../src/number/branded-types/positive-uint16.mts"],"sourcesContent":["import { type PositiveUint16 as TtfImported_PositiveUint16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type PositiveUint16 = TtfImported_PositiveUint16;\n\ntype ElementType = PositiveUint16;\n\nconst typeNameInMessage = 'a positive integer in [1, 2^16)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n div,\n fromNumber,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n 1,\n number\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 1,\n MAX_VALUE: 2 ** 16 - 1,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a positive integer in [1, 2^16).\n *\n * Returns `true` for a positive integer in [1, 2^16) — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive integer in [1, 2^16), `false` otherwise\n */\nexport const isPositiveUint16 = is;\n\n/**\n * Casts a `number` to the `PositiveUint16` branded type.\n *\n * Validates that the value is a positive integer in [1, 2^16) and returns it\n * with the `PositiveUint16` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `PositiveUint16`\n * @throws {TypeError} If the value is not a positive integer in [1, 2^16)\n */\nexport const asPositiveUint16 = castType;\n\n/**\n * Namespace providing type-safe operations for the `PositiveUint16` branded\n * type.\n *\n * The `PositiveUint16` type represents a positive integer in [1, 2^16).\n * Division (`div`) uses floor division.\n */\nexport const PositiveUint16 = {\n /**\n * Type guard that checks if a value is a positive integer in [1, 2^16).\n *\n * @param value - The value to check\n * @returns `true` if the value is a positive integer in [1, 2^16), `false` otherwise\n * @see {@link isPositiveUint16} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `PositiveUint16` (the lower saturation\n * target of `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `PositiveUint16` (the upper saturation\n * target of `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given positive integers.\n *\n * @param values - The positive integers to compare (at least one required)\n * @returns The smallest value as a `PositiveUint16`\n */\n min: min_,\n\n /**\n * Returns the largest of the given positive integers.\n *\n * @param values - The positive integers to compare (at least one required)\n * @returns The largest value as a `PositiveUint16`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `PositiveUint16`, rounding to the\n * nearest integer and saturating the result into the range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * Unlike `asPositiveUint16`, this is total: out-of-range inputs are clamped\n * to the nearest representable `PositiveUint16` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as a `PositiveUint16`\n */\n fromNumber,\n\n /**\n * Generates a random `PositiveUint16` 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 `PositiveUint16` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `PositiveUint16`\n * (floored to an integer).\n *\n * @param a - The base positive integer\n * @param b - The exponent positive integer\n * @returns `a ** b` as a `PositiveUint16`\n */\n pow,\n\n /**\n * Adds two positive integers, returning `a + b` as a `PositiveUint16`.\n *\n * @param a - The first positive integer\n * @param b - The second positive integer\n * @returns The sum of `a` and `b` as a `PositiveUint16`\n */\n add,\n\n /**\n * Subtracts two positive integers, returning `a - b` as a `PositiveUint16`.\n *\n * @param a - The first positive integer\n * @param b - The second positive integer\n * @returns The difference of `a` and `b` as a `PositiveUint16`\n */\n sub,\n\n /**\n * Multiplies two positive integers, returning `a * b` as a `PositiveUint16`.\n *\n * @param a - The first positive integer\n * @param b - The second positive integer\n * @returns The product of `a` and `b` as a `PositiveUint16`\n */\n mul,\n\n /**\n * Divides two positive integers using floor division (`⌊a / b⌋`): the result\n * is `a / b` rounded toward negative infinity, as a `PositiveUint16`.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as a `PositiveUint16`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof PositiveUint16,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range'\n >\n>('=');\n\nexpectType<\n typeof PositiveUint16,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,iCAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAA;AAAA,EACA,UAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,SAAA,EAAW,CAAA;AAAA,EACX,SAAA,EAAW,KAAK,EAAA,GAAK,CAAA;AAAA,EACrB;AACF,CAAU,CAAA;AAWH,MAAM,gBAAA,GAAmB;AAYzB,MAAM,gBAAA,GAAmB;AASzB,MAAM,cAAA,GAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5B,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaL,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AACF;;;;"}
|
|
@@ -53,11 +53,13 @@ export declare const PositiveUint32: {
|
|
|
53
53
|
*/
|
|
54
54
|
readonly is: (a: number) => a is TtfImported_PositiveUint32;
|
|
55
55
|
/**
|
|
56
|
-
* The smallest value representable as `PositiveUint32
|
|
56
|
+
* The smallest value representable as `PositiveUint32` (the lower saturation
|
|
57
|
+
* target of `fromNumber`).
|
|
57
58
|
*/
|
|
58
59
|
readonly MIN_VALUE: 1;
|
|
59
60
|
/**
|
|
60
|
-
* The largest value representable as `PositiveUint32
|
|
61
|
+
* The largest value representable as `PositiveUint32` (the upper saturation
|
|
62
|
+
* target of `fromNumber`).
|
|
61
63
|
*/
|
|
62
64
|
readonly MAX_VALUE: number;
|
|
63
65
|
/**
|
|
@@ -75,13 +77,17 @@ export declare const PositiveUint32: {
|
|
|
75
77
|
*/
|
|
76
78
|
readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_PositiveUint32>[]) => TtfImported_PositiveUint32;
|
|
77
79
|
/**
|
|
78
|
-
*
|
|
79
|
-
* integer and
|
|
80
|
+
* Converts an arbitrary `number` into a `PositiveUint32`, rounding to the
|
|
81
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
82
|
+
* MAX_VALUE]`.
|
|
80
83
|
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
84
|
+
* Unlike `asPositiveUint32`, this is total: out-of-range inputs are clamped
|
|
85
|
+
* to the nearest representable `PositiveUint32` instead of throwing.
|
|
86
|
+
*
|
|
87
|
+
* @param value - The value to convert
|
|
88
|
+
* @returns The value as a `PositiveUint32`
|
|
83
89
|
*/
|
|
84
|
-
readonly
|
|
90
|
+
readonly fromNumber: (x: number) => TtfImported_PositiveUint32;
|
|
85
91
|
/**
|
|
86
92
|
* Generates a random `PositiveUint32` within the given range.
|
|
87
93
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positive-uint32.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/positive-uint32.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,IAAI,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAIlF,MAAM,MAAM,cAAc,GAAG,0BAA0B,CAAC;AA+BxD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,gDAAK,CAAC;AAEnC;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;MAAW,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;IACzB;;;;;;OAMG;;IAGH;;
|
|
1
|
+
{"version":3,"file":"positive-uint32.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/positive-uint32.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,IAAI,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAIlF,MAAM,MAAM,cAAc,GAAG,0BAA0B,CAAC;AA+BxD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,gDAAK,CAAC;AAEnC;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;MAAW,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;IACzB;;;;;;OAMG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;OAOG;;;;;;;;;;;;;;;;;CAEK,CAAC"}
|
|
@@ -6,8 +6,8 @@ const {
|
|
|
6
6
|
MIN_VALUE,
|
|
7
7
|
add,
|
|
8
8
|
castType,
|
|
9
|
-
clamp,
|
|
10
9
|
div,
|
|
10
|
+
fromNumber,
|
|
11
11
|
is,
|
|
12
12
|
max: max_,
|
|
13
13
|
min: min_,
|
|
@@ -33,11 +33,13 @@ const PositiveUint32 = {
|
|
|
33
33
|
*/
|
|
34
34
|
is,
|
|
35
35
|
/**
|
|
36
|
-
* The smallest value representable as `PositiveUint32
|
|
36
|
+
* The smallest value representable as `PositiveUint32` (the lower saturation
|
|
37
|
+
* target of `fromNumber`).
|
|
37
38
|
*/
|
|
38
39
|
MIN_VALUE,
|
|
39
40
|
/**
|
|
40
|
-
* The largest value representable as `PositiveUint32
|
|
41
|
+
* The largest value representable as `PositiveUint32` (the upper saturation
|
|
42
|
+
* target of `fromNumber`).
|
|
41
43
|
*/
|
|
42
44
|
MAX_VALUE,
|
|
43
45
|
/**
|
|
@@ -55,13 +57,17 @@ const PositiveUint32 = {
|
|
|
55
57
|
*/
|
|
56
58
|
max: max_,
|
|
57
59
|
/**
|
|
58
|
-
*
|
|
59
|
-
* integer and
|
|
60
|
+
* Converts an arbitrary `number` into a `PositiveUint32`, rounding to the
|
|
61
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
62
|
+
* MAX_VALUE]`.
|
|
60
63
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
64
|
+
* Unlike `asPositiveUint32`, this is total: out-of-range inputs are clamped
|
|
65
|
+
* to the nearest representable `PositiveUint32` instead of throwing.
|
|
66
|
+
*
|
|
67
|
+
* @param value - The value to convert
|
|
68
|
+
* @returns The value as a `PositiveUint32`
|
|
63
69
|
*/
|
|
64
|
-
|
|
70
|
+
fromNumber,
|
|
65
71
|
/**
|
|
66
72
|
* Generates a random `PositiveUint32` within the given range.
|
|
67
73
|
*
|