Created
November 16, 2018 03:09
-
-
Save nyawach/872a2b3b4f15739b89ad91a50051bfa4 to your computer and use it in GitHub Desktop.
Promiesの逐次実行
This file contains hidden or 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
const series = promises => new Promise((resolve, reject) => { | |
let len = promises.length | |
let i = 0 | |
let results = [] | |
const doPromise = () => | |
promises[i]() | |
.then(res => { | |
i++ | |
results.push(res) | |
return i < len ? doPromise() : resolve(results) | |
}) | |
doPromise() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment