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

Function struct

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

Source from the content-addressed store, hash-verified

552}
553
554const struct = <NER extends Record<string, Config.Config<any>>>(r: NER): Config.Config<
555 {
556 [K in keyof NER]: [NER[K]] extends [{ [ConfigTypeId]: { _A: (_: never) => infer A } }] ? A : never
557 }
558> => {
559 const entries = Object.entries(r)
560 let result = pipe(entries[0][1], map((value) => ({ [entries[0][0]]: value })))
561 if (entries.length === 1) {
562 return result as any
563 }
564 const rest = entries.slice(1)
565 for (const [key, config] of rest) {
566 result = pipe(
567 result,
568 zipWith(config, (record, value) => ({ ...record, [key]: value }))
569 )
570 }
571 return result as any
572}
573
574/** @internal */
575export 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…