Skip to content

Instantly share code, notes, and snippets.

@yokotak0527
Last active Aug 28, 2019
Embed
What would you like to do?
並列処理を直列処理にする案
function async1 () {
return new Promise(resolve => {
setTimeout(() => {
resolve('async1 done')
}, 3000)
})
}
function async2 () {
return new Promise(resolve => {
setTimeout(() => {
resolve('async2 done')
}, 1000)
})
}
(async list => {
for (let f of list) console.log(await f())
})([async1, async2])
@yokotak0527

This comment has been minimized.

Copy link
Owner Author

@yokotak0527 yokotak0527 commented Aug 28, 2019

async 使ってるので、この処理自体がPromiseを返してしまう。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment