wireit
Version:
Upgrade your npm scripts to make them smarter and more efficient
35 lines • 756 B
JavaScript
/**
* @license
* Copyright 2022 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* Convenience class for tracking a promise alongside its resolve and reject
* functions.
*/
export class Deferred {
#resolve;
#reject;
#settled = false;
constructor() {
let res, rej;
this.promise = new Promise((resolve, reject) => {
res = resolve;
rej = reject;
});
this.#resolve = res;
this.#reject = rej;
}
get settled() {
return this.#settled;
}
resolve(value) {
this.#settled = true;
this.#resolve(value);
}
reject(reason) {
this.#settled = true;
this.#reject(reason);
}
}
//# sourceMappingURL=deferred.js.map