X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Futils.ts;h=dd839bc491b622aa871b876424474d24abdfb44e;hb=2ac6677fd9d31c7132d88980a5f3b239d6949716;hp=c568a29a049eda2de26cf9bd99d63e613294bc3f;hpb=5bbdaeff9b95f2ecb177394f869e9d0715e38e9e;p=poolifier.git
diff --git a/src/utils.ts b/src/utils.ts
index c568a29a..dd839bc4 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -1,6 +1,8 @@
import { getRandomValues } from 'node:crypto'
import * as os from 'node:os'
+import type { TaskFunctionProperties } from './utility-types.js'
+import type { TaskFunctionObject } from './worker/task-functions.js'
import type { KillBehavior } from './worker/worker-options.js'
/**
@@ -205,7 +207,7 @@ export const max = (...args: number[]): number =>
* @internal
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export const once = (
+export const once = >(
fn: (...args: A) => R,
context: C
): ((...args: A) => R) => {
@@ -220,3 +222,18 @@ export const once = (
return result
}
}
+
+export const buildTaskFunctionProperties = (
+ name: string,
+ taskFunctionObject: TaskFunctionObject | undefined
+): TaskFunctionProperties => {
+ return {
+ name,
+ ...(taskFunctionObject?.priority != null && {
+ priority: taskFunctionObject.priority
+ }),
+ ...(taskFunctionObject?.strategy != null && {
+ strategy: taskFunctionObject.strategy
+ })
+ }
+}