import { IEnumerable } from "../types" ; import { ArrayEnumerable } from "./ArrayEnumerable" ; import { BasicEnumerable } from "./BasicEnumerable" ; param source returns export const isEnumerable = ( source ) : source is IEnumerable < any > => { if ( ! source ) { return false ; } if ( source instanceof BasicEnumerable ) { return true ; } if ( source instanceof ArrayEnumerable ) { return true ; } if ( typeof source [ Symbol . iterator ] !== "function" ) { return false ; } const propertyNames = Object . getOwnPropertyNames ( BasicEnumerable . prototype ) . filter ( ( v ) => v !== "constructor" ) ; const methods = source . prototype || source ; for ( const prop of propertyNames ) { if ( typeof methods [ prop ] !== "function" ) { return false ; } } return true ; } ;