Effect CommunityEC
Effect Communityโ€ข2y agoโ€ข
4 replies
Toby

Creating a TaggedRequest with Transformation

Anyone know how to create a TaggedRequest that also performs a transformation? i.e.

const ArrToStr = S.Uint8Array.pipe(
  S.transform(
    S.string, 
    (arr) => new TextDecoder().decode(arr),
    (str) => new TextEncoder().encode(str)
  )
)

export class Req extends S.TaggedRequest<Req>()('req', S.string, S.string, {
  arr: ArrToStr
}) {}

// how can I pass a Uint8Array here
new Req({ arr: new Uint8Array() })


(I actually want to bas64encode some binary data to a string before sending it across the wire, but this code illustrates the point)
Was this page helpful?