| 19 | let i = 0 |
| 20 | |
| 21 | const next = total => { |
| 22 | const el = iterator.next() |
| 23 | |
| 24 | if (el.done) { |
| 25 | resolve(total) |
| 26 | return |
| 27 | } |
| 28 | |
| 29 | Promise.all([total, el.value]) |
| 30 | .then(value => { |
| 31 | // eslint-disable-next-line no-plusplus |
| 32 | next(reducer(value[0], value[1], i++)) |
| 33 | }) |
| 34 | .catch(reject) |
| 35 | } |
| 36 | |
| 37 | next(initVal) |
| 38 | }) |