4 ms·
I do that all the time (exaggerated). const p1 = heavy_foo() const p2 = heavy_bar() await some_baz() const r2 = await p2 … return [await p1, r2, …]
by wruza 4y ago
I do that all the time (exaggerated).
const p1 = heavy_foo()
const p2 = heavy_bar()
await some_baz()
const r2 = await p2
…
return [await p1, r2, …]
It is useful in “threaded” code which does many things in parallel runs. Or in this code:
const [p, done] = block()
obj.on("event", done)
const res = await p
…
The implementation of block() is left as an exercise for the reader ;)