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