跳至主要內容
实现async-await

此次我们来实现一个 async await 内部实现
实际上 async 就是生成器的语法糖,await 就是 then 的语法糖,
平常我们使用的过程中

示例

const getDate = () =>
  new Promise((resolve, reject) => setTimeout(() => resolve("data"), 1000));
async function test() {
  const res = await getDate();
  console.log("data:", res);
  const res2 = await getDate();
  console.log("data2:", res2);
}
// 输出
//data:data
//data2:data

ZiHao...大约 3 分钟记录技术实践 -