Created
March 4, 2016 20:55
-
-
Save chriscauley/f4d49d59c7a85efe35e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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