function promiseReduce (iterable, reducer, initialValue) { return iterable.reduce((previousPromise, currentPromise, count) => { return Promise.resolve(previousPromise).then(result => { return Promise.resolve(currentPromise).then(current => { return reducer(result, current, count) }) }) }, Promise.resolve(initialValue)) }
Or you can use Bluebird.js
No comments:
Post a Comment