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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 10x 3876x 1214x 2662x 2662x 10x 10x 4295x 10x 2645x 10x 3582x 10x 5597x 10x 10x 10x 1849x | import { Prototype } from './types.util';
export function getPrototype(
// eslint-disable-next-line @typescript-eslint/ban-types
target: Record<string, any> | Function | undefined,
): Prototype<any> {
if (isFunction(target)) {
return target.prototype;
} else Iif (target === null || target === undefined) {
return target as any;
}
// eslint-disable-next-line no-prototype-builtins
return Object.getOwnPropertyDescriptor(target, 'constructor')?.enumerable ===
false
? target
: Object.getPrototypeOf(target);
}
export function isAnnotation(obj: unknown): boolean {
return (
typeof obj === 'function' &&
typeof (obj as any).ref?.groupId === 'string' &&
typeof (obj as any).ref?.name === 'string'
);
}
export function isFunction(
value: unknown,
): value is (...args: unknown[]) => unknown {
return typeof value === 'function';
}
export function isObject(value: unknown): value is object {
return typeof value === 'object' && !Array.isArray(value);
}
export function isNumber(value: unknown): value is number {
return typeof value === 'number';
}
export function isUndefined(value: unknown): value is undefined {
return typeof value === 'undefined';
}
export function isEmpty(value: unknown[]): boolean {
return value.length === 0;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function isPromise(obj: any): obj is Promise<unknown> {
return isFunction(obj?.then);
}
export function isClassInstance(obj: any): boolean {
return (
typeof obj === 'object' && getPrototype(obj) === Object.getPrototypeOf(obj)
);
}
|