prom-race

1.0.0 • Public • Published

prom-race

Build status Test coverage NPM version NPM Downloads Prettier Conventional Commits

A better Promise.race

Why use It?

  1. Promise.race() returning a forever pending promise when supplied an empty iterable, but prom-race will NOT!
  2. 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 = require('prom-race')

API

race

index.js:14-58

Parameters

  • iterable {Iterable} An iterable object, such as an Array.
  • options Object {{}}
    • options.cancelWhenFinished {boolean} - Whether call the others promises' cancel method. (optional, default true)

Returns Promise<any>

Contributing

  • Fork it!
  • Create your new branch:
    git checkout -b feature-new or git 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)' or git 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 🐟

Package Sidebar

Install

npm i prom-race

Weekly Downloads

11

Version

1.0.0

License

MIT

Unpacked Size

9.63 kB

Total Files

11

Last publish

Collaborators

  • moyuyc