Skip to content

Commit

Permalink
Merge pull request #979 from marcolino/master
Browse files Browse the repository at this point in the history
Updated README.md
  • Loading branch information
aearly committed Jan 7, 2016
2 parents ed30825 + a3d1e80 commit 87fdf85
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,52 @@ async.waterfall([
// result now equals 'done'
});
```
Or, with named functions:
```js
async.waterfall([
myFirstFunction,
mySecondFunction,
myLastFunction,
], function (err, result) {
// result now equals 'done'
});
function myFirstFunction(callback) {
callback(null, 'one', 'two');
}
function mySecondFunction(arg1, arg2, callback) {
// arg1 now equals 'one' and arg2 now equals 'two'
callback(null, 'three');
}
function myLastFunction(arg1, callback) {
// arg1 now equals 'three'
callback(null, 'done');
}
```
Or, if you need to pass any argument to the first function:
```js
async.waterfall([
async.apply(myFirstFunction, 'zero'),
mySecondFunction,
myLastFunction,
], function (err, result) {
// result now equals 'done'
});
function myFirstFunction(arg1, callback) {
// arg1 now equals 'zero'
callback(null, 'one', 'two');
}
function mySecondFunction(arg1, arg2, callback) {
// arg1 now equals 'one' and arg2 now equals 'two'
callback(null, 'three');
}
function myLastFunction(arg1, callback) {
// arg1 now equals 'three'
callback(null, 'done');
}
```
---------------------------------------
<a name="compose" />
Expand Down

0 comments on commit 87fdf85

Please sign in to comment.