JSFiddle - React, Tailwind, and code Playground

by ronnjoe

JavaScript

var array = [
function(callback) {
console.log("first function called in " + (new Date().getTime() - timestamp) + "ms");
callback();
},
function(callback) {
console.log("second function called in " + (new Date().getTime() - timestamp) +
"ms");
callback();
},
function(callback) {
console.log("third function called in " + (new Date().getTime() - timestamp) + "ms");
callback();
}
];
timestamp = new Date().getTime();

function *generate(array,callback){
async function returnSelf(item) { 
	console.log("here");
  item(callback);
	//return await item(callback); 
}
/* async function flow() {
  return await array.map(abc);
} */
for (var item of array) {
			//yield *abc(returnSelf);
      //yield *abc(item);
      //array.map(abc);
       var generator =  abc(item);
            console.log(generator.next());      
            console.log(generator.next());
}
function *abc(item){
	yield;
  //returnSelf(item);
  return item(callback);
  //foo();
}
}

function foo(x){
	console.log(" just printing ");
  x();
}
var gent = generate(array, function() {
	//Print the log only if the condition is statisfied
//if(myApp.isFunctionCompleted){
console.log("all functions finished in " + (new Date().getTime() - timestamp) + "ms");
//}
});
gent.next();
gent.next();
//console.log(gent.next());