new Promise() → {Promise}
Create a promise whose fate is determined by resolver
- Source:
Returns:
promise
- Type
- Promise
Methods
(static) all(promises) → {Promise}
Return a promise that will fulfill when all promises in the
input array have fulfilled, or will reject when one of the
promises rejects.
Parameters:
Name | Type | Description |
---|---|---|
promises |
array | array of promises |
- Source:
Returns:
promise for array of fulfillment values
- Type
- Promise
(static) race(promises) → {Promise}
Fulfill-reject competitive race. Return a promise that will settle
to the same state as the earliest input promise to settle.
WARNING: The ES6 Promise spec requires that race()ing an empty array
must return a promise that is pending forever. This implementation
returns a singleton forever-pending promise, the same singleton that is
returned by Promise.never(), thus can be checked with ===
Parameters:
Name | Type | Description |
---|---|---|
promises |
array | array of promises to race |
- Source:
Returns:
if input is non-empty, a promise that will settle
to the same outcome as the earliest input promise to settle. if empty
is empty, returns a promise that will never settle.
- Type
- Promise
(static) reject(x) → {Promise}
Return a reject promise with x as its reason (x is used verbatim)
Parameters:
Name | Type | Description |
---|---|---|
x |
* |
- Source:
Returns:
rejected promise
- Type
- Promise
(static) resolve(x) → {Promise}
Returns a trusted promise. If x is already a trusted promise, it is
returned, otherwise returns a new trusted Promise which follows x.
Parameters:
Name | Type | Description |
---|---|---|
x |
* |
- Source:
Returns:
promise
- Type
- Promise
catch(onRejectednullable) → {Promise}
If this promise cannot be fulfilled due to an error, call onRejected to
handle the error. Shortcut for .then(undefined, onRejected)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
onRejected |
function |
<nullable> |
- Source:
Returns:
- Type
- Promise
then(onFulfilledopt, onRejectedopt, onProgressopt) → {Promise}
Transform this promise's fulfillment value, returning a new Promise
for the transformed result. If the promise cannot be fulfilled, onRejected
is called with the reason. onProgress *may* be called with updates toward
this promise's fulfillment.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
onFulfilled |
function |
<optional> |
fulfillment handler |
onRejected |
function |
<optional> |
rejection handler |
onProgress |
function |
<optional> |
progress handler |
- Source:
Returns:
new promise
- Type
- Promise