1 | // Pulled from https://github.com/joliss/promise-map-series and prettied up a bit
|
2 |
|
3 | module.exports = function sequence(array, iterator) {
|
4 | let currentPromise = Promise.resolve()
|
5 | return Promise.all(
|
6 | array.map((value, i) => {
|
7 | return currentPromise = currentPromise.then(() => iterator(value, i, array))
|
8 | })
|
9 | )
|
10 | }
|