# run-waterfall

> Run an array of functions in series, each passing its results to the next function (waterfall)

Latest version **1.1.7** (published 2020-10-27) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.7 |
| Published | 2020-10-27 |
| First published | 2014-04-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 91 |
| Author | Feross Aboukhadijeh |
| Maintainers | feross |
| Keywords | waterfall, series, async, function, callback, asynchronous, run, array, run waterfall |

## Links

- npm: https://www.npmjs.com/package/run-waterfall
- Repository: https://github.com/feross/run-waterfall
- Issues: https://github.com/feross/run-waterfall/issues
- Funding: https://github.com/sponsors/feross
- npm.io page: https://npm.io/package/run-waterfall

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.1.7 (latest) — 2020-10-27
- 1.1.6 — 2018-04-26
- 1.1.5 — 2018-04-26
- 1.1.4 — 2018-03-17
- 1.1.3 — 2015-09-22
- 1.1.2 — 2015-06-24
- 1.1.1 — 2015-05-05
- 1.1.0 — 2015-03-19
- 1.0.2 — 2014-04-29
- 1.0.1 — 2014-04-29
- 1.0.0 — 2014-04-29

## README

# run-waterfall [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]

[travis-image]: https://img.shields.io/travis/feross/run-waterfall/master.svg
[travis-url]: https://travis-ci.org/feross/run-waterfall
[npm-image]: https://img.shields.io/npm/v/run-waterfall.svg
[npm-url]: https://npmjs.org/package/run-waterfall
[downloads-image]: https://img.shields.io/npm/dm/run-waterfall.svg
[downloads-url]: https://npmjs.org/package/run-waterfall
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard-url]: https://standardjs.com

### Run an array of functions in series, **each passing its results to the next function**

![waterfall](https://raw.githubusercontent.com/feross/run-waterfall/master/img.png) [![Sauce Test Status](https://saucelabs.com/browser-matrix/run-waterfall.svg)](https://saucelabs.com/u/run-waterfall)

### install

```
npm install run-waterfall
```

### usage

#### waterfall(tasks, [callback])

Runs the `tasks` array of functions in series, **each passing their results to the next in
the array**. However, if any of the `tasks` pass an error to their own callback, the next
function is not executed, and the main `callback` is immediately called with the error.

##### arguments

- `tasks` - An array of functions to run, each function is passed a
`callback(err, result1, result2, ...)` it must call on completion. The first argument is
an error (which can be `null`) and any further arguments will be passed as arguments in
order to the next task.
- `callback(err, [results])` - An optional callback to run once all the functions have
completed. This will be passed the results of the last task's callback.

##### example

```js
var waterfall = require('run-waterfall')

waterfall([
  function (callback) {
    callback(null, 'one', 'two')
  },
  function (arg1, arg2, callback) {
    // arg1 now equals 'one' and arg2 now equals 'two'
    callback(null, 'three')
  },
  function (arg1, callback) {
    // arg1 now equals 'three'
    callback(null, 'done', 'wohoo')
  }
], function (err, result1, result2) {
   // result1 now equals 'done'
   // result2 now equals 'wohoo'
})
```

This module is basically equavalent to
[`async.waterfall`](https://github.com/caolan/async#waterfalltasks-callback), but it's
handy to just have the functions you need instead of the kitchen sink. Modularity!
Especially handy if you're serving to the browser and need to reduce your javascript
bundle size.

Works great in the browser with [browserify](http://browserify.org/)!

### see also

- [run-auto](https://github.com/feross/run-auto)
- [run-parallel](https://github.com/feross/run-parallel)
- [run-parallel-limit](https://github.com/feross/run-parallel-limit)
- [run-series](https://github.com/feross/run-series)

### license

MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).

Image credit: Waterfall designed by Luis Prado

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