- } else if (taskFunctionOperation === 'remove') {
- response = this.removeTaskFunction(taskFunctionName as string)
- } else if (taskFunctionOperation === 'default') {
- response = this.setDefaultTaskFunction(taskFunctionName as string)
+ }
+ let response: TaskFunctionOperationResult
+ switch (taskFunctionOperation) {
+ case 'add':
+ response = this.addTaskFunction(
+ taskFunctionName,
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
+ new Function(`return ${taskFunction}`)() as TaskFunction<
+ Data,
+ Response
+ >
+ )
+ break
+ case 'remove':
+ response = this.removeTaskFunction(taskFunctionName)
+ break
+ case 'default':
+ response = this.setDefaultTaskFunction(taskFunctionName)
+ break
+ default:
+ response = { status: false, error: new Error('Unknown task operation') }
+ break