1async function foo(things) {
2 const results = [];
3 for (const thing of things) {
4 // Good: all asynchronous operations are immediately started.
5 results.push(bar(thing));
6 }
7 // Now that all the asynchronous operations are running, here we wait until they all complete.
8 return baz(await Promise.all(results));
9}
10