import { AsyncIterableX } from '../asynciterablex.js'; import { concat } from '../concat.js'; import { whileDo } from '../whiledo.js'; import { MonoTypeOperatorAsyncFunction } from '../../interfaces.js'; /** * Generates an async-iterable sequence by repeating a source sequence as long as the given loop postcondition holds. * * @template TSource The type of elements in the source sequence. * @param {((signal?: AbortSignal) => boolean | Promise)} condition Loop condition. * @returns {MonoTypeOperatorAsyncFunction} An operator that generates an async-iterable by repeating a * source sequence while the postcondition holds. */ export function doWhile( condition: (signal?: AbortSignal) => boolean | Promise ): MonoTypeOperatorAsyncFunction { return function doWhileOperatorFunction(source: AsyncIterable): AsyncIterableX { return concat(source, whileDo(source, condition)); }; }