Files
hapi/cli/src/utils/future.ts
T
2025-12-16 15:03:50 +08:00

24 lines
501 B
TypeScript

export class Future<T> {
private _resolve!: (value: T) => void;
private _reject!: (reason?: any) => void;
private _promise: Promise<T>;
constructor() {
this._promise = new Promise((resolve, reject) => {
this._resolve = resolve;
this._reject = reject;
});
}
resolve(value: T) {
this._resolve(value);
}
reject(reason?: any) {
this._reject(reason);
}
get promise() {
return this._promise;
}
}