Skip to content

Instantly share code, notes, and snippets.

@riston
Created April 22, 2012 11:57
Show Gist options
  • Save riston/2463820 to your computer and use it in GitHub Desktop.
Save riston/2463820 to your computer and use it in GitHub Desktop.
Async code flow forEach
var names = ['Juhan', 'Mikk', 'Tuuli', 'Oskar'];
var newList = [];
function welcome(name, callback) {
name += ', hello';
console.log(name);
newList.push(name);
callback(null, name);
}
async.forEach(names, welcome, function(err) {
console.log('Completed');
console.log(newList);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment