Skip to content

Instantly share code, notes, and snippets.

@canalun
Last active February 26, 2024 06:16
Show Gist options
  • Save canalun/487c9ce5e95da0a9c5a422829b2307a5 to your computer and use it in GitHub Desktop.
Save canalun/487c9ce5e95da0a9c5a422829b2307a5 to your computer and use it in GitHub Desktop.
const sleep = (ms) => {
const now = performance.now()
while (performance.now() - now < ms) {
// wait
}
}
(function setSleepRepeatedly() {
Promise.resolve().then(() => {
sleep(3000)
setTimeout(setSleepRepeatedly, Math.random()*2000)
})
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment