+ protected handleTaskFunctionOperationMessage (
+ message: MessageValue<Data>
+ ): void {
+ const { taskFunctionOperation, taskFunction, taskFunctionName } = message
+ let response!: TaskFunctionOperationReturnType
+ if (taskFunctionOperation === 'add') {
+ response = this.addTaskFunction(
+ taskFunctionName as string,
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
+ new Function(`return ${taskFunction as string}`)() as TaskFunction<
+ Data,
+ Response
+ >
+ )
+ } else if (taskFunctionOperation === 'remove') {
+ response = this.removeTaskFunction(taskFunctionName as string)
+ } else if (taskFunctionOperation === 'default') {
+ response = this.setDefaultTaskFunction(taskFunctionName as string)
+ }
+ this.sendToMainWorker({
+ taskFunctionOperation,
+ taskFunctionOperationStatus: response.status,
+ workerError: {
+ name: taskFunctionName as string,
+ message: this.handleError(response.error as Error | string)
+ }
+ })
+ }
+