Created
June 19, 2017 12:27
-
-
Save fgo/74a85f94e5690b6acbe96206649b6e26 to your computer and use it in GitHub Desktop.
Go to sleep JavaScript
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 function | |
| // Usage: sleep(42000); // Sleep for 42 seconds | |
| function sleep(ms) { | |
| var start = new Date().getTime(); | |
| for (var i = 0; i < 1e7; i++) { | |
| if ((new Date().getTime() - start) > ms){ | |
| break; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment