PbinaryType
Bun

property

ServerWebSocket.binaryType

binaryType?: 'arraybuffer' | 'uint8array' | 'nodebuffer'

Sets how binary data is returned in events.

  • if nodebuffer, binary data is returned as Buffer objects. (default)
  • if arraybuffer, binary data is returned as ArrayBuffer objects.
  • if uint8array, binary data is returned as Uint8Array objects.
let ws: WebSocket;
ws.binaryType = "uint8array";
ws.addEventListener("message", ({ data }) => {
  console.log(data instanceof Uint8Array); // true
});