Created
February 27, 2015 16:45
-
-
Save alepez/f1067c6569ab48fbb4c0 to your computer and use it in GitHub Desktop.
makeLazy
This file contains 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
var makeLazy = function (fn, delay) { | |
var timeHandler; | |
return function () { | |
clearTimeout(timeHandler); | |
timeHandler = setTimeout(fn.bind.apply(fn, [null].concat(Array.prototype.slice.call(arguments))), delay); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/a/21507470