Guides Streams
Convert a ReadableStream to a Uint8Array
To convert a ReadableStream to a Uint8Array, read its contents into an ArrayBuffer with Bun.readableStreamToArrayBuffer, then create a Uint8Array that points to the buffer.
const stream = new ReadableStream();
const buf = await Bun.readableStreamToArrayBuffer(stream);
const uint8 = new Uint8Array(buf);Bun.readableStreamToBytes converts to a Uint8Array directly.
const stream = new ReadableStream();
const uint8 = await Bun.readableStreamToBytes(stream);