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

Function encodeShared

packages/effect/src/ui/MessageLog.ts:1519–1538  ·  view source on GitHub ↗
(
    component: Component.Mountable.Any,
    shared: Component.SharedRecord | undefined
  )

Source from the content-addressed store, hash-verified

1517 }
1518 }
1519 const encodeShared = (
1520 component: Component.Mountable.Any,
1521 shared: Component.SharedRecord | undefined
1522 ): { readonly shared?: Schema.Json } => {
1523 if (shared === undefined) return {}
1524 const out: Record<string, Schema.Json> = {}
1525 for (const read of sharedReads.readsOf(component.definition)) {
1526 const value = shared[read.name]
1527 if (value === undefined) continue
1528 const schema = read.key.sharesSchema
1529 out[read.name] = schema === undefined
1530 ? structural(value)
1531 : encodeWith(
1532 schema,
1533 `${read.key.name}.shares`,
1534 value
1535 ) as Schema.Json
1536 }
1537 return { shared: cap(out) }
1538 }
1539 const encodeCollected = (
1540 component: Component.Mountable.Any,
1541 collected: ReadonlyArray<unknown> | undefined

Callers 1

encodeFunction · 0.85

Calls 3

structuralFunction · 0.85
encodeWithFunction · 0.85
capFunction · 0.85

Tested by

no test coverage detected