build(ci): refine autofix GH action
[poolifier.git] / src / worker / utils.ts
index 486d92e77a73e8f3ac003b655b34e1a4b4615574..59a0289b79e78e9a9020257b872aca0c95486999 100644 (file)
@@ -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 = <Data = unknown, Response = unknown>(
-  name: string,
-  fnObj: TaskFunctionObject<Data, Response>
-): void => {
+export const checkValidTaskFunctionObjectEntry = <
+  Data = unknown,
+  Response = unknown
+>(
+    name: string,
+    fnObj: TaskFunctionObject<Data, Response>
+  ): void => {
   if (typeof name !== 'string') {
     throw new TypeError('A taskFunctions parameter object key is not a string')
   }
@@ -51,11 +57,7 @@ export const checkValidTaskFunctionEntry = <Data = unknown, Response = unknown>(
       `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)
 }