Created
May 3, 2018 17:11
-
-
Save senthilmpro/2978ca176330c306bfc2ba21b6728644 to your computer and use it in GitHub Desktop.
Asynchronously (await) delay timer
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(timeout) { | |
return new Promise((resolve) => { | |
setTimeout(resolve, timeout); | |
}); | |
} | |
/** | |
* then use it like this. | |
* async function f1() { | |
* await delay(3000); | |
* } | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment