tiny-future
Version:
A tiny way to make `Promise` more convenient to use without any dependencies.
33 lines (30 loc) • 647 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;
});
}
}
}
exports.Future = Future;
//# sourceMappingURL=main.cjs.map