Files
bun.sh/docs/guides/streams/node-readable-to-uint8array.md
Meghan Denny 5caca9cd48 add .bytes() method to various readables (#11104)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: nektro <nektro@users.noreply.github.com>
2024-05-16 19:10:50 -07:00

400 B

name
name
Convert a Node.js Readable to an Uint8Array

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

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