Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /** * Interface for classes that can be used as a type guard. * @see {@link Symbol.hasInstance} */ export interface IInstanceOf { /** * Checks if the object is an instance of the type. * @param obj The object to check. * @returns Whether the object is an instance of the type. */ [Symbol.hasInstance](obj: unknown): boolean; } /** * Checks if the object is an {@link IInstanceOf}. * @param obj The object to check. * @returns Whether the object is an {@link IInstanceOf}. */ export function isIInstanceOf(obj: unknown): obj is IInstanceOf { return ( obj != null && typeof obj === 'object' && typeof (obj as IInstanceOf)[Symbol.hasInstance] === 'function' ); } |