( id: string, decode: (s: string) => either_.Either<string, Encoding.DecodeException>, encode: (u: string) => string )
| 6297 | ) |
| 6298 | |
| 6299 | const 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. |
no test coverage detected