Bun Convert a Node.js Readable to a Blob

Convert a Node.js Readable to a Blob

jarle Updated

File contents

Convert a Node.js Readable to a Blob

To convert a Node.js Readable stream to a Blob in Bun, you can create a new Response object with the stream as the body, then use response.blob() to read the stream into a Blob.

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

jarle/bun-skills/tree/main/skills/bun-guides-streams-node-readable-to-blob commit 578dba6759

Frequently asked questions

npx skillmds@latest add jarle/bun-convert-a-node-js-readable-to-a-blob