import { AsyncIterableX } from '../asynciterablex' ; import { MonoTypeOperatorAsyncFunction } from '../../interfaces' ; export class WithAbortAsyncIterable < TSource > extends AsyncIterableX < TSource > { private _source : AsyncIterable < TSource > ; private _signal : AbortSignal ; constructor ( source , signal ) { super ( ) ; this . _source = source ; this . _signal = signal ; } withAbort ( signal ) { return new WithAbortAsyncIterable < TSource > ( this . _source , signal ) ; } [ Symbol . asyncIterator ] ( ) { return this . _source [ Symbol . asyncIterator ] ( this . _signal ) ; } } template TSource param { AbortSignal } signal returns { MonoTypeOperatorAsyncFunction < TSource > } export function withAbort < TSource > ( signal ) { return function withAbortOperatorFunction ( source ) : AsyncIterableX < TSource > { return new WithAbortAsyncIterable ( source , signal ) ; } ; } template TSource param { AsyncIterable < TSource > } source param { AbortSignal } signal returns { AsyncIterable < TSource > } export function wrapWithAbort < TSource > ( source , signal ? ) { return signal ? new WithAbortAsyncIterable ( source , signal ) : source ; }