Socket
Socket
Sign inDemoInstall

promise-sequential

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    promise-sequential

Simple like Promise.all(), but sequentially!


Version published
Weekly downloads
70K
decreased by-2.05%
Maintainers
1
Install size
6.58 kB
Created
Weekly downloads
 

Readme

Source

promise-sequential

Simple like Promise.all(), but sequentially!

NPM version

Npm Downloads

Installation

npm install --save promise-sequential

Usage

const sequential = require('promise-sequential');

const items = [
  () => new Promise( ... )
  () => new Promise( ... )
  () => new Promise( ... )
];

sequential(items)
.then(res => {
  // ...
})
.catch(err => {
  // ...
})

There is only one difference between Promise.all usage and promise-sequential usage: promise-sequential receive an Array of functions that each returns a promise.

Each function brings three params:

NameDescription
previousResponseThe response of previous iteration
responsesAll responses received at the time
countThe current count.

More complex usage


const sequential = require('promise-sequential');
const array = [1,2,3,4,5];

sequential(array.map((item) => {
  return function(previousResponse, responses, count) {

    return new Promise(resolve => {
      setTimeout(() => {
        resolve(item)
      }, 1000)
    })

  }
}))
.then(res => {
  // ...
})
.catch(err => {
  // ...
})

Keywords

FAQs

Last updated on 20 Sep 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc