Skip to content

Instantly share code, notes, and snippets.

@atog
Created April 22, 2014 12:46
Show Gist options
  • Save atog/11177720 to your computer and use it in GitHub Desktop.
Save atog/11177720 to your computer and use it in GitHub Desktop.
var delay = (function() {
var timer = 0;
return function(ms, callback) {
clearTimeout(timer);
return timer = setTimeout(callback, ms);
};
})();
USAGE:
delay(2000, function() { console.log("HI"); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment