Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

promise-count

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-count

Come in handy a few times; an alternative to `Promise.all` but without the fail-fast behaviour ```js const promise1 = new Promise((resolve, reject) => setTimeout(() => reject(1), 5000)) const promise2 = new Promise((resolve, reject) => resolve(2)) promise

  • 0.0.7
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

promise-count

Come in handy a few times; an alternative to Promise.all but without the fail-fast behaviour

const promise1 = new Promise((resolve, reject) => setTimeout(() => reject(1), 5000))
const promise2 = new Promise((resolve, reject) => resolve(2))
promises = [promise1, promise2, promise2]
// calling PromiseCount(promises) would resolve to 
[{success: true, value: 2}, {success: true, value: 2}, { success: false, value: 1}]

Example usage

async () => {
  const promises = [promise1, promise2, promise2]

  const results = await PromiseCount(promises)

  console.log('Number of resolved promises:', results.filter(r => r.success).length)
  console.log('Number of rejected promises:', results.filter(r => !r.success).length)
}

FAQs

Package last updated on 22 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc