Skip to content

Instantly share code, notes, and snippets.

@stash
Created April 26, 2013 13:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stash/5467459 to your computer and use it in GitHub Desktop.
Save stash/5467459 to your computer and use it in GitHub Desktop.
async.waterfall gotchas
var async = require('async');
/*jshint noarg:false */
function first(next) {
console.log('first', arguments);
next(); // no params = nothing in next step
}
function second(next) {
console.log('second', arguments);
next(null); // no "result" params = nothing in next step
}
function third(next) {
console.log('third', arguments);
next(null,null); // explicit null param = one parameter in next step
}
function fourth(isNull, next) {
console.log('fourth', arguments);
next(null,'all done');
}
async.waterfall([
first,
second,
third,
fourth
], function(err,lastResult) {
console.log('finally', arguments);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment