ts-data-forge 10.0.0 → 11.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/dist/array/impl/array-utils-creation.d.mts +3 -3
- package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-creation.mjs.map +1 -1
- package/dist/array/impl/array-utils-element-access.d.mts +4 -4
- package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
- package/dist/{guard/as-length-bounded-array.d.mts → array/impl/array-utils-length-bounded-array-cast.d.mts} +9 -9
- package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts.map +1 -0
- package/dist/{guard/as-length-bounded-array.mjs → array/impl/array-utils-length-bounded-array-cast.mjs} +2 -2
- package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -0
- package/dist/{guard/is-length-bounded-array.d.mts → array/impl/array-utils-length-bounded-array-guard.d.mts} +13 -13
- package/dist/array/impl/array-utils-length-bounded-array-guard.d.mts.map +1 -0
- package/dist/{guard/is-length-bounded-array.mjs → array/impl/array-utils-length-bounded-array-guard.mjs} +1 -1
- package/dist/array/impl/array-utils-length-bounded-array-guard.mjs.map +1 -0
- package/dist/array/impl/array-utils-modification.d.mts +9 -9
- package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
- package/dist/array/impl/array-utils-modification.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.d.mts +9 -9
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-size.d.mts +3 -3
- package/dist/array/impl/array-utils-size.mjs.map +1 -1
- package/dist/array/impl/array-utils-slicing.d.mts +9 -9
- package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
- package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
- package/dist/array/impl/array-utils-transformation.d.mts +16 -10
- package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/array/impl/index.d.mts +2 -0
- package/dist/array/impl/index.d.mts.map +1 -1
- package/dist/array/impl/index.mjs +2 -0
- package/dist/array/impl/index.mjs.map +1 -1
- package/dist/entry-point.mjs +1 -3
- package/dist/entry-point.mjs.map +1 -1
- package/dist/guard/index.d.mts +0 -3
- package/dist/guard/index.d.mts.map +1 -1
- package/dist/guard/index.mjs +0 -3
- package/dist/guard/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -3
- package/dist/index.mjs.map +1 -1
- package/dist/number/branded-types/finite-number.d.mts +47 -61
- package/dist/number/branded-types/finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/finite-number.mjs +37 -41
- package/dist/number/branded-types/finite-number.mjs.map +1 -1
- package/dist/number/branded-types/int.d.mts +40 -46
- package/dist/number/branded-types/int.d.mts.map +1 -1
- package/dist/number/branded-types/int.mjs +29 -31
- package/dist/number/branded-types/int.mjs.map +1 -1
- package/dist/number/branded-types/int16.d.mts +65 -58
- package/dist/number/branded-types/int16.d.mts.map +1 -1
- package/dist/number/branded-types/int16.mjs +49 -45
- package/dist/number/branded-types/int16.mjs.map +1 -1
- package/dist/number/branded-types/int32.d.mts +65 -58
- package/dist/number/branded-types/int32.d.mts.map +1 -1
- package/dist/number/branded-types/int32.mjs +49 -45
- package/dist/number/branded-types/int32.mjs.map +1 -1
- package/dist/number/branded-types/negative-finite-number.d.mts +68 -59
- package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/negative-finite-number.mjs +52 -46
- package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/negative-int.d.mts +60 -48
- package/dist/number/branded-types/negative-int.d.mts.map +1 -1
- package/dist/number/branded-types/negative-int.mjs +40 -36
- package/dist/number/branded-types/negative-int.mjs.map +1 -1
- package/dist/number/branded-types/negative-safe-int.d.mts +57 -56
- package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/negative-safe-int.mjs +40 -41
- package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.d.mts +74 -64
- package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.mjs +58 -51
- package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int16.d.mts +64 -57
- package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-int16.mjs +47 -43
- package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int32.d.mts +64 -58
- package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-int32.mjs +47 -44
- package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-finite-number.d.mts +64 -54
- package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-finite-number.mjs +48 -41
- package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-int.d.mts +41 -146
- package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-int.mjs +27 -107
- package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-safe-int.d.mts +54 -53
- package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-positive-safe-int.mjs +37 -39
- package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.d.mts +62 -49
- package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.mjs +46 -37
- package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int.d.mts +51 -38
- package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int.mjs +31 -27
- package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int16.d.mts +52 -53
- package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int16.mjs +36 -39
- package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int32.d.mts +52 -54
- package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int32.mjs +36 -40
- package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.d.mts +53 -54
- package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs +36 -40
- package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.d.mts +52 -53
- package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.mjs +35 -39
- package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.d.mts +52 -53
- package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.mjs +35 -39
- package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
- package/dist/number/branded-types/positive-finite-number.d.mts +74 -63
- package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/positive-finite-number.mjs +58 -50
- package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/positive-int.d.mts +46 -68
- package/dist/number/branded-types/positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int.mjs +34 -49
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-int16.d.mts +61 -57
- package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int16.mjs +44 -43
- package/dist/number/branded-types/positive-int16.mjs.map +1 -1
- package/dist/number/branded-types/positive-int32.d.mts +61 -57
- package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int32.mjs +44 -43
- package/dist/number/branded-types/positive-int32.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.d.mts +62 -57
- package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs +45 -43
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint16.d.mts +61 -57
- package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint16.mjs +44 -43
- package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint32.d.mts +61 -58
- package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint32.mjs +44 -44
- package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.d.mts +43 -62
- package/dist/number/branded-types/safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/safe-int.mjs +35 -42
- package/dist/number/branded-types/safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-uint.d.mts +62 -57
- package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
- package/dist/number/branded-types/safe-uint.mjs +46 -44
- package/dist/number/branded-types/safe-uint.mjs.map +1 -1
- package/dist/number/branded-types/uint.d.mts +63 -50
- package/dist/number/branded-types/uint.d.mts.map +1 -1
- package/dist/number/branded-types/uint.mjs +42 -39
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/branded-types/uint16.d.mts +60 -58
- package/dist/number/branded-types/uint16.d.mts.map +1 -1
- package/dist/number/branded-types/uint16.mjs +44 -43
- package/dist/number/branded-types/uint16.mjs.map +1 -1
- package/dist/number/branded-types/uint32.d.mts +59 -55
- package/dist/number/branded-types/uint32.d.mts.map +1 -1
- package/dist/number/branded-types/uint32.mjs +42 -42
- package/dist/number/branded-types/uint32.mjs.map +1 -1
- package/dist/number/enum/int8.d.mts +56 -65
- package/dist/number/enum/int8.d.mts.map +1 -1
- package/dist/number/enum/int8.mjs +44 -43
- package/dist/number/enum/int8.mjs.map +1 -1
- package/dist/number/enum/uint8.d.mts +60 -58
- package/dist/number/enum/uint8.d.mts.map +1 -1
- package/dist/number/enum/uint8.mjs +44 -43
- package/dist/number/enum/uint8.mjs.map +1 -1
- package/dist/string/index.d.mts +2 -0
- package/dist/string/index.d.mts.map +1 -0
- package/dist/string/index.mjs +2 -0
- package/dist/string/index.mjs.map +1 -0
- package/dist/string/str.d.mts +273 -0
- package/dist/string/str.d.mts.map +1 -0
- package/dist/string/str.mjs +42 -0
- package/dist/string/str.mjs.map +1 -0
- package/package.json +31 -92
- package/src/array/impl/array-utils-creation.mts +2 -1
- package/src/array/impl/array-utils-element-access.mts +3 -3
- package/src/array/impl/array-utils-element-access.test.mts +3 -3
- package/src/{guard/as-length-bounded-array.mts → array/impl/array-utils-length-bounded-array-cast.mts} +9 -9
- package/src/{guard/as-length-bounded-array.test.mts → array/impl/array-utils-length-bounded-array-cast.test.mts} +2 -2
- package/src/{guard/is-length-bounded-array.mts → array/impl/array-utils-length-bounded-array-guard.mts} +12 -12
- package/src/{guard/is-length-bounded-array.test.mts → array/impl/array-utils-length-bounded-array-guard.test.mts} +2 -2
- package/src/array/impl/array-utils-modification.mts +9 -8
- package/src/array/impl/array-utils-modification.test.mts +6 -1
- package/src/array/impl/array-utils-reducing-value.mts +9 -9
- package/src/array/impl/array-utils-size.mts +2 -2
- package/src/array/impl/array-utils-slicing.mts +24 -13
- package/src/array/impl/array-utils-transformation.mts +18 -12
- package/src/array/impl/array-utils-transformation.test.mts +12 -12
- package/src/array/impl/index.mts +2 -0
- package/src/guard/index.mts +0 -3
- package/src/index.mts +1 -0
- package/src/number/branded-types/finite-number.mts +47 -61
- package/src/number/branded-types/int.mts +40 -46
- package/src/number/branded-types/int16.mts +65 -58
- package/src/number/branded-types/int32.mts +65 -58
- package/src/number/branded-types/negative-finite-number.mts +68 -68
- package/src/number/branded-types/negative-int.mts +60 -57
- package/src/number/branded-types/negative-safe-int.mts +57 -65
- package/src/number/branded-types/non-negative-finite-number.mts +74 -64
- package/src/number/branded-types/non-negative-int16.mts +64 -57
- package/src/number/branded-types/non-negative-int32.mts +64 -58
- package/src/number/branded-types/non-positive-finite-number.mts +64 -54
- package/src/number/branded-types/non-positive-int.mts +41 -146
- package/src/number/branded-types/non-positive-safe-int.mts +54 -53
- package/src/number/branded-types/non-zero-finite-number.mts +62 -51
- package/src/number/branded-types/non-zero-int.mts +51 -38
- package/src/number/branded-types/non-zero-int16.mts +52 -53
- package/src/number/branded-types/non-zero-int32.mts +52 -54
- package/src/number/branded-types/non-zero-safe-int.mts +53 -54
- package/src/number/branded-types/non-zero-uint16.mts +52 -53
- package/src/number/branded-types/non-zero-uint32.mts +52 -53
- package/src/number/branded-types/positive-finite-number.mts +74 -63
- package/src/number/branded-types/positive-int.mts +46 -68
- package/src/number/branded-types/positive-int16.mts +61 -57
- package/src/number/branded-types/positive-int32.mts +61 -57
- package/src/number/branded-types/positive-safe-int.mts +62 -57
- package/src/number/branded-types/positive-uint16.mts +61 -57
- package/src/number/branded-types/positive-uint32.mts +61 -58
- package/src/number/branded-types/safe-int.mts +43 -62
- package/src/number/branded-types/safe-uint.mts +62 -57
- package/src/number/branded-types/uint.mts +63 -50
- package/src/number/branded-types/uint16.mts +60 -58
- package/src/number/branded-types/uint32.mts +59 -55
- package/src/number/enum/int8.mts +56 -65
- package/src/number/enum/uint8.mts +60 -58
- package/src/string/index.mts +1 -0
- package/src/string/str.mts +371 -0
- package/src/string/str.test.mts +215 -0
- package/dist/guard/as-length-bounded-array.d.mts.map +0 -1
- package/dist/guard/as-length-bounded-array.mjs.map +0 -1
- package/dist/guard/is-length-bounded-array.d.mts.map +0 -1
- package/dist/guard/is-length-bounded-array.mjs.map +0 -1
- package/dist/guard/is-length-bounded-string.d.mts +0 -163
- package/dist/guard/is-length-bounded-string.d.mts.map +0 -1
- package/dist/guard/is-length-bounded-string.mjs +0 -7
- package/dist/guard/is-length-bounded-string.mjs.map +0 -1
- package/src/guard/is-length-bounded-string.mts +0 -199
- package/src/guard/is-length-bounded-string.test.mts +0 -170
|
@@ -1,119 +1,121 @@
|
|
|
1
1
|
import { type Uint8 as TtfImported_Uint8 } from 'ts-type-forge';
|
|
2
2
|
export type Uint8 = TtfImported_Uint8;
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Type guard that checks if a value is an non-negative integer less than 256.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Returns `true` for an non-negative integer less than 256 — a value with no
|
|
7
|
+
* fractional component.
|
|
8
|
+
*
|
|
9
|
+
* @param value - The value to check
|
|
10
|
+
* @returns `true` if the value is an non-negative integer less than 256, `false` otherwise
|
|
8
11
|
*/
|
|
9
12
|
export declare const isUint8: (x: number) => x is Uint8;
|
|
10
13
|
/**
|
|
11
|
-
* Casts a number to
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
+
* Casts a `number` to the `Uint8` branded type.
|
|
15
|
+
*
|
|
16
|
+
* Validates that the value is an non-negative integer less than 256 and returns
|
|
17
|
+
* it with the `Uint8` brand. Throws a `TypeError` otherwise.
|
|
14
18
|
*
|
|
15
|
-
* @param value The value to cast
|
|
16
|
-
* @returns The value as
|
|
17
|
-
* @throws {TypeError} If the value is not
|
|
19
|
+
* @param value - The value to cast
|
|
20
|
+
* @returns The value as an `Uint8`
|
|
21
|
+
* @throws {TypeError} If the value is not an non-negative integer less than 256
|
|
18
22
|
*/
|
|
19
23
|
export declare const asUint8: (x: number) => Uint8;
|
|
20
24
|
/**
|
|
21
|
-
* Namespace providing type-safe
|
|
22
|
-
* integers.
|
|
25
|
+
* Namespace providing type-safe operations for the `Uint8` branded type.
|
|
23
26
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* constraint, with negative results clamped to 0 and overflow results clamped
|
|
27
|
-
* to MAX_VALUE.
|
|
27
|
+
* The `Uint8` type represents an non-negative integer less than 256. Division
|
|
28
|
+
* (`div`) uses floor division.
|
|
28
29
|
*/
|
|
29
30
|
export declare const Uint8: {
|
|
30
31
|
/**
|
|
31
|
-
* Type guard that checks if a value is an
|
|
32
|
+
* Type guard that checks if a value is an non-negative integer less than 256.
|
|
32
33
|
*
|
|
33
|
-
* @param value The value to check
|
|
34
|
-
* @returns `true` if the value is an
|
|
35
|
-
*
|
|
34
|
+
* @param value - The value to check
|
|
35
|
+
* @returns `true` if the value is an non-negative integer less than 256, `false` otherwise
|
|
36
|
+
* @see {@link isUint8} for usage examples
|
|
36
37
|
*/
|
|
37
38
|
readonly is: (x: number) => x is Uint8;
|
|
38
39
|
/**
|
|
39
|
-
* The
|
|
40
|
-
*
|
|
41
|
-
* @readonly
|
|
40
|
+
* The smallest value representable as `Uint8`.
|
|
42
41
|
*/
|
|
43
42
|
readonly MIN_VALUE: 0;
|
|
44
43
|
/**
|
|
45
|
-
* The
|
|
46
|
-
*
|
|
47
|
-
* @readonly
|
|
44
|
+
* The largest value representable as `Uint8`.
|
|
48
45
|
*/
|
|
49
46
|
readonly MAX_VALUE: 255;
|
|
50
47
|
/**
|
|
51
|
-
* Returns the
|
|
48
|
+
* Returns the largest of the given non-negative integers.
|
|
52
49
|
*
|
|
53
|
-
* @param values The
|
|
54
|
-
* @returns The
|
|
50
|
+
* @param values - The non-negative integers to compare (at least one required)
|
|
51
|
+
* @returns The largest value as an `Uint8`
|
|
55
52
|
*/
|
|
56
53
|
readonly max: (...values: readonly Uint8[]) => Uint8;
|
|
57
54
|
/**
|
|
58
|
-
* Returns the
|
|
55
|
+
* Returns the smallest of the given non-negative integers.
|
|
59
56
|
*
|
|
60
|
-
* @param values The
|
|
61
|
-
* @returns The
|
|
57
|
+
* @param values - The non-negative integers to compare (at least one required)
|
|
58
|
+
* @returns The smallest value as an `Uint8`
|
|
62
59
|
*/
|
|
63
60
|
readonly min: (...values: readonly Uint8[]) => Uint8;
|
|
64
61
|
/**
|
|
65
|
-
* Clamps a number
|
|
62
|
+
* Clamps a `number` into the `Uint8` range, rounding to the nearest integer
|
|
63
|
+
* and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
|
|
66
64
|
*
|
|
67
|
-
* @param value The
|
|
68
|
-
* @returns The
|
|
65
|
+
* @param value - The value to clamp
|
|
66
|
+
* @returns The clamped value as an `Uint8`
|
|
69
67
|
*/
|
|
70
68
|
readonly clamp: (a: number) => Uint8;
|
|
71
69
|
/**
|
|
72
|
-
* Generates a random Uint8
|
|
70
|
+
* Generates a random `Uint8` within the given range.
|
|
71
|
+
*
|
|
72
|
+
* The range is inclusive on both ends.
|
|
73
73
|
*
|
|
74
|
-
* @param min The minimum value (inclusive)
|
|
75
|
-
* @param max The maximum value (inclusive)
|
|
76
|
-
* @returns A random Uint8
|
|
74
|
+
* @param min - The minimum value (inclusive)
|
|
75
|
+
* @param max - The maximum value (inclusive)
|
|
76
|
+
* @returns A random `Uint8` in `[min, max]`
|
|
77
77
|
*/
|
|
78
78
|
readonly random: (min: Uint8, max: Uint8) => Uint8;
|
|
79
79
|
/**
|
|
80
|
-
* Raises
|
|
80
|
+
* Raises `a` to the power `b`, returning `a ** b` as an `Uint8` (floored to
|
|
81
|
+
* an integer).
|
|
81
82
|
*
|
|
82
|
-
* @param
|
|
83
|
-
* @param
|
|
84
|
-
* @returns `
|
|
83
|
+
* @param a - The base non-negative integer
|
|
84
|
+
* @param b - The exponent non-negative integer
|
|
85
|
+
* @returns `a ** b` as an `Uint8`
|
|
85
86
|
*/
|
|
86
87
|
readonly pow: (x: Uint8, y: Uint8) => Uint8;
|
|
87
88
|
/**
|
|
88
|
-
* Adds two
|
|
89
|
+
* Adds two non-negative integers, returning `a + b` as an `Uint8`.
|
|
89
90
|
*
|
|
90
|
-
* @param
|
|
91
|
-
* @param
|
|
92
|
-
* @returns `
|
|
91
|
+
* @param a - The first non-negative integer
|
|
92
|
+
* @param b - The second non-negative integer
|
|
93
|
+
* @returns The sum of `a` and `b` as an `Uint8`
|
|
93
94
|
*/
|
|
94
95
|
readonly add: (x: Uint8, y: Uint8) => Uint8;
|
|
95
96
|
/**
|
|
96
|
-
* Subtracts two
|
|
97
|
+
* Subtracts two non-negative integers, returning `a - b` as an `Uint8`.
|
|
97
98
|
*
|
|
98
|
-
* @param
|
|
99
|
-
* @param
|
|
100
|
-
* @returns `
|
|
99
|
+
* @param a - The first non-negative integer
|
|
100
|
+
* @param b - The second non-negative integer
|
|
101
|
+
* @returns The difference of `a` and `b` as an `Uint8`
|
|
101
102
|
*/
|
|
102
103
|
readonly sub: (x: Uint8, y: Uint8) => Uint8;
|
|
103
104
|
/**
|
|
104
|
-
* Multiplies two
|
|
105
|
+
* Multiplies two non-negative integers, returning `a * b` as an `Uint8`.
|
|
105
106
|
*
|
|
106
|
-
* @param
|
|
107
|
-
* @param
|
|
108
|
-
* @returns `
|
|
107
|
+
* @param a - The first non-negative integer
|
|
108
|
+
* @param b - The second non-negative integer
|
|
109
|
+
* @returns The product of `a` and `b` as an `Uint8`
|
|
109
110
|
*/
|
|
110
111
|
readonly mul: (x: Uint8, y: Uint8) => Uint8;
|
|
111
112
|
/**
|
|
112
|
-
* Divides two
|
|
113
|
+
* Divides two non-negative integers using floor division (`⌊a / b⌋`): the
|
|
114
|
+
* result is `a / b` rounded toward negative infinity, as an `Uint8`.
|
|
113
115
|
*
|
|
114
|
-
* @param
|
|
115
|
-
* @param
|
|
116
|
-
* @returns
|
|
116
|
+
* @param a - The dividend
|
|
117
|
+
* @param b - The divisor (must be non-zero)
|
|
118
|
+
* @returns The floored quotient as an `Uint8`
|
|
117
119
|
*/
|
|
118
120
|
readonly div: (x: Uint8, y: Exclude<Uint8, 0>) => Uint8;
|
|
119
121
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint8.d.mts","sourceRoot":"","sources":["../../../src/number/enum/uint8.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,IAAI,iBAAiB,EAAe,MAAM,eAAe,CAAC;AAI7E,MAAM,MAAM,KAAK,GAAG,iBAAiB,CAAC;AA+CtC
|
|
1
|
+
{"version":3,"file":"uint8.d.mts","sourceRoot":"","sources":["../../../src/number/enum/uint8.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,IAAI,iBAAiB,EAAe,MAAM,eAAe,CAAC;AAI7E,MAAM,MAAM,KAAK,GAAG,iBAAiB,CAAC;AA+CtC;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,MApCL,MAAM,KAAG,CAAC,IAAI,KAoCJ,CAAC;AAE1B;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,MA9CC,MAAM,KAAG,KA8CC,CAAC;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,KAAK;IAChB;;;;;;OAMG;qBA/DU,MAAM,KAAG,CAAC,IAAI,KAAK;IAkEhC;;OAEG;;IAGH;;OAEG;;IAGH;;;;;OAKG;8BAtEoB,SAAS,KAAK,EAAE,KAAG,KAAK;IAyE/C;;;;;OAKG;8BAjFoB,SAAS,KAAK,EAAE,KAAG,KAAK;IAoF/C;;;;;;OAMG;wBA5Fa,MAAM,KAAG,KAAK;IA+F9B;;;;;;;;OAQG;2BArFgB,KAAK,OAAO,KAAK,KAAG,KAAK;IAwF5C;;;;;;;OAOG;sBAzGW,KAAK,KAAK,KAAK,KAAG,KAAK;IA4GrC;;;;;;OAMG;sBAhHW,KAAK,KAAK,KAAK,KAAG,KAAK;IAmHrC;;;;;;OAMG;sBAvHW,KAAK,KAAK,KAAK,KAAG,KAAK;IA0HrC;;;;;;OAMG;sBA9HW,KAAK,KAAK,KAAK,KAAG,KAAK;IAiIrC;;;;;;;OAOG;sBAtIW,KAAK,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,KAAG,KAAK;CAwIzC,CAAC"}
|
|
@@ -34,92 +34,93 @@ const isUint8 = is;
|
|
|
34
34
|
const asUint8 = castType;
|
|
35
35
|
const Uint8 = {
|
|
36
36
|
/**
|
|
37
|
-
* Type guard that checks if a value is an
|
|
37
|
+
* Type guard that checks if a value is an non-negative integer less than 256.
|
|
38
38
|
*
|
|
39
|
-
* @param value The value to check
|
|
40
|
-
* @returns `true` if the value is an
|
|
41
|
-
*
|
|
39
|
+
* @param value - The value to check
|
|
40
|
+
* @returns `true` if the value is an non-negative integer less than 256, `false` otherwise
|
|
41
|
+
* @see {@link isUint8} for usage examples
|
|
42
42
|
*/
|
|
43
43
|
is,
|
|
44
44
|
/**
|
|
45
|
-
* The
|
|
46
|
-
*
|
|
47
|
-
* @readonly
|
|
45
|
+
* The smallest value representable as `Uint8`.
|
|
48
46
|
*/
|
|
49
47
|
MIN_VALUE,
|
|
50
48
|
/**
|
|
51
|
-
* The
|
|
52
|
-
*
|
|
53
|
-
* @readonly
|
|
49
|
+
* The largest value representable as `Uint8`.
|
|
54
50
|
*/
|
|
55
51
|
MAX_VALUE,
|
|
56
52
|
/**
|
|
57
|
-
* Returns the
|
|
53
|
+
* Returns the largest of the given non-negative integers.
|
|
58
54
|
*
|
|
59
|
-
* @param values The
|
|
60
|
-
* @returns The
|
|
55
|
+
* @param values - The non-negative integers to compare (at least one required)
|
|
56
|
+
* @returns The largest value as an `Uint8`
|
|
61
57
|
*/
|
|
62
58
|
max: max_,
|
|
63
59
|
/**
|
|
64
|
-
* Returns the
|
|
60
|
+
* Returns the smallest of the given non-negative integers.
|
|
65
61
|
*
|
|
66
|
-
* @param values The
|
|
67
|
-
* @returns The
|
|
62
|
+
* @param values - The non-negative integers to compare (at least one required)
|
|
63
|
+
* @returns The smallest value as an `Uint8`
|
|
68
64
|
*/
|
|
69
65
|
min: min_,
|
|
70
66
|
/**
|
|
71
|
-
* Clamps a number
|
|
67
|
+
* Clamps a `number` into the `Uint8` range, rounding to the nearest integer
|
|
68
|
+
* and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
|
|
72
69
|
*
|
|
73
|
-
* @param value The
|
|
74
|
-
* @returns The
|
|
70
|
+
* @param value - The value to clamp
|
|
71
|
+
* @returns The clamped value as an `Uint8`
|
|
75
72
|
*/
|
|
76
73
|
clamp,
|
|
77
74
|
/**
|
|
78
|
-
* Generates a random Uint8
|
|
75
|
+
* Generates a random `Uint8` within the given range.
|
|
76
|
+
*
|
|
77
|
+
* The range is inclusive on both ends.
|
|
79
78
|
*
|
|
80
|
-
* @param min The minimum value (inclusive)
|
|
81
|
-
* @param max The maximum value (inclusive)
|
|
82
|
-
* @returns A random Uint8
|
|
79
|
+
* @param min - The minimum value (inclusive)
|
|
80
|
+
* @param max - The maximum value (inclusive)
|
|
81
|
+
* @returns A random `Uint8` in `[min, max]`
|
|
83
82
|
*/
|
|
84
83
|
random,
|
|
85
84
|
/**
|
|
86
|
-
* Raises
|
|
85
|
+
* Raises `a` to the power `b`, returning `a ** b` as an `Uint8` (floored to
|
|
86
|
+
* an integer).
|
|
87
87
|
*
|
|
88
|
-
* @param
|
|
89
|
-
* @param
|
|
90
|
-
* @returns `
|
|
88
|
+
* @param a - The base non-negative integer
|
|
89
|
+
* @param b - The exponent non-negative integer
|
|
90
|
+
* @returns `a ** b` as an `Uint8`
|
|
91
91
|
*/
|
|
92
92
|
pow,
|
|
93
93
|
/**
|
|
94
|
-
* Adds two
|
|
94
|
+
* Adds two non-negative integers, returning `a + b` as an `Uint8`.
|
|
95
95
|
*
|
|
96
|
-
* @param
|
|
97
|
-
* @param
|
|
98
|
-
* @returns `
|
|
96
|
+
* @param a - The first non-negative integer
|
|
97
|
+
* @param b - The second non-negative integer
|
|
98
|
+
* @returns The sum of `a` and `b` as an `Uint8`
|
|
99
99
|
*/
|
|
100
100
|
add,
|
|
101
101
|
/**
|
|
102
|
-
* Subtracts two
|
|
102
|
+
* Subtracts two non-negative integers, returning `a - b` as an `Uint8`.
|
|
103
103
|
*
|
|
104
|
-
* @param
|
|
105
|
-
* @param
|
|
106
|
-
* @returns `
|
|
104
|
+
* @param a - The first non-negative integer
|
|
105
|
+
* @param b - The second non-negative integer
|
|
106
|
+
* @returns The difference of `a` and `b` as an `Uint8`
|
|
107
107
|
*/
|
|
108
108
|
sub,
|
|
109
109
|
/**
|
|
110
|
-
* Multiplies two
|
|
110
|
+
* Multiplies two non-negative integers, returning `a * b` as an `Uint8`.
|
|
111
111
|
*
|
|
112
|
-
* @param
|
|
113
|
-
* @param
|
|
114
|
-
* @returns `
|
|
112
|
+
* @param a - The first non-negative integer
|
|
113
|
+
* @param b - The second non-negative integer
|
|
114
|
+
* @returns The product of `a` and `b` as an `Uint8`
|
|
115
115
|
*/
|
|
116
116
|
mul,
|
|
117
117
|
/**
|
|
118
|
-
* Divides two
|
|
118
|
+
* Divides two non-negative integers using floor division (`⌊a / b⌋`): the
|
|
119
|
+
* result is `a / b` rounded toward negative infinity, as an `Uint8`.
|
|
119
120
|
*
|
|
120
|
-
* @param
|
|
121
|
-
* @param
|
|
122
|
-
* @returns
|
|
121
|
+
* @param a - The dividend
|
|
122
|
+
* @param b - The divisor (must be non-zero)
|
|
123
|
+
* @returns The floored quotient as an `Uint8`
|
|
123
124
|
*/
|
|
124
125
|
div
|
|
125
126
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint8.mjs","sources":["../../../src/number/enum/uint8.mts"],"sourcesContent":["import { type Uint8 as TtfImported_Uint8, type Uint16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type Uint8 = TtfImported_Uint8;\n\nconst typeNameInMessage = 'an non-negative integer less than 256';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n castType: castTypeImpl,\n clamp: clampImpl,\n is: isImpl,\n random: randomImpl,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<Uint16, 0, 255>(\n {\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 0,\n MAX_VALUE: 255,\n typeNameInMessage,\n } as const,\n);\n\nconst is = (x: number): x is Uint8 => isImpl(x);\n\nconst castType = (x: number): Uint8 =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n castTypeImpl(x) as Uint8;\n\nconst clamp = (a: number): Uint8 => castType(clampImpl(a));\n\nconst min_ = (...values: readonly Uint8[]): Uint8 =>\n castType(Math.min(...values));\n\nconst max_ = (...values: readonly Uint8[]): Uint8 =>\n castType(Math.max(...values));\n\nconst pow = (x: Uint8, y: Uint8): Uint8 => clamp(x ** y);\n\nconst add = (x: Uint8, y: Uint8): Uint8 => clamp(x + y);\n\nconst sub = (x: Uint8, y: Uint8): Uint8 => clamp(x - y);\n\nconst mul = (x: Uint8, y: Uint8): Uint8 => clamp(x * y);\n\nconst div = (x: Uint8, y: Exclude<Uint8, 0>): Uint8 => clamp(Math.floor(x / y));\n\nconst random = (min: Uint8, max: Uint8): Uint8 =>\n castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"uint8.mjs","sources":["../../../src/number/enum/uint8.mts"],"sourcesContent":["import { type Uint8 as TtfImported_Uint8, type Uint16 } from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type Uint8 = TtfImported_Uint8;\n\nconst typeNameInMessage = 'an non-negative integer less than 256';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n castType: castTypeImpl,\n clamp: clampImpl,\n is: isImpl,\n random: randomImpl,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<Uint16, 0, 255>(\n {\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 0,\n MAX_VALUE: 255,\n typeNameInMessage,\n } as const,\n);\n\nconst is = (x: number): x is Uint8 => isImpl(x);\n\nconst castType = (x: number): Uint8 =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n castTypeImpl(x) as Uint8;\n\nconst clamp = (a: number): Uint8 => castType(clampImpl(a));\n\nconst min_ = (...values: readonly Uint8[]): Uint8 =>\n castType(Math.min(...values));\n\nconst max_ = (...values: readonly Uint8[]): Uint8 =>\n castType(Math.max(...values));\n\nconst pow = (x: Uint8, y: Uint8): Uint8 => clamp(x ** y);\n\nconst add = (x: Uint8, y: Uint8): Uint8 => clamp(x + y);\n\nconst sub = (x: Uint8, y: Uint8): Uint8 => clamp(x - y);\n\nconst mul = (x: Uint8, y: Uint8): Uint8 => clamp(x * y);\n\nconst div = (x: Uint8, y: Exclude<Uint8, 0>): Uint8 => clamp(Math.floor(x / y));\n\nconst random = (min: Uint8, max: Uint8): Uint8 =>\n castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));\n\n/**\n * Type guard that checks if a value is an non-negative integer less than 256.\n *\n * Returns `true` for an non-negative integer less than 256 — a value with no\n * fractional component.\n *\n * @param value - The value to check\n * @returns `true` if the value is an non-negative integer less than 256, `false` otherwise\n */\nexport const isUint8 = is;\n\n/**\n * Casts a `number` to the `Uint8` branded type.\n *\n * Validates that the value is an non-negative integer less than 256 and returns\n * it with the `Uint8` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as an `Uint8`\n * @throws {TypeError} If the value is not an non-negative integer less than 256\n */\nexport const asUint8 = castType;\n\n/**\n * Namespace providing type-safe operations for the `Uint8` branded type.\n *\n * The `Uint8` type represents an non-negative integer less than 256. Division\n * (`div`) uses floor division.\n */\nexport const Uint8 = {\n /**\n * Type guard that checks if a value is an non-negative integer less than 256.\n *\n * @param value - The value to check\n * @returns `true` if the value is an non-negative integer less than 256, `false` otherwise\n * @see {@link isUint8} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `Uint8`.\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `Uint8`.\n */\n MAX_VALUE,\n\n /**\n * Returns the largest of the given non-negative integers.\n *\n * @param values - The non-negative integers to compare (at least one required)\n * @returns The largest value as an `Uint8`\n */\n max: max_,\n\n /**\n * Returns the smallest of the given non-negative integers.\n *\n * @param values - The non-negative integers to compare (at least one required)\n * @returns The smallest value as an `Uint8`\n */\n min: min_,\n\n /**\n * Clamps a `number` into the `Uint8` range, rounding to the nearest integer\n * and constraining the result to `[MIN_VALUE, MAX_VALUE]`.\n *\n * @param value - The value to clamp\n * @returns The clamped value as an `Uint8`\n */\n clamp,\n\n /**\n * Generates a random `Uint8` within the given range.\n *\n * The range is inclusive on both ends.\n *\n * @param min - The minimum value (inclusive)\n * @param max - The maximum value (inclusive)\n * @returns A random `Uint8` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as an `Uint8` (floored to\n * an integer).\n *\n * @param a - The base non-negative integer\n * @param b - The exponent non-negative integer\n * @returns `a ** b` as an `Uint8`\n */\n pow,\n\n /**\n * Adds two non-negative integers, returning `a + b` as an `Uint8`.\n *\n * @param a - The first non-negative integer\n * @param b - The second non-negative integer\n * @returns The sum of `a` and `b` as an `Uint8`\n */\n add,\n\n /**\n * Subtracts two non-negative integers, returning `a - b` as an `Uint8`.\n *\n * @param a - The first non-negative integer\n * @param b - The second non-negative integer\n * @returns The difference of `a` and `b` as an `Uint8`\n */\n sub,\n\n /**\n * Multiplies two non-negative integers, returning `a * b` as an `Uint8`.\n *\n * @param a - The first non-negative integer\n * @param b - The second non-negative integer\n * @returns The product of `a` and `b` as an `Uint8`\n */\n mul,\n\n /**\n * Divides two non-negative integers using floor division (`⌊a / b⌋`): the\n * result is `a / b` rounded toward negative infinity, as an `Uint8`.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as an `Uint8`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof Uint8,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n Uint16,\n 'int' | 'non-negative' | 'range'\n >\n>('=');\n"],"names":[],"mappings":";;AAMA,MAAM,iBAAA,GAAoB,uCAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA,EAAU,YAAA;AAAA,EACV,KAAA,EAAO,SAAA;AAAA,EACP,EAAA,EAAI,MAAA;AAAA,EACJ,MAAA,EAAQ;AACV,CAAA,GAAI,qBAAqB,kBAAA,CAAmB,mBAAA;AAAA,EAC1C;AAAA,IACE,oBAAA,EAAsB,aAAA;AAAA,IACtB,SAAA,EAAW,CAAA;AAAA,IACX,SAAA,EAAW,GAAA;AAAA,IACX;AAAA;AAEJ,CAAA;AAEA,MAAM,EAAA,GAAK,CAAC,CAAA,KAA0B,MAAA,CAAO,CAAC,CAAA;AAE9C,MAAM,WAAW,CAAC,CAAA;AAAA;AAAA,EAEhB,aAAa,CAAC;AAAA,CAAA;AAEhB,MAAM,QAAQ,CAAC,CAAA,KAAqB,QAAA,CAAS,SAAA,CAAU,CAAC,CAAC,CAAA;AAEzD,MAAM,IAAA,GAAO,IAAI,MAAA,KACf,QAAA,CAAS,KAAK,GAAA,CAAI,GAAG,MAAM,CAAC,CAAA;AAE9B,MAAM,IAAA,GAAO,IAAI,MAAA,KACf,QAAA,CAAS,KAAK,GAAA,CAAI,GAAG,MAAM,CAAC,CAAA;AAE9B,MAAM,MAAM,CAAC,CAAA,EAAU,CAAA,KAAoB,KAAA,CAAM,KAAK,CAAC,CAAA;AAEvD,MAAM,MAAM,CAAC,CAAA,EAAU,CAAA,KAAoB,KAAA,CAAM,IAAI,CAAC,CAAA;AAEtD,MAAM,MAAM,CAAC,CAAA,EAAU,CAAA,KAAoB,KAAA,CAAM,IAAI,CAAC,CAAA;AAEtD,MAAM,MAAM,CAAC,CAAA,EAAU,CAAA,KAAoB,KAAA,CAAM,IAAI,CAAC,CAAA;AAEtD,MAAM,GAAA,GAAM,CAAC,CAAA,EAAU,CAAA,KAAgC,MAAM,IAAA,CAAK,KAAA,CAAM,CAAA,GAAI,CAAC,CAAC,CAAA;AAE9E,MAAM,MAAA,GAAS,CAAC,GAAA,EAAY,GAAA,KAC1B,QAAA,CAAS,UAAA,CAAW,YAAA,CAAa,GAAG,CAAA,EAAG,YAAA,CAAa,GAAG,CAAC,CAAC,CAAA;AAWpD,MAAM,OAAA,GAAU;AAYhB,MAAM,OAAA,GAAU;AAQhB,MAAM,KAAA,GAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQnB,EAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA,EAKA,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,EASL,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,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AACF;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/string/index.mts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|