const callBack = function(fileName) {
return new Promise(function(resolve, reject) {
setTimeout(() => {
resolve()
}, 4000)
})
}
const gen = function*() {
let f1 = yield callBack()
console.log('a1')
let f2 = yield callBack()
console.log('a2')
}
function run(gen) {
let g = gen()
function next() {
let result = g.next()
if (result.done) return result.value
result.value.then(function() {
next()
})
}
next()
}
run(gen)
网友评论