Created
November 10, 2016 08:55
-
-
Save xhinking/169545b3724340093f4fd6bd9e3bf39e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 timeoutify(fn, delay) { | |
var intv = setTimeout(function() { | |
intv = null | |
fn(new Error("Timeout!")) | |
}, delay) | |
return function() { | |
if (intv) { | |
clearTimeout(intv) | |
fn.apply(this, arguments) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment