Created
November 10, 2016 09:12
-
-
Save xhinking/6875e03e1198aecef42d0ee087e4a8ee 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 asyncify(fn) { | |
var orig_fn = fn, | |
intv = setTimeout(function() { | |
intv = null | |
if (fn) fn() | |
}, 0) | |
fn = null | |
return function() { | |
if (intv) { | |
fn = orig_fn.bind.apply(orig_fn, [this].concat([].slice.call(arguments))) | |
} else { | |
orig_fn.apply(this, arguments) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment