1.0.2 • Published 7 years ago

timeout-racer v1.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

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