UNPKG

@3fv/guard

Version:

TypeScript guard suite

27 lines (26 loc) 1.23 kB
/** * Is ES6+ class * * @see https://stackoverflow.com/questions/29093396/how-do-you-check-the-difference-between-an-ecmascript-6-class-and-function/49510834 * * @param {any} value * @returns {boolean} */ import type { ClassConstructor, TypeGuard } from "./types"; export declare function isNativeClass<T = any>(value: any): value is ClassConstructor<T>; /** * Is Conventional Class * Looks for function with capital first letter MyClass * First letter is the 9th character * If changed, isClass must also be updated * @param {any} value * @returns {boolean} */ export declare function isConventionalClass<T = any>(value: any): value is ClassConstructor<T>; export declare function isClass<T = any>(value: any, includeConventional?: boolean): value is ClassConstructor<T>; export declare function createInstanceOfGuard<T, Ctor extends ClassConstructor<T>>(ctor: Ctor): ((o: any) => o is T); export declare function instanceOf<T extends {}, Ctor extends ClassConstructor<T>>(ctor: Ctor): (o: any) => o is T; export declare function createGenericGuard<T>(tester: (val: any) => val is T): TypeGuard<T>; export declare function createGenericGuard<T>(type: { new (): T; }, tester: (val: any) => val is T): TypeGuard<T>;