import { AsyncIterableX } from '../asynciterablex.js'; import { MonoTypeOperatorAsyncFunction } from '../../interfaces.js'; import { wrapWithAbort } from './withabort.js'; import { throwIfAborted } from '../../aborterror.js'; /** @ignore */ export class IgnoreElementsAsyncIterable extends AsyncIterableX { private _source: AsyncIterable; constructor(source: AsyncIterable) { super(); this._source = source; } async *[Symbol.asyncIterator](signal?: AbortSignal): AsyncIterator { throwIfAborted(signal); // eslint-disable-next-line no-empty for await (const _ of wrapWithAbort(this._source, signal)) { } } } /** * Ignores all elements in an async-iterable sequence leaving only the termination messages. * * @template TSource The type of the elements in the source sequence * @returns {MonoTypeOperatorAsyncFunction} An operator that returns an empty async-iterable sequence * that signals termination, successful or exceptional, of the source sequence. */ export function ignoreElements(): MonoTypeOperatorAsyncFunction { return function ignoreElementsOperatorFunction( source: AsyncIterable ): AsyncIterableX { return new IgnoreElementsAsyncIterable(source); }; }