If value is a Q promise, returns the promise. If value is a promise from another library it is coerced into a Q promise (where possible).
If value is a Q promise, returns the promise. If value is a promise from another library it is coerced into a Q promise (where possible).
If value is not a promise, returns a promise that is fulfilled with value.
A settable property that lets you turn on long stack trace support. If turned on, "stack jumps" will be tracked across asynchronous promise operations, so that if an uncaught error is thrown by done or a rejection reason's stack property is inspected in a rejection callback, a long stack trace is produced.
A settable property that will intercept any uncaught errors that would otherwise be thrown in the next tick of the event loop, usually as a result of done. Can be useful for getting the full stack trace of an error in browsers, which is not usually possible with window.onerror.
(reason: any, value: T) => void
A sugar method, equivalent to promise.then(undefined, onRejected).
A sugar method, equivalent to promise.then(undefined, onRejected).
Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed.
Much like then, but with different behavior around unhandled rejection. If there is an unhandled rejection, either because promise is rejected and no onRejected callback was provided, or because onFulfilled or onRejected threw an error or returned a rejected promise, the resulting rejection reason is thrown as an exception in a future turn of the event loop.
This method should be used to terminate chains of promises that will not be passed elsewhere. Since exceptions thrown in then callbacks are consumed and transformed into rejections, exceptions at the end of the chain are easy to accidentally, silently ignore. By arranging for the exception to be thrown in a future turn of the event loop, so that it won't be caught, it causes an onerror event on the browser window, or an uncaughtException event on Node.js's process object.
Exceptions thrown by done will have long stack traces, if Q.longStackSupport is set to true. If Q.onerror is set, exceptions will be delivered there instead of thrown in a future turn.
The Golden Rule of done vs. then usage is: either return your promise to someone else, or if the chain ends with you, call done to terminate it.
Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object.
finally returns a promise, which will become resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise returned from callback is finished.
Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object.
finally returns a promise, which will become resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise returned from callback is finished.
Returns a promise to get the named property of an object. Essentially equivalent to
promise.then(function (o) { return o[propertyName]; });
Returns a "state snapshot" object, which will be in one of three forms:
Returns a promise for the result of calling the named method of an object with the given variadic arguments. The object itself is this in the function, just like a synchronous method call.
Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the result is always true.
boolean
Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false.
boolean
Returns whether a given promise is in the rejected state. When the static version is used on non-promises, the result is always false.
boolean
Returns a promise for an array of the property names of an object. Essentially equivalent to
promise.then(function (o) { return Object.keys(o); });
Returns a promise for the result of calling the named method of an object with the given array of arguments. The object itself is this in the function, just like a synchronous method call. Essentially equivalent to
promise.then(function (o) { return o[methodName].apply(o, args); });
A sugar method, equivalent to promise.then(undefined, undefined, onProgress).
Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason.
This is especially useful in conjunction with all
The then method from the Promises/A+ specification, with an additional progress handler.
The then method from the Promises/A+ specification, with an additional progress handler.
The then method from the Promises/A+ specification, with an additional progress handler.
The then method from the Promises/A+ specification, with an additional progress handler.
A sugar method, equivalent to promise.then(function () { throw reason; }).
A sugar method, equivalent to promise.then(function () { return value; }).
any
"fulfilled", "rejected", "pending"
Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
Returns a promise that is fulfilled with an array of promise state snapshots, but only after all the original promises have settled, i.e. become either fulfilled or rejected.
Returns a promise that is fulfilled with an array of promise state snapshots, but only after all the original promises have settled, i.e. become either fulfilled or rejected.
This is an experimental tool for converting a generator function into a deferred function. This has the potential of reducing nested callbacks in engines that support yield.
(...args: any[]) => Q.Promise<T>
Returns a "deferred" object with a: promise property resolve(value) method reject(reason) method notify(value) method makeNodeResolver() method
Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed.
Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed.
(...args: any[]) => Q.Promise<T>
(...args: any[]) => Q.Promise<T>
(...args: any[]) => Q.Promise<T>
Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the result is always true.
boolean
Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false.
boolean
Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false.
boolean
Returns whether the given value is a Q promise.
boolean
Returns whether the given value is a promise (i.e. it's an object with a then function).
boolean
Returns whether a given promise is in the rejected state. When the static version is used on non-promises, the result is always false.
boolean
(...args: any[]) => Q.Promise<T>
(...args: any[]) => Q.Promise<T>
Creates a new version of func that accepts any combination of promise and non-promise values, converting them to their fulfillment values before calling the original func. The returned version also always returns a promise: if func does a return or throw, then Q.promised(func) will return fulfilled or rejected promise, respectively.
This can be useful for creating functions that accept either promises or non-promise values, and for ensuring that the function always returns a promise even in the face of unintentional thrown exceptions.
(...args: any[]) => Q.Promise<T>
Returns a promise that is rejected with reason.
Calling resolve with a pending promise causes promise to wait on the passed promise, becoming fulfilled with its fulfillment value or rejected with its rejection reason (or staying pending forever, if the passed promise does). Calling resolve with a rejected promise causes promise to be rejected with the passed promise's rejection reason. Calling resolve with a fulfilled promise causes promise to be fulfilled with the passed promise's fulfillment value. Calling resolve with a non-promise value causes promise to be fulfilled with that value.
Calling resolve with a pending promise causes promise to wait on the passed promise, becoming fulfilled with its fulfillment value or rejected with its rejection reason (or staying pending forever, if the passed promise does). Calling resolve with a rejected promise causes promise to be rejected with the passed promise's rejection reason. Calling resolve with a fulfilled promise causes promise to be fulfilled with the passed promise's fulfillment value. Calling resolve with a non-promise value causes promise to be fulfilled with that value.
Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. This is especially useful in conjunction with all.
Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. This is especially useful in conjunction with all.
Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. This is especially useful in conjunction with all.
Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. This is especially useful in conjunction with all.
Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. This is especially useful in conjunction with all.
Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. This is especially useful in conjunction with all.
Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. This is especially useful in conjunction with all.
Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. This is especially useful in conjunction with all.
Returns a promise that will have the same result as promise, except that if promise is not fulfilled or rejected before ms milliseconds, the returned promise will be rejected with an Error with the given message. If message is not supplied, the message will be "Timed out after " + ms + " ms".