import { AsyncIterableX } from '../asynciterablex' ; import { MonoTypeOperatorAsyncFunction } from '../../interfaces' ; import { wrapWithAbort } from './withabort' ; import { throwIfAborted } from '../../aborterror' ; export class SkipUntilAsyncIterable < TSource > extends AsyncIterableX < TSource > { private _source : AsyncIterable < TSource > ; private _other : ( signal ? : AbortSignal ) => Promise < any > ; constructor ( source , other ) { super ( ) ; this . _source = source ; this . _other = other ; } async * [ Symbol . asyncIterator ] ( signal ? ) { throwIfAborted ( signal ) ; let otherDone = false ; this . _other ( signal ) . then ( ( ) => ( otherDone = true ) ) ; for await ( const item of wrapWithAbort ( this . _source , signal ) ) { if ( otherDone ) { yield item ; } } } } template TSource param { ( signal ? : AbortSignal ) => Promise < any > } other returns { MonoTypeOperatorAsyncFunction < TSource > } export function skipUntil < TSource > ( other ) { return function skipUntilOperatorFunction ( source ) : AsyncIterableX < TSource > { return new SkipUntilAsyncIterable < TSource > ( source , other ) ; } ; }