MCPcopy Index your code
hub / github.com/Effect-TS/effect / allEither

Function allEither

packages/effect/src/internal/fiberRuntime.ts:1927–1963  ·  view source on GitHub ↗
(
  effects: Iterable<Effect.Effect<any, any, any>>,
  reconcile: Option.Option<(as: ReadonlyArray<any>) => any>,
  options?: {
    readonly concurrency?: Concurrency | undefined
    readonly batching?: boolean | "inherit" | undefined
    readonly discard?: boolean | undefined
    readonly mode?: "default" | "validate" | "either" | undefined
    readonly concurrentFinalizers?: boolean | undefined
  }
)

Source from the content-addressed store, hash-verified

1925}
1926
1927const allEither = (
1928 effects: Iterable<Effect.Effect<any, any, any>>,
1929 reconcile: Option.Option<(as: ReadonlyArray<any>) => any>,
1930 options?: {
1931 readonly concurrency?: Concurrency | undefined
1932 readonly batching?: boolean | "inherit" | undefined
1933 readonly discard?: boolean | undefined
1934 readonly mode?: "default" | "validate" | "either" | undefined
1935 readonly concurrentFinalizers?: boolean | undefined
1936 }
1937) => {
1938 const eitherEffects: Array<Effect.Effect<Either.Either<unknown, unknown>, never, unknown>> = []
1939 for (const effect of effects) {
1940 eitherEffects.push(core.either(effect))
1941 }
1942
1943 if (options?.discard) {
1944 return forEach(eitherEffects, identity, {
1945 concurrency: options?.concurrency,
1946 batching: options?.batching,
1947 discard: true,
1948 concurrentFinalizers: options?.concurrentFinalizers
1949 })
1950 }
1951
1952 return core.map(
1953 forEach(eitherEffects, identity, {
1954 concurrency: options?.concurrency,
1955 batching: options?.batching,
1956 concurrentFinalizers: options?.concurrentFinalizers
1957 }),
1958 (eithers) =>
1959 reconcile._tag === "Some" ?
1960 reconcile.value(eithers) :
1961 eithers
1962 )
1963}
1964
1965/* @internal */
1966export const all = <

Callers 1

allFunction · 0.85

Calls 4

eitherMethod · 0.80
forEachFunction · 0.70
mapMethod · 0.65
valueMethod · 0.45

Tested by

no test coverage detected