Run an array of functions in series, each passing its results to the next function (waterfall)
npm install run-waterfall[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
!waterfall 
```
npm install run-waterfall
#### waterfall(tasks, [callback])
Runs the tasks array of functions in series, **each passing their results to the next intasks
the array**. However, if any of the pass an error to their own callback, the nextcallback
function is not executed, and the main is immediately called with the error.
##### arguments
- tasks - An array of functions to run, each function is passed acallback(err, result1, result2, ...) it must call on completion. The first argument isnull
an error (which can be ) and any further arguments will be passed as arguments incallback(err, [results])
order to the next task.
- - 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`, 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!
- run-auto
- run-parallel
- run-parallel-limit
- run-series
MIT. Copyright (c) Feross Aboukhadijeh.
Image credit: Waterfall designed by Luis Prado