Skip to content

Instantly share code, notes, and snippets.

@LMnet
Created October 24, 2013 04:40
Show Gist options
  • Save LMnet/7131460 to your computer and use it in GitHub Desktop.
Save LMnet/7131460 to your computer and use it in GitHub Desktop.
Synchronous JavaScript timeout.
/**
* Synchronous timeout
* @param {Integer} delay Delay in milliseconds
*/
var syncTimeout = function(delay){
var endTime = new Date((new Date()).getTime() + delay);
var curTime;
do {
curTime = new Date();
}while(curTime.getTime() <= endTime.getTime());
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment