ts-data-forge 11.0.1 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts +65 -5
- package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-array-cast.mjs +69 -27
- package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -1
- package/dist/array/impl/index.mjs +1 -1
- 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/dist/string/str.d.mts +70 -5
- package/dist/string/str.d.mts.map +1 -1
- package/dist/string/str.mjs +72 -26
- package/dist/string/str.mjs.map +1 -1
- package/package.json +1 -1
- package/src/array/impl/array-utils-length-bounded-array-cast.mts +204 -39
- package/src/array/impl/array-utils-length-bounded-array-cast.test.mts +126 -0
- 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
- package/src/string/str.mts +201 -39
- package/src/string/str.test.mts +76 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-negative-int16.mjs","sources":["../../../src/number/branded-types/non-negative-int16.mts"],"sourcesContent":["import { type NonNegativeInt16 as TtfImported_NonNegativeInt16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonNegativeInt16 = TtfImported_NonNegativeInt16;\n\ntype ElementType = NonNegativeInt16;\n\nconst typeNameInMessage = 'a non-negative integer in [0, 2^15)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n
|
|
1
|
+
{"version":3,"file":"non-negative-int16.mjs","sources":["../../../src/number/branded-types/non-negative-int16.mts"],"sourcesContent":["import { type NonNegativeInt16 as TtfImported_NonNegativeInt16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonNegativeInt16 = TtfImported_NonNegativeInt16;\n\ntype ElementType = NonNegativeInt16;\n\nconst typeNameInMessage = 'a non-negative integer in [0, 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 0,\n number\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 0,\n MAX_VALUE: 2 ** 15 - 1,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a non-negative integer in [0, 2^15).\n *\n * Returns `true` for a non-negative integer in [0, 2^15) — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-negative integer in [0, 2^15), `false` otherwise\n */\nexport const isNonNegativeInt16 = is;\n\n/**\n * Casts a `number` to the `NonNegativeInt16` branded type.\n *\n * Validates that the value is a non-negative integer in [0, 2^15) and returns\n * it with the `NonNegativeInt16` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonNegativeInt16`\n * @throws {TypeError} If the value is not a non-negative integer in [0, 2^15)\n */\nexport const asNonNegativeInt16 = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonNegativeInt16` branded\n * type.\n *\n * The `NonNegativeInt16` type represents a non-negative integer in [0, 2^15).\n * Division (`div`) uses floor division.\n */\nexport const NonNegativeInt16 = {\n /**\n * Type guard that checks if a value is a non-negative integer in [0, 2^15).\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-negative integer in [0, 2^15), `false` otherwise\n * @see {@link isNonNegativeInt16} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `NonNegativeInt16` (the lower\n * saturation target of `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `NonNegativeInt16` (the upper saturation\n * target of `fromNumber`).\n */\n MAX_VALUE,\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 a `NonNegativeInt16`\n */\n min: min_,\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 a `NonNegativeInt16`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `NonNegativeInt16`, rounding to the\n * nearest integer and saturating the result into the range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * Unlike `asNonNegativeInt16`, this is total: out-of-range inputs are clamped\n * to the nearest representable `NonNegativeInt16` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as a `NonNegativeInt16`\n */\n fromNumber,\n\n /**\n * Generates a random `NonNegativeInt16` 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 `NonNegativeInt16` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NonNegativeInt16`\n * (floored to an integer).\n *\n * @param a - The base non-negative integer\n * @param b - The exponent non-negative integer\n * @returns `a ** b` as a `NonNegativeInt16`\n */\n pow,\n\n /**\n * Adds two non-negative integers, returning `a + b` as a `NonNegativeInt16`.\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 a `NonNegativeInt16`\n */\n add,\n\n /**\n * Subtracts two non-negative integers, returning `a - b` as a\n * `NonNegativeInt16`.\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 a `NonNegativeInt16`\n */\n sub,\n\n /**\n * Multiplies two non-negative integers, returning `a * b` as a\n * `NonNegativeInt16`.\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 a `NonNegativeInt16`\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 a\n * `NonNegativeInt16`.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as a `NonNegativeInt16`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof NonNegativeInt16,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'non-negative' | 'range'\n >\n>('=');\n\nexpectType<\n typeof NonNegativeInt16,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'non-negative' | 'range'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,qCAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,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,kBAAA,GAAqB;AAY3B,MAAM,kBAAA,GAAqB;AAS3B,MAAM,gBAAA,GAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ9B,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;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA;AACF;;;;"}
|
|
@@ -52,11 +52,13 @@ export declare const NonNegativeInt32: {
|
|
|
52
52
|
*/
|
|
53
53
|
readonly is: (a: number) => a is TtfImported_NonNegativeInt32;
|
|
54
54
|
/**
|
|
55
|
-
* The smallest value representable as `NonNegativeInt32
|
|
55
|
+
* The smallest value representable as `NonNegativeInt32` (the lower
|
|
56
|
+
* saturation target of `fromNumber`).
|
|
56
57
|
*/
|
|
57
58
|
readonly MIN_VALUE: 0;
|
|
58
59
|
/**
|
|
59
|
-
* The largest value representable as `NonNegativeInt32
|
|
60
|
+
* The largest value representable as `NonNegativeInt32` (the upper saturation
|
|
61
|
+
* target of `fromNumber`).
|
|
60
62
|
*/
|
|
61
63
|
readonly MAX_VALUE: number;
|
|
62
64
|
/**
|
|
@@ -74,13 +76,17 @@ export declare const NonNegativeInt32: {
|
|
|
74
76
|
*/
|
|
75
77
|
readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_NonNegativeInt32>[]) => TtfImported_NonNegativeInt32;
|
|
76
78
|
/**
|
|
77
|
-
*
|
|
78
|
-
* nearest integer and
|
|
79
|
+
* Converts an arbitrary `number` into a `NonNegativeInt32`, rounding to the
|
|
80
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
81
|
+
* MAX_VALUE]`.
|
|
79
82
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
83
|
+
* Unlike `asNonNegativeInt32`, this is total: out-of-range inputs are clamped
|
|
84
|
+
* to the nearest representable `NonNegativeInt32` instead of throwing.
|
|
85
|
+
*
|
|
86
|
+
* @param value - The value to convert
|
|
87
|
+
* @returns The value as a `NonNegativeInt32`
|
|
82
88
|
*/
|
|
83
|
-
readonly
|
|
89
|
+
readonly fromNumber: (x: number) => TtfImported_NonNegativeInt32;
|
|
84
90
|
/**
|
|
85
91
|
* Generates a random `NonNegativeInt32` within the given range.
|
|
86
92
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-negative-int32.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-negative-int32.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,IAAI,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAItF,MAAM,MAAM,gBAAgB,GAAG,4BAA4B,CAAC;AA+B5D;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,kDAAK,CAAC;AAErC;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;MAAW,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;;;;;OAMG;;IAGH;;
|
|
1
|
+
{"version":3,"file":"non-negative-int32.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-negative-int32.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,IAAI,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAItF,MAAM,MAAM,gBAAgB,GAAG,4BAA4B,CAAC;AA+B5D;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,kDAAK,CAAC;AAErC;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;MAAW,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;;;;;OAMG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;;OAQG;;;;;;;;;;;;;;;;;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 NonNegativeInt32 = {
|
|
|
33
33
|
*/
|
|
34
34
|
is,
|
|
35
35
|
/**
|
|
36
|
-
* The smallest value representable as `NonNegativeInt32
|
|
36
|
+
* The smallest value representable as `NonNegativeInt32` (the lower
|
|
37
|
+
* saturation target of `fromNumber`).
|
|
37
38
|
*/
|
|
38
39
|
MIN_VALUE,
|
|
39
40
|
/**
|
|
40
|
-
* The largest value representable as `NonNegativeInt32
|
|
41
|
+
* The largest value representable as `NonNegativeInt32` (the upper saturation
|
|
42
|
+
* target of `fromNumber`).
|
|
41
43
|
*/
|
|
42
44
|
MAX_VALUE,
|
|
43
45
|
/**
|
|
@@ -55,13 +57,17 @@ const NonNegativeInt32 = {
|
|
|
55
57
|
*/
|
|
56
58
|
max: max_,
|
|
57
59
|
/**
|
|
58
|
-
*
|
|
59
|
-
* nearest integer and
|
|
60
|
+
* Converts an arbitrary `number` into a `NonNegativeInt32`, rounding to the
|
|
61
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
62
|
+
* MAX_VALUE]`.
|
|
60
63
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
64
|
+
* Unlike `asNonNegativeInt32`, this is total: out-of-range inputs are clamped
|
|
65
|
+
* to the nearest representable `NonNegativeInt32` instead of throwing.
|
|
66
|
+
*
|
|
67
|
+
* @param value - The value to convert
|
|
68
|
+
* @returns The value as a `NonNegativeInt32`
|
|
63
69
|
*/
|
|
64
|
-
|
|
70
|
+
fromNumber,
|
|
65
71
|
/**
|
|
66
72
|
* Generates a random `NonNegativeInt32` within the given range.
|
|
67
73
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-negative-int32.mjs","sources":["../../../src/number/branded-types/non-negative-int32.mts"],"sourcesContent":["import { type NonNegativeInt32 as TtfImported_NonNegativeInt32 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonNegativeInt32 = TtfImported_NonNegativeInt32;\n\ntype ElementType = NonNegativeInt32;\n\nconst typeNameInMessage = 'a non-negative integer in [0, 2^31)';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n
|
|
1
|
+
{"version":3,"file":"non-negative-int32.mjs","sources":["../../../src/number/branded-types/non-negative-int32.mts"],"sourcesContent":["import { type NonNegativeInt32 as TtfImported_NonNegativeInt32 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonNegativeInt32 = TtfImported_NonNegativeInt32;\n\ntype ElementType = NonNegativeInt32;\n\nconst typeNameInMessage = 'a non-negative integer in [0, 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 0,\n number\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 0,\n MAX_VALUE: 2 ** 31 - 1,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a non-negative integer in [0, 2^31).\n *\n * Returns `true` for a non-negative integer in [0, 2^31) — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-negative integer in [0, 2^31), `false` otherwise\n */\nexport const isNonNegativeInt32 = is;\n\n/**\n * Casts a `number` to the `NonNegativeInt32` branded type.\n *\n * Validates that the value is a non-negative integer in [0, 2^31) and returns\n * it with the `NonNegativeInt32` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonNegativeInt32`\n * @throws {TypeError} If the value is not a non-negative integer in [0, 2^31)\n */\nexport const asNonNegativeInt32 = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonNegativeInt32` branded\n * type.\n *\n * The `NonNegativeInt32` type represents a non-negative integer in [0, 2^31).\n * Division (`div`) uses floor division.\n */\nexport const NonNegativeInt32 = {\n /**\n * Type guard that checks if a value is a non-negative integer in [0, 2^31).\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-negative integer in [0, 2^31), `false` otherwise\n * @see {@link isNonNegativeInt32} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `NonNegativeInt32` (the lower\n * saturation target of `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `NonNegativeInt32` (the upper saturation\n * target of `fromNumber`).\n */\n MAX_VALUE,\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 a `NonNegativeInt32`\n */\n min: min_,\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 a `NonNegativeInt32`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `NonNegativeInt32`, rounding to the\n * nearest integer and saturating the result into the range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * Unlike `asNonNegativeInt32`, this is total: out-of-range inputs are clamped\n * to the nearest representable `NonNegativeInt32` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as a `NonNegativeInt32`\n */\n fromNumber,\n\n /**\n * Generates a random `NonNegativeInt32` 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 `NonNegativeInt32` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NonNegativeInt32`\n * (floored to an integer).\n *\n * @param a - The base non-negative integer\n * @param b - The exponent non-negative integer\n * @returns `a ** b` as a `NonNegativeInt32`\n */\n pow,\n\n /**\n * Adds two non-negative integers, returning `a + b` as a `NonNegativeInt32`.\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 a `NonNegativeInt32`\n */\n add,\n\n /**\n * Subtracts two non-negative integers, returning `a - b` as a\n * `NonNegativeInt32`.\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 a `NonNegativeInt32`\n */\n sub,\n\n /**\n * Multiplies two non-negative integers, returning `a * b` as a\n * `NonNegativeInt32`.\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 a `NonNegativeInt32`\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 a\n * `NonNegativeInt32`.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as a `NonNegativeInt32`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof NonNegativeInt32,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'non-negative' | 'range'\n >\n>('=');\n\nexpectType<\n typeof NonNegativeInt32,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'non-negative' | 'range'\n >\n>('<=');\n"],"names":[],"mappings":";;AAQA,MAAM,iBAAA,GAAoB,qCAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,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,kBAAA,GAAqB;AAY3B,MAAM,kBAAA,GAAqB;AAS3B,MAAM,gBAAA,GAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ9B,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;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA;AACF;;;;"}
|
|
@@ -49,7 +49,8 @@ export declare const NonPositiveFiniteNumber: {
|
|
|
49
49
|
*/
|
|
50
50
|
readonly is: (a: number) => a is TtfImported_NonPositiveFiniteNumber;
|
|
51
51
|
/**
|
|
52
|
-
* The largest value representable as `NonPositiveFiniteNumber
|
|
52
|
+
* The largest value representable as `NonPositiveFiniteNumber` (the upper
|
|
53
|
+
* saturation target of `fromNumber`).
|
|
53
54
|
*/
|
|
54
55
|
readonly MAX_VALUE: 0;
|
|
55
56
|
/**
|
|
@@ -67,13 +68,17 @@ export declare const NonPositiveFiniteNumber: {
|
|
|
67
68
|
*/
|
|
68
69
|
readonly max: (...values: readonly TtfImported_NonPositiveFiniteNumber[]) => TtfImported_NonPositiveFiniteNumber;
|
|
69
70
|
/**
|
|
70
|
-
*
|
|
71
|
-
* MAX_VALUE]`.
|
|
71
|
+
* Converts an arbitrary `number` into a `NonPositiveFiniteNumber`, saturating
|
|
72
|
+
* it into the range `[MIN_VALUE, MAX_VALUE]`.
|
|
72
73
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
74
|
+
* Unlike `asNonPositiveFiniteNumber`, this is total: out-of-range inputs are
|
|
75
|
+
* clamped to the nearest representable `NonPositiveFiniteNumber` instead of
|
|
76
|
+
* throwing.
|
|
77
|
+
*
|
|
78
|
+
* @param value - The value to convert
|
|
79
|
+
* @returns The value as a `NonPositiveFiniteNumber`
|
|
75
80
|
*/
|
|
76
|
-
readonly
|
|
81
|
+
readonly fromNumber: (x: number) => TtfImported_NonPositiveFiniteNumber;
|
|
77
82
|
/**
|
|
78
83
|
* Returns the greatest integer less than or equal to a non-positive finite
|
|
79
84
|
* number.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-positive-finite-number.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-positive-finite-number.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,uBAAuB,IAAI,mCAAmC,EAAE,MAAM,eAAe,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,MAAM,uBAAuB,GAAG,mCAAmC,CAAC;AAE1E,KAAK,WAAW,GAAG,uBAAuB,CAAC;AA2D3C;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,yDAAK,CAAC;AAE5C;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;MAAW,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;IAClC;;;;;;OAMG;;IAGH;;
|
|
1
|
+
{"version":3,"file":"non-positive-finite-number.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-positive-finite-number.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,uBAAuB,IAAI,mCAAmC,EAAE,MAAM,eAAe,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,MAAM,uBAAuB,GAAG,mCAAmC,CAAC;AAE1E,KAAK,WAAW,GAAG,uBAAuB,CAAC;AA2D3C;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,yDAAK,CAAC;AAE5C;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;MAAW,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;IAClC;;;;;;OAMG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;OAMG;wBAjHA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,qBAAqB,CAC9D,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,CAC3D;IAiHC;;;;;;OAMG;uBA9GA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,qBAAqB,CAC9D,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,CAC3D;IA8GC;;;;;;OAMG;wBA7GA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,qBAAqB,CAC9D,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,CAC3D;IA6GC;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;CAEK,CAAC"}
|
|
@@ -5,7 +5,7 @@ const {
|
|
|
5
5
|
MAX_VALUE,
|
|
6
6
|
add,
|
|
7
7
|
castType,
|
|
8
|
-
|
|
8
|
+
fromNumber,
|
|
9
9
|
is,
|
|
10
10
|
max: max_,
|
|
11
11
|
min: min_,
|
|
@@ -45,7 +45,8 @@ const NonPositiveFiniteNumber = {
|
|
|
45
45
|
*/
|
|
46
46
|
is,
|
|
47
47
|
/**
|
|
48
|
-
* The largest value representable as `NonPositiveFiniteNumber
|
|
48
|
+
* The largest value representable as `NonPositiveFiniteNumber` (the upper
|
|
49
|
+
* saturation target of `fromNumber`).
|
|
49
50
|
*/
|
|
50
51
|
MAX_VALUE,
|
|
51
52
|
/**
|
|
@@ -63,13 +64,17 @@ const NonPositiveFiniteNumber = {
|
|
|
63
64
|
*/
|
|
64
65
|
max: max_,
|
|
65
66
|
/**
|
|
66
|
-
*
|
|
67
|
-
* MAX_VALUE]`.
|
|
67
|
+
* Converts an arbitrary `number` into a `NonPositiveFiniteNumber`, saturating
|
|
68
|
+
* it into the range `[MIN_VALUE, MAX_VALUE]`.
|
|
68
69
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
70
|
+
* Unlike `asNonPositiveFiniteNumber`, this is total: out-of-range inputs are
|
|
71
|
+
* clamped to the nearest representable `NonPositiveFiniteNumber` instead of
|
|
72
|
+
* throwing.
|
|
73
|
+
*
|
|
74
|
+
* @param value - The value to convert
|
|
75
|
+
* @returns The value as a `NonPositiveFiniteNumber`
|
|
71
76
|
*/
|
|
72
|
-
|
|
77
|
+
fromNumber,
|
|
73
78
|
/**
|
|
74
79
|
* Returns the greatest integer less than or equal to a non-positive finite
|
|
75
80
|
* number.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-positive-finite-number.mjs","sources":["../../../src/number/branded-types/non-positive-finite-number.mts"],"sourcesContent":["import { type NonPositiveFiniteNumber as TtfImported_NonPositiveFiniteNumber } from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonPositiveFiniteNumber = TtfImported_NonPositiveFiniteNumber;\n\ntype ElementType = NonPositiveFiniteNumber;\n\nconst typeNameInMessage = 'a non-positive finite number';\n\nconst {\n MAX_VALUE,\n add,\n castType,\n
|
|
1
|
+
{"version":3,"file":"non-positive-finite-number.mjs","sources":["../../../src/number/branded-types/non-positive-finite-number.mts"],"sourcesContent":["import { type NonPositiveFiniteNumber as TtfImported_NonPositiveFiniteNumber } from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonPositiveFiniteNumber = TtfImported_NonPositiveFiniteNumber;\n\ntype ElementType = NonPositiveFiniteNumber;\n\nconst typeNameInMessage = 'a non-positive finite number';\n\nconst {\n MAX_VALUE,\n add,\n castType,\n fromNumber,\n is,\n max: max_,\n min: min_,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForFloat<\n ElementType,\n number,\n 0\n>({\n MIN_VALUE: Number.MAX_VALUE * -1,\n MAX_VALUE: 0,\n typeNameInMessage,\n} as const);\n\nconst floor = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.floor(\n x,\n ) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\nconst ceil = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.ceil(x) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\nconst round = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.round(\n x,\n ) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\n/**\n * Type guard that checks if a value is a non-positive finite number.\n *\n * Returns `true` only for a finite value — never `NaN`, `Infinity`, or\n * `-Infinity`.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-positive finite number, `false` otherwise\n */\nexport const isNonPositiveFiniteNumber = is;\n\n/**\n * Casts a `number` to the `NonPositiveFiniteNumber` branded type.\n *\n * Validates that the value is a non-positive finite number and returns it with\n * the `NonPositiveFiniteNumber` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonPositiveFiniteNumber`\n * @throws {TypeError} If the value is not a non-positive finite number\n */\nexport const asNonPositiveFiniteNumber = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonPositiveFiniteNumber`\n * branded type.\n *\n * The `NonPositiveFiniteNumber` type represents a non-positive finite number.\n */\nexport const NonPositiveFiniteNumber = {\n /**\n * Type guard that checks if a value is a non-positive finite number.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-positive finite number, `false` otherwise\n * @see {@link isNonPositiveFiniteNumber} for usage examples\n */\n is,\n\n /**\n * The largest value representable as `NonPositiveFiniteNumber` (the upper\n * saturation target of `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given non-positive finite numbers.\n *\n * @param values - The non-positive finite numbers to compare (at least one required)\n * @returns The smallest value as a `NonPositiveFiniteNumber`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-positive finite numbers.\n *\n * @param values - The non-positive finite numbers to compare (at least one required)\n * @returns The largest value as a `NonPositiveFiniteNumber`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `NonPositiveFiniteNumber`, saturating\n * it into the range `[MIN_VALUE, MAX_VALUE]`.\n *\n * Unlike `asNonPositiveFiniteNumber`, this is total: out-of-range inputs are\n * clamped to the nearest representable `NonPositiveFiniteNumber` instead of\n * throwing.\n *\n * @param value - The value to convert\n * @returns The value as a `NonPositiveFiniteNumber`\n */\n fromNumber,\n\n /**\n * Returns the greatest integer less than or equal to a non-positive finite\n * number.\n *\n * @param a - The non-positive finite number value\n * @returns The floored value as an integer\n */\n floor,\n\n /**\n * Returns the smallest integer greater than or equal to a non-positive finite\n * number.\n *\n * @param a - The non-positive finite number value\n * @returns The ceiled value as an integer\n */\n ceil,\n\n /**\n * Returns the value of a non-positive finite number rounded to the nearest\n * integer.\n *\n * @param a - The non-positive finite number value\n * @returns The rounded value as an integer\n */\n round,\n\n /**\n * Generates a random `NonPositiveFiniteNumber` 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 `NonPositiveFiniteNumber` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a\n * `NonPositiveFiniteNumber`.\n *\n * @param a - The base non-positive finite number\n * @param b - The exponent non-positive finite number\n * @returns `a ** b` as a `NonPositiveFiniteNumber`\n */\n pow,\n\n /**\n * Adds two non-positive finite numbers, returning `a + b` as a\n * `NonPositiveFiniteNumber`.\n *\n * @param a - The first non-positive finite number\n * @param b - The second non-positive finite number\n * @returns The sum of `a` and `b` as a `NonPositiveFiniteNumber`\n */\n add,\n\n /**\n * Subtracts two non-positive finite numbers, returning `a - b` as a\n * `NonPositiveFiniteNumber`.\n *\n * @param a - The first non-positive finite number\n * @param b - The second non-positive finite number\n * @returns The difference of `a` and `b` as a `NonPositiveFiniteNumber`\n */\n sub,\n} as const;\n"],"names":[],"mappings":";;AAOA,MAAM,iBAAA,GAAoB,8BAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,iBAAA,CAI1C;AAAA,EACA,SAAA,EAAW,OAAO,SAAA,GAAY,EAAA;AAAA,EAC9B,SAAA,EAAW,CAAA;AAAA,EACX;AACF,CAAU,CAAA;AAEV,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAA;AAAA,IACH;AAAA;AACF,CAAA;AAIF,MAAM,OAAO,CACX,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAK,CAAC;AAAA,CAAA;AAIb,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAA;AAAA,IACH;AAAA;AACF,CAAA;AAaK,MAAM,yBAAA,GAA4B;AAYlC,MAAM,yBAAA,GAA4B;AAQlC,MAAM,uBAAA,GAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQrC,EAAA;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,EASA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AACF;;;;"}
|
|
@@ -54,7 +54,8 @@ export declare const NonPositiveInt: {
|
|
|
54
54
|
*/
|
|
55
55
|
readonly is: (a: number) => a is TtfImported_NonPositiveInt;
|
|
56
56
|
/**
|
|
57
|
-
* The largest value representable as `NonPositiveInt
|
|
57
|
+
* The largest value representable as `NonPositiveInt` (the upper saturation
|
|
58
|
+
* target of `fromNumber`).
|
|
58
59
|
*/
|
|
59
60
|
readonly MAX_VALUE: 0;
|
|
60
61
|
/**
|
|
@@ -72,13 +73,17 @@ export declare const NonPositiveInt: {
|
|
|
72
73
|
*/
|
|
73
74
|
readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>[]) => TtfImported_NonPositiveInt;
|
|
74
75
|
/**
|
|
75
|
-
*
|
|
76
|
-
* integer and
|
|
76
|
+
* Converts an arbitrary `number` into a `NonPositiveInt`, rounding to the
|
|
77
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
78
|
+
* MAX_VALUE]`.
|
|
77
79
|
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
+
* Unlike `asNonPositiveInt`, this is total: out-of-range inputs are clamped
|
|
81
|
+
* to the nearest representable `NonPositiveInt` instead of throwing.
|
|
82
|
+
*
|
|
83
|
+
* @param value - The value to convert
|
|
84
|
+
* @returns The value as a `NonPositiveInt`
|
|
80
85
|
*/
|
|
81
|
-
readonly
|
|
86
|
+
readonly fromNumber: (x: number) => TtfImported_NonPositiveInt;
|
|
82
87
|
/**
|
|
83
88
|
* Generates a random `NonPositiveInt` within the given range.
|
|
84
89
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-positive-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-positive-int.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,IAAI,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAGlF,MAAM,MAAM,cAAc,GAAG,0BAA0B,CAAC;AA4BxD;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,gDAAK,CAAC;AAEnC;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;MAAW,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc;IACzB;;;;;;OAMG;;IAGH;;
|
|
1
|
+
{"version":3,"file":"non-positive-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-positive-int.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,IAAI,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAGlF,MAAM,MAAM,cAAc,GAAG,0BAA0B,CAAC;AA4BxD;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,gDAAK,CAAC;AAEnC;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;MAAW,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc;IACzB;;;;;;OAMG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;OAOG;;CAEK,CAAC"}
|
|
@@ -5,7 +5,7 @@ const {
|
|
|
5
5
|
MAX_VALUE,
|
|
6
6
|
add,
|
|
7
7
|
castType,
|
|
8
|
-
|
|
8
|
+
fromNumber,
|
|
9
9
|
is,
|
|
10
10
|
max: max_,
|
|
11
11
|
min: min_,
|
|
@@ -30,7 +30,8 @@ const NonPositiveInt = {
|
|
|
30
30
|
*/
|
|
31
31
|
is,
|
|
32
32
|
/**
|
|
33
|
-
* The largest value representable as `NonPositiveInt
|
|
33
|
+
* The largest value representable as `NonPositiveInt` (the upper saturation
|
|
34
|
+
* target of `fromNumber`).
|
|
34
35
|
*/
|
|
35
36
|
MAX_VALUE,
|
|
36
37
|
/**
|
|
@@ -48,13 +49,17 @@ const NonPositiveInt = {
|
|
|
48
49
|
*/
|
|
49
50
|
max: max_,
|
|
50
51
|
/**
|
|
51
|
-
*
|
|
52
|
-
* integer and
|
|
52
|
+
* Converts an arbitrary `number` into a `NonPositiveInt`, rounding to the
|
|
53
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
54
|
+
* MAX_VALUE]`.
|
|
53
55
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
+
* Unlike `asNonPositiveInt`, this is total: out-of-range inputs are clamped
|
|
57
|
+
* to the nearest representable `NonPositiveInt` instead of throwing.
|
|
58
|
+
*
|
|
59
|
+
* @param value - The value to convert
|
|
60
|
+
* @returns The value as a `NonPositiveInt`
|
|
56
61
|
*/
|
|
57
|
-
|
|
62
|
+
fromNumber,
|
|
58
63
|
/**
|
|
59
64
|
* Generates a random `NonPositiveInt` within the given range.
|
|
60
65
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-positive-int.mjs","sources":["../../../src/number/branded-types/non-positive-int.mts"],"sourcesContent":["import { type NonPositiveInt as TtfImported_NonPositiveInt } from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonPositiveInt = TtfImported_NonPositiveInt;\n\ntype ElementType = NonPositiveInt;\n\nconst typeNameInMessage = 'a non-positive integer';\n\nconst {\n MAX_VALUE,\n add,\n castType,\n
|
|
1
|
+
{"version":3,"file":"non-positive-int.mjs","sources":["../../../src/number/branded-types/non-positive-int.mts"],"sourcesContent":["import { type NonPositiveInt as TtfImported_NonPositiveInt } from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonPositiveInt = TtfImported_NonPositiveInt;\n\ntype ElementType = NonPositiveInt;\n\nconst typeNameInMessage = 'a non-positive integer';\n\nconst {\n MAX_VALUE,\n add,\n castType,\n fromNumber,\n is,\n max: max_,\n min: min_,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n number,\n 0\n>({\n integerOrSafeInteger: 'Integer',\n MIN_VALUE: -Number.MAX_VALUE,\n MAX_VALUE: 0,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a non-positive integer.\n *\n * Returns `true` for a non-positive integer — a value with no fractional\n * component, including values outside the safe integer range (unlike\n * `SafeInt`).\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-positive integer, `false` otherwise\n */\nexport const isNonPositiveInt = is;\n\n/**\n * Casts a `number` to the `NonPositiveInt` branded type.\n *\n * Validates that the value is a non-positive integer and returns it with the\n * `NonPositiveInt` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonPositiveInt`\n * @throws {TypeError} If the value is not a non-positive integer\n */\nexport const asNonPositiveInt = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonPositiveInt` branded\n * type.\n *\n * The `NonPositiveInt` type represents a non-positive integer. Division (`div`)\n * uses floor division.\n *\n * Unlike `SafeInt`, `NonPositiveInt` allows values outside the safe integer\n * range (±2^53 − 1), so very large magnitudes may lose precision in\n * JavaScript's `number` type.\n */\nexport const NonPositiveInt = {\n /**\n * Type guard that checks if a value is a non-positive integer.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-positive integer, `false` otherwise\n * @see {@link isNonPositiveInt} for usage examples\n */\n is,\n\n /**\n * The largest value representable as `NonPositiveInt` (the upper saturation\n * target of `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given non-positive integers.\n *\n * @param values - The non-positive integers to compare (at least one required)\n * @returns The smallest value as a `NonPositiveInt`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-positive integers.\n *\n * @param values - The non-positive integers to compare (at least one required)\n * @returns The largest value as a `NonPositiveInt`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `NonPositiveInt`, rounding to the\n * nearest integer and saturating the result into the range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * Unlike `asNonPositiveInt`, this is total: out-of-range inputs are clamped\n * to the nearest representable `NonPositiveInt` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as a `NonPositiveInt`\n */\n fromNumber,\n\n /**\n * Generates a random `NonPositiveInt` 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 `NonPositiveInt` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NonPositiveInt`\n * (floored to an integer).\n *\n * @param a - The base non-positive integer\n * @param b - The exponent non-positive integer\n * @returns `a ** b` as a `NonPositiveInt`\n */\n pow,\n\n /**\n * Adds two non-positive integers, returning `a + b` as a `NonPositiveInt`.\n *\n * @param a - The first non-positive integer\n * @param b - The second non-positive integer\n * @returns The sum of `a` and `b` as a `NonPositiveInt`\n */\n add,\n\n /**\n * Subtracts two non-positive integers, returning `a - b` as a\n * `NonPositiveInt`.\n *\n * @param a - The first non-positive integer\n * @param b - The second non-positive integer\n * @returns The difference of `a` and `b` as a `NonPositiveInt`\n */\n sub,\n} as const;\n"],"names":[],"mappings":";;AAOA,MAAM,iBAAA,GAAoB,wBAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,SAAA;AAAA,EACtB,SAAA,EAAW,CAAC,MAAA,CAAO,SAAA;AAAA,EACnB,SAAA,EAAW,CAAA;AAAA,EACX;AACF,CAAU,CAAA;AAYH,MAAM,gBAAA,GAAmB;AAYzB,MAAM,gBAAA,GAAmB;AAazB,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;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;AAAA,EAUA;AACF;;;;"}
|
|
@@ -50,11 +50,13 @@ export declare const NonPositiveSafeInt: {
|
|
|
50
50
|
*/
|
|
51
51
|
readonly is: (a: number) => a is TtfImported_NonPositiveSafeInt;
|
|
52
52
|
/**
|
|
53
|
-
* The smallest value representable as `NonPositiveSafeInt
|
|
53
|
+
* The smallest value representable as `NonPositiveSafeInt` (the lower
|
|
54
|
+
* saturation target of `fromNumber`).
|
|
54
55
|
*/
|
|
55
56
|
readonly MIN_VALUE: number;
|
|
56
57
|
/**
|
|
57
|
-
* The largest value representable as `NonPositiveSafeInt
|
|
58
|
+
* The largest value representable as `NonPositiveSafeInt` (the upper
|
|
59
|
+
* saturation target of `fromNumber`).
|
|
58
60
|
*/
|
|
59
61
|
readonly MAX_VALUE: 0;
|
|
60
62
|
/**
|
|
@@ -72,13 +74,18 @@ export declare const NonPositiveSafeInt: {
|
|
|
72
74
|
*/
|
|
73
75
|
readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveSafeInt>[]) => TtfImported_NonPositiveSafeInt;
|
|
74
76
|
/**
|
|
75
|
-
*
|
|
76
|
-
* nearest integer and
|
|
77
|
+
* Converts an arbitrary `number` into a `NonPositiveSafeInt`, rounding to the
|
|
78
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
79
|
+
* MAX_VALUE]`.
|
|
77
80
|
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
81
|
+
* Unlike `asNonPositiveSafeInt`, this is total: out-of-range inputs are
|
|
82
|
+
* clamped to the nearest representable `NonPositiveSafeInt` instead of
|
|
83
|
+
* throwing.
|
|
84
|
+
*
|
|
85
|
+
* @param value - The value to convert
|
|
86
|
+
* @returns The value as a `NonPositiveSafeInt`
|
|
80
87
|
*/
|
|
81
|
-
readonly
|
|
88
|
+
readonly fromNumber: (x: number) => TtfImported_NonPositiveSafeInt;
|
|
82
89
|
/**
|
|
83
90
|
* Generates a random `NonPositiveSafeInt` within the given range.
|
|
84
91
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-positive-safe-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-positive-safe-int.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,IAAI,8BAA8B,EAAE,MAAM,eAAe,CAAC;AAG1F,MAAM,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AA6BhE;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,oDAAK,CAAC;AAEvC;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;MAAW,CAAC;AAE7C;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;IAC7B;;;;;;OAMG;;IAGH;;
|
|
1
|
+
{"version":3,"file":"non-positive-safe-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-positive-safe-int.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,IAAI,8BAA8B,EAAE,MAAM,eAAe,CAAC;AAG1F,MAAM,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AA6BhE;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,oDAAK,CAAC;AAEvC;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;MAAW,CAAC;AAE7C;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;IAC7B;;;;;;OAMG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;;OAWG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;OAOG;;CAEK,CAAC"}
|
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
MIN_VALUE,
|
|
7
7
|
add,
|
|
8
8
|
castType,
|
|
9
|
-
|
|
9
|
+
fromNumber,
|
|
10
10
|
is,
|
|
11
11
|
max: max_,
|
|
12
12
|
min: min_,
|
|
@@ -31,11 +31,13 @@ const NonPositiveSafeInt = {
|
|
|
31
31
|
*/
|
|
32
32
|
is,
|
|
33
33
|
/**
|
|
34
|
-
* The smallest value representable as `NonPositiveSafeInt
|
|
34
|
+
* The smallest value representable as `NonPositiveSafeInt` (the lower
|
|
35
|
+
* saturation target of `fromNumber`).
|
|
35
36
|
*/
|
|
36
37
|
MIN_VALUE,
|
|
37
38
|
/**
|
|
38
|
-
* The largest value representable as `NonPositiveSafeInt
|
|
39
|
+
* The largest value representable as `NonPositiveSafeInt` (the upper
|
|
40
|
+
* saturation target of `fromNumber`).
|
|
39
41
|
*/
|
|
40
42
|
MAX_VALUE,
|
|
41
43
|
/**
|
|
@@ -53,13 +55,18 @@ const NonPositiveSafeInt = {
|
|
|
53
55
|
*/
|
|
54
56
|
max: max_,
|
|
55
57
|
/**
|
|
56
|
-
*
|
|
57
|
-
* nearest integer and
|
|
58
|
+
* Converts an arbitrary `number` into a `NonPositiveSafeInt`, rounding to the
|
|
59
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
60
|
+
* MAX_VALUE]`.
|
|
58
61
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
62
|
+
* Unlike `asNonPositiveSafeInt`, this is total: out-of-range inputs are
|
|
63
|
+
* clamped to the nearest representable `NonPositiveSafeInt` instead of
|
|
64
|
+
* throwing.
|
|
65
|
+
*
|
|
66
|
+
* @param value - The value to convert
|
|
67
|
+
* @returns The value as a `NonPositiveSafeInt`
|
|
61
68
|
*/
|
|
62
|
-
|
|
69
|
+
fromNumber,
|
|
63
70
|
/**
|
|
64
71
|
* Generates a random `NonPositiveSafeInt` within the given range.
|
|
65
72
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-positive-safe-int.mjs","sources":["../../../src/number/branded-types/non-positive-safe-int.mts"],"sourcesContent":["import { type NonPositiveSafeInt as TtfImported_NonPositiveSafeInt } from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonPositiveSafeInt = TtfImported_NonPositiveSafeInt;\n\ntype ElementType = NonPositiveSafeInt;\n\nconst typeNameInMessage = 'a non-positive safe integer';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n
|
|
1
|
+
{"version":3,"file":"non-positive-safe-int.mjs","sources":["../../../src/number/branded-types/non-positive-safe-int.mts"],"sourcesContent":["import { type NonPositiveSafeInt as TtfImported_NonPositiveSafeInt } from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonPositiveSafeInt = TtfImported_NonPositiveSafeInt;\n\ntype ElementType = NonPositiveSafeInt;\n\nconst typeNameInMessage = 'a non-positive safe integer';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n fromNumber,\n is,\n max: max_,\n min: min_,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n number,\n 0\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: Number.MIN_SAFE_INTEGER,\n MAX_VALUE: 0,\n typeNameInMessage,\n} as const);\n\n/**\n * Type guard that checks if a value is a non-positive safe integer.\n *\n * Returns `true` for a non-positive safe integer — a value with no fractional\n * component.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-positive safe integer, `false` otherwise\n */\nexport const isNonPositiveSafeInt = is;\n\n/**\n * Casts a `number` to the `NonPositiveSafeInt` branded type.\n *\n * Validates that the value is a non-positive safe integer and returns it with\n * the `NonPositiveSafeInt` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonPositiveSafeInt`\n * @throws {TypeError} If the value is not a non-positive safe integer\n */\nexport const asNonPositiveSafeInt = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonPositiveSafeInt` branded\n * type.\n *\n * The `NonPositiveSafeInt` type represents a non-positive safe integer.\n * Division (`div`) uses floor division.\n */\nexport const NonPositiveSafeInt = {\n /**\n * Type guard that checks if a value is a non-positive safe integer.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-positive safe integer, `false` otherwise\n * @see {@link isNonPositiveSafeInt} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `NonPositiveSafeInt` (the lower\n * saturation target of `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `NonPositiveSafeInt` (the upper\n * saturation target of `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given non-positive safe integers.\n *\n * @param values - The non-positive safe integers to compare (at least one required)\n * @returns The smallest value as a `NonPositiveSafeInt`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-positive safe integers.\n *\n * @param values - The non-positive safe integers to compare (at least one required)\n * @returns The largest value as a `NonPositiveSafeInt`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into a `NonPositiveSafeInt`, rounding to the\n * nearest integer and saturating the result into the range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * Unlike `asNonPositiveSafeInt`, this is total: out-of-range inputs are\n * clamped to the nearest representable `NonPositiveSafeInt` instead of\n * throwing.\n *\n * @param value - The value to convert\n * @returns The value as a `NonPositiveSafeInt`\n */\n fromNumber,\n\n /**\n * Generates a random `NonPositiveSafeInt` 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 `NonPositiveSafeInt` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a `NonPositiveSafeInt`\n * (floored to an integer).\n *\n * @param a - The base non-positive safe integer\n * @param b - The exponent non-positive safe integer\n * @returns `a ** b` as a `NonPositiveSafeInt`\n */\n pow,\n\n /**\n * Adds two non-positive safe integers, returning `a + b` as a\n * `NonPositiveSafeInt`.\n *\n * @param a - The first non-positive safe integer\n * @param b - The second non-positive safe integer\n * @returns The sum of `a` and `b` as a `NonPositiveSafeInt`\n */\n add,\n\n /**\n * Subtracts two non-positive safe integers, returning `a - b` as a\n * `NonPositiveSafeInt`.\n *\n * @param a - The first non-positive safe integer\n * @param b - The second non-positive safe integer\n * @returns The difference of `a` and `b` as a `NonPositiveSafeInt`\n */\n sub,\n} as const;\n"],"names":[],"mappings":";;AAOA,MAAM,iBAAA,GAAoB,6BAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,WAAW,MAAA,CAAO,gBAAA;AAAA,EAClB,SAAA,EAAW,CAAA;AAAA,EACX;AACF,CAAU,CAAA;AAWH,MAAM,oBAAA,GAAuB;AAY7B,MAAM,oBAAA,GAAuB;AAS7B,MAAM,kBAAA,GAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhC,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;AAAA,EAcL,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AACF;;;;"}
|
|
@@ -53,11 +53,13 @@ export declare const NonZeroInt16: {
|
|
|
53
53
|
*/
|
|
54
54
|
readonly is: (a: number) => a is TtfImported_NonZeroInt16;
|
|
55
55
|
/**
|
|
56
|
-
* The smallest value representable as `NonZeroInt16
|
|
56
|
+
* The smallest value representable as `NonZeroInt16` (the lower saturation
|
|
57
|
+
* target of `fromNumber`).
|
|
57
58
|
*/
|
|
58
59
|
readonly MIN_VALUE: number;
|
|
59
60
|
/**
|
|
60
|
-
* The largest value representable as `NonZeroInt16
|
|
61
|
+
* The largest value representable as `NonZeroInt16` (the upper saturation
|
|
62
|
+
* target of `fromNumber`).
|
|
61
63
|
*/
|
|
62
64
|
readonly MAX_VALUE: number;
|
|
63
65
|
/**
|
|
@@ -84,13 +86,17 @@ export declare const NonZeroInt16: {
|
|
|
84
86
|
*/
|
|
85
87
|
readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_NonZeroInt16>[]) => TtfImported_NonZeroInt16;
|
|
86
88
|
/**
|
|
87
|
-
*
|
|
88
|
-
* integer and
|
|
89
|
+
* Converts an arbitrary `number` into a `NonZeroInt16`, rounding to the
|
|
90
|
+
* nearest integer and saturating the result into the range `[MIN_VALUE,
|
|
91
|
+
* MAX_VALUE]`.
|
|
89
92
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
93
|
+
* Unlike `asNonZeroInt16`, this is total: out-of-range inputs are clamped to
|
|
94
|
+
* the nearest representable `NonZeroInt16` instead of throwing.
|
|
95
|
+
*
|
|
96
|
+
* @param value - The value to convert
|
|
97
|
+
* @returns The value as a `NonZeroInt16`
|
|
92
98
|
*/
|
|
93
|
-
readonly
|
|
99
|
+
readonly fromNumber: (x: number) => TtfImported_NonZeroInt16;
|
|
94
100
|
/**
|
|
95
101
|
* Generates a random `NonZeroInt16` within the given range.
|
|
96
102
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-zero-int16.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-zero-int16.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,IAAI,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAI9E,MAAM,MAAM,YAAY,GAAG,wBAAwB,CAAC;AA8BpD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,8CAAK,CAAC;AAEjC;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;MAAW,CAAC;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,YAAY;IACvB;;;;;;OAMG;;IAGH;;
|
|
1
|
+
{"version":3,"file":"non-zero-int16.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-zero-int16.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,IAAI,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAI9E,MAAM,MAAM,YAAY,GAAG,wBAAwB,CAAC;AA8BpD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,8CAAK,CAAC;AAEjC;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;MAAW,CAAC;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,YAAY;IACvB;;;;;;OAMG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;;;;OAOG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;CAEK,CAAC"}
|