waitWithTimeout
Callable
Type parameters
- T
Parameters
awaitable: Promise<T> | AsyncFunction<T, unknown>
The promise or function to wait for.
timeout: number
The timeout in milliseconds.
error: Error
(Optional) The error to throw if the timeout reached.
Returns Promise<T>
Wait for a promise but interrupt it if it did not resolve within a given timeout. If the timeout reached, before the promise code resolve, either throw an error if an error object was provided, or return
undefined
.