Created
September 25, 2014 23:25
-
-
Save potch/03927c763b21c938b369 to your computer and use it in GitHub Desktop.
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(fn, ms) { | |
this.timeout = null; | |
this.fn = fn; | |
this.ms = ms; | |
} | |
Debounce.prototype.start = function () { | |
this.timeout = setTimeout(this.fn, this.ms); | |
}; | |
Debounce.prototype.reset = function () { | |
this.abort(); | |
this.start(); | |
}; | |
Debounce.prototype.abort = function () { | |
clearTimeout(this.timeout); | |
}; |
Author
potch
commented
Oct 8, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment