import { AsyncIterableX } from '../asynciterablex' ; import { MonoTypeOperatorAsyncFunction } from '../../interfaces' ; import { wrapWithAbort } from './withabort' ; import { throwIfAborted } from '../../aborterror' ; export class SkipAsyncIterable < TSource > extends AsyncIterableX < TSource > { private _source : AsyncIterable < TSource > ; private _count : number ; constructor ( source , count ) { super ( ) ; this . _source = source ; this . _count = count ; } async * [ Symbol . asyncIterator ] ( signal ? ) { throwIfAborted ( signal ) ; const source = wrapWithAbort ( this . _source , signal ) ; const it = source [ Symbol . asyncIterator ] ( ) ; let count = this . _count ; let next ; while ( count > 0 && ! ( next = await it . next ( ) ) . done ) { count -- ; } if ( count <= 0 ) { while ( ! ( next = await it . next ( ) ) . done ) { yield next . value ; } } } } template TSource param { number } count returns { MonoTypeOperatorAsyncFunction < TSource > } export function skip < TSource > ( count ) { return function skipOperatorFunction ( source ) : AsyncIterableX < TSource > { return new SkipAsyncIterable < TSource > ( source , count ) ; } ; }