1.0.2 • Published 8 years ago
timeout-racer v1.0.2
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-racerUsage
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
1.0.2
8 years ago