tiny-future
Version:
A tiny way to make `Promise` more convenient to use without any dependencies.
31 lines (29 loc) • 626 B
JavaScript
class Future {
/**
* Resolve the created Promise.
*/
resolve;
/**
* Reject the created Promise.
*/
reject;
/**
* The Promise created by the Future.
*/
promise;
constructor() {
if (typeof Promise.withResolvers === "function") {
const { promise, resolve, reject } = Promise.withResolvers();
this.promise = promise;
this.resolve = resolve;
this.reject = reject;
} else {
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
}
}
}
export { Future };
//# sourceMappingURL=main.mjs.map