Prelude API
    Preparing search index...

    Function eventually

    • Repeatedly run f until predicate holds for its result.

      retry(n, duration) is consulted exactly once per candidate attempt with the zero-based attempt index and the elapsed milliseconds at which that attempt would start (i.e. including the delay before it), so a stateful predicate can count attempts and a duration-based one is not overshot by the delay. When it refuses, no further sleep happens and reject receives an Error reporting the number of attempts actually made.

      Type Parameters

      • T
      • U

      Parameters

      • f: () => Promise<T>
      • __namedParameters: {
            delay?: number;
            predicate?: (value: T | U) => boolean;
            reject?: (err: unknown) => U;
            retry?: (n: number, duration: number) => boolean;
            signal?: AbortSignal;
        } = {}
        • Optionaldelay?: number
        • Optionalpredicate?: (value: T | U) => boolean
        • Optionalreject?: (err: unknown) => U
        • Optionalretry?: (n: number, duration: number) => boolean
        • Optionalsignal?: AbortSignal

          Aborting rejects the returned promise with signal.reason at once (not through reject): a pending delay is cut short, no further attempt starts, and an attempt already in flight is left to settle on its own with its outcome dropped — pass the same signal to f when its work should stop too.

      Returns Promise<T | U>