cdk-common 2.0.299 → 2.0.301
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.
- package/.jsii +26 -2
- package/API.md +20 -0
- package/lib/main.js +1 -1
- package/lib/managed-policies.d.ts +4 -0
- package/lib/managed-policies.js +5 -1
- package/node_modules/@types/concat-stream/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/concat-stream/node_modules/@types/node/globals.d.ts +1 -1
- package/node_modules/@types/concat-stream/node_modules/@types/node/http.d.ts +7 -0
- package/node_modules/@types/concat-stream/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/concat-stream/node_modules/@types/node/ts4.8/http.d.ts +7 -0
- package/node_modules/@types/form-data/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/form-data/node_modules/@types/node/globals.d.ts +1 -1
- package/node_modules/@types/form-data/node_modules/@types/node/http.d.ts +7 -0
- package/node_modules/@types/form-data/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/form-data/node_modules/@types/node/ts4.8/http.d.ts +7 -0
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/globals.d.ts +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/promise/Readme.md +14 -0
- package/node_modules/promise/domains/core.js +39 -39
- package/node_modules/promise/domains/es6-extensions.js +51 -7
- package/node_modules/promise/domains/rejection-tracking.js +14 -14
- package/node_modules/promise/domains/synchronous.js +10 -10
- package/node_modules/promise/index.d.ts +15 -0
- package/node_modules/promise/lib/core.js +39 -39
- package/node_modules/promise/lib/es6-extensions.js +51 -7
- package/node_modules/promise/lib/rejection-tracking.js +14 -14
- package/node_modules/promise/lib/synchronous.js +10 -10
- package/node_modules/promise/package.json +1 -1
- package/node_modules/promise/setimmediate/core.js +39 -39
- package/node_modules/promise/setimmediate/es6-extensions.js +51 -7
- package/node_modules/promise/setimmediate/rejection-tracking.js +14 -14
- package/node_modules/promise/setimmediate/synchronous.js +10 -10
- package/node_modules/promise/src/es6-extensions.js +44 -0
- 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:
|
|
11
|
+
* Last updated: Wed, 26 Oct 2022 20:32:58 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
|
|
14
14
|
|
|
@@ -76,7 +76,7 @@ declare var AbortSignal: typeof globalThis extends {onmessage: any; AbortSignal:
|
|
|
76
76
|
: {
|
|
77
77
|
prototype: AbortSignal;
|
|
78
78
|
new(): AbortSignal;
|
|
79
|
-
|
|
79
|
+
abort(reason?: any): AbortSignal;
|
|
80
80
|
timeout(milliseconds: number): AbortSignal;
|
|
81
81
|
};
|
|
82
82
|
//#endregion borrowed
|
|
@@ -1595,6 +1595,13 @@ declare module 'http' {
|
|
|
1595
1595
|
*/
|
|
1596
1596
|
function validateHeaderValue(name: string, value: string): void;
|
|
1597
1597
|
|
|
1598
|
+
/**
|
|
1599
|
+
* Set the maximum number of idle HTTP parsers. Default: 1000.
|
|
1600
|
+
* @param count
|
|
1601
|
+
* @since v18.8.0, v16.18.0
|
|
1602
|
+
*/
|
|
1603
|
+
function setMaxIdleHTTPParsers(count: number): void;
|
|
1604
|
+
|
|
1598
1605
|
let globalAgent: Agent;
|
|
1599
1606
|
/**
|
|
1600
1607
|
* Read-only property specifying the maximum allowed size of HTTP headers in bytes.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "18.11.
|
|
3
|
+
"version": "18.11.7",
|
|
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": "
|
|
230
|
+
"typesPublisherContentHash": "e64a34cfa8ad95a9b0e877bc576e260483e6152920c5641be7813e087342864a",
|
|
231
231
|
"typeScriptVersion": "4.1"
|
|
232
232
|
}
|
|
@@ -1595,6 +1595,13 @@ declare module 'http' {
|
|
|
1595
1595
|
*/
|
|
1596
1596
|
function validateHeaderValue(name: string, value: string): void;
|
|
1597
1597
|
|
|
1598
|
+
/**
|
|
1599
|
+
* Set the maximum number of idle HTTP parsers. Default: 1000.
|
|
1600
|
+
* @param count
|
|
1601
|
+
* @since v18.8.0, v16.18.0
|
|
1602
|
+
*/
|
|
1603
|
+
function setMaxIdleHTTPParsers(count: number): void;
|
|
1604
|
+
|
|
1598
1605
|
let globalAgent: Agent;
|
|
1599
1606
|
/**
|
|
1600
1607
|
* Read-only property specifying the maximum allowed size of HTTP headers in bytes.
|
|
@@ -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:
|
|
11
|
+
* Last updated: Wed, 26 Oct 2022 20:32:58 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
|
|
14
14
|
|
|
@@ -76,7 +76,7 @@ declare var AbortSignal: typeof globalThis extends {onmessage: any; AbortSignal:
|
|
|
76
76
|
: {
|
|
77
77
|
prototype: AbortSignal;
|
|
78
78
|
new(): AbortSignal;
|
|
79
|
-
|
|
79
|
+
abort(reason?: any): AbortSignal;
|
|
80
80
|
timeout(milliseconds: number): AbortSignal;
|
|
81
81
|
};
|
|
82
82
|
//#endregion borrowed
|
|
@@ -1595,6 +1595,13 @@ declare module 'http' {
|
|
|
1595
1595
|
*/
|
|
1596
1596
|
function validateHeaderValue(name: string, value: string): void;
|
|
1597
1597
|
|
|
1598
|
+
/**
|
|
1599
|
+
* Set the maximum number of idle HTTP parsers. Default: 1000.
|
|
1600
|
+
* @param count
|
|
1601
|
+
* @since v18.8.0, v16.18.0
|
|
1602
|
+
*/
|
|
1603
|
+
function setMaxIdleHTTPParsers(count: number): void;
|
|
1604
|
+
|
|
1598
1605
|
let globalAgent: Agent;
|
|
1599
1606
|
/**
|
|
1600
1607
|
* Read-only property specifying the maximum allowed size of HTTP headers in bytes.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "18.11.
|
|
3
|
+
"version": "18.11.7",
|
|
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": "
|
|
230
|
+
"typesPublisherContentHash": "e64a34cfa8ad95a9b0e877bc576e260483e6152920c5641be7813e087342864a",
|
|
231
231
|
"typeScriptVersion": "4.1"
|
|
232
232
|
}
|
|
@@ -1595,6 +1595,13 @@ declare module 'http' {
|
|
|
1595
1595
|
*/
|
|
1596
1596
|
function validateHeaderValue(name: string, value: string): void;
|
|
1597
1597
|
|
|
1598
|
+
/**
|
|
1599
|
+
* Set the maximum number of idle HTTP parsers. Default: 1000.
|
|
1600
|
+
* @param count
|
|
1601
|
+
* @since v18.8.0, v16.18.0
|
|
1602
|
+
*/
|
|
1603
|
+
function setMaxIdleHTTPParsers(count: number): void;
|
|
1604
|
+
|
|
1598
1605
|
let globalAgent: Agent;
|
|
1599
1606
|
/**
|
|
1600
1607
|
* Read-only property specifying the maximum allowed size of HTTP headers in bytes.
|
|
@@ -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/v14.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Wed, 26 Oct 2022 20:33:01 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: `AbortController`, `AbortSignal`, `Buffer`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
|
|
14
14
|
|
|
@@ -114,7 +114,7 @@ declare var AbortController: {
|
|
|
114
114
|
declare var AbortSignal: {
|
|
115
115
|
prototype: AbortSignal;
|
|
116
116
|
new(): AbortSignal;
|
|
117
|
-
|
|
117
|
+
abort(reason?: any): AbortSignal;
|
|
118
118
|
timeout(milliseconds: number): AbortSignal;
|
|
119
119
|
};
|
|
120
120
|
//#endregion borrowed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "14.18.
|
|
3
|
+
"version": "14.18.33",
|
|
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": "
|
|
230
|
+
"typesPublisherContentHash": "132921d8fea35693f1adaf8d9110efe9ffdd29c6863478ce1130b46dae22336a",
|
|
231
231
|
"typeScriptVersion": "4.1"
|
|
232
232
|
}
|
|
@@ -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.
|
|
62
|
-
this.
|
|
63
|
-
this.
|
|
64
|
-
this.
|
|
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.
|
|
69
|
-
Promise.
|
|
70
|
-
Promise.
|
|
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.
|
|
90
|
-
self = self.
|
|
89
|
+
while (self._y === 3) {
|
|
90
|
+
self = self._z;
|
|
91
91
|
}
|
|
92
|
-
if (Promise.
|
|
93
|
-
Promise.
|
|
92
|
+
if (Promise._B) {
|
|
93
|
+
Promise._B(self);
|
|
94
94
|
}
|
|
95
|
-
if (self.
|
|
96
|
-
if (self.
|
|
97
|
-
self.
|
|
98
|
-
self.
|
|
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.
|
|
102
|
-
self.
|
|
103
|
-
self.
|
|
101
|
+
if (self._x === 1) {
|
|
102
|
+
self._x = 2;
|
|
103
|
+
self._A = [self._A, deferred];
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
|
-
self.
|
|
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.
|
|
114
|
+
var cb = self._y === 1 ? deferred.onFulfilled : deferred.onRejected;
|
|
115
115
|
if (cb === null) {
|
|
116
|
-
if (self.
|
|
117
|
-
resolve(deferred.promise, self.
|
|
116
|
+
if (self._y === 1) {
|
|
117
|
+
resolve(deferred.promise, self._z);
|
|
118
118
|
} else {
|
|
119
|
-
reject(deferred.promise, self.
|
|
119
|
+
reject(deferred.promise, self._z);
|
|
120
120
|
}
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
|
-
var ret = tryCallOne(cb, self.
|
|
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.
|
|
152
|
-
self.
|
|
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.
|
|
161
|
-
self.
|
|
160
|
+
self._y = 1;
|
|
161
|
+
self._z = newValue;
|
|
162
162
|
finale(self);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
function reject(self, newValue) {
|
|
166
|
-
self.
|
|
167
|
-
self.
|
|
168
|
-
if (Promise.
|
|
169
|
-
Promise.
|
|
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.
|
|
175
|
-
handle(self, self.
|
|
176
|
-
self.
|
|
174
|
+
if (self._x === 1) {
|
|
175
|
+
handle(self, self._A);
|
|
176
|
+
self._A = null;
|
|
177
177
|
}
|
|
178
|
-
if (self.
|
|
179
|
-
for (var i = 0; i < self.
|
|
180
|
-
handle(self, self.
|
|
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.
|
|
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.
|
|
20
|
-
p.
|
|
21
|
-
p.
|
|
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.
|
|
71
|
-
val = val.
|
|
70
|
+
while (val._y === 3) {
|
|
71
|
+
val = val._z;
|
|
72
72
|
}
|
|
73
|
-
if (val.
|
|
74
|
-
if (val.
|
|
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.
|
|
16
|
-
Promise.
|
|
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.
|
|
27
|
+
Promise._B = function (promise) {
|
|
28
28
|
if (
|
|
29
|
-
promise.
|
|
30
|
-
rejections[promise.
|
|
29
|
+
promise._y === 2 && // IS REJECTED
|
|
30
|
+
rejections[promise._E]
|
|
31
31
|
) {
|
|
32
|
-
if (rejections[promise.
|
|
33
|
-
onHandled(promise.
|
|
32
|
+
if (rejections[promise._E].logged) {
|
|
33
|
+
onHandled(promise._E);
|
|
34
34
|
} else {
|
|
35
|
-
clearTimeout(rejections[promise.
|
|
35
|
+
clearTimeout(rejections[promise._E].timeout);
|
|
36
36
|
}
|
|
37
|
-
delete rejections[promise.
|
|
37
|
+
delete rejections[promise._E];
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
Promise.
|
|
41
|
-
if (promise.
|
|
42
|
-
promise.
|
|
43
|
-
rejections[promise.
|
|
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.
|
|
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.
|
|
21
|
-
return this.
|
|
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.
|
|
28
|
+
return this._z;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
Promise.prototype.getReason = function () {
|
|
32
|
-
if (this.
|
|
33
|
-
return this.
|
|
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.
|
|
40
|
+
return this._z;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
Promise.prototype.getState = function () {
|
|
44
|
-
if (this.
|
|
45
|
-
return this.
|
|
44
|
+
if (this._y === 3) {
|
|
45
|
+
return this._z.getState();
|
|
46
46
|
}
|
|
47
|
-
if (this.
|
|
47
|
+
if (this._y === -1 || this._y === -2) {
|
|
48
48
|
return 0;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
return this.
|
|
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.
|
|
62
|
-
this.
|
|
63
|
-
this.
|
|
64
|
-
this.
|
|
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.
|
|
69
|
-
Promise.
|
|
70
|
-
Promise.
|
|
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.
|
|
90
|
-
self = self.
|
|
89
|
+
while (self._y === 3) {
|
|
90
|
+
self = self._z;
|
|
91
91
|
}
|
|
92
|
-
if (Promise.
|
|
93
|
-
Promise.
|
|
92
|
+
if (Promise._B) {
|
|
93
|
+
Promise._B(self);
|
|
94
94
|
}
|
|
95
|
-
if (self.
|
|
96
|
-
if (self.
|
|
97
|
-
self.
|
|
98
|
-
self.
|
|
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.
|
|
102
|
-
self.
|
|
103
|
-
self.
|
|
101
|
+
if (self._x === 1) {
|
|
102
|
+
self._x = 2;
|
|
103
|
+
self._A = [self._A, deferred];
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
|
-
self.
|
|
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.
|
|
114
|
+
var cb = self._y === 1 ? deferred.onFulfilled : deferred.onRejected;
|
|
115
115
|
if (cb === null) {
|
|
116
|
-
if (self.
|
|
117
|
-
resolve(deferred.promise, self.
|
|
116
|
+
if (self._y === 1) {
|
|
117
|
+
resolve(deferred.promise, self._z);
|
|
118
118
|
} else {
|
|
119
|
-
reject(deferred.promise, self.
|
|
119
|
+
reject(deferred.promise, self._z);
|
|
120
120
|
}
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
|
-
var ret = tryCallOne(cb, self.
|
|
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.
|
|
152
|
-
self.
|
|
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.
|
|
161
|
-
self.
|
|
160
|
+
self._y = 1;
|
|
161
|
+
self._z = newValue;
|
|
162
162
|
finale(self);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
function reject(self, newValue) {
|
|
166
|
-
self.
|
|
167
|
-
self.
|
|
168
|
-
if (Promise.
|
|
169
|
-
Promise.
|
|
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.
|
|
175
|
-
handle(self, self.
|
|
176
|
-
self.
|
|
174
|
+
if (self._x === 1) {
|
|
175
|
+
handle(self, self._A);
|
|
176
|
+
self._A = null;
|
|
177
177
|
}
|
|
178
|
-
if (self.
|
|
179
|
-
for (var i = 0; i < self.
|
|
180
|
-
handle(self, self.
|
|
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.
|
|
182
|
+
self._A = null;
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|