plainfp - v0.1.0
    Preparing search index...

    Function allWithConcurrency

    • Run an array of async factories with bounded concurrency. Factories are invoked lazily so only up to concurrency run at once. Short-circuits on the first err — in-flight factories finish but no new ones start.

      Factories must return a ResultAsync. If one rejects (rather than resolving to err), the rejection propagates and the overall promise rejects — wrap throwing code with fromPromise/fromAsync so failures become typed err values.

      Type Parameters

      • T
      • E

      Parameters

      Returns ResultAsyncType<T[], E>

      RangeError if concurrency < 1.

      const factories = userIds.map(id =>
      () => fromPromise(fetchUser(id), e => ({ code: "LOAD", cause: e })),
      )
      const users = await allWithConcurrency(factories, 5)