question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to migrate from Q.js?

See original GitHub issue

I’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:closed
  • Created 10 years ago
  • Comments:30 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
petkaantonovcommented, Dec 21, 2014

I finally got around it

https://github.com/petkaantonov/bluebird-q https://www.npmjs.com/package/bluebird-q

@spion Unfortunately bbq was taken 😛

1reaction
petkaantonovcommented, Feb 5, 2014

@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:

var Promise = require("bluebird");
Promise.promisifyAll(require("redis").RedisClient.prototype);

...

redisClient.getAsync("key").then(...)

(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:

  • promisifyAll
  • predicate and error type extension for .catch
  • .bind
  • cancellation
  • .map
  • .reduce
  • .filter
  • .props
  • .any
  • .some
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found