async-autotarget
Select a specific subtree (or union of subtrees) of required functions from an input object appropriate for async.auto() [1]. The goal is to simplify writing async workflows with async.auto.
- https://github.com/caolan/async#auto
example
var async = require('async');
var autotarget = require('async-autotarget');
var everything = {
'vase': getVase,
'roses': [vase, getRoses],
'candles': ['roses', getCandles],
'oysters': getOysters,
'dessert': getDessert,
'movie': getMovie,
'popcorn': ['movie', getPopcorn]
};
function lovelyEvening(callback) {
async.auto(everything, function(err, evening) {
if (err) {
process.stderr.write("It was not meant to be.\n");
callback(err);
return;
}
callback(null, evening);
});
}
function movieNight(callback) {
async.auto(autotarget(everything, 'popcorn'), callback);
}
function movieNightWithDessert(callback) {
async.auto(autotarget(everything, ['popcorn', 'dessert']), callback);
}