News for hackers. Stuff that matters.
Re:Code optimizations when using async/await by WolfOliver on Tuesday January 04, 2022 @10:27AM (#29795741)
> Assuming the first request is done much faster than the second request, we can already utilize the CPU and doSomeCalculation while waiting for the second request to finish. In this case, the shown code is better than Promise.all([request1, request2]).
Re:Code optimizations when using async/await by duped on Tuesday January 04, 2022 @10:44AM (#29795962)

    Promise.all([request1.then(doSomeWork), request2])

?
Re:Code optimizations when using async/await by WolfOliver on Tuesday January 04, 2022 @10:58AM (#29796184)
yes this would work. It's just nested.
Re:Code optimizations when using async/await by Footkerchief on Tuesday January 04, 2022 @12:09PM (#29797075)
The nesting has the advantage of directly expressing the dependency structure of the promises, which is otherwise a bit hard to infer.