@creejs/commons-lang 2.1.26 → 2.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2052,9 +2052,10 @@
2052
2052
  * * One task failed, it will start next task immediately, Not Wait for the bulk(maxParallel) to complete
2053
2053
  * @param {Array<Function|Promise<any>>} tasks - Array of async functions to execute
2054
2054
  * @param {number} [maxParallel=5] - Maximum number of tasks to run in parallel
2055
+ * @param {string} [failureMessage] - Error message when all tasks failed
2055
2056
  * @returns {Promise<any>} Resolves with the result of the first successfully completed task
2056
2057
  */
2057
- async function parallelAny (tasks, maxParallel = 5) {
2058
+ async function parallelAny (tasks, maxParallel = 5, failureMessage) {
2058
2059
  assertArray(tasks, 'tasks');
2059
2060
  assertNumber(maxParallel);
2060
2061
  if (tasks.length === 0) {
@@ -2099,7 +2100,7 @@
2099
2100
  // No task left, and No successful execution, reject with errors
2100
2101
  if (errors.length >= tasks.length) {
2101
2102
  if (deferred.pending) {
2102
- deferred.reject(new AggregatedError('All Tasks Failed', errors));
2103
+ deferred.reject(new AggregatedError(failureMessage ?? 'All Tasks Failed', errors));
2103
2104
  return
2104
2105
  }
2105
2106
  }