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

Function makeValueSchema

packages/effect/src/SchemaRepresentation.ts:899–906  ·  view source on GitHub ↗
(type: Type, value: Schema.Codec<Value>)

Source from the content-addressed store, hash-verified

897 thunk: RepresentationSchema
898})
899function makeValueSchema<Type extends string, Value>(type: Type, value: Schema.Codec<Value>) {
900 return value.pipe(
901 Schema.encodeTo(Schema.Struct({ type: Schema.tag(type), value }), {
902 decode: SchemaGetter.transform((encoded: { readonly type: Type; readonly value: Value }) => encoded.value),
903 encode: SchemaGetter.transform((value: Value) => ({ type, value }))
904 })
905 )
906}
907const StringValueCodec = makeValueSchema("string", Schema.String)
908const NumberValueCodec = makeValueSchema("number", Schema.Number)
909const LiteralSchema = Schema.Struct({

Callers 1

Calls 3

pipeMethod · 0.65
tagMethod · 0.65
transformMethod · 0.65

Tested by

no test coverage detected