Creates a Promise that rejects after ms milliseconds if the provided Promise did not resolve or reject in time.
ms
Reject if promise takes over 500ms to resolve or reject
const timeoutAfter500ms = timeoutPromise(500, "err");try { await timeoutAfter500ms(myPromise); // takes over 500 ms} catch(err) { console.log(err); // "err"}
a new Promise that either uses the response of the provided Promise or rejects after ms milliseconds
the number of milliseconds for the timeout
Optional
the optional error to reject with
Generated using TypeDoc
Creates a Promise that rejects after
msmilliseconds if the provided Promise did not resolve or reject in time.Example
Reject if promise takes over 500ms to resolve or reject
Returns
a new Promise that either uses the response of the provided Promise or rejects after
msmilliseconds