顺序执行promise
//生成待执行promise函数 | |
function promiseFunc(index) { | |
return function () { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log(index) | |
resolve(index) | |
}, 1000) | |
}) | |
} | |
} | |
async function queue(list) { | |
let index = 0 | |
while (index >= 0 && index < list.length) { | |
await list[index]() | |
index++ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment