Skip to content

Instantly share code, notes, and snippets.

@questsin
Created February 20, 2019 14:55
Show Gist options
  • Save questsin/890c2c47ef8d7b9dc0d9016828b1a02b to your computer and use it in GitHub Desktop.
Save questsin/890c2c47ef8d7b9dc0d9016828b1a02b to your computer and use it in GitHub Desktop.
const async = require('async');
var items = [1,2,3,4,5,6,7,8,10];
function callback(){
console.log("done");
}
// 1st para in async.each() is the array of items
async.each(items,
// 2nd param is the function that each item is passed to
function(item, callback){
console.log(item);
callback();
},
// 3rd param is the function to call when everything's done
function(err){
// All tasks are done now
console.log("done");
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment