Skip to content

Instantly share code, notes, and snippets.

@element6
Created November 11, 2018 07:41
Show Gist options
  • Save element6/155cad8168d7f8eb3d13191b84208978 to your computer and use it in GitHub Desktop.
Save element6/155cad8168d7f8eb3d13191b84208978 to your computer and use it in GitHub Desktop.
Promise helper
// 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