import { AsyncIterableX } from '../asynciterablex' ; import { MonoTypeOperatorAsyncFunction } from '../../interfaces' ; import { wrapWithAbort } from './withabort' ; import { throwIfAborted } from '../../aborterror' ; export class EndWithAsyncIterable < TSource > extends AsyncIterableX < TSource > { private _source : AsyncIterable < TSource > ; private _args : TSource [ ] ; constructor ( source , args ) { super ( ) ; this . _source = source ; this . _args = args ; } async * [ Symbol . asyncIterator ] ( signal ? ) { throwIfAborted ( signal ) ; for await ( const item of wrapWithAbort ( this . _source , signal ) ) { yield item ; } for ( const x of this . _args ) { yield x ; } } } template TSource param { ... TSource [ ] } args returns { MonoTypeOperatorAsyncFunction < TSource > } export function endWith < TSource > ( ... args ) { return function endsWithOperatorFunction ( source ) : AsyncIterableX < TSource > { return new EndWithAsyncIterable < TSource > ( source , args ) ; } ; }