Skip to main content
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);

See Bun’s other ReadableStream conversion functions.