Yup - all promises are "started" before you await them.
I still typically prefer Promise.all though. It's a bit more obvious what's going on (IMO) and you can skip the additional lines for assigning the promises to variables.
FYI, Promise.all does not guarantee that. It doesn't orchestrate actually running the Promises at all (this is impossible the way Promises work), just that they're all resolved at the end, with results in the same order they were passed in.
The implementation of Promise.all could use one array for results and fill it in any order as soon as any promise resolves while awaits will always proceed in strict order (like a generator). But that's an implementation detail that a JS programmer doesn't need to think about.
15 comments
[ 3.4 ms ] story [ 42.7 ms ] threadThere is the odd sense of randomness to the choices in all these CLI upgrades. Can't quite put my finger on it. It brings to mind the saga of Wasabi.
edit: just checked and your version is indeed parallel. Interesting.
I still typically prefer Promise.all though. It's a bit more obvious what's going on (IMO) and you can skip the additional lines for assigning the promises to variables.
Your version guarantees the three are executed before moving forward. The order may differ on each run.
The implementation of Promise.all could use one array for results and fill it in any order as soon as any promise resolves while awaits will always proceed in strict order (like a generator). But that's an implementation detail that a JS programmer doesn't need to think about.