)
}
const boundFn = fn.bind(this)
- this.taskFunctions.set(name, boundFn)
if (firstEntry) {
this.taskFunctions.set(DEFAULT_TASK_NAME, boundFn)
firstEntry = false
}
+ this.taskFunctions.set(name, boundFn)
}
if (firstEntry) {
throw new Error('taskFunctions parameter object is empty')
if (typeof fn !== 'function') {
throw new TypeError('fn parameter is not a function')
}
- const boundFn = fn.bind(this)
try {
+ const boundFn = fn.bind(this)
if (
this.taskFunctions.get(name) ===
this.taskFunctions.get(DEFAULT_TASK_NAME)
}
/**
- * Sets the default task function to use when no task function name is specified.
+ * Lists the names of the worker's task functions.
+ *
+ * @returns The names of the worker's task functions.
+ */
+ public listTaskFunctions (): string[] {
+ return Array.from(this.taskFunctions.keys())
+ }
+
+ /**
+ * Sets the default task function to use in the worker.
*
* @param name - The name of the task function to use as default task function.
* @returns Whether the default task function was set or not.