Skip to content

Instantly share code, notes, and snippets.

@chrismeyersfsu
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismeyersfsu/b589f15ac6e196c0d23e to your computer and use it in GitHub Desktop.
Save chrismeyersfsu/b589f15ac6e196c0d23e to your computer and use it in GitHub Desktop.
async waterfall calldown with multiple arguments
// Notice the _.partialRight() call vs. the anonymous function needed in the file below.
var async = require('async');
var _ = require('lodash');
async.waterfall([
function (callback) {
getBeer(callback);
}, function (beer, callback) {
getBottleOpener(_.partialRight(callback, beer));
}
], function (err, bottleOpener, beer) {
openBeer(beer, bottleOpener);
})
function getBeer(cb) {
cb(null, 'beer');
}
function getBottleOpener(cb) {
cb(null, 'bottleOpener');
}
fucntion openBeer(beer, bottleOpener) {
}
}
var async = require('async');
async.waterfall([
function (callback) {
getBeer(callback);
}, function (beer, callback) {
getBottleOpener(function(err, bottleOpener) {
callback(err, beer, bottleOpener)
})
}
], function (err, beer, bottleOpener) {
openBeer(beer, bottleOpener);
})
function getBeer(cb) {
cb(null, 'beer');
}
function getBottleOpener(cb) {
cb(null, 'bottleOpener');
}
fucntion openBeer(beer, bottleOpener) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment