mini-effect
    Preparing search index...

    Function any

    • Runs all effects in parallel and resolves with the first successful result.

      Type Parameters

      • const E extends Effect<any, any, any, any>[]

        A tuple of Effect types

      Parameters

      • values: E

        An array of effects to run in parallel

      Returns Effect<
          inferReturn<E[number]>,
          inferError<E[number]>,
          inferDependency<E[number]>,
          inferProvides<E[number]>,
      >

      An Effect that resolves with the first success value

      Behaves like Promise.any — all effects start concurrently and the returned effect resolves as soon as any effect succeeds. The remaining effects are aborted. If all effects fail, the error is an AggregateError containing every rejection reason.

      import { fn, fail, succeed, run } from "mini-effect";
      import { any } from "mini-effect/concurrency";

      const result = await run(any([fail("a"), succeed(42), fail("c")]));
      // => 42