X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2Futils.ts;h=d0883893581b0a14c24cb415bef585541b71c446;hb=910416386b4f7d0da4e6f0d8551cefa2539c5ced;hp=486d92e77a73e8f3ac003b655b34e1a4b4615574;hpb=31847469b406e46688d8aafb880e250706dd8aee;p=poolifier.git diff --git a/src/worker/utils.ts b/src/worker/utils.ts index 486d92e7..d0883893 100644 --- a/src/worker/utils.ts +++ b/src/worker/utils.ts @@ -1,4 +1,7 @@ -import { checkValidWorkerChoiceStrategy } from '../pools/utils.js' +import { + checkValidPriority, + checkValidWorkerChoiceStrategy +} from '../pools/utils.js' import { isPlainObject } from '../utils.js' import type { TaskFunctionObject } from './task-functions.js' import { KillBehaviors, type WorkerOptions } from './worker-options.js' @@ -33,10 +36,13 @@ export const checkValidWorkerOptions = ( } } -export const checkValidTaskFunctionEntry = ( - name: string, - fnObj: TaskFunctionObject -): void => { +export const checkValidTaskFunctionObjectEntry = < + Data = unknown, + Response = unknown +>( + name: string, + fnObj: TaskFunctionObject + ): void => { if (typeof name !== 'string') { throw new TypeError('A taskFunctions parameter object key is not a string') } @@ -51,11 +57,7 @@ export const checkValidTaskFunctionEntry = ( `taskFunction object 'taskFunction' property '${fnObj.taskFunction}' is not a function` ) } - if (fnObj.priority != null && !Number.isSafeInteger(fnObj.priority)) { - throw new TypeError( - `taskFunction object 'priority' property '${fnObj.priority}' is not an integer` - ) - } + checkValidPriority(fnObj.priority) checkValidWorkerChoiceStrategy(fnObj.strategy) }