Last active
August 28, 2019 15:46
-
-
Save yokotak0527/d0ed55429df8589acbeb820f09ae27d9 to your computer and use it in GitHub Desktop.
並列処理を直列処理にする案
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
async 使ってるので、この処理自体がPromiseを返してしまう。