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

Function all

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

Source from the content-addressed store, hash-verified

398 * @since 2.0.0
399 */
400export function all<const Arg extends Iterable<Config<any>> | Record<string, Config<any>>>(
401 arg: Arg
402): Config<
403 [Arg] extends [ReadonlyArray<Config<any>>] ? {
404 -readonly [K in keyof Arg]: [Arg[K]] extends [Config<infer A>] ? A : never
405 }
406 : [Arg] extends [Iterable<Config<infer A>>] ? Array<A>
407 : [Arg] extends [Record<string, Config<any>>] ? {
408 -readonly [K in keyof Arg]: [Arg[K]] extends [Config<infer A>] ? A : never
409 }
410 : never
411> {
412 const configs: Array<Config<any>> | Record<string, Config<any>> = Array.isArray(arg)
413 ? arg
414 : Symbol.iterator in arg
415 ? [...arg as any]
416 : arg
417 if (Array.isArray(configs)) {
418 return make((provider, pathPrefix) =>
419 Effect.flatMapEager(
420 Effect.all(configs.map((config) => Effect.result(evaluateAt(config, provider, pathPrefix)))),
421 resolveArray
422 )
423 ) as any
424 } else {
425 return make((provider, pathPrefix) =>
426 Effect.flatMapEager(
427 Effect.all(Rec.map(configs, (config) => Effect.result(evaluateAt(config, provider, pathPrefix)))),
428 resolveRecord
429 )
430 ) as any
431 }
432}
433
434const resolveArray = (
435 results: ReadonlyArray<Result.Result<Resolution<any>, EvaluationFailure>>

Callers 1

unwrapFunction · 0.70

Calls 5

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

Tested by

no test coverage detected