要在 Bun 中將 Node.js Readable 流轉換為 Uint8Array,你可以使用流作為 body 創建一個新的 Response 對象,然後使用 bytes() 將流讀取為 Uint8Array。
ts
import { Readable } from "stream";
const stream = Readable.from(["Hello, ", "world!"]);
const buf = await new Response(stream).bytes();