JSFiddle - React, Tailwind, and code Playground
by Puni Charana
JavaScript
function asyncEach(iterableList, callback, done) {
var i = -1,
length = iterableList.length;
function loop() {
i++;
if (i === length) {
done();
return;
}
callback(iterableList[i], loop);
}
loop();
}
var foo = [
{name:'Yoshita'},
{name:'Arpit'},
{name:'Anu'},
{name:'Ritesh'}
];
asyncEach(foo, function(item, callback) {
setTimeout(function(){
console.log('Iteration ' + item.name);
callback();
}, 1500);
}, function() {
console.log('All done!');
});