summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Early <alexander.early@gmail.com>2016-01-07 14:56:48 -0800
committerAlexander Early <alexander.early@gmail.com>2016-01-07 14:56:48 -0800
commit87fdf85f097d8a55d25eb745e5615344bc453c3a (patch)
treed5ad9aa440434fc4e8fc6d913d9ddaf10442de56
parented308256f5810ea015bb7673bcfe3d29545786ff (diff)
parenta3d1e801216dcc1a75468997839e17828e7433c7 (diff)
downloadasync-87fdf85f097d8a55d25eb745e5615344bc453c3a.tar.gz
Merge pull request #979 from marcolino/master
Updated README.md
-rw-r--r--README.md46
1 files changed, 46 insertions, 0 deletions
diff --git a/README.md b/README.md
index 0ec79c1..d5d1b7e 100644
--- a/README.md
+++ b/README.md
@@ -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" />