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