Skip to content

لتحويل Node.js Readable stream إلى كائن JSON في Bun، يمكنك إنشاء كائن Response جديد مع stream كجسم، ثم استخدام response.json() لقراءة stream إلى كائن JSON.

ts
import { Readable } from "stream";
const stream = Readable.from([JSON.stringify({ hello: "world" })]);
const json = await new Response(stream).json();
console.log(json); // { hello: "world" }

Bun بواسطة www.bunjs.com.cn تحرير