Last active
December 23, 2015 00:09
-
-
Save chirag64/6551430 to your computer and use it in GitHub Desktop.
Use this only in terms of desperation because this function will keep the CPU busy as long as it exits. I hate JavaScript for the lack of a proper sleep 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
function sleep(milliseconds) { | |
var start = new Date().getTime(); | |
while(true) { | |
if ((new Date().getTime() - start) > milliseconds) { | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment