The only original insight of this blog post is that it's nice to be able to use `sleep()` without async/await in Go, which is also true for Rust and Rust has Async.
It does not stem from async/await that Javascript doesn't have sleep()
It does not stem from async/await that Javascript doesn't have sleep()
function sleep(ms) {
return new Promise((resolve) =>
setTimeout(() => resolve(), ms)
);
}https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...
Sleep() should halt, this returns immediately
If I want my code to actually halt, I can either make myself red and use await on your red function, or I resign myself to put everything after the sleep in a .then()
Atomics.wait(this.sleepBuffer, 0, 0, ms)>Thrown in one of the following cases:
>If the current thread cannot be blocked (for example, because it's the main thread).
I guess that's why it's not so widely used