import { InjectionToken, Type } from '@angular/core'; export function getSourceForInstance(instance: T): T { return Object.getPrototypeOf(instance); } export function isClassInstance(obj: object): boolean { return ( !!obj.constructor && obj.constructor.name !== 'Object' && obj.constructor.name !== 'Function' ); } export function isClass( classOrRecord: Type | Record ): classOrRecord is Type { return typeof classOrRecord === 'function'; } export function getClasses( classesAndRecords: Array | Record> ): Type[] { return classesAndRecords.filter(isClass); } export function isToken( tokenOrRecord: | Type | InjectionToken | Record ): tokenOrRecord is Type | InjectionToken { return tokenOrRecord instanceof InjectionToken || isClass(tokenOrRecord); } // TODO: replace with RxJS interfaces when possible // needs dependency on RxJS >=7 export interface NextNotification { kind: 'N'; value: T; } export interface ErrorNotification { kind: 'E'; error: any; } export interface CompleteNotification { kind: 'C'; } export type ObservableNotification = | NextNotification | ErrorNotification | CompleteNotification;