Skip to content

Instantly share code, notes, and snippets.

@chirag64
Last active December 23, 2015 00:09
Show Gist options
  • Save chirag64/6551430 to your computer and use it in GitHub Desktop.
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.
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