whatwg / streams

Streams Standard
https://streams.spec.whatwg.org/
Other
1.34k stars 155 forks source link

ReadableStream.prototype.text(), .blob(), and .bytes() #1311

Open jasnell opened 2 months ago

jasnell commented 2 months ago

Adds utility methods to akin to the Body mixin for fully reading the contents of a ReadableStream as either text, a Blob, or a Uint8Array.

This is a first pass at addressing #1019 ....

In this, I add only the text(), bytes(), and blob() methods. text() returns a promise for UTF-8 decoded text, bytes() returns a promise for a Uint8Array, and blob() returns a promise for a Blob. It is modeled heavily on the fetch spec Body mixin definitions with a few tweaks.

Refs: https://github.com/whatwg/streams/issues/1019


(See WHATWG Working Mode: Changes for more details.)


Preview | Diff