🚀 This release removes many layers of deprecated methods and brings Q closer to alignment with Mark Miller’s TC39 strawman for concurrency. At the same 🛠 time, it fixes many bugs and adds a few features around error handling. Finally, ⚡️ it comes with an updated and comprehensive API Reference.
🚚 The following deprecated or undocumented methods have been removed. Their replacements are listed here:
0.8.x method 0.9 replacement Q.ref Q call, apply, bind () fcall/invoke, fapply/post, fbind ncall, napply () nfcall/ninvoke, nfapply/npost end done put set node nbind nend nodeify isResolved isPending deferred.node deferred.makeNodeResolver Method, sender dispatcher send dispatch view, viewInfo (none)
(*) Use of
thispis discouraged. For calling methods, use
Alignment with the Concurrency Strawman
- Q now exports a
Q(value)function, an alias for
Q.bindwere removed to make room for the same methods on the function prototype.
invokehas been aliased to
sendin all its forms.
postwith no method name acts like
- Long stack traces can be turned off by setting
Q.stackJumpLimitto zero. In the future, this property will be used to fine tune how many stack jumps are retained in long stack traces; for now, anything nonzero is treated as one (since Q only tracks one stack jump at the moment, see #144). #168
- In Node.js, if there are unhandled rejections when the process exits, they are output to the console. #115
put) no longer have a fulfillment value.
- Q promises are no longer frozen, which helps with performance.
thenRejectis now included, as a counterpart to
- 💻 The included browser
nextTickshim is now faster. #195 @rkatic.
🐛 Bug Fixes
- Q now works in Internet Explorer 10. #186 @ForbesLindesay
fbindno longer hard-binds the returned function's
Q.rejectno longer leaks memory. #148
npostwith no arguments now works. #207
allResolvednow works with non-Q promises ("thenables"). #179
keysbehavior is now correct even in browsers without native
Object.keys. #192 @rkatic
exceptionproperty now work correctly if the rejection reason is falsy. #198
Internals and Advanced
- The internal interface for a promise now uses
dispatchPromise(resolve, op, operands)instead of
sendPromise(op, resolve, ...operands), which reduces the cases where Q needs to do argument slicing.
- The internal protocol uses different operands. "put" is now "set". "del" is now "delete". "view" and "viewInfo" have been removed.
Q.fulfillhas been added. It is distinct from
Q.resolvein that it does not pass promises through, nor coerces promises from other systems. The promise becomes the fulfillment value. This is only recommended for use when trying to fulfill a promise with an object that has a
thenfunction that is at the same time not a promise.
- Q now exports a
thisp-less versions of
nbind. The latter are now deprecated. #142
- Long stack traces no longer cause linearly-growing memory usage when chaining promises together. #111
error.stackin a rejection handler will now give a long stack trace. #103
Q.timeoutto clear its timeout handle when the promise is rejected; previously, it kept the event loop alive until the timeout period expired. #145 @dfilatov
q/queuemodule, which exports an infinite promise queue constructor.
doneas a replacement for
end, taking the usual fulfillment, rejection, and progress handlers. It's essentially equivalent to
then(f, r, p).end().
Q.onerror, a settable error trap that you can use to get full stack traces for uncaught errors. #94
thenResolveas a shortcut for returning a constant value once a promise is fulfilled. #108 @ForbesLindesay
- Various tweaks to progress notification, including propagation and transformation of progress values and only forwarding a single progress object.
nodeify. It no longer returns an always-fulfilled promise when a Node callback is passed.
deferred.rejectno longer (sometimes) return
- Fixed stack traces getting mangled if they hit
endtwice. #116 #121 @ef4
npostto work on promises for objects with Node methods. #134
- Fixed accidental coercion of objects with nontrivial
Dates, by the promise's
spreadnot calling the passed rejection handler if given a rejected promise.
- Added preliminary progress notification support, via
promise.then(onFulfilled, onRejected, onProgress),
delreturn the object acted upon for easier chaining. #84
- Fixed coercion cycles with cooperating promises. #106
ninvoketo pass the correct
- Fixed various cases involving unorthodox rejection reasons. #73 #90 @ef4
- Fixed double-resolving of misbehaved custom promises. #75
- Sped up
Q.allfor arrays contain already-resolved promises or scalar values. @ForbesLindesay
- Made stack trace filtering work when concatenating assets. #93 @ef4
- Added warnings for deprecated methods. @ForbesLindesay
.npmignorefile so that dependent packages get a slimmer
- Added preliminary support for long traces (@domenic)
fbindfor non-thisp promised function calls.
returnfor async generators, where generators are implemented.
- Rejected promises now have an "exception" property. If an object isRejected(object), then object.valueOf().exception will be the wrapped error.
- Added Jasmine specifications
- Support Internet Explorers 7–9 (with multiple bug fixes @domenic)
- Support Firefox 12
- Support Safari 5.1.5
- Support Chrome 18
promise.timeoutis now rejected with an
Errorobject and the message now includes the duration of the timeout in miliseconds. This doesn't constitute (in my opinion) a backward-incompatibility since it is a change of an undocumented and unspecified public behavior, but if you happened to depend on the exception being a string, you will need to revise your code.
deferred.makeNodeResolver()to replace the more cryptic
- Added experimental
Q.promise(maker(resolve, reject))to make a promise inside a callback, such that thrown exceptions in the callback are converted and the resolver and rejecter are arguments. This is a shorthand for making a deferred directly and inspired by @gozala’s stream constructor pattern and the Microsoft Windows Metro Promise constructor interface.
- Added experimental
Q.begin()that is intended to kick off chains of
.thenso that each of these can be reordered without having to edit the new and former first step.
isResolvedto the promise prototype.
allResolvedfor waiting for every promise to either be fulfilled or rejected, without propagating an error. @utvara #53
Q.bindas a method to transform functions that return and throw into promise-returning functions. See an example. @domenic
nbind, and added
napplyto complete the set.
noderemains as deprecated. @domenic #58
Methodremains as deprecated and will be removed in the next major version since I expect it has very little usage.
- Added browser console message indicating a live list of unhandled errors.
- Added support for
setImmediate(available via polyfill) as a browser-side
nextTickimplementation. #44 #50 #59
- Stopped using the event-queue dependency, which was in place for
Narwhal support: now directly using
- WARNING: EXPERIMENTAL: added
del. These properties are enquoted in the library for cross-browser compatibility, but may be used as property names in modern engines.