import { IterableX } from '../iterablex' ; import { OperatorFunction } from '../../interfaces' ; export class FilterIterable < TSource > extends IterableX < TSource > { private _source : Iterable < TSource > ; private _predicate : ( value : TSource , index : number ) => boolean ; private _thisArg ? : any ; constructor ( source , predicate , thisArg ? ) { super ( ) ; this . _source = source ; this . _predicate = predicate ; this . _thisArg = thisArg ; } * [ Symbol . iterator ] ( ) { let i = 0 ; for ( const item of this . _source ) { if ( this . _predicate . call ( this . _thisArg , item , i ++ ) ) { yield item ; } } } } export function filter < T , S extends T > ( predicate , thisArg ? ) ; export function filter < T > ( predicate , thisArg ? ) ; template TSource param { ( ( value : TSource , index : number ) => boolean ) } predicate param { * } thisArg returns { OperatorFunction < TSource , TSource > } export function filter < TSource > ( predicate , thisArg ? ) { return function filterOperatorFunction ( source ) : IterableX < TSource > { return new FilterIterable < TSource > ( source , predicate , thisArg ) ; } ; }