1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.createPromiseWithResolver = void 0;
|
4 | const doNothing = () => undefined;
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function createPromiseWithResolver() {
|
10 | let alreadyResolved = false;
|
11 | let resolvedTo;
|
12 | let resolver = doNothing;
|
13 | const promise = new Promise(resolve => {
|
14 | if (alreadyResolved) {
|
15 | resolve(resolvedTo);
|
16 | }
|
17 | else {
|
18 | resolver = resolve;
|
19 | }
|
20 | });
|
21 | const exposedResolver = (value) => {
|
22 | alreadyResolved = true;
|
23 | resolvedTo = value;
|
24 | resolver(resolvedTo);
|
25 | };
|
26 | return [promise, exposedResolver];
|
27 | }
|
28 | exports.createPromiseWithResolver = createPromiseWithResolver;
|