import { AsyncIterableX } from './asynciterablex' ; import { throwIfAborted } from '../aborterror' ; export class RepeatValueAsyncIterable < TSource > extends AsyncIterableX < TSource > { private _value : TSource ; private _count : number ; constructor ( value , count ) { super ( ) ; this . _value = value ; this . _count = count ; } async * [ Symbol . asyncIterator ] ( signal ? ) { if ( this . _count === - 1 ) { while ( 1 ) { throwIfAborted ( signal ) ; yield this . _value ; } } else { for ( let i = 0 ; i < this . _count ; i ++ ) { throwIfAborted ( signal ) ; yield this . _value ; } } } } template TSource param { TSource } value param { number } count returns { AsyncIterableX < TSource > } export function repeatValue < TSource > ( value , count = - 1 ) { return new RepeatValueAsyncIterable < TSource > ( value , count ) ; }