From: Jérôme Benoit Date: Sun, 9 Jul 2023 21:29:41 +0000 (+0200) Subject: refactor: improve task functions type checking X-Git-Tag: v2.6.13~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=42e2b8a65c55e5ed573c3a0dab961ea774b62496;p=poolifier.git refactor: improve task functions type checking Signed-off-by: Jérôme Benoit --- 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'