(direction: "client" | "server", message: Frame)
| 32 | type Frame = string | Uint8Array |
| 33 | |
| 34 | const encodeEvent = (direction: "client" | "server", message: Frame): WebSocketEvent => |
| 35 | typeof message === "string" |
| 36 | ? { direction, kind: "text", body: message } |
| 37 | : { direction, kind: "binary", body: Buffer.from(message).toString("base64"), bodyEncoding: "base64" } |
| 38 | |
| 39 | const decodeEvent = (event: WebSocketEvent): Frame => |
| 40 | event.kind === "text" ? event.body : new Uint8Array(Buffer.from(event.body, "base64")) |
no test coverage detected