How to migrate from Q.js?
See original GitHub issueI’m currently using Q.js and investigating bluebird.
Would be nice if i could just replace
var q=require("Q")
With
q=require("bluebird")
What should I expect?
Issue Analytics
- State:
- Created 10 years ago
- Comments:30 (9 by maintainers)
Top Results From Across the Web
How do I convert Q.defer() to Promise for instance variables?
defer() to Promises that do NOT resolve immediately. For example, take the following code.
Read more >Second Look at Promises using Native ES6 vs. q.js
This is trivial. Using q. js, Q. spread() converts the results of an array of promises to a list of method arguments.
Read more >q - npm
Start using q in your project by running `npm i q`. There are 10208 other projects in the npm registry using q.
Read more >Promises in Node.js with Q. An alternative to callbacks - Medium
Wrap some basic Node workflows converting callbacks into promises; Rewrite one of the async methods into one that uses promises; Write something ...
Read more >Migrate to Node.js 16 - Auth0
Describes Auth0 features affected by the Node.js v12 to Node.js v16 migration and provides recommendations for migration.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I finally got around it
https://github.com/petkaantonov/bluebird-q https://www.npmjs.com/package/bluebird-q
@spion Unfortunately bbq was taken 😛
@xaka
In short:
Bluebird is 2 orders of magnitude (~100x) faster with more features and with the shared features being better, for example full stack traces. It also uses 20x less memory. Memory usage and performance alone is reason enough if you are using promises at server side.
Personally the feature to die for is
promisifyAll
which in many cases turns a callback api into optimized promise api. Ironically this will give you more performance than libraries that use promises to begin with (due to cast overhead). Although if those other libraries use bluebird and you use bluebird 1.0.2, casting will be very fast again.For example with the redis library:
(The redis api will have *Async methods that return bluebird promises with just 1 line)
There is many intricacies with this, for example the promisified methods allow you to differentiate between thrown errors and callback errors using the
.catch(RejectionError)
or.error
(also unique bluebird feature) which many people have needed.Features that have no correspondence in Q:
.catch