1、async 函数
async 函数是什么?一句话,它就是 Generator 函数的语法糖。async函数就是将 Generator 函数的星号(*)替换成async,将yield替换成await,仅此而已。
async函数自带执行器,只要调用了asyncReadFile函数,它就会自动执行,输出最后结果。不像 Generator 函数,需要调用next方法,或者用co模块。
const asyncReadFile = async function () {
const f1 = await readFile('/etc/fstab');
const f2 = await readFile('/etc/shells');
console.log(f1.toString());
console.log(f2.toString(