]> zoso.dev Git - libnemo.git/commitdiff
Improve environment detection.
authorChris Duncan <chris@zoso.dev>
Wed, 4 Dec 2024 07:23:25 +0000 (23:23 -0800)
committerChris Duncan <chris@zoso.dev>
Wed, 4 Dec 2024 07:23:25 +0000 (23:23 -0800)
src/lib/pool.ts

index 6360beeb2edb467fdf972f931a7e6ccaef7c0b25..4c4830028754ce38cc94635f3ec527e322c7db5f 100644 (file)
@@ -1,7 +1,10 @@
 // SPDX-FileCopyrightText: 2024 Chris Duncan <chris@zoso.dev>
 // 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