• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"use strict";
2module.exports =
3    function(Promise, PromiseArray, debug) {
4var PromiseInspection = Promise.PromiseInspection;
5var util = require("./util");
6
7function SettledPromiseArray(values) {
8    this.constructor$(values);
9}
10util.inherits(SettledPromiseArray, PromiseArray);
11
12SettledPromiseArray.prototype._promiseResolved = function (index, inspection) {
13    this._values[index] = inspection;
14    var totalResolved = ++this._totalResolved;
15    if (totalResolved >= this._length) {
16        this._resolve(this._values);
17        return true;
18    }
19    return false;
20};
21
22SettledPromiseArray.prototype._promiseFulfilled = function (value, index) {
23    var ret = new PromiseInspection();
24    ret._bitField = 33554432;
25    ret._settledValueField = value;
26    return this._promiseResolved(index, ret);
27};
28SettledPromiseArray.prototype._promiseRejected = function (reason, index) {
29    var ret = new PromiseInspection();
30    ret._bitField = 16777216;
31    ret._settledValueField = reason;
32    return this._promiseResolved(index, ret);
33};
34
35Promise.settle = function (promises) {
36    debug.deprecated(".settle()", ".reflect()");
37    return new SettledPromiseArray(promises).promise();
38};
39
40Promise.prototype.settle = function () {
41    return Promise.settle(this);
42};
43};
44