From 2e7a4a62e6c2723bca04e2a9b58d5d74f6c00f5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ramirez=20Vargas=2C=20Jos=C3=A9=20Pablo?= Date: Fri, 19 Sep 2025 18:32:08 -0600 Subject: [PATCH] fix(node): Use prototype name to check for the Worker class to allow other Worker implementations - This was done specifically for the `web-worker` NPM package but should work for others that polyfill. --- src/workers/AsyncWorker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workers/AsyncWorker.ts b/src/workers/AsyncWorker.ts index 332efa4..f88b965 100644 --- a/src/workers/AsyncWorker.ts +++ b/src/workers/AsyncWorker.ts @@ -55,7 +55,7 @@ export class AsyncWorker any>> #taskRunning; #enqueue; constructor(worker: Worker | SharedWorker, tasks: Tasks) { - this.#iWorker = worker instanceof Worker ? new InternalWorker(worker) : new InternalSharedWorker(worker); + this.#iWorker = Object.getPrototypeOf(worker).name === 'Worker' ? new InternalWorker(worker as Worker) : new InternalSharedWorker(worker as SharedWorker); this.#queue = new Queue(); this.#taskRunning = false; this.#enqueue = Object.keys(tasks).reduce((prev, curr) => {