X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2Fabstract-worker.ts;h=93a36bad382fe5781f35d73b71a8169510b818ac;hb=8e5ca0401467b0a5c40b20a40ef08db6c05b9561;hp=7aa626f1610a3cd4f4e30ca23232b640a1eca410;hpb=5c4d16da7677746e563fdcfe7f82cbb842d1c9e6;p=poolifier.git diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 7aa626f1..93a36bad 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' @@ -266,7 +271,7 @@ export abstract class AbstractWorker< /** * Worker message listener. * - * @param message - Message received. + * @param message - The received message. */ protected messageListener (message: MessageValue): void { if (message.workerId === this.id) { @@ -298,7 +303,7 @@ export abstract class AbstractWorker< } /** - * Starts the worker alive check interval. + * Starts the worker aliveness check interval. */ private startCheckAlive (): void { this.lastTaskTimestamp = performance.now() @@ -310,7 +315,7 @@ export abstract class AbstractWorker< } /** - * Stops the worker alive check interval. + * Stops the worker aliveness check interval. */ private stopCheckAlive (): void { this.aliveInterval != null && clearInterval(this.aliveInterval) @@ -375,7 +380,7 @@ export abstract class AbstractWorker< } /** - * Runs the given function synchronously. + * Runs the given task function synchronously. * * @param fn - Task function that will be executed. * @param task - Input data for the task function. @@ -413,7 +418,7 @@ export abstract class AbstractWorker< } /** - * Runs the given function asynchronously. + * Runs the given task function asynchronously. * * @param fn - Task function that will be executed. * @param task - Input data for the task function.