📜  在循环中使用 await 的 await 保留字 testcafe - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:54.133000             🧑  作者: Mango

代码示例1
async function foo(things) {
  const results = [];
  for (const thing of things) {
    // Good: all asynchronous operations are immediately started.
    results.push(bar(thing));
  }
  // Now that all the asynchronous operations are running, here we wait until they all complete.
  return baz(await Promise.all(results));
}