若要將 Node.js Readable
串流轉換為 Bun 中的字串,您可以建立一個新的 Response
物件,並將串流作為主體,然後使用 response.text()
將串流讀取為字串。
import { Readable } from "stream";
const stream = Readable.from([Buffer.from("Hello, world!")]);
const text = await new Response(stream).text();
console.log(text); // "Hello, world!"