function * read() {
let content = yield fs.read('./open.text','utf8');
let body = yield fs.read('./content.text','utf8');
return body;
}
const it = read()
let {value,done} = it.next();
let {value,done} = it.next(value);
console.log(value)
myCo(read()).then((data)=>{
console.log(data) data ==> 上面的body
})
function myCo(it) {
return newPromise((resolve,reject)=>{
function next(nextVal) {
let {value,done} = it.next(nextVal);
done && resolve(value)
!done && Promise.resolve(value).then((data)=>{
next(data)
})
}
next()
})
}