import type {
TaskAsyncFunction,
TaskFunction,
+ TaskFunctionOperationReturnType,
TaskFunctions,
TaskSyncFunction
} from './task-functions'
-interface TaskFunctionOperationReturnType {
- status: boolean
- error?: Error
-}
-
const DEFAULT_MAX_INACTIVE_TIME = 60000
const DEFAULT_WORKER_OPTIONS: WorkerOptions = {
/**
this.taskFunctions.set(DEFAULT_TASK_NAME, boundFn)
}
this.taskFunctions.set(name, boundFn)
- this.sendTaskFunctionsListToMainWorker()
+ this.sendTaskFunctionNamesToMainWorker()
return { status: true }
} catch (error) {
return { status: false, error: error as Error }
)
}
const deleteStatus = this.taskFunctions.delete(name)
- this.sendTaskFunctionsListToMainWorker()
+ this.sendTaskFunctionNamesToMainWorker()
return { status: deleteStatus }
} catch (error) {
return { status: false, error: error as Error }
): void {
const { taskFunctionOperation, taskFunction, taskFunctionName } = message
let response!: TaskFunctionOperationReturnType
- if (taskFunctionOperation === 'has') {
- response = this.hasTaskFunction(taskFunctionName as string)
- } else if (taskFunctionOperation === 'add') {
+ if (taskFunctionOperation === 'add') {
response = this.addTaskFunction(
taskFunctionName as string,
// eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
): void
/**
- * Sends the list of task function names to the main worker.
+ * Sends task function names to the main worker.
*/
- protected sendTaskFunctionsListToMainWorker (): void {
+ protected sendTaskFunctionNamesToMainWorker (): void {
this.sendToMainWorker({
taskFunctionNames: this.listTaskFunctionNames(),
workerId: this.id