Co.js and bluebird.js - what's the difference?

Can someone help me understand the differences between using Koa.js and Bluebird.js using ES6 Harmony. In particular, how

co( function * () { //stuff } ); 

compare

 Promise.coroutine( function * () { //stuff } ); 

It seems that Koa should use Bluebird and not recreate the wheel. What else?

+6
source share
2 answers

Currently, the difference is that Koa allows you to get more than just promises.

However, a function is added that allows you to not only give callbacks, tricks, etc., but also any arbitrary thing that comes to your mind. Bluebird is also the fastest. Therefore, after this version, koa should just use the blue bird.

See https://github.com/petkaantonov/bluebird/issues/131#issuecomment-36975495

+2
source

There is a transfer request for using Bluebird. The remarks there should make some things clearer. co relies on the built-in V8 Promises feature provided at 0.11, while Bluebird aims to work well at 0.10. You can use co in versions below 0.11, but then Bluebird will be the best option. In this link, you can see that the tests show that co is not slower than Bluebird, so the argument is incorrect. Plus, these are just 300 lines of code adhering to KISS, which is usually good practice. So this is not a recreation of the wheel. This is losing weight. You can read the code and understand what it does in a few minutes. It took me an hour to read the Bluebird API document. It is also mentioned that the implementation of V8 is broken , so Bluebird can be used for the interim period.

+2
source

All Articles