diff --git a/src/mods/future/future.ts b/src/mods/future/future.ts index e40d6fb..c8397b1 100644 --- a/src/mods/future/future.ts +++ b/src/mods/future/future.ts @@ -1,7 +1,7 @@ export class Future { - readonly resolve: (value: T) => void - readonly reject: (error: unknown) => void + #resolve?: (value: T) => void + #reject?: (error: unknown) => void readonly promise: Promise @@ -9,15 +9,18 @@ export class Future { * Just like a Promise but you can manually resolve or reject it */ constructor() { - let resolve: (value: T) => void - let reject: (error: unknown) => void - this.promise = new Promise((subresolve, subreject) => { - resolve = subresolve - reject = subreject + this.#resolve = subresolve + this.#reject = subreject }) + } - this.resolve = resolve! - this.reject = reject! + get resolve() { + return this.#resolve! } + + get reject() { + return this.#reject! + } + }