Skip to content

Instantly share code, notes, and snippets.

@lyuehh
Created September 19, 2014 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyuehh/4a5cc185bca1a6306522 to your computer and use it in GitHub Desktop.
Save lyuehh/4a5cc185bca1a6306522 to your computer and use it in GitHub Desktop.
function debouncer(func, timeout) {
var timeoutID;
timeout = timeout || 300;
return function () {
var scope = this , args = arguments;
clearTimeout( timeoutID );
timeoutID = setTimeout( function () {
func.apply( scope , Array.prototype.slice.call( args ) );
}, timeout);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment