test: add test for worker task function object
[poolifier.git] / src / pools / utils.ts
index 6a6c1fa9d3aa9d14946d760e09301ad878ce901a..36bd8939fdf82155c208d966d502d3098f11ffe3 100644 (file)
@@ -87,6 +87,19 @@ export const checkDynamicPoolSize = (
   }
 }
 
+export const checkValidPriority = (priority: number | undefined): void => {
+  if (priority != null && !Number.isSafeInteger(priority)) {
+    throw new TypeError(`Invalid priority '${priority}'`)
+  }
+  if (
+    priority != null &&
+    Number.isSafeInteger(priority) &&
+    (priority < -20 || priority > 19)
+  ) {
+    throw new RangeError('Property priority must be between -20 and 19')
+  }
+}
+
 export const checkValidWorkerChoiceStrategy = (
   workerChoiceStrategy: WorkerChoiceStrategy | undefined
 ): void => {