Skip to main content

Documentation Index

Fetch the complete documentation index at: https://bun.zhcndoc.com/llms.txt

Use this file to discover all available pages before exploring further.

要在 Bun 中将 Node.js 的 Readable 流转换为 JSON 对象,可以创建一个以该流作为主体的新 Response 对象,然后使用 response.json() 将流读取为 JSON 对象。
import { Readable } from "stream";
const stream = Readable.from([JSON.stringify({ hello: "world" })]);
const json = await new Response(stream).json();
console.log(json); // { hello: "world" }