Skip to content

Instantly share code, notes, and snippets.

@cramhead
Created June 13, 2014 19:16
Show Gist options
  • Save cramhead/82ed3e5bc48d90716694 to your computer and use it in GitHub Desktop.
Save cramhead/82ed3e5bc48d90716694 to your computer and use it in GitHub Desktop.
call the function every so many calls
// call the func every count times
var every = function(count, func) {
var self = this,
counter = 0;
return function(arg) {
counter++;
// console.log('counter is ' + counter);
if (counter === count) {
counter = 0;
// console.log("reset counter");
func(arg);
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment