Created
January 15, 2021 01:50
-
-
Save nafeu/04c3e4af3708859e868b26cb2252dcd3 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 delay(delayedFunction, time) { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
try { | |
resolve(delayedFunction()); | |
} catch (error) { | |
reject(error.message); | |
} | |
}, time); | |
}); | |
} | |
async function main() { | |
/* Now we can use 'await' in here with our `delay` function. */ | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment