Skip to content

Instantly share code, notes, and snippets.

@akumpf
Created January 11, 2013 23:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akumpf/4514973 to your computer and use it in GitHub Desktop.
Save akumpf/4514973 to your computer and use it in GitHub Desktop.
function loop(init, fnCondition, fnUpdate, fnRun, fnDone){
var index = 0;
index = (init.constructor.name === "function")?init():init;
function next(){
index = fnUpdate(index);
if(fnCondition(index)){
setTimeout(function(){
fnRun(index, next);
}, 0);
}else{
if(fnDone) fnDone(index);
}
}
fnRun(index,next);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment