import { IterableX } from '../iterablex' ; import { MonoTypeOperatorFunction } from '../../interfaces' ; export class RepeatIterable < TSource > extends IterableX < TSource > { private _source : Iterable < TSource > ; private _count : number ; constructor ( source , count ) { super ( ) ; this . _source = source ; this . _count = count ; } * [ Symbol . iterator ] ( ) { if ( this . _count === - 1 ) { while ( 1 ) { for ( const item of this . _source ) { yield item ; } } } else { for ( let i = 0 ; i < this . _count ; i ++ ) { for ( const item of this . _source ) { yield item ; } } } } } template TSource param { number } count returns { MonoTypeOperatorFunction < TSource > } export function repeat < TSource > ( count = - 1 ) { return function repeatOperatorFunction ( source ) : IterableX < TSource > { return new RepeatIterable < TSource > ( source , count ) ; } ; }