New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

promise-sequential

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

promise-sequential

Simple like Promise.all(), but sequentially!

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15K
decreased by-42.11%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 20 Sep 2016

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