The type of value the predicate returns.
The function to evaluate repeatedly until it returns a truthy value.
Optional
options: number | OptionsEither the timeout duration in milliseconds, or an options object for configuring the wait behavior.
Optional
intervalBetweenAttempts: numberThe interval (in milliseconds) between predicate evaluations. Ignored if options
is an object.
A promise that resolves to the truthy value returned by the predicate, or rejects with a TimeoutError
if the timeout is reached.
Waits until a predicate evaluates to a truthy value or the specified timeout is reached.
Example
Basic usage with a simple condition:
Example
Usage with custom interval between attempts:
Example
Infinite wait with manual timeout handling: