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

promise-control-flow

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-control-flow

Wrapping the contra library to support promises (parallel/series)

  • 1.2.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30
decreased by-54.55%
Maintainers
1
Weekly downloads
 
Created
Source

promise-control-flow

Build Status Coverage Status

Wrapping the contra library to support working with promises. This enables you to pass promise-generating functions to the parallel and series methods and returns a promise instead of having to specify a callback

Install

npm install promise-control-flow

This module can be used for Node.js as well as browsers using Browserify.

Usage

Basic usage

const flow = require('promise-control-flow')

// Note: promisesArray expects to be built out of *functions*
// that return promises, because else the promises start 
// instantly and can't be run in series anymore.
let promiseArray = [
  () => new Promise(resolve => resolve('Test.')),
  // ...
]

// Work on all promises in parallel
flow.parallel(promiseArray)
  .then(results => console.log(results))

// Work on the promises in series
flow.series(promiseArray)
  .then(results => console.log(results))

API

  • parallel(tasks, [limit], [silenceErrors])
    • tasks - List of promise-returning functions
    • limit - Optional concurrency limit
    • silenceErrors - If optionally set to true, ignore errors in the promises and return null for failed promises instead
  • series(tasks, [silenceErrors])
    • tasks - List of promise-returning functions
    • silenceErrors - If optionally set to true, ignore errors in the promises and return null for failed promises instead

Tests

npm test

Licence

MIT

FAQs

Package last updated on 25 Sep 2018

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