Hacker News new | past | comments | ask | show | jobs | submit login

The canonical way to execute a collection of promises serially is through Array.prototype.reduce:

  let finalResult = promises.reduce((current, next) => current.then(next), Promise.resolve());
(I've used ES6 syntax, but you can do this in ES5.1 as well. You can also substitute Promise.prototype.then.call for the arrow function.)

The beauty of this one-liner is that it works with any promise-like object: you don't need to use BlueBird, you don't even need to use a uniform promise implementation, it'll work with anything that follows the Promises/A+ spec.

This is cool! Thanks for sharing!

In my case, there is a bit less code, but I really do appreciate how your implementation is not Bluebird-dependent.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact