Skip to content

Instantly share code, notes, and snippets.

@yokotak0527
Last active August 28, 2019 15:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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
Copy link
Author

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

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