# p-waterfall

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

Latest version **3.0.0** (published 2021-04-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install p-waterfall
pnpm add p-waterfall
yarn add p-waterfall
bun add p-waterfall
```

## Health

**Score 43/100 (D)** — status: abandoned.

Positive: has types package; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2021-04-09 |
| First published | 2016-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/p-waterfall) |
| Module format | ESM |
| Node | >=12 |
| Dependencies | 1 |
| Unpacked size | 9.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 79 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | promise, waterfall, series, serial, sequence, sequential, ordered, task, tasks, array, collection, iterable, iterator, async, await, promises, bluebird |

## Links

- npm: https://www.npmjs.com/package/p-waterfall
- Repository: https://github.com/sindresorhus/p-waterfall
- Homepage: https://github.com/sindresorhus/p-waterfall#readme
- Issues: https://github.com/sindresorhus/p-waterfall/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/p-waterfall

## Dependencies (1)

- [p-reduce](https://npm.io/package/p-reduce.md) ^3.0.0

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 3.0.0 (latest) — 2021-04-09
- 2.1.1 — 2020-12-18
- 2.1.0 — 2019-04-03
- 2.0.0 — 2019-03-18
- 1.0.0 — 2016-11-22

## README

# p-waterfall

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

## Install

```
$ npm install p-waterfall
```

## Usage

```js
import pWaterfall from 'p-waterfall';

const tasks = [
	initialValue => getEmoji(initialValue),
	previousValue => `I ❤️ ${previousValue}`
];

console.log(await pWaterfall(tasks, 'unicorn'));
//=> 'I ❤️ 🦄'
```

## API

### pWaterfall(tasks, initialValue?)

Returns a `Promise` that is fulfilled when all promises returned from calling the functions in `tasks` are fulfilled, or rejects if any of the promises reject. The fulfilled value is the value returned from the last task.

#### tasks

Type: `Iterable<Function>`

Functions are expected to return a value. If a `Promise` is returned, it's awaited before continuing with the next task.

#### initialValue

Type: `unknown`

Value to use as `previousValue` in the first task.

## Related

- [p-series](https://github.com/sindresorhus/p-series) - Run promise-returning & async functions in series
- [p-each-series](https://github.com/sindresorhus/p-each-series) - Iterate over promises serially
- [More…](https://github.com/sindresorhus/promise-fun)

---

<div align="center">
	<b>
		<a href="https://tidelift.com/subscription/pkg/npm-p-waterfall?utm_source=npm-p-waterfall&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
	</b>
	<br>
	<sub>
		Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
	</sub>
</div>

---
_Source: https://npm.io/package/p-waterfall · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
