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

@chymz/promise-utils

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chymz/promise-utils

Promise utils functions

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

PromiseUtils

Some useful functions for promises

Install :

npm install @chymz/promise-utils

Progress callback

When you call all(), props(), series() or seriesProps() returned promise have an available progress() method to listen progress of promises executions

Usage :

import PromiseUtils from '@chymz/promise-utils';

PromiseUtils.all([
  promise(),
  promise(),
  promise()
])
.progress((current, total) => {
  let percent = current / total * 100;
})
.then(results => {
  // ...
})

props()

Instead of using an array with Promise.all() you can pass an object to PromiseUtils.props()

Usage :

import PromiseUtils from '@chymz/promise-utils';

PromiseUtils.props({
  one: promise(),
  two: promise()
})
.then(results => {
  /*
  results object is like :
    {
      one: 'result of first promise',
      two: 'result of second promise'
    }
  */
})

series()

@todo : description (see tests/index.js)

seriesProps()

@todo : description (see tests/index.js)

Override Promise class used by this lib

If you don't want to use native Promise class, you can do this :

import Bluebird from 'bluebird';
import PromiseUtils from 'promise-utils';

PromiseUtils.Promise = Bluebird;

// or simply :

global.Promise = Bluebird;

Todo

  • Polyfill note for IE11 & Old browsers
  • series() & seriesProps() description/samples

License

See LICENSE file

Keywords

FAQs

Package last updated on 08 Mar 2017

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