// Sync version function sleep(sleepDuration){ var now = new Date().getTime(); while(new Date().getTime() < now + sleepDuration){ /* do nothing */ } }