Skip to content

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

ts
import { Readable } from "stream";
const stream = Readable.from(["Hello, ", "world!"]);
const buf = await new Response(stream).bytes();

Bun by www.bunjs.com.cn 編集