https://github.com/caiogondim/timeout-racer.js
🏎️ Timeout for promises race
https://github.com/caiogondim/timeout-racer.js
Last synced: about 2 months ago
JSON representation
🏎️ Timeout for promises race
- Host: GitHub
- URL: https://github.com/caiogondim/timeout-racer.js
- Owner: caiogondim
- Created: 2017-01-11T20:16:56.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-17T17:40:06.000Z (about 7 years ago)
- Last Synced: 2025-03-18T14:56:47.065Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 68.4 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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
```js
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](https://caiogondim.com) ·
GitHub [@caiogondim](https://github.com/caiogondim) ·
Twitter [@caio_gondim](https://twitter.com/caio_gondim)