MCPcopy
hub / github.com/Effect-TS/effect / ReadonlyMapFromRecord

Function ReadonlyMapFromRecord

packages/effect/src/Schema.ts:7733–7747  ·  view source on GitHub ↗
({ key, value }: {
  key: Schema<KA, string, KR>
  value: Schema<VA, VI, VR>
})

Source from the content-addressed store, hash-verified

7731 * @since 3.10.0
7732 */
7733export const ReadonlyMapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
7734 key: Schema<KA, string, KR>
7735 value: Schema<VA, VI, VR>
7736}): SchemaClass<ReadonlyMap<KA, VA>, { readonly [x: string]: VI }, KR | VR> =>
7737 transform(
7738 Record({ key: encodedBoundSchema(key), value }).annotations({
7739 description: "a record to be decoded into a ReadonlyMap"
7740 }),
7741 ReadonlyMapFromSelf({ key, value: typeSchema(value) }),
7742 {
7743 strict: true,
7744 decode: (i) => new Map(Object.entries(i)),
7745 encode: (a) => Object.fromEntries(a)
7746 }
7747 )
7748
7749/**
7750 * @category Map transformations

Callers

nothing calls this directly

Calls 7

RecordFunction · 0.85
encodedBoundSchemaFunction · 0.85
typeSchemaFunction · 0.85
entriesMethod · 0.80
transformInterface · 0.70
ReadonlyMapFromSelfFunction · 0.70
annotationsMethod · 0.65

Tested by

no test coverage detected