From f6a156c13b981b2de2096b3a1ec21c17e321cabc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Haz=20=C3=86=2041?= <4405263+hazae41@users.noreply.github.com> Date: Sat, 4 Mar 2023 11:39:21 +0100 Subject: [PATCH] clean --- src/mods/future/future.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) 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! + } + }