Skip to content

Instantly share code, notes, and snippets.

@ilyahuman
Created November 14, 2020 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilyahuman/3c1cfe9814b490b497eac35d2b05e116 to your computer and use it in GitHub Desktop.
Save ilyahuman/3c1cfe9814b490b497eac35d2b05e116 to your computer and use it in GitHub Desktop.
// Function will wait until needed time but will block your eventloop
function sleep(time = 0) {
const wakeUpTime = Date.now() + time
while (Date.now() < wakeUpTime) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment