Skip to content

Instantly share code, notes, and snippets.

@sscovil
Last active January 14, 2016 19:18
Show Gist options
  • Save sscovil/93fcb7505b3374143e37 to your computer and use it in GitHub Desktop.
Save sscovil/93fcb7505b3374143e37 to your computer and use it in GitHub Desktop.
Function for creating a synchronous delay, apposed to using setTimeout which invokes a callback function asynchronously
function delay(millis) {
var start = new Date().getTime();
var end = start + millis;
var current;
do {
current = new Date().getTime();
} while(current < end);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment