3 ms·
Not sure where you mean by synchronously but if you mean what I think you mean then that is not correct behaviour. This is important to ensure predicatibility.
by frutiger 2y ago
Not sure where you mean by synchronously but if you mean what I think you mean then that is not correct behaviour. This is important to ensure predicatibility.
Eg.
Promise.then(() => console.log(“a”));
console.log(“b”)
must log [“b”, “a”] and not [“a”, “b”].
- canadahonk 2y agoThis type of test does work as expected. The "sync" means that it does not feature a full event loop (yet) so cannot easily support async I/O or some more "advanced" use cases.
- spankalee 2y agoThere's a WASI async functions proposal I think? Are you looking at supporting that so you don't have to bring your own event loop?
- cowsandmilk 2y agoJavaScript doesn’t make the guarantee you are claiming here
- fwip 2y agoWhat do you mean? Does JavaScript allow the `then` of a promise to execute before the contents of the promise?
- jitl 2y agoYes, it does. Promise continuations always run in the micro task queue per the standard. I guess if someone mutates the promise prototype it’s not guaranteed, but the spec does guarantee this order