Skip to content

Instantly share code, notes, and snippets.

@dbellettini
Created September 6, 2011 10:04
Show Gist options
  • Save dbellettini/1197174 to your computer and use it in GitHub Desktop.
Save dbellettini/1197174 to your computer and use it in GitHub Desktop.
Delayed function
function makeDelayedFunction(oldFunction, delay) {
var obj = { timeout: false };
return function () {
if (obj.timeout) {
clearTimeout(obj.timeout);
}
obj.timeout = setTimeout(function () {
obj.timeout = false;
oldFunction();
}, delay);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment