TS-Scribe - v1.2.0
    Preparing search index...

    Function asyncForEachSettled

    • Asynchronously iterates over an array, collecting errors without throwing. Unlike asyncForEach, this function never throws due to callback errors — all items are processed and errors are collected in the returned errors array.

      Use this when you want all items processed regardless of individual failures.

      Type Parameters

      • T

        The type of elements in the input array

      Parameters

      • array: T[]

        The array of elements to iterate over.

      • callback: (element: T, index: number, array: T[]) => Promise<void>

        The asynchronous callback function.

      • Optionaloptions: { concurrency?: number; signal?: AbortSignal } = {}

        Optional configuration

        • Optionalconcurrency?: number

          Maximum number of concurrent operations

        • Optionalsignal?: AbortSignal

          AbortSignal to cancel processing.

      Returns Promise<AsyncForEachSettledResult>

      Promise resolving to an object with collected errors.

      If concurrency is not a positive integer.

      If the input array is null or undefined.

      If the signal is aborted.

      const { errors } = await asyncForEachSettled(items, processItem);
      if (errors.length > 0) {
      console.error('Some items failed:', errors);
      }