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)

// How to implement automatic execution
/ / = = = = = = / /

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()
    })
}



Copy the code