Skip to content

Instantly share code, notes, and snippets.

@chhantyal
Created February 22, 2017 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chhantyal/a3eab380a7790af992af2d9f564362fc to your computer and use it in GitHub Desktop.
Save chhantyal/a3eab380a7790af992af2d9f564362fc to your computer and use it in GitHub Desktop.
Javascript/NodeJS sleep function. Javascript doesn't have built-in sleep function, thus this is workaround.
function sleep(milliSeconds) {
var startTime = new Date().getTime();
while (new Date().getTime() < startTime + milliSeconds);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment