Skip to content

Instantly share code, notes, and snippets.

@jaredcacurak
Last active August 29, 2015 13:57
Show Gist options
  • Save jaredcacurak/9856391 to your computer and use it in GitHub Desktop.
Save jaredcacurak/9856391 to your computer and use it in GitHub Desktop.
Shim setTimeout
(function () {
'use strict';
var _setTimeout = setTimeout;
setTimeout = function (fn/*, delay, callbackParm1, callbackParm2, etc. */) {
var delay, callbackParameters;
delay = arguments[1] || 0;
callbackParameters = Array.prototype.slice.call(arguments, 2);
return _setTimeout((typeof fn === 'function')
? function () { return fn.apply(this, callbackParameters); }
: fn, delay);
};
_setTimeout(function (acceptsCallbackParameters) {
if (!!acceptsCallbackParameters) {
setTimeout = _setTimeout;
}
}, 0, true);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment