]> git.codecow.com Git - libnemo.git/commitdiff
Eliminate redundant assignment function.
authorChris Duncan <chris@zoso.dev>
Tue, 9 Sep 2025 04:00:39 +0000 (21:00 -0700)
committerChris Duncan <chris@zoso.dev>
Tue, 9 Sep 2025 04:00:39 +0000 (21:00 -0700)
src/lib/vault/index.ts

index ca5487b8bd7e0be64edfcb9f6fed22e7dc6e4352..646fad6e75aa52c6dc9c37118d08328b0bf3d2a8 100644 (file)
@@ -46,24 +46,10 @@ export class Vault {
                Vault.#instances.push(this)
        }
 
-       prioritize<T extends Data> (data: NamedData): Promise<NamedData<T>> {
-               return this.#assign<T>(data, task => this.#queue.unshift(task))
-       }
-
        request<T extends Data> (data: NamedData): Promise<NamedData<T>> {
-               return this.#assign<T>(data, task => this.#queue.push(task))
-       }
-
-       terminate (): void {
-               this.#job = undefined
-               this.#worker.terminate()
-               this.#isTerminated = true
-       }
-
-       #assign<T extends Data> (data: NamedData, enqueue: (task: Task) => number): Promise<NamedData<T>> {
                return new Promise((resolve, reject): void => {
                        if (this.#isTerminated) {
-                               reject('Worker terminated')
+                               return reject('Worker terminated')
                        }
                        const task: Task = {
                                id: performance.now(),
@@ -71,11 +57,17 @@ export class Vault {
                                resolve,
                                reject
                        }
-                       enqueue(task)
+                       this.#queue.push(task)
                        if (this.#isIdle) this.#process()
                })
        }
 
+       terminate (): void {
+               this.#job = undefined
+               this.#worker.terminate()
+               this.#isTerminated = true
+       }
+
        #process = (): void => {
                this.#job = this.#queue.shift()
                this.#isIdle = this.#job == null