import { Observable , Subscriber , Unsubscribable } from 'rxjs' ; interface AsyncIterator < T > { next ( value ? ) : Promise < IteratorResult < T > > ; return ? ( value ? ) : Promise < IteratorResult < T > > ; throw ? ( e ? ) : Promise < IteratorResult < T > > ; } export function fromAsyncIterator < T > ( iterator ) { return new Observable ( ( subscriber ) : Unsubscribable => { async function forwardValues ( ) { try { for ( let next = await iterator . next ( ) ; ! subscriber . closed && ! next . done ; ) { subscriber . next ( next . value ) ; next = await iterator . next ( ) ; } subscriber . complete ( ) ; } catch ( e ) { subscriber . error ( e ) ; } } forwardValues ( ) ; return { unsubscribe : ( ) => { } , } ; } ) ; }