Skip to main content
Bun 提供了许多便捷函数,用于将 ReadableStream 的内容读取为不同格式。此示例代码将 ReadableStream 的内容读取为 ArrayBuffer,然后创建一个指向该 ArrayBufferBuffer
const stream = new ReadableStream();
const arrBuf = await Bun.readableStreamToArrayBuffer(stream);
const nodeBuf = Buffer.from(arrBuf);

有关 Bun 其他 ReadableStream 转换函数的文档,请参见 Docs > API > Utils