prom-race
A better
Promise.race
Why use It?
Promise.race()
returning a forever pending promise when supplied an empty iterable, butprom-race
will NOT!prom-race
will call the others promises'cancel
method if possible.
Installation
npm install prom-race# or use yarn yarn add prom-race
Usage
const promRace =
API
race
Parameters
iterable
{Iterable} An iterable object, such as an Array.options
Object {{}}options.cancelWhenFinished
{boolean} - Whether call the others promises'cancel
method. (optional, defaulttrue
)
Returns Promise<any>
Contributing
- Fork it!
- Create your new branch:
git checkout -b feature-new
orgit checkout -b fix-which-bug
- Start your magic work now
- Make sure npm test passes
- Commit your changes:
git commit -am 'feat: some description (close #123)'
orgit commit -am 'fix: some description (fix #123)'
- Push to the branch:
git push
- Submit a pull request :)
Authors
This library is written and maintained by imcuttle, moyuyc95@gmail.com.
License
MIT - imcuttle 🐟