MCPcopy Create free account
hub / github.com/Effect-TS/effect / allEither

Function allEither

packages/effect/src/internal/fiberRuntime.ts:1937–1973  ·  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

1935}
1936
1937const allEither = (
1938 effects: Iterable<Effect.Effect<any, any, any>>,
1939 reconcile: Option.Option<(as: ReadonlyArray<any>) => any>,
1940 options?: {
1941 readonly concurrency?: Concurrency | undefined
1942 readonly batching?: boolean | "inherit" | undefined
1943 readonly discard?: boolean | undefined
1944 readonly mode?: "default" | "validate" | "either" | undefined
1945 readonly concurrentFinalizers?: boolean | undefined
1946 }
1947) => {
1948 const eitherEffects: Array<Effect.Effect<Either.Either<unknown, unknown>, never, unknown>> = []
1949 for (const effect of effects) {
1950 eitherEffects.push(core.either(effect))
1951 }
1952
1953 if (options?.discard) {
1954 return forEach(eitherEffects, identity, {
1955 concurrency: options?.concurrency,
1956 batching: options?.batching,
1957 discard: true,
1958 concurrentFinalizers: options?.concurrentFinalizers
1959 })
1960 }
1961
1962 return core.map(
1963 forEach(eitherEffects, identity, {
1964 concurrency: options?.concurrency,
1965 batching: options?.batching,
1966 concurrentFinalizers: options?.concurrentFinalizers
1967 }),
1968 (eithers) =>
1969 reconcile._tag === "Some" ?
1970 reconcile.value(eithers) :
1971 eithers
1972 )
1973}
1974
1975/* @internal */
1976export 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