From a3b95da5a63e0bc278579ea68f3019850b3271ce Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Tue, 3 Dec 2024 12:17:05 -0800 Subject: [PATCH] Add function return typings and variable typings. --- src/lib/pool.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lib/pool.ts b/src/lib/pool.ts index dad96c6..76daf0f 100644 --- a/src/lib/pool.ts +++ b/src/lib/pool.ts @@ -21,11 +21,11 @@ export class Pool { #approach: 'converge' | 'divide' = 'divide' #cores: number = Math.max(1, navigator.hardwareConcurrency ?? 1 - 1) #queue: object[] = [] - #resolve: Function = (value: unknown) => { } + #resolve: Function = (value: unknown): void => { } #results: object[] = [] #threads: Thread[] = [] - get isDone () { + get isDone (): boolean { for (const thread of this.#threads) { if (thread.isBusy) { return false @@ -51,7 +51,7 @@ export class Pool { } } - #assign (thread: Thread, next: any[]) { + #assign (thread: Thread, next: any[]): void { if (next.length > 0) { thread.isBusy = true const buf = new TextEncoder().encode(JSON.stringify(next)).buffer @@ -59,8 +59,7 @@ export class Pool { } } - #report (thread: Thread, result: any[]) { - this.#results.push(...result) + #report (thread: Thread, result: any[]): void { thread.isBusy = false if (this.#approach === 'converge') { this.#stop() @@ -70,7 +69,7 @@ export class Pool { } } - #stop () { + #stop (): void { for (const thread of this.#threads) { const msg = ['stop'] const buf = new TextEncoder().encode(JSON.stringify(msg)).buffer -- 2.34.1