Quote from site :
Async is a utility module which provides straight-forward, powerful functions
for working with asynchronous JavaScript. Although originally designed for
use with Node.js, it can also be used directly in the
browser. Also supports component.
Async provides around 20 functions that include the usual 'functional'
suspects (map
, reduce
, filter
, each
…) as well as some common patterns
for asynchronous control flow (parallel
, series
, waterfall
…). All these
functions assume you follow the Node.js convention of providing a single
callback as the last argument of your async
function.
https://github.com/caolan/async
Quick Examples :
async.map(['file1','file2','file3'], fs.stat, function(err, results){
// results is now an array of stats for each file
});
async.filter(['file1','file2','file3'], fs.exists, function(results){
// results now equals an array of the existing files
});
async.parallel([
function(){ ... },
function(){ ... }
], callback);
async.series([
function(){ ... },
function(){ ... }
]);