Created
January 24, 2012 10:58
-
-
Save fduch2k/1669615 to your computer and use it in GitHub Desktop.
underscore mixin for repeatly calls the function
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
| _.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