Created
March 31, 2020 20:46
-
-
Save nandomoreirame/3675e47e5a1674987acb1ce245f8b224 to your computer and use it in GitHub Desktop.
Timeout with Promise for use async await
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
const timeout = ms => new Promise(resolve => setTimeout(resolve, ms)); | |
const sleep = async (fn, ...args) => { | |
await timeout(3000); | |
return fn(...args); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment