import { IterableActivity , Source , isSource } from "./activity" ; export type FilterCallback < T > = ( value : T , index : number ) => boolean ; function filterGen < T = any > ( callbackFn ) { return function * ( source ) { let i = - 1 ; for ( const item of source ) { if ( callbackFn ( item , ++ i ) ) { yield item ; } } } ; } export function filter < T = any > ( callbackFn ) ; export function filter < T > ( source , callbackFn ) ; export function filter < T > ( s_or_cb , callbackFn ? ) { return isSource ( s_or_cb ) ? filterGen ( callbackFn ! ) ( s_or_cb ) : filterGen ( s_or_cb ) ; }