@augment-vir/common 11.3.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/augments/runtime-type-of.d.ts +4 -4
- package/dist/cjs/augments/runtime-type-of.js +2 -2
- package/dist/cjs/augments/type.d.ts +1 -0
- package/dist/esm/augments/runtime-type-of.d.ts +4 -4
- package/dist/esm/augments/runtime-type-of.js +2 -2
- package/dist/esm/augments/type.d.ts +1 -0
- package/dist/types/augments/runtime-type-of.d.ts +4 -4
- package/dist/types/augments/type.d.ts +1 -0
- package/package.json +2 -2
|
@@ -3,18 +3,18 @@ declare function rawGetTypeOf(x: any): "string" | "number" | "bigint" | "boolean
|
|
|
3
3
|
type RawTypeOf = ReturnType<typeof rawGetTypeOf>;
|
|
4
4
|
export type RuntimeTypeOf = RawTypeOf | 'array';
|
|
5
5
|
export type RuntimeTypeOfMapping = {
|
|
6
|
-
array: any[]
|
|
6
|
+
array: any[] | ReadonlyArray<any>;
|
|
7
7
|
bigint: bigint;
|
|
8
8
|
boolean: boolean;
|
|
9
|
-
function: AnyFunction
|
|
9
|
+
function: AnyFunction | Readonly<AnyFunction>;
|
|
10
10
|
number: number;
|
|
11
|
-
object: Record<PropertyKey, unknown
|
|
11
|
+
object: Record<PropertyKey, unknown> | Readonly<Record<PropertyKey, unknown>>;
|
|
12
12
|
string: string;
|
|
13
13
|
symbol: symbol;
|
|
14
14
|
undefined: undefined;
|
|
15
15
|
};
|
|
16
16
|
export declare function getRuntimeTypeOf(input: unknown): RuntimeTypeOf;
|
|
17
17
|
export declare function isRuntimeTypeOf<T extends RuntimeTypeOf>(input: unknown, testType: T): input is RuntimeTypeOfMapping[T];
|
|
18
|
-
export declare function assertRuntimeTypeOf<T extends RuntimeTypeOf>(input: unknown, testType: T): asserts input is RuntimeTypeOfMapping[T];
|
|
18
|
+
export declare function assertRuntimeTypeOf<T extends RuntimeTypeOf>(input: unknown, testType: T, inputName: string): asserts input is RuntimeTypeOfMapping[T];
|
|
19
19
|
export {};
|
|
20
20
|
//# sourceMappingURL=runtime-type-of.d.ts.map
|
|
@@ -15,9 +15,9 @@ function isRuntimeTypeOf(input, testType) {
|
|
|
15
15
|
return inputType === testType;
|
|
16
16
|
}
|
|
17
17
|
exports.isRuntimeTypeOf = isRuntimeTypeOf;
|
|
18
|
-
function assertRuntimeTypeOf(input, testType) {
|
|
18
|
+
function assertRuntimeTypeOf(input, testType, inputName) {
|
|
19
19
|
if (!isRuntimeTypeOf(input, testType)) {
|
|
20
|
-
throw new TypeError(`'${
|
|
20
|
+
throw new TypeError(`'${inputName}' is of type '${getRuntimeTypeOf(input)}' but type '${testType}' was expected.`);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
exports.assertRuntimeTypeOf = assertRuntimeTypeOf;
|
|
@@ -58,4 +58,5 @@ export type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
|
58
58
|
* input.
|
|
59
59
|
*/
|
|
60
60
|
export declare function ensureType<ExpectedType = never>(input: NoInfer<ExpectedType>): NoInfer<ExpectedType>;
|
|
61
|
+
export type TypedFunction<ParametersGeneric extends any[], ReturnTypeGeneric> = (...args: ParametersGeneric) => ReturnTypeGeneric;
|
|
61
62
|
//# sourceMappingURL=type.d.ts.map
|
|
@@ -3,18 +3,18 @@ declare function rawGetTypeOf(x: any): "string" | "number" | "bigint" | "boolean
|
|
|
3
3
|
type RawTypeOf = ReturnType<typeof rawGetTypeOf>;
|
|
4
4
|
export type RuntimeTypeOf = RawTypeOf | 'array';
|
|
5
5
|
export type RuntimeTypeOfMapping = {
|
|
6
|
-
array: any[]
|
|
6
|
+
array: any[] | ReadonlyArray<any>;
|
|
7
7
|
bigint: bigint;
|
|
8
8
|
boolean: boolean;
|
|
9
|
-
function: AnyFunction
|
|
9
|
+
function: AnyFunction | Readonly<AnyFunction>;
|
|
10
10
|
number: number;
|
|
11
|
-
object: Record<PropertyKey, unknown
|
|
11
|
+
object: Record<PropertyKey, unknown> | Readonly<Record<PropertyKey, unknown>>;
|
|
12
12
|
string: string;
|
|
13
13
|
symbol: symbol;
|
|
14
14
|
undefined: undefined;
|
|
15
15
|
};
|
|
16
16
|
export declare function getRuntimeTypeOf(input: unknown): RuntimeTypeOf;
|
|
17
17
|
export declare function isRuntimeTypeOf<T extends RuntimeTypeOf>(input: unknown, testType: T): input is RuntimeTypeOfMapping[T];
|
|
18
|
-
export declare function assertRuntimeTypeOf<T extends RuntimeTypeOf>(input: unknown, testType: T): asserts input is RuntimeTypeOfMapping[T];
|
|
18
|
+
export declare function assertRuntimeTypeOf<T extends RuntimeTypeOf>(input: unknown, testType: T, inputName: string): asserts input is RuntimeTypeOfMapping[T];
|
|
19
19
|
export {};
|
|
20
20
|
//# sourceMappingURL=runtime-type-of.d.ts.map
|
|
@@ -10,8 +10,8 @@ export function isRuntimeTypeOf(input, testType) {
|
|
|
10
10
|
const inputType = getRuntimeTypeOf(input);
|
|
11
11
|
return inputType === testType;
|
|
12
12
|
}
|
|
13
|
-
export function assertRuntimeTypeOf(input, testType) {
|
|
13
|
+
export function assertRuntimeTypeOf(input, testType, inputName) {
|
|
14
14
|
if (!isRuntimeTypeOf(input, testType)) {
|
|
15
|
-
throw new TypeError(`'${
|
|
15
|
+
throw new TypeError(`'${inputName}' is of type '${getRuntimeTypeOf(input)}' but type '${testType}' was expected.`);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -58,4 +58,5 @@ export type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
|
58
58
|
* input.
|
|
59
59
|
*/
|
|
60
60
|
export declare function ensureType<ExpectedType = never>(input: NoInfer<ExpectedType>): NoInfer<ExpectedType>;
|
|
61
|
+
export type TypedFunction<ParametersGeneric extends any[], ReturnTypeGeneric> = (...args: ParametersGeneric) => ReturnTypeGeneric;
|
|
61
62
|
//# sourceMappingURL=type.d.ts.map
|
|
@@ -3,18 +3,18 @@ declare function rawGetTypeOf(x: any): "string" | "number" | "bigint" | "boolean
|
|
|
3
3
|
type RawTypeOf = ReturnType<typeof rawGetTypeOf>;
|
|
4
4
|
export type RuntimeTypeOf = RawTypeOf | 'array';
|
|
5
5
|
export type RuntimeTypeOfMapping = {
|
|
6
|
-
array: any[]
|
|
6
|
+
array: any[] | ReadonlyArray<any>;
|
|
7
7
|
bigint: bigint;
|
|
8
8
|
boolean: boolean;
|
|
9
|
-
function: AnyFunction
|
|
9
|
+
function: AnyFunction | Readonly<AnyFunction>;
|
|
10
10
|
number: number;
|
|
11
|
-
object: Record<PropertyKey, unknown
|
|
11
|
+
object: Record<PropertyKey, unknown> | Readonly<Record<PropertyKey, unknown>>;
|
|
12
12
|
string: string;
|
|
13
13
|
symbol: symbol;
|
|
14
14
|
undefined: undefined;
|
|
15
15
|
};
|
|
16
16
|
export declare function getRuntimeTypeOf(input: unknown): RuntimeTypeOf;
|
|
17
17
|
export declare function isRuntimeTypeOf<T extends RuntimeTypeOf>(input: unknown, testType: T): input is RuntimeTypeOfMapping[T];
|
|
18
|
-
export declare function assertRuntimeTypeOf<T extends RuntimeTypeOf>(input: unknown, testType: T): asserts input is RuntimeTypeOfMapping[T];
|
|
18
|
+
export declare function assertRuntimeTypeOf<T extends RuntimeTypeOf>(input: unknown, testType: T, inputName: string): asserts input is RuntimeTypeOfMapping[T];
|
|
19
19
|
export {};
|
|
20
20
|
//# sourceMappingURL=runtime-type-of.d.ts.map
|
|
@@ -58,4 +58,5 @@ export type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
|
58
58
|
* input.
|
|
59
59
|
*/
|
|
60
60
|
export declare function ensureType<ExpectedType = never>(input: NoInfer<ExpectedType>): NoInfer<ExpectedType>;
|
|
61
|
+
export type TypedFunction<ParametersGeneric extends any[], ReturnTypeGeneric> = (...args: ParametersGeneric) => ReturnTypeGeneric;
|
|
61
62
|
//# sourceMappingURL=type.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augment-vir/common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/electrovir/augment-vir/issues"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"test:types": "tsc --noEmit"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"type-fest": "^3.5.
|
|
27
|
+
"type-fest": "^3.5.3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"typescript": "^4.9.4"
|