Created
November 11, 2018 07:41
-
-
Save element6/155cad8168d7f8eb3d13191b84208978 to your computer and use it in GitHub Desktop.
Promise helper
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
// promised setTimeout | |
function setTimeoutAsync(fn, ms) { | |
return new Promise((res, rej) => { | |
setTimeout(() => { | |
try{ | |
res(fn()) | |
} catch(err) { | |
rej(err) | |
} | |
}, ms) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment