import { AsyncIterableX } from './asynciterablex' ; import { sleep } from './_sleep' ; import { throwIfAborted } from '../aborterror' ; class IntervalAsyncIterable extends AsyncIterableX < number > { private _dueTime : number ; constructor ( dueTime ) { super ( ) ; this . _dueTime = dueTime ; } async * [ Symbol . asyncIterator ] ( signal ? ) { throwIfAborted ( signal ) ; let i = 0 ; while ( 1 ) { await sleep ( this . _dueTime , signal ) ; yield i ++ ; } } } param { number } dueTime returns { AsyncIterableX < number > } export function interval ( dueTime ) { return new IntervalAsyncIterable ( dueTime ) ; }