Optionaldelay?: numberOptionalpredicate?: (value: T | U) => booleanOptionalreject?: (err: unknown) => UOptionalretry?: (n: number, duration: number) => booleanOptionalsignal?: AbortSignalAborting 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.
Repeatedly run
funtilpredicateholds 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 thedelaybefore it), so a stateful predicate can count attempts and a duration-based one is not overshot by the delay. When it refuses, no furthersleephappens andrejectreceives anErrorreporting the number of attempts actually made.