Skip to content

Instantly share code, notes, and snippets.

@boo1ean
Last active October 11, 2015 02:28
Show Gist options
  • Save boo1ean/3789171 to your computer and use it in GitHub Desktop.
Save boo1ean/3789171 to your computer and use it in GitHub Desktop.
Delay callback for typehead
var delay = (function() {
var timer = 0;
return function(callback, ms) {
if (typeof(callback) == 'function' && typeof(ms) == 'number') {
clearTimeout(timer);
timer = setTimeout(callback, ms);
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment