From 42e2b8a65c55e5ed573c3a0dab961ea774b62496 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 9 Jul 2023 23:29:41 +0200 Subject: [PATCH] refactor: improve task functions type checking MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/worker/abstract-worker.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 7aa626f1..1c1ff3d7 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -123,6 +123,11 @@ export abstract class AbstractWorker< } else if (isPlainObject(taskFunctions)) { let firstEntry = true for (const [name, fn] of Object.entries(taskFunctions)) { + if (typeof name !== 'string') { + throw new TypeError( + 'A taskFunctions parameter object key is not a string' + ) + } if (typeof fn !== 'function') { throw new TypeError( 'A taskFunctions parameter object value is not a function' -- 2.34.1