Last active
January 14, 2016 19:18
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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