refactor: silence linter
[poolifier.git] / src / pools / abstract-pool.ts
index 3b676faa7a4f28309743d38328ab0e35ab80818a..712de0b7da4c38c2808e1be61da7fced8e372da0 100644 (file)
@@ -588,7 +588,8 @@ export abstract class AbstractPool<
   }
 
   /**
-   * The pool readiness boolean status.
+   * Whether the pool is ready or not.
+   * @returns The pool readiness boolean status.
    */
   private get ready (): boolean {
     if (this.empty) {
@@ -606,7 +607,8 @@ export abstract class AbstractPool<
   }
 
   /**
-   * The pool emptiness boolean status.
+   * Whether the pool is empty or not.
+   * @returns The pool emptiness boolean status.
    */
   protected get empty (): boolean {
     return this.minimumNumberOfWorkers === 0 && this.workerNodes.length === 0
@@ -820,8 +822,7 @@ export abstract class AbstractPool<
 
   /**
    * Whether the pool is full or not.
-   *
-   * The pool filling boolean status.
+   * @returns The pool fullness boolean status.
    */
   protected get full (): boolean {
     return (
@@ -832,8 +833,7 @@ export abstract class AbstractPool<
 
   /**
    * Whether the pool is busy or not.
-   *
-   * The pool busyness boolean status.
+   * @returns The pool busyness boolean status.
    */
   protected abstract get busy (): boolean
 
@@ -1225,11 +1225,36 @@ export abstract class AbstractPool<
     })
   }
 
+
+  /** @inheritDoc */
+  public mapExecute (
+    data: Iterable<Data>,
+    name?: string,
+    transferList?: readonly TransferListItem[]
+  ): Promise<Response[]> {
+    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+    if (data == null) {
+      throw new TypeError('data argument must be a defined iterable')
+    }
+    if (typeof data[Symbol.iterator] !== 'function') {
+      throw new TypeError('data argument must be an iterable')
+    }
+    if (!Array.isArray(data)) {
+      data = [...data]
+    }
+    return Promise.all(
+      (data as Data[]).map(data => this.execute(data, name, transferList))
+    )
+  }
+
   /**
    * Starts the minimum number of workers.
    * @param initWorkerNodeUsage - Whether to initialize the worker node usage or not. @defaultValue false
    */
   private startMinimumNumberOfWorkers (initWorkerNodeUsage = false): void {
+    if (this.minimumNumberOfWorkers === 0) {
+      return
+    }
     this.startingMinimumNumberOfWorkers = true
     while (
       this.workerNodes.reduce(