From: Chris Duncan Date: Wed, 4 Dec 2024 07:23:25 +0000 (-0800) Subject: Improve environment detection. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=a6eb04d554f6319138f3f510b5cc9d9418c8e4d0;p=libnemo.git Improve environment detection. --- diff --git a/src/lib/pool.ts b/src/lib/pool.ts index 6360bee..4c48300 100644 --- a/src/lib/pool.ts +++ b/src/lib/pool.ts @@ -1,7 +1,10 @@ // SPDX-FileCopyrightText: 2024 Chris Duncan // SPDX-License-Identifier: GPL-3.0-or-later -if (globalThis.Worker == null) { +/** +* Polyfill for window methods which do not exist when executing Node.js tests. +*/ +if (typeof window === 'undefined' && typeof self === 'undefined') { const { Worker } = await import('node:worker_threads') //@ts-expect-error Worker.prototype.addEventListener = Worker.prototype.addListener