Advertisement
dwhitzzz

sleepFunction

Apr 22nd, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sleepFor( sleepDuration ){
  2.     console.log("begin sleep");
  3.     var now = new Date().getTime();
  4.     while(new Date().getTime() < now + sleepDuration){ /* do nothing */ }
  5.     console.log("end sleep");
  6. }
  7.  
  8.            
  9. sleepFor(2000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement