The author sees this code and realizes it's unnecessarily serial:
save('userData', userData) .then(() => save('session', sessionPrefences)) .then(() => ({ userData, sessionPrefences })
await save('userData', userData); await save('session', sessionPrefences); return { userData, sessionPrefences }
await Promise.all([ save('userData', userData), save('session', sessionPrefences) ]); return { userData, sessionPrefences }
The author sees this code and realizes it's unnecessarily serial:
But doesn't see that the async/await version is serial, even though it's arguably even _more_ obvious? The transform to being parallel is pretty easy to read too: On top of that, the try/catch section is out of date. try/catch does not deoptimize the block in modern engines, and async/await absolutely integrates better with try/catch for much more bulletproof error handling.