1 | "use strict";
|
2 | var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
3 | if (kind === "m") throw new TypeError("Private method is not writable");
|
4 | if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
5 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
6 | return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
7 | };
|
8 | var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
9 | if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
10 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
11 | return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
12 | };
|
13 | var _ExtendablePromise_instances, _ExtendablePromise_values, _ExtendablePromise_promise, _ExtendablePromise_numAdded, _ExtendablePromise_numSettled, _ExtendablePromise_fulfill, _ExtendablePromise_reject, _a;
|
14 | Object.defineProperty(exports, "__esModule", { value: true });
|
15 | exports.ExtendablePromise = void 0;
|
16 |
|
17 | const resolvable_promise_1 = require("@worker-tools/resolvable-promise");
|
18 |
|
19 |
|
20 |
|
21 | class ExtendablePromise {
|
22 | constructor(f) {
|
23 | _ExtendablePromise_instances.add(this);
|
24 | _ExtendablePromise_values.set(this, []);
|
25 | _ExtendablePromise_promise.set(this, void 0);
|
26 | _ExtendablePromise_numAdded.set(this, 0);
|
27 | _ExtendablePromise_numSettled.set(this, 0);
|
28 | Object.defineProperty(this, _a, {
|
29 | enumerable: true,
|
30 | configurable: true,
|
31 | writable: true,
|
32 | value: 'ExtendablePromise'
|
33 | });
|
34 |
|
35 | __classPrivateFieldSet(this, _ExtendablePromise_promise, new resolvable_promise_1.ResolvablePromise(), "f");
|
36 | this.waitUntil(f);
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | }
|
43 | waitUntil(f) {
|
44 | var _b;
|
45 | if (f != null) {
|
46 | const i = __classPrivateFieldGet(this, _ExtendablePromise_numAdded, "f");
|
47 | Promise.resolve(f)
|
48 | .then(v => __classPrivateFieldGet(this, _ExtendablePromise_instances, "m", _ExtendablePromise_fulfill).call(this, i, v), r => __classPrivateFieldGet(this, _ExtendablePromise_instances, "m", _ExtendablePromise_reject).call(this, i, r));
|
49 | __classPrivateFieldSet(this, _ExtendablePromise_numAdded, (_b = __classPrivateFieldGet(this, _ExtendablePromise_numAdded, "f"), _b++, _b), "f");
|
50 | }
|
51 | }
|
52 |
|
53 | get settled() { return __classPrivateFieldGet(this, _ExtendablePromise_promise, "f").settled; }
|
54 | then(onfulfilled, onrejected) {
|
55 | return __classPrivateFieldGet(this, _ExtendablePromise_promise, "f").then(onfulfilled, onrejected);
|
56 | }
|
57 | catch(onrejected) {
|
58 | return __classPrivateFieldGet(this, _ExtendablePromise_promise, "f").catch(onrejected);
|
59 | }
|
60 | finally(onfinally) {
|
61 | return __classPrivateFieldGet(this, _ExtendablePromise_promise, "f").finally(onfinally);
|
62 | }
|
63 | }
|
64 | exports.ExtendablePromise = ExtendablePromise;
|
65 | _ExtendablePromise_values = new WeakMap(), _ExtendablePromise_promise = new WeakMap(), _ExtendablePromise_numAdded = new WeakMap(), _ExtendablePromise_numSettled = new WeakMap(), _ExtendablePromise_instances = new WeakSet(), _ExtendablePromise_fulfill = function _ExtendablePromise_fulfill(i, value) {
|
66 | var _b;
|
67 | __classPrivateFieldGet(this, _ExtendablePromise_values, "f")[i] = { status: 'fulfilled', value };
|
68 | if (__classPrivateFieldSet(this, _ExtendablePromise_numSettled, (_b = __classPrivateFieldGet(this, _ExtendablePromise_numSettled, "f"), ++_b), "f") === __classPrivateFieldGet(this, _ExtendablePromise_numAdded, "f")) {
|
69 | __classPrivateFieldGet(this, _ExtendablePromise_promise, "f").resolve(__classPrivateFieldGet(this, _ExtendablePromise_values, "f"));
|
70 | }
|
71 | }, _ExtendablePromise_reject = function _ExtendablePromise_reject(i, reason) {
|
72 | var _b;
|
73 | __classPrivateFieldGet(this, _ExtendablePromise_values, "f")[i] = { status: 'rejected', reason };
|
74 | if (__classPrivateFieldSet(this, _ExtendablePromise_numSettled, (_b = __classPrivateFieldGet(this, _ExtendablePromise_numSettled, "f"), ++_b), "f") === __classPrivateFieldGet(this, _ExtendablePromise_numAdded, "f")) {
|
75 | __classPrivateFieldGet(this, _ExtendablePromise_promise, "f").resolve(__classPrivateFieldGet(this, _ExtendablePromise_values, "f"));
|
76 | }
|
77 | }, _a = Symbol.toStringTag;
|
78 |
|
\ | No newline at end of file |