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

Function all

packages/effect/src/Config.ts:434–464  ·  view source on GitHub ↗
(
  arg: Arg
)

Source from the content-addressed store, hash-verified

432 * @since 2.0.0
433 */
434export function all<const Arg extends Iterable<Config<any>> | Record<PropertyKey, Config<any>>>(
435 arg: Arg
436): Config<
437 [Arg] extends [ReadonlyArray<Config<any>>] ? {
438 -readonly [K in keyof Arg]: [Arg[K]] extends [Config<infer A>] ? A : never
439 }
440 : [Arg] extends [Iterable<Config<infer A>>] ? Array<A>
441 : [Arg] extends [Record<PropertyKey, Config<any>>] ? {
442 -readonly [K in keyof Arg]: [Arg[K]] extends [Config<infer A>] ? A : never
443 }
444 : never
445> {
446 const configs: Array<Config<any>> | Record<PropertyKey, Config<any>> = globalThis.Array.isArray(arg)
447 ? arg
448 : Symbol.iterator in arg
449 ? [...arg as any]
450 : arg
451 return make<any>((provider, pathPrefix) =>
452 globalThis.Array.isArray(configs)
453 ? Effect.mapEager(
454 Effect.all(configs.map((config) => evaluateAt(config, provider, pathPrefix))),
455 Result.all
456 )
457 : Effect.mapEager(
458 Effect.all(Object.fromEntries(
459 InternalRecord.ownEnumerableKeys(configs).map((key) => [key, evaluateAt(configs[key], provider, pathPrefix)])
460 )),
461 Result.all
462 )
463 ) as any
464}
465
466/**
467 * Provides a fallback value when the config is absent.

Callers 1

unwrapFunction · 0.70

Calls 4

evaluateAtFunction · 0.85
makeFunction · 0.70
allMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected