add .bytes() method to various readables (#11104)

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: nektro <nektro@users.noreply.github.com>
This commit is contained in:
Meghan Denny
2024-05-16 19:10:50 -07:00
committed by GitHub
parent ac6eaac403
commit 5caca9cd48
39 changed files with 659 additions and 68 deletions

View File

@@ -275,6 +275,7 @@ Bun.stringWidth("\u001b[31mhello\u001b[0m", { countAnsiEscapeCodes: true }); //
```
This is useful for:
- Aligning text in a terminal
- Quickly checking if a string contains ANSI escape codes
- Measuring the width of a string in a terminal
@@ -372,7 +373,6 @@ npm/string-width 95,000 chars ansi+emoji+ascii 3.68 s/iter (3.66 s
{% /details %}
TypeScript definition:
```ts
@@ -400,7 +400,6 @@ namespace Bun {
}
```
<!-- ## `Bun.enableANSIColors()` -->
## `Bun.fileURLToPath()`
@@ -603,6 +602,9 @@ stream; // => ReadableStream
await Bun.readableStreamToArrayBuffer(stream);
// => ArrayBuffer
await Bun.readableStreamToBytes(stream);
// => Uint8Array
await Bun.readableStreamToBlob(stream);
// => Blob