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'
/**
* @internal
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export const once = <A extends any[], R, C>(
+export const once = <A extends any[], R, C extends ThisType<any>>(
fn: (...args: A) => R,
context: C
): ((...args: A) => R) => {
return result
}
}
+
+export const buildTaskFunctionProperties = <Data, Response>(
+ name: string,
+ taskFunctionObject: TaskFunctionObject<Data, Response> | undefined
+): TaskFunctionProperties => {
+ return {
+ name,
+ ...(taskFunctionObject?.priority != null && {
+ priority: taskFunctionObject.priority
+ }),
+ ...(taskFunctionObject?.strategy != null && {
+ strategy: taskFunctionObject.strategy
+ })
+ }
+}