timeout-racer
v1.0.2
Published
Timeout for promises race
Downloads
4
Readme
timeout-racer
timeoutRacer
is a promise that rejects itself after n
miliseconds passed as an argument.
Useful to put a timeout on races between Promises.
Installation
npm install --save timeout-racer
Usage
Promise.race([
fooBarPromise(),
timeoutRacer(15000)
])
.then(() => {
// Will run if `fooBarPromise` resolves
})
.catch(() => {
// Will run if 15000 miliseconds passed
// or `fooBarPromise` rejects.
})
Credits
- Icon by Corey Felter from the Noun Project
caiogondim.com · GitHub @caiogondim · Twitter @caio_gondim