build(deps-dev): apply updates
[poolifier.git] / src / worker / abstract-worker.ts
index 5fcc3419b2c1acc8d9ea39ca556c199a9ff44ea9..dfcadf280f689c01cdb4fb9cb583d8138fe19135 100644 (file)
@@ -79,20 +79,17 @@ export abstract class AbstractWorker<
   /**
    * Constructs a new poolifier worker.
    *
-   * @param type - The type of async event.
    * @param isMain - Whether this is the main worker or not.
    * @param mainWorker - Reference to main worker.
    * @param taskFunctions - Task function(s) processed by the worker when the pool's `execution` function is invoked. The first function is the default function.
    * @param opts - Options for the worker.
    */
   public constructor (
-    type: string,
     protected readonly isMain: boolean,
     private readonly mainWorker: MainWorker,
     taskFunctions: TaskFunction<Data, Response> | TaskFunctions<Data, Response>,
     protected opts: WorkerOptions = DEFAULT_WORKER_OPTIONS
   ) {
-    // super(type)
     if (this.isMain == null) {
       throw new Error('isMain parameter is mandatory')
     }
@@ -484,7 +481,7 @@ export abstract class AbstractWorker<
    *
    * @param task - The task to execute.
    */
-  protected run (task: Task<Data>): void {
+  protected readonly run = (task: Task<Data>): void => {
     const { name, taskId, data } = task
     const taskFunctionName = name ?? DEFAULT_TASK_NAME
     if (!this.taskFunctions.has(taskFunctionName)) {
@@ -512,10 +509,10 @@ export abstract class AbstractWorker<
    * @param fn - Task function that will be executed.
    * @param task - Input data for the task function.
    */
-  protected runSync (
+  protected readonly runSync = (
     fn: TaskSyncFunction<Data, Response>,
     task: Task<Data>
-  ): void {
+  ): void => {
     const { name, taskId, data } = task
     try {
       let taskPerformance = this.beginTaskPerformance(name)
@@ -546,10 +543,10 @@ export abstract class AbstractWorker<
    * @param fn - Task function that will be executed.
    * @param task - Input data for the task function.
    */
-  protected runAsync (
+  protected readonly runAsync = (
     fn: TaskAsyncFunction<Data, Response>,
     task: Task<Data>
-  ): void {
+  ): void => {
     const { name, taskId, data } = task
     let taskPerformance = this.beginTaskPerformance(name)
     fn(data)