Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

settle.js 1.2KB

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