Created
September 7, 2017 09:13
-
-
Save ivuorinen/969e01e6b26d9a8716be4dec8e8975c0 to your computer and use it in GitHub Desktop.
sleep.js
This file contains hidden or 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
/** | |
* sleep(1000).then(function () { console.log('zzZZzzZZ...'); }); | |
* | |
* @author gsamaras <https://stackoverflow.com/a/951057/594940> | |
* @param {Integer} ms | |
* @returns {Promise} | |
*/ | |
window.sleep = function sleep(ms) { | |
return ( | |
new Promise(function (resolve, reject) { | |
setTimeout(function () { | |
resolve(); | |
}, ms); | |
}) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment