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

Function struct

packages/effect/src/internal/config.ts:567–585  ·  view source on GitHub ↗
(r: NER)

Source from the content-addressed store, hash-verified

565}
566
567const struct = <NER extends Record<string, Config.Config<any>>>(r: NER): Config.Config<
568 {
569 [K in keyof NER]: [NER[K]] extends [{ [ConfigTypeId]: { _A: (_: never) => infer A } }] ? A : never
570 }
571> => {
572 const entries = Object.entries(r)
573 let result = pipe(entries[0][1], map((value) => ({ [entries[0][0]]: value })))
574 if (entries.length === 1) {
575 return result as any
576 }
577 const rest = entries.slice(1)
578 for (const [key, config] of rest) {
579 result = pipe(
580 result,
581 zipWith(config, (record, value) => ({ ...record, [key]: value }))
582 )
583 }
584 return result as any
585}
586
587/** @internal */
588export const succeed = <A>(value: A): Config.Config<A> => {

Callers 2

allFunction · 0.70
unwrapFunction · 0.70

Calls 4

zipWithFunction · 0.85
entriesMethod · 0.80
pipeFunction · 0.70
mapFunction · 0.50

Tested by

no test coverage detected