Skip to content

Instantly share code, notes, and snippets.

@tlrobinson
Created October 22, 2008 08:24
Show Gist options
  • Save tlrobinson/18578 to your computer and use it in GitHub Desktop.
Save tlrobinson/18578 to your computer and use it in GitHub Desktop.
function callbackWrap(object, property, callbackArgNum, wrapperMaker, extra) {
var original = object[property];
object[property] = function() {
arguments[callbackArgNum] = wrapperMaker(arguments[callbackArgNum], extra);
return original.apply(this, arguments);
}
return original;
}
function performSelectorsWrapper(wrappedFunction) {
return function() {
wrappedFunction.apply(this, arguments);
[[CPRunLoop currentRunLoop] performSelectors];
}
}
setTimeoutOriginal = callbackWrap(window, "setTimeout", 0, performSelectorsWrapper);
setIntervalOriginal = callbackWrap(window, "setInterval", 0, performSelectorsWrapper);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment