Created
November 8, 2016 02:47
-
-
Save Muscipular/ee10f903d9ad460d086bc534361b9f69 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
window.execEx = function(fn, maxTime) { | |
return new Promise(function (resolve, reject) { | |
var timer = setTimeout(function () { | |
if(timer) { | |
timer = false; | |
console.log('reject'); | |
reject(); | |
} | |
}, maxTime); | |
var f = function() { | |
if(timer) { | |
timer = false; | |
console.log('resolve') | |
resolve(); | |
clearTimeout(timer); | |
} | |
}; | |
fn(f); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment