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

promise-flow

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-flow

Utility module for functions that return promises

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
63
increased by31.25%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

promise-flow

Utility module for functions that return promises

Example

import * as pf from 'promise-flow';

pf.allObject({
  key1: Promise.resolve('value from a promise'),
  key2: 'non-promise value'
}).then(function(result) {
  // result == { key1: 'value from a promise', key2: 'non-promise value' }
});

API

allObject(object)

Returns a promise that resolves with a copy of the input object when all values have resolved.

promise_flow.allObject({
  key1: Promise.resolve('value from a promise'),
  key2: 'non-promise value'
}).then(function(result) {
  // result == { key1: 'value from a promise', key2: 'non-promise value' }
});

series(factories)

Signature series<T>(factories: Array<() => Promise<T> | T): Array<T>

Takes an array of functions that will be executed in series. Each one will wait until the previous function is done.

If one of the functions returns a rejected promise or throws an error then the resulting promise will reject with that error.

promise_flow.series([
  () => Promise.resolve('value from a promise'),
  () => 'non-promise value'
]).then(function(result) {
  // result == ['value from a promise', 'non-promise value']
});

parallel(factories)

Signature parallel<T>(factories: Array<() => Promise<T> | T): Array<T>

Same as series but will run all functions in parallel.

Keywords

FAQs

Package last updated on 07 Sep 2015

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