[ES6] 異步操作 async 函數

Async 函数是什么?

一句话,它就是 Generator 函数的语法糖。
但是Generator 還是太複雜

async函数:

1
2
3
4
5
6
const asyncReadFile = async function () {
const afile = await readFile('/etc/fstab');
const bfile = await readFile('/etc/shells');
console.log(afile.toString());
console.log(bfile.toString());
};
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×