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

Function MapFromRecord

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

Source from the content-addressed store, hash-verified

7751 * @since 3.10.0
7752 */
7753export const MapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
7754 key: Schema<KA, string, KR>
7755 value: Schema<VA, VI, VR>
7756}): SchemaClass<Map<KA, VA>, { readonly [x: string]: VI }, KR | VR> =>
7757 transform(
7758 Record({ key: encodedBoundSchema(key), value }).annotations({
7759 description: "a record to be decoded into a Map"
7760 }),
7761 MapFromSelf({ key, value: typeSchema(value) }),
7762 {
7763 strict: true,
7764 decode: (i) => new Map(Object.entries(i)),
7765 encode: (a) => Object.fromEntries(a)
7766 }
7767 )
7768
7769const setArbitrary =
7770 <A>(item: LazyArbitrary<A>, ctx: ArbitraryGenerationContext): LazyArbitrary<ReadonlySet<A>> => (fc) => {

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected