timeout
Create a promise that rejects after some time
246 bytes
Usage
The timeout
function creates a promise that rejects after a specified delay, with an optional custom error message or error function.
The default error is a TimeoutError
with the message “Operation timed out”.
Example with Promise.race
One of the most useful ways to use _.timeout
with Promise.race
to set a timeout for an asynchronous operation.