-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is Q a superset of a native Promise? #843
Comments
follow up question, what is the interopability between native promises and Q promises? Are these both legal const nativePromise = (n) => new Promise(resolve => setTimeout(resolve, n))
const qPromise = (n) => {
const deferred = q.defer()
setTimeout(() => deferred.resolve(), n)
return deferred.promise
}
const qPromiseFromNative = Q.resolve(nativePromise(100))
const nativePromiseFromQ = Promise.resolve(qPromise(100)) |
No, but it is pretty close, for example native promises have more guarantees on timings |
Thanks, I was able to discover some differences with unhandledRejections as well. A native promise will become unhandled at the end of one node event loop. A Q promise does not have that guarantee. Q uses its own custom nextTick, so it makes sense. If you wish to elaborate on their differences I would be interested. If not, feel free to close this issue. I see that there are subtle differences now. |
@andykais well, I (helped) spec how unhandledRejection behaves in Node ( https://gist.github.com/benjamingr/0237932cee84712951a2 ) and I added the events to Q ( #643 ). I don't think you should rely on the differences between Q and Node here :] |
Hi, new to using
Q
here in an existing codebase. Could someone clarify this for me? AQ
promise has all the functionality of a native promise, with no changed behavior, correct? There are only additional methods that allow more functionality?#836 mentioned that you can coerce a promise from a
Q
promise withbut I want to know if a Q promise can simply be used in-place of a native promise.
The text was updated successfully, but these errors were encountered: