Skip to content

Instantly share code, notes, and snippets.

@fduch2k
Created January 24, 2012 10:58
Show Gist options
  • Select an option

  • Save fduch2k/1669615 to your computer and use it in GitHub Desktop.

Select an option

Save fduch2k/1669615 to your computer and use it in GitHub Desktop.
underscore mixin for repeatly calls the function
_.mixin({
repeat: function(func, times, delay, context) {
delay = delay || 100;
context = context || this;
var intervalId = setInterval(function() {
func.apply(context);
if (--times < 1)
clearInterval(intervalId);
}, delay);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment