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

Function makeEncodingTransformation

packages/effect/src/Schema.ts:6299–6318  ·  view source on GitHub ↗
(
  id: string,
  decode: (s: string) => either_.Either<string, Encoding.DecodeException>,
  encode: (u: string) => string
)

Source from the content-addressed store, hash-verified

6297)
6298
6299const makeEncodingTransformation = (
6300 id: string,
6301 decode: (s: string) => either_.Either<string, Encoding.DecodeException>,
6302 encode: (u: string) => string
6303) =>
6304 transformOrFail(
6305 String$.annotations({
6306 description: `A string that is interpreted as being ${id}-encoded and will be decoded into a UTF-8 string`
6307 }),
6308 String$,
6309 {
6310 strict: true,
6311 decode: (i, _, ast) =>
6312 either_.mapLeft(
6313 decode(i),
6314 (decodeException) => new ParseResult.Type(ast, i, decodeException.message)
6315 ),
6316 encode: (a) => ParseResult.succeed(encode(a))
6317 }
6318 ).annotations({ identifier: `StringFrom${id}` })
6319
6320/**
6321 * Decodes a base64 (RFC4648) encoded string into a UTF-8 string.

Callers 1

Schema.tsFile · 0.85

Calls 4

transformOrFailInterface · 0.85
decodeFunction · 0.70
encodeFunction · 0.70
annotationsMethod · 0.65

Tested by

no test coverage detected