From 2390972ffc744259f08492ded784927ca5a4c283 Mon Sep 17 00:00:00 2001 From: Techbot121 Date: Sat, 4 Jan 2025 17:47:05 +0100 Subject: [PATCH] better variable naming --- app/Container.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/Container.ts b/app/Container.ts index 7990ee9..9d0dd96 100644 --- a/app/Container.ts +++ b/app/Container.ts @@ -35,35 +35,35 @@ export class Container { } } - async getService( - type: Name, + async getService( + service: ServiceName, timeoutMs = 30000 - ): Promise { - if (this.services[type]) { - return this.services[type]; + ): Promise { + if (this.services[service]) { + return this.services[service]; } // Create or return existing promise for this service - if (!this.pendingServices.has(type)) { + if (!this.pendingServices.has(service)) { this.pendingServices.set( - type, + service, new Promise((resolve, reject) => { const timeoutId = setTimeout(() => { - this.pendingServices.delete(type); - reject(new Error(`Timeout waiting for service: ${type}`)); + this.pendingServices.delete(service); + reject(new Error(`Timeout waiting for service: ${service}`)); }, timeoutMs); const checkInterval = setInterval(() => { - if (this.services[type]) { + if (this.services[service]) { clearTimeout(timeoutId); clearInterval(checkInterval); - resolve(this.services[type]); + resolve(this.services[service]); } }, 100); }) ); } - return this.pendingServices.get(type) as Promise; + return this.pendingServices.get(service) as Promise; } }