Created
June 13, 2014 19:16
-
-
Save cramhead/82ed3e5bc48d90716694 to your computer and use it in GitHub Desktop.
call the function every so many calls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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