Skip to content

Instantly share code, notes, and snippets.

@seyedi
Created November 21, 2013 06:02
Show Gist options
  • Save seyedi/7576761 to your computer and use it in GitHub Desktop.
Save seyedi/7576761 to your computer and use it in GitHub Desktop.
function interval(func, wait, times){
var interv = function(w, t){
return function(){
if(typeof t === "undefined" || t-- > 0){
setTimeout(interv, w);
try{
func.call(null);
}
catch(e){
t = 0;
throw e.toString();
}
}
};
}(wait, times);
setTimeout(interv, wait);
};
//Usage
interval(function(){
// Code block goes here
}, 1000, 10);
@seyedi
Copy link
Author

seyedi commented Nov 21, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment