feat: add mapExecute() helper for bulk tasks execution
[poolifier.git] / src / pools / abstract-pool.ts
index 3b676faa7a4f28309743d38328ab0e35ab80818a..8dedf2052baa90603be809d488639f0e9cb256fd 100644 (file)
@@ -1225,6 +1225,18 @@ export abstract class AbstractPool<
     })
   }
 
+
+  /** @inheritDoc */
+  public mapExecute (
+    data: Iterable<Data>,
+    name?: string,
+    transferList?: readonly TransferListItem[]
+  ): Promise<Response[]> {
+    return Promise.all(
+      [...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