docs: refine changelog entry
[poolifier.git] / src / worker / abstract-worker.ts
index 1b8a673c2a78d461288bc6c4f30fa8eb5a942285..8a6b2104317a7a229dbca9943497b21e5e26f66f 100644 (file)
@@ -142,11 +142,11 @@ export abstract class AbstractWorker<
           )
         }
         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')
@@ -242,7 +242,16 @@ export abstract class AbstractWorker<
   }
 
   /**
-   * 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.
@@ -317,7 +326,7 @@ export abstract class AbstractWorker<
     this.activeInterval = setInterval(
       this.checkActive.bind(this),
       (this.opts.maxInactiveTime ?? DEFAULT_MAX_INACTIVE_TIME) / 2
-    )
+    ).unref()
   }
 
   /**