ts-data-forge 1.0.0 → 1.0.1
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 +1 -1
- package/dist/array/array-utils.d.mts +2617 -0
- package/dist/array/array-utils.d.mts.map +1 -0
- package/dist/array/array-utils.mjs +2915 -0
- package/dist/array/array-utils.mjs.map +1 -0
- package/dist/array/index.d.mts +3 -0
- package/dist/array/index.d.mts.map +1 -0
- package/dist/array/index.mjs +3 -0
- package/dist/array/index.mjs.map +1 -0
- package/dist/array/tuple-utils.d.mts +421 -0
- package/dist/array/tuple-utils.d.mts.map +1 -0
- package/dist/array/tuple-utils.mjs +391 -0
- package/dist/array/tuple-utils.mjs.map +1 -0
- package/dist/collections/imap-mapped.d.mts +445 -0
- package/dist/collections/imap-mapped.d.mts.map +1 -0
- package/dist/collections/imap-mapped.mjs +424 -0
- package/dist/collections/imap-mapped.mjs.map +1 -0
- package/dist/collections/imap.d.mts +359 -0
- package/dist/collections/imap.d.mts.map +1 -0
- package/dist/collections/imap.mjs +338 -0
- package/dist/collections/imap.mjs.map +1 -0
- package/dist/collections/index.d.mts +7 -0
- package/dist/collections/index.d.mts.map +1 -0
- package/dist/collections/index.mjs +7 -0
- package/dist/collections/index.mjs.map +1 -0
- package/dist/collections/iset-mapped.d.mts +576 -0
- package/dist/collections/iset-mapped.d.mts.map +1 -0
- package/dist/collections/iset-mapped.mjs +522 -0
- package/dist/collections/iset-mapped.mjs.map +1 -0
- package/dist/collections/iset.d.mts +426 -0
- package/dist/collections/iset.d.mts.map +1 -0
- package/dist/collections/iset.mjs +437 -0
- package/dist/collections/iset.mjs.map +1 -0
- package/dist/collections/queue.d.mts +190 -0
- package/dist/collections/queue.d.mts.map +1 -0
- package/dist/collections/queue.mjs +317 -0
- package/dist/collections/queue.mjs.map +1 -0
- package/dist/collections/stack.d.mts +210 -0
- package/dist/collections/stack.d.mts.map +1 -0
- package/dist/collections/stack.mjs +353 -0
- package/dist/collections/stack.mjs.map +1 -0
- package/dist/expect-type.d.mts +199 -0
- package/dist/expect-type.d.mts.map +1 -0
- package/dist/expect-type.mjs +201 -0
- package/dist/expect-type.mjs.map +1 -0
- package/dist/functional/index.d.mts +5 -0
- package/dist/functional/index.d.mts.map +1 -0
- package/dist/functional/index.mjs +5 -0
- package/dist/functional/index.mjs.map +1 -0
- package/dist/functional/match.d.mts +215 -0
- package/dist/functional/match.d.mts.map +1 -0
- package/dist/functional/match.mjs +139 -0
- package/dist/functional/match.mjs.map +1 -0
- package/dist/functional/optional.d.mts +517 -0
- package/dist/functional/optional.d.mts.map +1 -0
- package/dist/functional/optional.mjs +532 -0
- package/dist/functional/optional.mjs.map +1 -0
- package/dist/functional/pipe.d.mts +185 -0
- package/dist/functional/pipe.d.mts.map +1 -0
- package/dist/functional/pipe.mjs +129 -0
- package/dist/functional/pipe.mjs.map +1 -0
- package/dist/functional/result.d.mts +796 -0
- package/dist/functional/result.d.mts.map +1 -0
- package/dist/functional/result.mjs +844 -0
- package/dist/functional/result.mjs.map +1 -0
- package/dist/globals.d.mts +38 -0
- package/dist/guard/has-key.d.mts +100 -0
- package/dist/guard/has-key.d.mts.map +1 -0
- package/dist/guard/has-key.mjs +94 -0
- package/dist/guard/has-key.mjs.map +1 -0
- package/dist/guard/index.d.mts +8 -0
- package/dist/guard/index.d.mts.map +1 -0
- package/dist/guard/index.mjs +8 -0
- package/dist/guard/index.mjs.map +1 -0
- package/dist/guard/is-non-empty-string.d.mts +106 -0
- package/dist/guard/is-non-empty-string.d.mts.map +1 -0
- package/dist/guard/is-non-empty-string.mjs +108 -0
- package/dist/guard/is-non-empty-string.mjs.map +1 -0
- package/dist/guard/is-non-null-object.d.mts +105 -0
- package/dist/guard/is-non-null-object.d.mts.map +1 -0
- package/dist/guard/is-non-null-object.mjs +108 -0
- package/dist/guard/is-non-null-object.mjs.map +1 -0
- package/dist/guard/is-primitive.d.mts +146 -0
- package/dist/guard/is-primitive.d.mts.map +1 -0
- package/dist/guard/is-primitive.mjs +161 -0
- package/dist/guard/is-primitive.mjs.map +1 -0
- package/dist/guard/is-record.d.mts +151 -0
- package/dist/guard/is-record.d.mts.map +1 -0
- package/dist/guard/is-record.mjs +155 -0
- package/dist/guard/is-record.mjs.map +1 -0
- package/dist/guard/is-type.d.mts +430 -0
- package/dist/guard/is-type.d.mts.map +1 -0
- package/dist/guard/is-type.mjs +432 -0
- package/dist/guard/is-type.mjs.map +1 -0
- package/dist/guard/key-is-in.d.mts +158 -0
- package/dist/guard/key-is-in.d.mts.map +1 -0
- package/dist/guard/key-is-in.mjs +160 -0
- package/dist/guard/key-is-in.mjs.map +1 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +61 -0
- package/dist/index.mjs.map +1 -0
- package/dist/iterator/index.d.mts +2 -0
- package/dist/iterator/index.d.mts.map +1 -0
- package/dist/iterator/index.mjs +2 -0
- package/dist/iterator/index.mjs.map +1 -0
- package/dist/iterator/range.d.mts +97 -0
- package/dist/iterator/range.d.mts.map +1 -0
- package/dist/iterator/range.mjs +130 -0
- package/dist/iterator/range.mjs.map +1 -0
- package/dist/json/index.d.mts +2 -0
- package/dist/json/index.d.mts.map +1 -0
- package/dist/json/index.mjs +2 -0
- package/dist/json/index.mjs.map +1 -0
- package/dist/json/json.d.mts +597 -0
- package/dist/json/json.d.mts.map +1 -0
- package/dist/json/json.mjs +687 -0
- package/dist/json/json.mjs.map +1 -0
- package/dist/number/branded-types/finite-number.d.mts +291 -0
- package/dist/number/branded-types/finite-number.d.mts.map +1 -0
- package/dist/number/branded-types/finite-number.mjs +296 -0
- package/dist/number/branded-types/finite-number.mjs.map +1 -0
- package/dist/number/branded-types/index.d.mts +27 -0
- package/dist/number/branded-types/index.d.mts.map +1 -0
- package/dist/number/branded-types/index.mjs +27 -0
- package/dist/number/branded-types/index.mjs.map +1 -0
- package/dist/number/branded-types/int.d.mts +242 -0
- package/dist/number/branded-types/int.d.mts.map +1 -0
- package/dist/number/branded-types/int.mjs +239 -0
- package/dist/number/branded-types/int.mjs.map +1 -0
- package/dist/number/branded-types/int16.d.mts +162 -0
- package/dist/number/branded-types/int16.d.mts.map +1 -0
- package/dist/number/branded-types/int16.mjs +141 -0
- package/dist/number/branded-types/int16.mjs.map +1 -0
- package/dist/number/branded-types/int32.d.mts +155 -0
- package/dist/number/branded-types/int32.d.mts.map +1 -0
- package/dist/number/branded-types/int32.mjs +142 -0
- package/dist/number/branded-types/int32.mjs.map +1 -0
- package/dist/number/branded-types/non-negative-finite-number.d.mts +165 -0
- package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -0
- package/dist/number/branded-types/non-negative-finite-number.mjs +160 -0
- package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -0
- package/dist/number/branded-types/non-negative-int16.d.mts +160 -0
- package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -0
- package/dist/number/branded-types/non-negative-int16.mjs +138 -0
- package/dist/number/branded-types/non-negative-int16.mjs.map +1 -0
- package/dist/number/branded-types/non-negative-int32.d.mts +156 -0
- package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -0
- package/dist/number/branded-types/non-negative-int32.mjs +138 -0
- package/dist/number/branded-types/non-negative-int32.mjs.map +1 -0
- package/dist/number/branded-types/non-zero-finite-number.d.mts +154 -0
- package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -0
- package/dist/number/branded-types/non-zero-finite-number.mjs +160 -0
- package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -0
- package/dist/number/branded-types/non-zero-int.d.mts +131 -0
- package/dist/number/branded-types/non-zero-int.d.mts.map +1 -0
- package/dist/number/branded-types/non-zero-int.mjs +128 -0
- package/dist/number/branded-types/non-zero-int.mjs.map +1 -0
- package/dist/number/branded-types/non-zero-int16.d.mts +166 -0
- package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -0
- package/dist/number/branded-types/non-zero-int16.mjs +145 -0
- package/dist/number/branded-types/non-zero-int16.mjs.map +1 -0
- package/dist/number/branded-types/non-zero-int32.d.mts +158 -0
- package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -0
- package/dist/number/branded-types/non-zero-int32.mjs +145 -0
- package/dist/number/branded-types/non-zero-int32.mjs.map +1 -0
- package/dist/number/branded-types/non-zero-safe-int.d.mts +148 -0
- package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -0
- package/dist/number/branded-types/non-zero-safe-int.mjs +145 -0
- package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -0
- package/dist/number/branded-types/non-zero-uint16.d.mts +160 -0
- package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -0
- package/dist/number/branded-types/non-zero-uint16.mjs +140 -0
- package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -0
- package/dist/number/branded-types/non-zero-uint32.d.mts +156 -0
- package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -0
- package/dist/number/branded-types/non-zero-uint32.mjs +140 -0
- package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -0
- package/dist/number/branded-types/positive-finite-number.d.mts +171 -0
- package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -0
- package/dist/number/branded-types/positive-finite-number.mjs +165 -0
- package/dist/number/branded-types/positive-finite-number.mjs.map +1 -0
- package/dist/number/branded-types/positive-int.d.mts +270 -0
- package/dist/number/branded-types/positive-int.d.mts.map +1 -0
- package/dist/number/branded-types/positive-int.mjs +257 -0
- package/dist/number/branded-types/positive-int.mjs.map +1 -0
- package/dist/number/branded-types/positive-int16.d.mts +162 -0
- package/dist/number/branded-types/positive-int16.d.mts.map +1 -0
- package/dist/number/branded-types/positive-int16.mjs +139 -0
- package/dist/number/branded-types/positive-int16.mjs.map +1 -0
- package/dist/number/branded-types/positive-int32.d.mts +158 -0
- package/dist/number/branded-types/positive-int32.d.mts.map +1 -0
- package/dist/number/branded-types/positive-int32.mjs +139 -0
- package/dist/number/branded-types/positive-int32.mjs.map +1 -0
- package/dist/number/branded-types/positive-safe-int.d.mts +152 -0
- package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -0
- package/dist/number/branded-types/positive-safe-int.mjs +138 -0
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -0
- package/dist/number/branded-types/positive-uint16.d.mts +160 -0
- package/dist/number/branded-types/positive-uint16.d.mts.map +1 -0
- package/dist/number/branded-types/positive-uint16.mjs +139 -0
- package/dist/number/branded-types/positive-uint16.mjs.map +1 -0
- package/dist/number/branded-types/positive-uint32.d.mts +156 -0
- package/dist/number/branded-types/positive-uint32.d.mts.map +1 -0
- package/dist/number/branded-types/positive-uint32.mjs +139 -0
- package/dist/number/branded-types/positive-uint32.mjs.map +1 -0
- package/dist/number/branded-types/safe-int.d.mts +243 -0
- package/dist/number/branded-types/safe-int.d.mts.map +1 -0
- package/dist/number/branded-types/safe-int.mjs +240 -0
- package/dist/number/branded-types/safe-int.mjs.map +1 -0
- package/dist/number/branded-types/safe-uint.d.mts +151 -0
- package/dist/number/branded-types/safe-uint.d.mts.map +1 -0
- package/dist/number/branded-types/safe-uint.mjs +138 -0
- package/dist/number/branded-types/safe-uint.mjs.map +1 -0
- package/dist/number/branded-types/uint.d.mts +144 -0
- package/dist/number/branded-types/uint.d.mts.map +1 -0
- package/dist/number/branded-types/uint.mjs +132 -0
- package/dist/number/branded-types/uint.mjs.map +1 -0
- package/dist/number/branded-types/uint16.d.mts +157 -0
- package/dist/number/branded-types/uint16.d.mts.map +1 -0
- package/dist/number/branded-types/uint16.mjs +137 -0
- package/dist/number/branded-types/uint16.mjs.map +1 -0
- package/dist/number/branded-types/uint32.d.mts +185 -0
- package/dist/number/branded-types/uint32.d.mts.map +1 -0
- package/dist/number/branded-types/uint32.mjs +169 -0
- package/dist/number/branded-types/uint32.mjs.map +1 -0
- package/dist/number/enum/index.d.mts +3 -0
- package/dist/number/enum/index.d.mts.map +1 -0
- package/dist/number/enum/index.mjs +3 -0
- package/dist/number/enum/index.mjs.map +1 -0
- package/dist/number/enum/int8.d.mts +202 -0
- package/dist/number/enum/int8.d.mts.map +1 -0
- package/dist/number/enum/int8.mjs +296 -0
- package/dist/number/enum/int8.mjs.map +1 -0
- package/dist/number/enum/uint8.d.mts +128 -0
- package/dist/number/enum/uint8.d.mts.map +1 -0
- package/dist/number/enum/uint8.mjs +251 -0
- package/dist/number/enum/uint8.mjs.map +1 -0
- package/dist/number/index.d.mts +5 -0
- package/dist/number/index.d.mts.map +1 -0
- package/dist/number/index.mjs +31 -0
- package/dist/number/index.mjs.map +1 -0
- package/dist/number/num.d.mts +515 -0
- package/dist/number/num.d.mts.map +1 -0
- package/dist/number/num.mjs +513 -0
- package/dist/number/num.mjs.map +1 -0
- package/dist/number/refined-number-utils.d.mts +191 -0
- package/dist/number/refined-number-utils.d.mts.map +1 -0
- package/dist/number/refined-number-utils.mjs +179 -0
- package/dist/number/refined-number-utils.mjs.map +1 -0
- package/dist/object/index.d.mts +2 -0
- package/dist/object/index.d.mts.map +1 -0
- package/dist/object/index.mjs +2 -0
- package/dist/object/index.mjs.map +1 -0
- package/dist/object/object.d.mts +296 -0
- package/dist/object/object.d.mts.map +1 -0
- package/dist/object/object.mjs +295 -0
- package/dist/object/object.mjs.map +1 -0
- package/dist/others/cast-mutable.d.mts +110 -0
- package/dist/others/cast-mutable.d.mts.map +1 -0
- package/dist/others/cast-mutable.mjs +114 -0
- package/dist/others/cast-mutable.mjs.map +1 -0
- package/dist/others/cast-readonly.d.mts +189 -0
- package/dist/others/cast-readonly.d.mts.map +1 -0
- package/dist/others/cast-readonly.mjs +193 -0
- package/dist/others/cast-readonly.mjs.map +1 -0
- package/dist/others/if-then.d.mts +98 -0
- package/dist/others/if-then.d.mts.map +1 -0
- package/dist/others/if-then.mjs +100 -0
- package/dist/others/if-then.mjs.map +1 -0
- package/dist/others/index.d.mts +8 -0
- package/dist/others/index.d.mts.map +1 -0
- package/dist/others/index.mjs +8 -0
- package/dist/others/index.mjs.map +1 -0
- package/dist/others/map-nullable.d.mts +151 -0
- package/dist/others/map-nullable.d.mts.map +1 -0
- package/dist/others/map-nullable.mjs +159 -0
- package/dist/others/map-nullable.mjs.map +1 -0
- package/dist/others/memoize-function.d.mts +173 -0
- package/dist/others/memoize-function.d.mts.map +1 -0
- package/dist/others/memoize-function.mjs +189 -0
- package/dist/others/memoize-function.mjs.map +1 -0
- package/dist/others/tuple.d.mts +159 -0
- package/dist/others/tuple.d.mts.map +1 -0
- package/dist/others/tuple.mjs +161 -0
- package/dist/others/tuple.mjs.map +1 -0
- package/dist/others/unknown-to-string.d.mts +180 -0
- package/dist/others/unknown-to-string.d.mts.map +1 -0
- package/dist/others/unknown-to-string.mjs +211 -0
- package/dist/others/unknown-to-string.mjs.map +1 -0
- package/dist/tsconfig.json +1 -0
- package/package.json +16 -14
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { TsVerifiedInternals } from '../refined-number-utils.mjs';
|
|
2
|
+
|
|
3
|
+
const typeNameInMessage = 'a non-negative integer less than 2^16';
|
|
4
|
+
const { MIN_VALUE, MAX_VALUE, min: min_, max: max_, pow, add, sub, mul, div, random, is, castType, clamp, } = TsVerifiedInternals.RefinedNumberUtils.operatorsForInteger({
|
|
5
|
+
integerOrSafeInteger: 'SafeInteger',
|
|
6
|
+
MIN_VALUE: 0,
|
|
7
|
+
MAX_VALUE: 2 ** 16 - 1,
|
|
8
|
+
typeNameInMessage,
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a number is a Uint16 (16-bit unsigned integer in the range [0, 2^16)).
|
|
12
|
+
* @param value The value to check.
|
|
13
|
+
* @returns `true` if the value is a Uint16, `false` otherwise.
|
|
14
|
+
*/
|
|
15
|
+
const isUint16 = is;
|
|
16
|
+
/**
|
|
17
|
+
* Casts a number to a Uint16 type.
|
|
18
|
+
* @param value The value to cast.
|
|
19
|
+
* @returns The value as a Uint16 type.
|
|
20
|
+
* @throws {TypeError} If the value is not a non-negative integer less than 2^16.
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const x = asUint16(1000); // Uint16
|
|
24
|
+
* const y = asUint16(0); // Uint16
|
|
25
|
+
* // asUint16(-1); // throws TypeError
|
|
26
|
+
* // asUint16(70000); // throws TypeError
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
const asUint16 = castType;
|
|
30
|
+
/**
|
|
31
|
+
* Namespace providing type-safe arithmetic operations for 16-bit unsigned integers.
|
|
32
|
+
*
|
|
33
|
+
* All operations automatically clamp results to the valid Uint16 range [0, 65535].
|
|
34
|
+
* This ensures that all arithmetic maintains the 16-bit unsigned integer constraint,
|
|
35
|
+
* with negative results clamped to 0 and overflow results clamped to MAX_VALUE.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const a = asUint16(60000);
|
|
40
|
+
* const b = asUint16(10000);
|
|
41
|
+
*
|
|
42
|
+
* // Arithmetic operations with automatic clamping
|
|
43
|
+
* const sum = Uint16.add(a, b); // Uint16 (65535 - clamped to MAX_VALUE)
|
|
44
|
+
* const diff = Uint16.sub(b, a); // Uint16 (0 - clamped to MIN_VALUE)
|
|
45
|
+
* const product = Uint16.mul(a, b); // Uint16 (65535 - clamped due to overflow)
|
|
46
|
+
*
|
|
47
|
+
* // Range operations
|
|
48
|
+
* const clamped = Uint16.clamp(-100); // Uint16 (0)
|
|
49
|
+
* const minimum = Uint16.min(a, b); // Uint16 (10000)
|
|
50
|
+
* const maximum = Uint16.max(a, b); // Uint16 (60000)
|
|
51
|
+
*
|
|
52
|
+
* // Utility operations
|
|
53
|
+
* const random = Uint16.random(); // Uint16 (random value in [0, 65535])
|
|
54
|
+
* const power = Uint16.pow(asUint16(2), asUint16(10)); // Uint16 (1024)
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
const Uint16 = {
|
|
58
|
+
/**
|
|
59
|
+
* Type guard to check if a value is a Uint16.
|
|
60
|
+
* @param value The value to check.
|
|
61
|
+
* @returns `true` if the value is a 16-bit unsigned integer, `false` otherwise.
|
|
62
|
+
*/
|
|
63
|
+
is,
|
|
64
|
+
/**
|
|
65
|
+
* The minimum value for a 16-bit unsigned integer.
|
|
66
|
+
* @readonly
|
|
67
|
+
*/
|
|
68
|
+
MIN_VALUE,
|
|
69
|
+
/**
|
|
70
|
+
* The maximum value for a 16-bit unsigned integer.
|
|
71
|
+
* @readonly
|
|
72
|
+
*/
|
|
73
|
+
MAX_VALUE,
|
|
74
|
+
/**
|
|
75
|
+
* Returns the smaller of two Uint16 values.
|
|
76
|
+
* @param a The first Uint16.
|
|
77
|
+
* @param b The second Uint16.
|
|
78
|
+
* @returns The minimum value as a Uint16.
|
|
79
|
+
*/
|
|
80
|
+
min: min_,
|
|
81
|
+
/**
|
|
82
|
+
* Returns the larger of two Uint16 values.
|
|
83
|
+
* @param a The first Uint16.
|
|
84
|
+
* @param b The second Uint16.
|
|
85
|
+
* @returns The maximum value as a Uint16.
|
|
86
|
+
*/
|
|
87
|
+
max: max_,
|
|
88
|
+
/**
|
|
89
|
+
* Clamps a number to the Uint16 range.
|
|
90
|
+
* @param value The number to clamp.
|
|
91
|
+
* @returns The value clamped to [0, 65535] as a Uint16.
|
|
92
|
+
*/
|
|
93
|
+
clamp,
|
|
94
|
+
/**
|
|
95
|
+
* Generates a random Uint16 value within the valid range.
|
|
96
|
+
* @returns A random Uint16 between 0 and 65535.
|
|
97
|
+
*/
|
|
98
|
+
random,
|
|
99
|
+
/**
|
|
100
|
+
* Raises a Uint16 to the power of another Uint16.
|
|
101
|
+
* @param a The base Uint16.
|
|
102
|
+
* @param b The exponent Uint16.
|
|
103
|
+
* @returns `a ** b` clamped to [0, 65535] as a Uint16.
|
|
104
|
+
*/
|
|
105
|
+
pow,
|
|
106
|
+
/**
|
|
107
|
+
* Adds two Uint16 values.
|
|
108
|
+
* @param a The first Uint16.
|
|
109
|
+
* @param b The second Uint16.
|
|
110
|
+
* @returns `a + b` clamped to [0, 65535] as a Uint16.
|
|
111
|
+
*/
|
|
112
|
+
add,
|
|
113
|
+
/**
|
|
114
|
+
* Subtracts one Uint16 from another.
|
|
115
|
+
* @param a The minuend Uint16.
|
|
116
|
+
* @param b The subtrahend Uint16.
|
|
117
|
+
* @returns `a - b` clamped to [0, 65535] as a Uint16 (minimum 0).
|
|
118
|
+
*/
|
|
119
|
+
sub,
|
|
120
|
+
/**
|
|
121
|
+
* Multiplies two Uint16 values.
|
|
122
|
+
* @param a The first Uint16.
|
|
123
|
+
* @param b The second Uint16.
|
|
124
|
+
* @returns `a * b` clamped to [0, 65535] as a Uint16.
|
|
125
|
+
*/
|
|
126
|
+
mul,
|
|
127
|
+
/**
|
|
128
|
+
* Divides one Uint16 by another using floor division.
|
|
129
|
+
* @param a The dividend Uint16.
|
|
130
|
+
* @param b The divisor Uint16.
|
|
131
|
+
* @returns `⌊a / b⌋` clamped to [0, 65535] as a Uint16.
|
|
132
|
+
*/
|
|
133
|
+
div,
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export { Uint16, asUint16, isUint16 };
|
|
137
|
+
//# sourceMappingURL=uint16.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uint16.mjs","sources":["../../../src/number/branded-types/uint16.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA,MAAM,iBAAiB,GAAG,uCAAuC;AAEjE,MAAM,EACJ,SAAS,EACT,SAAS,EACT,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,IAAI,EACT,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,MAAM,EACN,EAAE,EACF,QAAQ,EACR,KAAK,GACN,GAAG,mBAAmB,CAAC,kBAAkB,CAAC,mBAAmB,CAI5D;AACA,IAAA,oBAAoB,EAAE,aAAa;AACnC,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC;IACtB,iBAAiB;AACT,CAAA,CAAC;AAEX;;;;AAIG;AACI,MAAM,QAAQ,GAAG;AAExB;;;;;;;;;;;;AAYG;AACI,MAAM,QAAQ,GAAG;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;AACI,MAAM,MAAM,GAAG;AACpB;;;;AAIG;IACH,EAAE;AAEF;;;AAGG;IACH,SAAS;AAET;;;AAGG;IACH,SAAS;AAET;;;;;AAKG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;AAKG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;AAIG;IACH,KAAK;AAEL;;;AAGG;IACH,MAAM;AAEN;;;;;AAKG;IACH,GAAG;AAEH;;;;;AAKG;IACH,GAAG;AAEH;;;;;AAKG;IACH,GAAG;AAEH;;;;;AAKG;IACH,GAAG;AAEH;;;;;AAKG;IACH,GAAG;;;;;"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a number is a Uint32 (32-bit unsigned integer in the range [0, 2^32)).
|
|
3
|
+
* @param value The value to check.
|
|
4
|
+
* @returns `true` if the value is a Uint32, `false` otherwise.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isUint32: (a: number) => a is Uint32;
|
|
7
|
+
/**
|
|
8
|
+
* Casts a number to a Uint32 type.
|
|
9
|
+
* @param value The value to cast.
|
|
10
|
+
* @returns The value as a Uint32 type.
|
|
11
|
+
* @throws {TypeError} If the value is not a non-negative integer less than 2^32.
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const x = asUint32(1000000); // Uint32
|
|
15
|
+
* const y = asUint32(0); // Uint32
|
|
16
|
+
* // asUint32(-1); // throws TypeError
|
|
17
|
+
* // asUint32(5000000000); // throws TypeError
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const asUint32: <N extends number>(x: N) => number & {
|
|
21
|
+
readonly NaNValue: false;
|
|
22
|
+
readonly "> -2^16": true;
|
|
23
|
+
readonly "> -2^32": true;
|
|
24
|
+
readonly ">= -2^15": true;
|
|
25
|
+
readonly ">= -2^31": true;
|
|
26
|
+
readonly ">=0": true;
|
|
27
|
+
readonly "< 2^32": true;
|
|
28
|
+
readonly Finite: true;
|
|
29
|
+
readonly Int: true;
|
|
30
|
+
readonly SafeInt: true;
|
|
31
|
+
} & Readonly<{
|
|
32
|
+
'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
|
|
33
|
+
}> & N;
|
|
34
|
+
/**
|
|
35
|
+
* Utility functions for working with Uint32 (32-bit unsigned integer) branded types.
|
|
36
|
+
* Provides type-safe operations that ensure results remain within the valid range [0, 2^32).
|
|
37
|
+
* All arithmetic operations are clamped to maintain the Uint32 constraint.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* // Type checking
|
|
42
|
+
* Uint32.is(1000000); // true
|
|
43
|
+
* Uint32.is(-1); // false
|
|
44
|
+
* Uint32.is(5000000000); // false (exceeds 2^32)
|
|
45
|
+
*
|
|
46
|
+
* // Constants
|
|
47
|
+
* console.log(Uint32.MIN_VALUE); // 0
|
|
48
|
+
* console.log(Uint32.MAX_VALUE); // 4294967295 (2^32 - 1)
|
|
49
|
+
*
|
|
50
|
+
* // Arithmetic operations (all results clamped to [0, 2^32))
|
|
51
|
+
* const a = asUint32(1000000);
|
|
52
|
+
* const b = asUint32(500000);
|
|
53
|
+
*
|
|
54
|
+
* Uint32.add(a, b); // Uint32 (1500000)
|
|
55
|
+
* Uint32.sub(a, b); // Uint32 (500000)
|
|
56
|
+
* Uint32.mul(a, b); // Uint32 (clamped if overflow)
|
|
57
|
+
* Uint32.div(a, b); // Uint32 (2)
|
|
58
|
+
* Uint32.pow(asUint32(2), asUint32(10)); // Uint32 (1024)
|
|
59
|
+
*
|
|
60
|
+
* // Utility functions
|
|
61
|
+
* Uint32.min(a, b); // Uint32 (500000)
|
|
62
|
+
* Uint32.max(a, b); // Uint32 (1000000)
|
|
63
|
+
* Uint32.clamp(asUint32(5000000000), Uint32.MIN_VALUE, Uint32.MAX_VALUE); // Uint32 (MAX_VALUE)
|
|
64
|
+
* Uint32.random(); // Random Uint32
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare const Uint32: {
|
|
68
|
+
/**
|
|
69
|
+
* Type guard that checks if a value is a 32-bit unsigned integer.
|
|
70
|
+
* @param value - The value to check
|
|
71
|
+
* @returns `true` if the value is within the range [0, 2^32), `false` otherwise
|
|
72
|
+
*/
|
|
73
|
+
readonly is: (a: number) => a is Uint32;
|
|
74
|
+
/**
|
|
75
|
+
* The minimum value for a Uint32.
|
|
76
|
+
* @readonly
|
|
77
|
+
*/
|
|
78
|
+
readonly MIN_VALUE: 0;
|
|
79
|
+
/**
|
|
80
|
+
* The maximum value for a Uint32.
|
|
81
|
+
* @readonly
|
|
82
|
+
*/
|
|
83
|
+
readonly MAX_VALUE: number;
|
|
84
|
+
/**
|
|
85
|
+
* Returns the minimum of multiple Uint32 values.
|
|
86
|
+
* @param values - The Uint32 values to compare
|
|
87
|
+
* @returns The smallest value as a Uint32
|
|
88
|
+
*/
|
|
89
|
+
readonly min: (...values: readonly WithSmallInt<Uint32, 40>[]) => Uint32;
|
|
90
|
+
/**
|
|
91
|
+
* Returns the maximum of multiple Uint32 values.
|
|
92
|
+
* @param values - The Uint32 values to compare
|
|
93
|
+
* @returns The largest value as a Uint32
|
|
94
|
+
*/
|
|
95
|
+
readonly max: (...values: readonly WithSmallInt<Uint32, 40>[]) => Uint32;
|
|
96
|
+
/**
|
|
97
|
+
* Clamps a Uint32 to be within the specified range.
|
|
98
|
+
* @param value - The value to clamp
|
|
99
|
+
* @param min - The minimum value
|
|
100
|
+
* @param max - The maximum value
|
|
101
|
+
* @returns The clamped value as a Uint32
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* Uint32.clamp(asUint32(5000000000), Uint32.MIN_VALUE, asUint32(1000)); // Uint32 (1000)
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
readonly clamp: (x: number) => Uint32;
|
|
108
|
+
/**
|
|
109
|
+
* Generates a random Uint32 value.
|
|
110
|
+
* @returns A random Uint32 value within [0, 2^32)
|
|
111
|
+
*/
|
|
112
|
+
readonly random: (min: WithSmallInt<Uint32, 40>, max: WithSmallInt<Uint32, 40>) => Uint32;
|
|
113
|
+
/**
|
|
114
|
+
* Raises a Uint32 to a power, with result clamped to [0, 2^32).
|
|
115
|
+
* @param a - The base Uint32
|
|
116
|
+
* @param b - The exponent Uint32
|
|
117
|
+
* @returns `a ** b` as a Uint32, clamped to valid range
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* Uint32.pow(asUint32(2), asUint32(10)); // Uint32 (1024)
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
readonly pow: (x: WithSmallInt<Uint32, 40>, y: WithSmallInt<Uint32, 40>) => Uint32;
|
|
124
|
+
/**
|
|
125
|
+
* Adds two Uint32 values, with result clamped to [0, 2^32).
|
|
126
|
+
* @param a - First Uint32
|
|
127
|
+
* @param b - Second Uint32
|
|
128
|
+
* @returns `a + b` as a Uint32, clamped to valid range
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* Uint32.add(asUint32(1000000), asUint32(500000)); // Uint32 (1500000)
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
readonly add: (x: WithSmallInt<Uint32, 40>, y: WithSmallInt<Uint32, 40>) => Uint32;
|
|
135
|
+
/**
|
|
136
|
+
* Subtracts two Uint32 values, with result clamped to [0, 2^32).
|
|
137
|
+
* @param a - First Uint32
|
|
138
|
+
* @param b - Second Uint32
|
|
139
|
+
* @returns `a - b` as a Uint32, clamped to valid range (minimum 0)
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* Uint32.sub(asUint32(1000000), asUint32(500000)); // Uint32 (500000)
|
|
143
|
+
* Uint32.sub(asUint32(100), asUint32(500)); // Uint32 (0) - clamped
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
readonly sub: (x: WithSmallInt<Uint32, 40>, y: WithSmallInt<Uint32, 40>) => Uint32;
|
|
147
|
+
/**
|
|
148
|
+
* Multiplies two Uint32 values, with result clamped to [0, 2^32).
|
|
149
|
+
* @param a - First Uint32
|
|
150
|
+
* @param b - Second Uint32
|
|
151
|
+
* @returns `a * b` as a Uint32, clamped to valid range
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* Uint32.mul(asUint32(1000), asUint32(500)); // Uint32 (500000)
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
readonly mul: (x: WithSmallInt<Uint32, 40>, y: WithSmallInt<Uint32, 40>) => Uint32;
|
|
158
|
+
/**
|
|
159
|
+
* Divides two Uint32 values using floor division, with result clamped to [0, 2^32).
|
|
160
|
+
* @param a - The dividend Uint32
|
|
161
|
+
* @param b - The divisor Uint32
|
|
162
|
+
* @returns `⌊a / b⌋` as a Uint32, clamped to valid range
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* Uint32.div(asUint32(1000000), asUint32(500000)); // Uint32 (2)
|
|
166
|
+
* Uint32.div(asUint32(7), asUint32(3)); // Uint32 (2) - floor division
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
readonly div: (x: WithSmallInt<Uint32, 40>, y: 1 | 2 | 3 | 32 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | 10 | 24 | 14 | 34 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 35 | 36 | 37 | 38 | 39 | NormalizeBrandUnion<number & {
|
|
170
|
+
readonly NaNValue: false;
|
|
171
|
+
readonly "!=0": true;
|
|
172
|
+
readonly "> -2^16": true;
|
|
173
|
+
readonly "> -2^32": true;
|
|
174
|
+
readonly ">= -2^15": true;
|
|
175
|
+
readonly ">= -2^31": true;
|
|
176
|
+
readonly ">=0": true;
|
|
177
|
+
readonly "< 2^32": true;
|
|
178
|
+
readonly Finite: true;
|
|
179
|
+
readonly Int: true;
|
|
180
|
+
readonly SafeInt: true;
|
|
181
|
+
} & Readonly<{
|
|
182
|
+
'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
|
|
183
|
+
}>>) => Uint32;
|
|
184
|
+
};
|
|
185
|
+
//# sourceMappingURL=uint32.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uint32.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/uint32.mts"],"names":[],"mappings":"AAgCA;;;;GAIG;AACH,eAAO,MAAM,QAAQ,4BAAK,CAAC;AAE3B;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;MAAW,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,MAAM;IACjB;;;;OAIG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;OAIG;;IAGH;;;;OAIG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;OAGG;;IAGH;;;;;;;;;OASG;;IAGH;;;;;;;;;OASG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;;;;OASG;;IAGH;;;;;;;;;;OAUG;;;;;;;;;;;;;;;;CAEK,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { TsVerifiedInternals } from '../refined-number-utils.mjs';
|
|
2
|
+
|
|
3
|
+
const typeNameInMessage = 'a non-negative integer less than 2^32';
|
|
4
|
+
const { MIN_VALUE, MAX_VALUE, min: min_, max: max_, pow, add, sub, mul, div, random, is, castType, clamp, } = TsVerifiedInternals.RefinedNumberUtils.operatorsForInteger({
|
|
5
|
+
integerOrSafeInteger: 'SafeInteger',
|
|
6
|
+
MIN_VALUE: 0,
|
|
7
|
+
MAX_VALUE: 2 ** 32 - 1,
|
|
8
|
+
typeNameInMessage,
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a number is a Uint32 (32-bit unsigned integer in the range [0, 2^32)).
|
|
12
|
+
* @param value The value to check.
|
|
13
|
+
* @returns `true` if the value is a Uint32, `false` otherwise.
|
|
14
|
+
*/
|
|
15
|
+
const isUint32 = is;
|
|
16
|
+
/**
|
|
17
|
+
* Casts a number to a Uint32 type.
|
|
18
|
+
* @param value The value to cast.
|
|
19
|
+
* @returns The value as a Uint32 type.
|
|
20
|
+
* @throws {TypeError} If the value is not a non-negative integer less than 2^32.
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const x = asUint32(1000000); // Uint32
|
|
24
|
+
* const y = asUint32(0); // Uint32
|
|
25
|
+
* // asUint32(-1); // throws TypeError
|
|
26
|
+
* // asUint32(5000000000); // throws TypeError
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
const asUint32 = castType;
|
|
30
|
+
/**
|
|
31
|
+
* Utility functions for working with Uint32 (32-bit unsigned integer) branded types.
|
|
32
|
+
* Provides type-safe operations that ensure results remain within the valid range [0, 2^32).
|
|
33
|
+
* All arithmetic operations are clamped to maintain the Uint32 constraint.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* // Type checking
|
|
38
|
+
* Uint32.is(1000000); // true
|
|
39
|
+
* Uint32.is(-1); // false
|
|
40
|
+
* Uint32.is(5000000000); // false (exceeds 2^32)
|
|
41
|
+
*
|
|
42
|
+
* // Constants
|
|
43
|
+
* console.log(Uint32.MIN_VALUE); // 0
|
|
44
|
+
* console.log(Uint32.MAX_VALUE); // 4294967295 (2^32 - 1)
|
|
45
|
+
*
|
|
46
|
+
* // Arithmetic operations (all results clamped to [0, 2^32))
|
|
47
|
+
* const a = asUint32(1000000);
|
|
48
|
+
* const b = asUint32(500000);
|
|
49
|
+
*
|
|
50
|
+
* Uint32.add(a, b); // Uint32 (1500000)
|
|
51
|
+
* Uint32.sub(a, b); // Uint32 (500000)
|
|
52
|
+
* Uint32.mul(a, b); // Uint32 (clamped if overflow)
|
|
53
|
+
* Uint32.div(a, b); // Uint32 (2)
|
|
54
|
+
* Uint32.pow(asUint32(2), asUint32(10)); // Uint32 (1024)
|
|
55
|
+
*
|
|
56
|
+
* // Utility functions
|
|
57
|
+
* Uint32.min(a, b); // Uint32 (500000)
|
|
58
|
+
* Uint32.max(a, b); // Uint32 (1000000)
|
|
59
|
+
* Uint32.clamp(asUint32(5000000000), Uint32.MIN_VALUE, Uint32.MAX_VALUE); // Uint32 (MAX_VALUE)
|
|
60
|
+
* Uint32.random(); // Random Uint32
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
const Uint32 = {
|
|
64
|
+
/**
|
|
65
|
+
* Type guard that checks if a value is a 32-bit unsigned integer.
|
|
66
|
+
* @param value - The value to check
|
|
67
|
+
* @returns `true` if the value is within the range [0, 2^32), `false` otherwise
|
|
68
|
+
*/
|
|
69
|
+
is,
|
|
70
|
+
/**
|
|
71
|
+
* The minimum value for a Uint32.
|
|
72
|
+
* @readonly
|
|
73
|
+
*/
|
|
74
|
+
MIN_VALUE,
|
|
75
|
+
/**
|
|
76
|
+
* The maximum value for a Uint32.
|
|
77
|
+
* @readonly
|
|
78
|
+
*/
|
|
79
|
+
MAX_VALUE,
|
|
80
|
+
/**
|
|
81
|
+
* Returns the minimum of multiple Uint32 values.
|
|
82
|
+
* @param values - The Uint32 values to compare
|
|
83
|
+
* @returns The smallest value as a Uint32
|
|
84
|
+
*/
|
|
85
|
+
min: min_,
|
|
86
|
+
/**
|
|
87
|
+
* Returns the maximum of multiple Uint32 values.
|
|
88
|
+
* @param values - The Uint32 values to compare
|
|
89
|
+
* @returns The largest value as a Uint32
|
|
90
|
+
*/
|
|
91
|
+
max: max_,
|
|
92
|
+
/**
|
|
93
|
+
* Clamps a Uint32 to be within the specified range.
|
|
94
|
+
* @param value - The value to clamp
|
|
95
|
+
* @param min - The minimum value
|
|
96
|
+
* @param max - The maximum value
|
|
97
|
+
* @returns The clamped value as a Uint32
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* Uint32.clamp(asUint32(5000000000), Uint32.MIN_VALUE, asUint32(1000)); // Uint32 (1000)
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
clamp,
|
|
104
|
+
/**
|
|
105
|
+
* Generates a random Uint32 value.
|
|
106
|
+
* @returns A random Uint32 value within [0, 2^32)
|
|
107
|
+
*/
|
|
108
|
+
random,
|
|
109
|
+
/**
|
|
110
|
+
* Raises a Uint32 to a power, with result clamped to [0, 2^32).
|
|
111
|
+
* @param a - The base Uint32
|
|
112
|
+
* @param b - The exponent Uint32
|
|
113
|
+
* @returns `a ** b` as a Uint32, clamped to valid range
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* Uint32.pow(asUint32(2), asUint32(10)); // Uint32 (1024)
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
pow,
|
|
120
|
+
/**
|
|
121
|
+
* Adds two Uint32 values, with result clamped to [0, 2^32).
|
|
122
|
+
* @param a - First Uint32
|
|
123
|
+
* @param b - Second Uint32
|
|
124
|
+
* @returns `a + b` as a Uint32, clamped to valid range
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* Uint32.add(asUint32(1000000), asUint32(500000)); // Uint32 (1500000)
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
add,
|
|
131
|
+
/**
|
|
132
|
+
* Subtracts two Uint32 values, with result clamped to [0, 2^32).
|
|
133
|
+
* @param a - First Uint32
|
|
134
|
+
* @param b - Second Uint32
|
|
135
|
+
* @returns `a - b` as a Uint32, clamped to valid range (minimum 0)
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* Uint32.sub(asUint32(1000000), asUint32(500000)); // Uint32 (500000)
|
|
139
|
+
* Uint32.sub(asUint32(100), asUint32(500)); // Uint32 (0) - clamped
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
sub,
|
|
143
|
+
/**
|
|
144
|
+
* Multiplies two Uint32 values, with result clamped to [0, 2^32).
|
|
145
|
+
* @param a - First Uint32
|
|
146
|
+
* @param b - Second Uint32
|
|
147
|
+
* @returns `a * b` as a Uint32, clamped to valid range
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* Uint32.mul(asUint32(1000), asUint32(500)); // Uint32 (500000)
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
mul,
|
|
154
|
+
/**
|
|
155
|
+
* Divides two Uint32 values using floor division, with result clamped to [0, 2^32).
|
|
156
|
+
* @param a - The dividend Uint32
|
|
157
|
+
* @param b - The divisor Uint32
|
|
158
|
+
* @returns `⌊a / b⌋` as a Uint32, clamped to valid range
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* Uint32.div(asUint32(1000000), asUint32(500000)); // Uint32 (2)
|
|
162
|
+
* Uint32.div(asUint32(7), asUint32(3)); // Uint32 (2) - floor division
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
div,
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export { Uint32, asUint32, isUint32 };
|
|
169
|
+
//# sourceMappingURL=uint32.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uint32.mjs","sources":["../../../src/number/branded-types/uint32.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA,MAAM,iBAAiB,GAAG,uCAAuC;AAEjE,MAAM,EACJ,SAAS,EACT,SAAS,EACT,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,IAAI,EACT,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,MAAM,EACN,EAAE,EACF,QAAQ,EACR,KAAK,GACN,GAAG,mBAAmB,CAAC,kBAAkB,CAAC,mBAAmB,CAI5D;AACA,IAAA,oBAAoB,EAAE,aAAa;AACnC,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC;IACtB,iBAAiB;AACT,CAAA,CAAC;AAEX;;;;AAIG;AACI,MAAM,QAAQ,GAAG;AAExB;;;;;;;;;;;;AAYG;AACI,MAAM,QAAQ,GAAG;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCG;AACI,MAAM,MAAM,GAAG;AACpB;;;;AAIG;IACH,EAAE;AAEF;;;AAGG;IACH,SAAS;AAET;;;AAGG;IACH,SAAS;AAET;;;;AAIG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;AAIG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;;;;;;AAUG;IACH,KAAK;AAEL;;;AAGG;IACH,MAAM;AAEN;;;;;;;;;AASG;IACH,GAAG;AAEH;;;;;;;;;AASG;IACH,GAAG;AAEH;;;;;;;;;;AAUG;IACH,GAAG;AAEH;;;;;;;;;AASG;IACH,GAAG;AAEH;;;;;;;;;;AAUG;IACH,GAAG;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/number/enum/index.mts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|