Last active
April 2, 2021 19:15
-
-
Save hozefam/33ef91295eb51202704ee5c11fb78406 to your computer and use it in GitHub Desktop.
Simulate delay in Javascript / Node using Promise
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 dbConnected = true; | |
const longRunningTask = (ms = 5000) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(dbConnected ? resolve : reject, ms); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment