A chainable API for Async.js
Async.js async is a great shortcut for restraining deeply nested functions and callbacks. This module adds a chainable API to:
(This is particularly useful in single-file executable scripts.)
Note: It is important to understand how Async.js works to appreciate this example.
var async = require'async-chained';asyncchain// Waterfall – expect a returned value from callbackfirstfetchSomething'id' next;returnif !returnedObj return next;returnedObjmarkReadnext;// SeriesthenpersistChanges5000 next;// Switch to parallelandfetchRandomandfetchRelated'id' done;// Finishfinishif err return cberr;cbnull results0 results1;;
function(cb)run in series
function(arg1…n, cb)where arg1…n is the expected arguments to be returned from the previous callback, this signature will always be matched so that the last argument is the callback
function(cb)run in parallel
This module will attempt to extend a shallow clone of whatever version async you already have. The module therefore makes available all the methods already available on standard async. Perhaps, if we can establish that the 'chain' method name wouldn't clash with standard async, we could just extend without cloning.