mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: nektro <nektro@users.noreply.github.com>
12 lines
400 B
Markdown
12 lines
400 B
Markdown
---
|
|
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`.
|
|
|
|
```ts
|
|
import { Readable } from "stream";
|
|
const stream = Readable.from(["Hello, ", "world!"]);
|
|
const buf = await new Response(stream).bytes();
|
|
```
|