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

p-waterfall

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-waterfall

Run promise-returning & async functions in series, each passing its result to the next

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is p-waterfall?

The p-waterfall npm package allows you to run promise-returning & async functions in series, each passing its result to the next. It is useful for scenarios where you need to perform a series of asynchronous operations in a specific order, with each operation depending on the result of the previous one.

What are p-waterfall's main functionalities?

Running a series of promise-returning functions

This feature allows you to run a series of promise-returning functions in sequence. Each function receives the result of the previous function as its input. In this example, the initial value is 5, and the series of operations results in 9.

const pWaterfall = require('p-waterfall');

const tasks = [
  initialValue => Promise.resolve(initialValue + 1),
  previousValue => Promise.resolve(previousValue * 2),
  previousValue => Promise.resolve(previousValue - 3)
];

pWaterfall(tasks, 5).then(result => {
  console.log(result); // 9
});

Running a series of async functions

This feature allows you to run a series of async functions in sequence. Each function receives the result of the previous function as its input. In this example, the initial value is 5, and the series of operations results in 9.

const pWaterfall = require('p-waterfall');

const tasks = [
  async initialValue => initialValue + 1,
  async previousValue => previousValue * 2,
  async previousValue => previousValue - 3
];

pWaterfall(tasks, 5).then(result => {
  console.log(result); // 9
});

Other packages similar to p-waterfall

Keywords

FAQs

Package last updated on 09 Apr 2021

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