Created
February 17, 2014 15:59
-
-
Save xphere/9053239 to your computer and use it in GitHub Desktop.
debounce.js
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
| function debounce(callback, timeout) { | |
| var timer; | |
| return function() { | |
| timer && clearTimeout(timer); | |
| timer = setTimeout(function(args) { | |
| timer = null; | |
| callback.apply(this, args); | |
| }.bind(this, arguments), timeout||100); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment