Skip to content

Instantly share code, notes, and snippets.

@chriscauley
Created March 4, 2016 20:55
Show Gist options
  • Save chriscauley/f4d49d59c7a85efe35e4 to your computer and use it in GitHub Desktop.
Save chriscauley/f4d49d59c7a85efe35e4 to your computer and use it in GitHub Desktop.
function do_later () {
var args = arguments,
callback,
timeout;
if(args.length < 2) {
throw new Error("Function do_later requires at least two arguments, " + args.length + " given");
}
for(i = 0, len = args.length; i < len; i++) {
if(typeof args[i] == 'function') {
callback = args[i];
}
if(typeof args[i] == 'number') {
timeout = args[i];
}
}
if(callback && timeout) {
window.setTimeout(callback, timeout);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment