Question

I see a lot of NodeJS articles recommending the Bluebird library for promisifying your code and avoiding callback spaghetti.

Is there any value in using such a library when using Node 4.2.4+ given that ES6 has native Promises? What can I do with Bluebird that I can't do with ES6 promises?

The Bluebird documenation is sparse and only really helps if you already "get" promises. Do I really need another library which might confuse the issue and introduce bugs?

Was it helpful?

Solution

Here's a good answer by the bluebird author about the speed issue with ES6 promises. Obviously, he has a bias, but he's also looked at the problem in quite some detail. Those issues that slow down ES6 promises are because of the way they are specified, and therefore are still present. I don't think it's drastic enough for speed to be your deciding factor, unless speed is really critical and you've verified the promises are your bottleneck, but it is there.

Much more importantly, ES6 promises are an extremely bare bones implementation, essentially the minimum you can do and still call it a promise. You're talking 6 methods compared to bluebird's 70 or so. Sure, you can make do with those 6, but when you start using promises in depth, you start running into the same kinds of problems over and over again. How do I implement a timeout? How do I easily convert existing functions to use promises? How do I compose and manipulate groups of promises more easily? These are the sorts of problems bluebird solves that ES6 makes you implement yourself.

Licensed under: CC-BY-SA with attribution
scroll top