tj/co 源码 --》更了解async await
// tj async+await = generator +co function co(it){ return new Promise((resolve,reject)=>{ // 异步迭代 需要next函数 function next(r){ let {value,done} = it.next(r); if(done){ resolve(value); }else{ Promise.resolve(value).then(data=>{ next(data); },reject) } } next(); }) } co(readAge()).then(data=>{ console.log(data); });