@vcsuite/check
Advanced tools
Comparing version
@@ -8,5 +8,8 @@ declare const matcherSymbol: unique symbol; | ||
}; | ||
export type Pattern = typeof String | typeof Number | typeof Function | typeof Symbol | typeof Boolean | typeof Function | typeof Integer | typeof NonEmptyString | (new (...args: unknown[]) => unknown) | undefined | null | string | number | boolean | [ | ||
export type Pattern = typeof String | typeof Number | typeof Function | typeof Symbol | typeof Boolean | typeof Function | typeof Integer | typeof NonEmptyString | (new (...args: any[]) => any) | // use of any is justified and required to pass constructors | ||
undefined | null | string | number | boolean | symbol | [ | ||
Pattern | ||
] | Record<string, Pattern> | Matcher<unknown>; | ||
] | { | ||
[k: string | symbol]: Pattern; | ||
} | Matcher<any>; | ||
export type PatternMatch<T extends Pattern> = T extends Matcher<infer U> ? U : T extends typeof String ? string : T extends typeof Number ? number : T extends typeof Boolean ? boolean : T extends typeof Object ? object : T extends typeof Function ? Function : T extends undefined | null | string | number | boolean ? T : T extends new (...args: unknown[]) => infer U ? U : T extends [Pattern] ? PatternMatch<T[0]>[] : T extends { | ||
@@ -27,3 +30,5 @@ [key: string]: Pattern; | ||
export declare function inRange<T extends typeof Number | typeof Integer = typeof Number>(lowerLimit: number, upperLimit: number, type?: T): Matcher<PatternMatch<T>>; | ||
export declare function ofEnum<T extends string | number | symbol>(enumObject: Record<string, T>): Matcher<T>; | ||
export declare function ofEnum<T extends string | number | symbol>(enumObject: { | ||
[key: string]: T; | ||
}): Matcher<T>; | ||
export {}; |
@@ -212,2 +212,5 @@ const matcherSymbol = Symbol('isMatcher'); | ||
} | ||
if (testPattern === Object) { | ||
return object(testValue, {}, test); | ||
} | ||
if (testPattern instanceof Function) { // assumes constructor | ||
@@ -219,5 +222,2 @@ if (testValue instanceof testPattern) { | ||
} | ||
if (testPattern === Object) { | ||
return object(testValue, {}, test); | ||
} | ||
if (typeof testPattern === 'object') { | ||
@@ -224,0 +224,0 @@ const objError = object(testValue, testPattern, test); |
{ | ||
"name": "@vcsuite/check", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "check utilities for input type safety", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
21122
0.38%393
1.29%0
-100%