Created
May 26, 2019 16:50
-
-
Save umcconnell/7962242be2a882f9771b177e41b3dd1c to your computer and use it in GitHub Desktop.
Fancy JS setTimeout function
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
/** | |
* JS promisified setTimeout | |
* | |
* @param {number} ms timeout time in ms | |
* @example | |
* wait(2000).then(console.log) | |
* // => logs after 2 seconds | |
* @returns {Promise} A promise that resolves after the specified time `ms` | |
*/ | |
let wait = ms => new Promise(res => setTimeout(res, ms)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment