import { IterableX } from '../iterablex.js'; import { repeatValue } from '../repeatvalue.js'; import { catchAll } from '../catcherror.js'; import { MonoTypeOperatorFunction } from '../../interfaces.js'; /** * Retries the iterable instance the number of given times. If not supplied, it will try infinitely. * * @template TSource The type of the elements in the source sequence. * @param {number} [count=-1] An optional number of times to retry, otherwise is set to infinite retries * @returns {MonoTypeOperatorAsyncFunction} An iterable sequence producing the elements of the * given sequence repeatedly until it terminates successfully. */ export function retry(count = -1): MonoTypeOperatorFunction { return function retryOperatorFunction(source: Iterable): IterableX { return catchAll(repeatValue>(source, count)); }; }