Skip to content

Bun で Node.js の Readable ストリームを文字列に変換するには、ストリームをボディとして新しい Response オブジェクトを作成し、response.text() を使用してストリームを文字列に読み取ります。

ts
import { Readable } from "stream";
const stream = Readable.from([Buffer.from("Hello, world!")]);
const text = await new Response(stream).text();
console.log(text); // "Hello, world!"

Bun by www.bunjs.com.cn 編集