Vim snippets for most commonly used async functions
Place javascript.async.snippets
in ~/vim/snippets
and that's it.
Type 'aseach' and get:
async.each(
${1:array},
function(${2:item}, callback){
${3:callback();}
},
function(err){
if(err)
${4}
}
);
Type 'aseachseries' and get:
async.eachSeries(
${1:array},
function(${2:item}, callback){
${3:callback();}
},
function(err){
if(err)
${4}
}
);
Type 'asmap' and get:
async.map(
${1:array},
function(${2:item}, callback){
${3:callback();}
},
function(err){
if(err)
${4}
}
);
Type 'asparallel' and get:
async.parallel({
${1:one}: function(callback){
${2://body}
},
${3:two}: function(callback){
${4://body}
},
},
function(err, ${5:results}) {
${6}
});
Type 'asseries' and get:
async.series({
${1:one}: function(callback){
${2:callback(null,{})}
},
${3:two}: function(callback){
${4:callback(null,{})}
},
},
function(err, ${5:results}) {
${6}
});
Type 'aswaterfall' and get:
async.waterfall([
function(callback){
callback(null, ${1:'one'}, ${2:'two'});
,
function(${3:arg1}, ${4:arg2}, callback){
callback(null, ${5:'three'});
},
function(${6:arg1}, callback){
callback(null, ${7:'done'});
}
], function (err, ${8:result}) {
${9}
});