cdk-common 2.0.298 → 2.0.300

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/.jsii +8 -2
  2. package/API.md +5 -0
  3. package/lib/main.js +1 -1
  4. package/lib/managed-policies.d.ts +1 -0
  5. package/lib/managed-policies.js +2 -1
  6. package/node_modules/@types/concat-stream/node_modules/@types/node/README.md +1 -1
  7. package/node_modules/@types/concat-stream/node_modules/@types/node/package.json +2 -2
  8. package/node_modules/@types/concat-stream/node_modules/@types/node/stream.d.ts +3 -3
  9. package/node_modules/@types/form-data/node_modules/@types/node/README.md +1 -1
  10. package/node_modules/@types/form-data/node_modules/@types/node/package.json +2 -2
  11. package/node_modules/@types/form-data/node_modules/@types/node/stream.d.ts +3 -3
  12. package/node_modules/promise/Readme.md +14 -0
  13. package/node_modules/promise/domains/core.js +39 -39
  14. package/node_modules/promise/domains/es6-extensions.js +51 -7
  15. package/node_modules/promise/domains/rejection-tracking.js +14 -14
  16. package/node_modules/promise/domains/synchronous.js +10 -10
  17. package/node_modules/promise/index.d.ts +15 -0
  18. package/node_modules/promise/lib/core.js +39 -39
  19. package/node_modules/promise/lib/es6-extensions.js +51 -7
  20. package/node_modules/promise/lib/rejection-tracking.js +14 -14
  21. package/node_modules/promise/lib/synchronous.js +10 -10
  22. package/node_modules/promise/package.json +1 -1
  23. package/node_modules/promise/setimmediate/core.js +39 -39
  24. package/node_modules/promise/setimmediate/es6-extensions.js +51 -7
  25. package/node_modules/promise/setimmediate/rejection-tracking.js +14 -14
  26. package/node_modules/promise/setimmediate/synchronous.js +10 -10
  27. package/node_modules/promise/src/es6-extensions.js +44 -0
  28. package/package.json +2 -2
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Sun, 23 Oct 2022 19:32:39 GMT
11
+ * Last updated: Mon, 24 Oct 2022 23:32:48 GMT
12
12
  * Dependencies: none
13
13
  * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
14
14
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "18.11.4",
3
+ "version": "18.11.5",
4
4
  "description": "TypeScript definitions for Node.js",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -227,6 +227,6 @@
227
227
  },
228
228
  "scripts": {},
229
229
  "dependencies": {},
230
- "typesPublisherContentHash": "510d7c55520137d9fd93e59476c958bf0749bee7c3f256c58974e635d2dcbfc4",
230
+ "typesPublisherContentHash": "789f85299ef1242ce3a980c6492790dbe838ee703cbb6ac4696f979006e9a7ef",
231
231
  "typeScriptVersion": "4.1"
232
232
  }
@@ -124,12 +124,12 @@ declare module 'stream' {
124
124
  readonly readableObjectMode: boolean;
125
125
  /**
126
126
  * Is `true` after `readable.destroy()` has been called.
127
- * @since v18.0.0
127
+ * @since v8.0.0
128
128
  */
129
129
  destroyed: boolean;
130
130
  /**
131
131
  * Is true after 'close' has been emitted.
132
- * @since v8.0.0
132
+ * @since v18.0.0
133
133
  */
134
134
  readonly closed: boolean;
135
135
  /**
@@ -579,7 +579,7 @@ declare module 'stream' {
579
579
  destroyed: boolean;
580
580
  /**
581
581
  * Is true after 'close' has been emitted.
582
- * @since v8.0.0
582
+ * @since v18.0.0
583
583
  */
584
584
  readonly closed: boolean;
585
585
  /**
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Sun, 23 Oct 2022 19:32:39 GMT
11
+ * Last updated: Mon, 24 Oct 2022 23:32:48 GMT
12
12
  * Dependencies: none
13
13
  * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
14
14
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "18.11.4",
3
+ "version": "18.11.5",
4
4
  "description": "TypeScript definitions for Node.js",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -227,6 +227,6 @@
227
227
  },
228
228
  "scripts": {},
229
229
  "dependencies": {},
230
- "typesPublisherContentHash": "510d7c55520137d9fd93e59476c958bf0749bee7c3f256c58974e635d2dcbfc4",
230
+ "typesPublisherContentHash": "789f85299ef1242ce3a980c6492790dbe838ee703cbb6ac4696f979006e9a7ef",
231
231
  "typeScriptVersion": "4.1"
232
232
  }
@@ -124,12 +124,12 @@ declare module 'stream' {
124
124
  readonly readableObjectMode: boolean;
125
125
  /**
126
126
  * Is `true` after `readable.destroy()` has been called.
127
- * @since v18.0.0
127
+ * @since v8.0.0
128
128
  */
129
129
  destroyed: boolean;
130
130
  /**
131
131
  * Is true after 'close' has been emitted.
132
- * @since v8.0.0
132
+ * @since v18.0.0
133
133
  */
134
134
  readonly closed: boolean;
135
135
  /**
@@ -579,7 +579,7 @@ declare module 'stream' {
579
579
  destroyed: boolean;
580
580
  /**
581
581
  * Is true after 'close' has been emitted.
582
- * @since v8.0.0
582
+ * @since v18.0.0
583
583
  */
584
584
  readonly closed: boolean;
585
585
  /**
@@ -141,6 +141,20 @@ Promise.all([Promise.resolve('a'), 'b', Promise.resolve('c')])
141
141
  })
142
142
  ```
143
143
 
144
+ #### Promise.any(array)
145
+
146
+ Returns a single promise that fulfills as soon as any of the promises in the iterable fulfills, with the value of the fulfilled promise. If no promises in the iterable fulfill (if all of the given promises are rejected), then the returned promise is rejected with an `AggregateError`
147
+
148
+ ```js
149
+ var rejected = Promise.reject(0);
150
+ var first = new Promise(function (resolve){ setTimeout(resolve, 100, 'quick') });
151
+ var second = new Promise(function (resolve){ setTimeout(resolve, 500, 'slow') });
152
+
153
+ var promises = [rejected, first, second];
154
+
155
+ Promise.any(promises) // => succeeds with `quick`
156
+ ```
157
+
144
158
  #### Promise.allSettled(array)
145
159
 
146
160
  Returns a promise that resolves after all of the given promises have either fulfilled or rejected, with an array of objects that each describes the outcome of each promise.
@@ -58,16 +58,16 @@ function Promise(fn) {
58
58
  if (typeof fn !== 'function') {
59
59
  throw new TypeError('Promise constructor\'s argument is not a function');
60
60
  }
61
- this._1 = 0;
62
- this._2 = 0;
63
- this._3 = null;
64
- this._4 = null;
61
+ this._x = 0;
62
+ this._y = 0;
63
+ this._z = null;
64
+ this._A = null;
65
65
  if (fn === noop) return;
66
66
  doResolve(fn, this);
67
67
  }
68
- Promise._5 = null;
69
- Promise._6 = null;
70
- Promise._7 = noop;
68
+ Promise._B = null;
69
+ Promise._C = null;
70
+ Promise._D = noop;
71
71
 
72
72
  Promise.prototype.then = function(onFulfilled, onRejected) {
73
73
  if (this.constructor !== Promise) {
@@ -86,24 +86,24 @@ function safeThen(self, onFulfilled, onRejected) {
86
86
  });
87
87
  }
88
88
  function handle(self, deferred) {
89
- while (self._2 === 3) {
90
- self = self._3;
89
+ while (self._y === 3) {
90
+ self = self._z;
91
91
  }
92
- if (Promise._5) {
93
- Promise._5(self);
92
+ if (Promise._B) {
93
+ Promise._B(self);
94
94
  }
95
- if (self._2 === 0) {
96
- if (self._1 === 0) {
97
- self._1 = 1;
98
- self._4 = deferred;
95
+ if (self._y === 0) {
96
+ if (self._x === 0) {
97
+ self._x = 1;
98
+ self._A = deferred;
99
99
  return;
100
100
  }
101
- if (self._1 === 1) {
102
- self._1 = 2;
103
- self._4 = [self._4, deferred];
101
+ if (self._x === 1) {
102
+ self._x = 2;
103
+ self._A = [self._A, deferred];
104
104
  return;
105
105
  }
106
- self._4.push(deferred);
106
+ self._A.push(deferred);
107
107
  return;
108
108
  }
109
109
  handleResolved(self, deferred);
@@ -111,16 +111,16 @@ function handle(self, deferred) {
111
111
 
112
112
  function handleResolved(self, deferred) {
113
113
  asap(function() {
114
- var cb = self._2 === 1 ? deferred.onFulfilled : deferred.onRejected;
114
+ var cb = self._y === 1 ? deferred.onFulfilled : deferred.onRejected;
115
115
  if (cb === null) {
116
- if (self._2 === 1) {
117
- resolve(deferred.promise, self._3);
116
+ if (self._y === 1) {
117
+ resolve(deferred.promise, self._z);
118
118
  } else {
119
- reject(deferred.promise, self._3);
119
+ reject(deferred.promise, self._z);
120
120
  }
121
121
  return;
122
122
  }
123
- var ret = tryCallOne(cb, self._3);
123
+ var ret = tryCallOne(cb, self._z);
124
124
  if (ret === IS_ERROR) {
125
125
  reject(deferred.promise, LAST_ERROR);
126
126
  } else {
@@ -148,8 +148,8 @@ function resolve(self, newValue) {
148
148
  then === self.then &&
149
149
  newValue instanceof Promise
150
150
  ) {
151
- self._2 = 3;
152
- self._3 = newValue;
151
+ self._y = 3;
152
+ self._z = newValue;
153
153
  finale(self);
154
154
  return;
155
155
  } else if (typeof then === 'function') {
@@ -157,29 +157,29 @@ function resolve(self, newValue) {
157
157
  return;
158
158
  }
159
159
  }
160
- self._2 = 1;
161
- self._3 = newValue;
160
+ self._y = 1;
161
+ self._z = newValue;
162
162
  finale(self);
163
163
  }
164
164
 
165
165
  function reject(self, newValue) {
166
- self._2 = 2;
167
- self._3 = newValue;
168
- if (Promise._6) {
169
- Promise._6(self, newValue);
166
+ self._y = 2;
167
+ self._z = newValue;
168
+ if (Promise._C) {
169
+ Promise._C(self, newValue);
170
170
  }
171
171
  finale(self);
172
172
  }
173
173
  function finale(self) {
174
- if (self._1 === 1) {
175
- handle(self, self._4);
176
- self._4 = null;
174
+ if (self._x === 1) {
175
+ handle(self, self._A);
176
+ self._A = null;
177
177
  }
178
- if (self._1 === 2) {
179
- for (var i = 0; i < self._4.length; i++) {
180
- handle(self, self._4[i]);
178
+ if (self._x === 2) {
179
+ for (var i = 0; i < self._A.length; i++) {
180
+ handle(self, self._A[i]);
181
181
  }
182
- self._4 = null;
182
+ self._A = null;
183
183
  }
184
184
  }
185
185
 
@@ -16,9 +16,9 @@ var ZERO = valuePromise(0);
16
16
  var EMPTYSTRING = valuePromise('');
17
17
 
18
18
  function valuePromise(value) {
19
- var p = new Promise(Promise._7);
20
- p._2 = 1;
21
- p._3 = value;
19
+ var p = new Promise(Promise._D);
20
+ p._y = 1;
21
+ p._z = value;
22
22
  return p;
23
23
  }
24
24
  Promise.resolve = function (value) {
@@ -67,11 +67,11 @@ Promise.all = function (arr) {
67
67
  function res(i, val) {
68
68
  if (val && (typeof val === 'object' || typeof val === 'function')) {
69
69
  if (val instanceof Promise && val.then === Promise.prototype.then) {
70
- while (val._2 === 3) {
71
- val = val._3;
70
+ while (val._y === 3) {
71
+ val = val._z;
72
72
  }
73
- if (val._2 === 1) return res(i, val._3);
74
- if (val._2 === 2) reject(val._3);
73
+ if (val._y === 1) return res(i, val._z);
74
+ if (val._y === 2) reject(val._z);
75
75
  val.then(function (val) {
76
76
  res(i, val);
77
77
  }, reject);
@@ -140,3 +140,47 @@ Promise.race = function (values) {
140
140
  Promise.prototype['catch'] = function (onRejected) {
141
141
  return this.then(null, onRejected);
142
142
  };
143
+
144
+ function getAggregateError(errors){
145
+ if(typeof AggregateError === 'function'){
146
+ return new AggregateError(errors,'All promises were rejected');
147
+ }
148
+
149
+ var error = new Error('All promises were rejected');
150
+
151
+ error.name = 'AggregateError';
152
+ error.errors = errors;
153
+
154
+ return error;
155
+ }
156
+
157
+ Promise.any = function promiseAny(values) {
158
+ return new Promise(function(resolve, reject) {
159
+ var promises = iterableToArray(values);
160
+ var hasResolved = false;
161
+ var rejectionReasons = [];
162
+
163
+ function resolveOnce(value) {
164
+ if (!hasResolved) {
165
+ hasResolved = true;
166
+ resolve(value);
167
+ }
168
+ }
169
+
170
+ function rejectionCheck(reason) {
171
+ rejectionReasons.push(reason);
172
+
173
+ if (rejectionReasons.length === promises.length) {
174
+ reject(getAggregateError(rejectionReasons));
175
+ }
176
+ }
177
+
178
+ if(promises.length === 0){
179
+ reject(getAggregateError(rejectionReasons));
180
+ } else {
181
+ promises.forEach(function(value){
182
+ Promise.resolve(value).then(resolveOnce, rejectionCheck);
183
+ });
184
+ }
185
+ });
186
+ };
@@ -12,8 +12,8 @@ var enabled = false;
12
12
  exports.disable = disable;
13
13
  function disable() {
14
14
  enabled = false;
15
- Promise._5 = null;
16
- Promise._6 = null;
15
+ Promise._B = null;
16
+ Promise._C = null;
17
17
  }
18
18
 
19
19
  exports.enable = enable;
@@ -24,27 +24,27 @@ function enable(options) {
24
24
  var id = 0;
25
25
  var displayId = 0;
26
26
  var rejections = {};
27
- Promise._5 = function (promise) {
27
+ Promise._B = function (promise) {
28
28
  if (
29
- promise._2 === 2 && // IS REJECTED
30
- rejections[promise._8]
29
+ promise._y === 2 && // IS REJECTED
30
+ rejections[promise._E]
31
31
  ) {
32
- if (rejections[promise._8].logged) {
33
- onHandled(promise._8);
32
+ if (rejections[promise._E].logged) {
33
+ onHandled(promise._E);
34
34
  } else {
35
- clearTimeout(rejections[promise._8].timeout);
35
+ clearTimeout(rejections[promise._E].timeout);
36
36
  }
37
- delete rejections[promise._8];
37
+ delete rejections[promise._E];
38
38
  }
39
39
  };
40
- Promise._6 = function (promise, err) {
41
- if (promise._1 === 0) { // not yet handled
42
- promise._8 = id++;
43
- rejections[promise._8] = {
40
+ Promise._C = function (promise, err) {
41
+ if (promise._x === 0) { // not yet handled
42
+ promise._E = id++;
43
+ rejections[promise._E] = {
44
44
  displayId: null,
45
45
  error: err,
46
46
  timeout: setTimeout(
47
- onUnhandled.bind(null, promise._8),
47
+ onUnhandled.bind(null, promise._E),
48
48
  // For reference errors and type errors, this almost always
49
49
  // means the programmer made a mistake, so log them after just
50
50
  // 100ms
@@ -17,38 +17,38 @@ Promise.enableSynchronous = function () {
17
17
  };
18
18
 
19
19
  Promise.prototype.getValue = function () {
20
- if (this._2 === 3) {
21
- return this._3.getValue();
20
+ if (this._y === 3) {
21
+ return this._z.getValue();
22
22
  }
23
23
 
24
24
  if (!this.isFulfilled()) {
25
25
  throw new Error('Cannot get a value of an unfulfilled promise.');
26
26
  }
27
27
 
28
- return this._3;
28
+ return this._z;
29
29
  };
30
30
 
31
31
  Promise.prototype.getReason = function () {
32
- if (this._2 === 3) {
33
- return this._3.getReason();
32
+ if (this._y === 3) {
33
+ return this._z.getReason();
34
34
  }
35
35
 
36
36
  if (!this.isRejected()) {
37
37
  throw new Error('Cannot get a rejection reason of a non-rejected promise.');
38
38
  }
39
39
 
40
- return this._3;
40
+ return this._z;
41
41
  };
42
42
 
43
43
  Promise.prototype.getState = function () {
44
- if (this._2 === 3) {
45
- return this._3.getState();
44
+ if (this._y === 3) {
45
+ return this._z.getState();
46
46
  }
47
- if (this._2 === -1 || this._2 === -2) {
47
+ if (this._y === -1 || this._y === -2) {
48
48
  return 0;
49
49
  }
50
50
 
51
- return this._2;
51
+ return this._y;
52
52
  };
53
53
  };
54
54
 
@@ -60,6 +60,21 @@ interface ThenPromiseConstructor {
60
60
  */
61
61
  new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => any): ThenPromise<T>;
62
62
 
63
+
64
+ /**
65
+ * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.
66
+ * @param values An array or iterable of Promises.
67
+ * @returns A new Promise.
68
+ */
69
+ any<T extends readonly unknown[] | []>(values: T): Promise<Awaited<T[number]>>;
70
+
71
+ /**
72
+ * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.
73
+ * @param values An array or iterable of Promises.
74
+ * @returns A new Promise.
75
+ */
76
+ any<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>
77
+
63
78
  /**
64
79
  * Creates a Promise that is resolved with an array of results when all
65
80
  * of the provided Promises resolve or reject.
@@ -58,16 +58,16 @@ function Promise(fn) {
58
58
  if (typeof fn !== 'function') {
59
59
  throw new TypeError('Promise constructor\'s argument is not a function');
60
60
  }
61
- this._1 = 0;
62
- this._2 = 0;
63
- this._3 = null;
64
- this._4 = null;
61
+ this._x = 0;
62
+ this._y = 0;
63
+ this._z = null;
64
+ this._A = null;
65
65
  if (fn === noop) return;
66
66
  doResolve(fn, this);
67
67
  }
68
- Promise._5 = null;
69
- Promise._6 = null;
70
- Promise._7 = noop;
68
+ Promise._B = null;
69
+ Promise._C = null;
70
+ Promise._D = noop;
71
71
 
72
72
  Promise.prototype.then = function(onFulfilled, onRejected) {
73
73
  if (this.constructor !== Promise) {
@@ -86,24 +86,24 @@ function safeThen(self, onFulfilled, onRejected) {
86
86
  });
87
87
  }
88
88
  function handle(self, deferred) {
89
- while (self._2 === 3) {
90
- self = self._3;
89
+ while (self._y === 3) {
90
+ self = self._z;
91
91
  }
92
- if (Promise._5) {
93
- Promise._5(self);
92
+ if (Promise._B) {
93
+ Promise._B(self);
94
94
  }
95
- if (self._2 === 0) {
96
- if (self._1 === 0) {
97
- self._1 = 1;
98
- self._4 = deferred;
95
+ if (self._y === 0) {
96
+ if (self._x === 0) {
97
+ self._x = 1;
98
+ self._A = deferred;
99
99
  return;
100
100
  }
101
- if (self._1 === 1) {
102
- self._1 = 2;
103
- self._4 = [self._4, deferred];
101
+ if (self._x === 1) {
102
+ self._x = 2;
103
+ self._A = [self._A, deferred];
104
104
  return;
105
105
  }
106
- self._4.push(deferred);
106
+ self._A.push(deferred);
107
107
  return;
108
108
  }
109
109
  handleResolved(self, deferred);
@@ -111,16 +111,16 @@ function handle(self, deferred) {
111
111
 
112
112
  function handleResolved(self, deferred) {
113
113
  asap(function() {
114
- var cb = self._2 === 1 ? deferred.onFulfilled : deferred.onRejected;
114
+ var cb = self._y === 1 ? deferred.onFulfilled : deferred.onRejected;
115
115
  if (cb === null) {
116
- if (self._2 === 1) {
117
- resolve(deferred.promise, self._3);
116
+ if (self._y === 1) {
117
+ resolve(deferred.promise, self._z);
118
118
  } else {
119
- reject(deferred.promise, self._3);
119
+ reject(deferred.promise, self._z);
120
120
  }
121
121
  return;
122
122
  }
123
- var ret = tryCallOne(cb, self._3);
123
+ var ret = tryCallOne(cb, self._z);
124
124
  if (ret === IS_ERROR) {
125
125
  reject(deferred.promise, LAST_ERROR);
126
126
  } else {
@@ -148,8 +148,8 @@ function resolve(self, newValue) {
148
148
  then === self.then &&
149
149
  newValue instanceof Promise
150
150
  ) {
151
- self._2 = 3;
152
- self._3 = newValue;
151
+ self._y = 3;
152
+ self._z = newValue;
153
153
  finale(self);
154
154
  return;
155
155
  } else if (typeof then === 'function') {
@@ -157,29 +157,29 @@ function resolve(self, newValue) {
157
157
  return;
158
158
  }
159
159
  }
160
- self._2 = 1;
161
- self._3 = newValue;
160
+ self._y = 1;
161
+ self._z = newValue;
162
162
  finale(self);
163
163
  }
164
164
 
165
165
  function reject(self, newValue) {
166
- self._2 = 2;
167
- self._3 = newValue;
168
- if (Promise._6) {
169
- Promise._6(self, newValue);
166
+ self._y = 2;
167
+ self._z = newValue;
168
+ if (Promise._C) {
169
+ Promise._C(self, newValue);
170
170
  }
171
171
  finale(self);
172
172
  }
173
173
  function finale(self) {
174
- if (self._1 === 1) {
175
- handle(self, self._4);
176
- self._4 = null;
174
+ if (self._x === 1) {
175
+ handle(self, self._A);
176
+ self._A = null;
177
177
  }
178
- if (self._1 === 2) {
179
- for (var i = 0; i < self._4.length; i++) {
180
- handle(self, self._4[i]);
178
+ if (self._x === 2) {
179
+ for (var i = 0; i < self._A.length; i++) {
180
+ handle(self, self._A[i]);
181
181
  }
182
- self._4 = null;
182
+ self._A = null;
183
183
  }
184
184
  }
185
185
 
@@ -16,9 +16,9 @@ var ZERO = valuePromise(0);
16
16
  var EMPTYSTRING = valuePromise('');
17
17
 
18
18
  function valuePromise(value) {
19
- var p = new Promise(Promise._7);
20
- p._2 = 1;
21
- p._3 = value;
19
+ var p = new Promise(Promise._D);
20
+ p._y = 1;
21
+ p._z = value;
22
22
  return p;
23
23
  }
24
24
  Promise.resolve = function (value) {
@@ -67,11 +67,11 @@ Promise.all = function (arr) {
67
67
  function res(i, val) {
68
68
  if (val && (typeof val === 'object' || typeof val === 'function')) {
69
69
  if (val instanceof Promise && val.then === Promise.prototype.then) {
70
- while (val._2 === 3) {
71
- val = val._3;
70
+ while (val._y === 3) {
71
+ val = val._z;
72
72
  }
73
- if (val._2 === 1) return res(i, val._3);
74
- if (val._2 === 2) reject(val._3);
73
+ if (val._y === 1) return res(i, val._z);
74
+ if (val._y === 2) reject(val._z);
75
75
  val.then(function (val) {
76
76
  res(i, val);
77
77
  }, reject);
@@ -140,3 +140,47 @@ Promise.race = function (values) {
140
140
  Promise.prototype['catch'] = function (onRejected) {
141
141
  return this.then(null, onRejected);
142
142
  };
143
+
144
+ function getAggregateError(errors){
145
+ if(typeof AggregateError === 'function'){
146
+ return new AggregateError(errors,'All promises were rejected');
147
+ }
148
+
149
+ var error = new Error('All promises were rejected');
150
+
151
+ error.name = 'AggregateError';
152
+ error.errors = errors;
153
+
154
+ return error;
155
+ }
156
+
157
+ Promise.any = function promiseAny(values) {
158
+ return new Promise(function(resolve, reject) {
159
+ var promises = iterableToArray(values);
160
+ var hasResolved = false;
161
+ var rejectionReasons = [];
162
+
163
+ function resolveOnce(value) {
164
+ if (!hasResolved) {
165
+ hasResolved = true;
166
+ resolve(value);
167
+ }
168
+ }
169
+
170
+ function rejectionCheck(reason) {
171
+ rejectionReasons.push(reason);
172
+
173
+ if (rejectionReasons.length === promises.length) {
174
+ reject(getAggregateError(rejectionReasons));
175
+ }
176
+ }
177
+
178
+ if(promises.length === 0){
179
+ reject(getAggregateError(rejectionReasons));
180
+ } else {
181
+ promises.forEach(function(value){
182
+ Promise.resolve(value).then(resolveOnce, rejectionCheck);
183
+ });
184
+ }
185
+ });
186
+ };