@hazae41/future
Version:
Just like a Promise but you can manually resolve or reject it
37 lines (35 loc) • 860 B
JavaScript
class Future {
promise;
/**
* Just a Promise with a resolve and reject function
*/
constructor(promise) {
if (promise == null) {
const { promise, resolve, reject } = Promise.withResolvers();
this.promise = promise;
this.
this.
}
else {
this.promise = promise;
this.
this.
}
}
static resolve(value) {
return new Future(Promise.resolve(value));
}
static reject(reason) {
return new Future(Promise.reject(reason));
}
get resolve() {
return this.
}
get reject() {
return this.
}
}
export { Future };
//# sourceMappingURL=future.mjs.map