streams icon indicating copy to clipboard operation
streams copied to clipboard

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

Open jasnell opened this issue 1 year ago • 2 comments

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


  • [ ] At least two implementers are interested (and none opposed):
    • Cloudflare Workers
    • Node.js
    • ...
  • [ ] Tests are written and can be reviewed and commented upon at:
  • [ ] Implementation bugs are filed:
    • Chromium: …
    • Gecko: …
    • WebKit: …
    • Deno: …
    • Node.js: …
  • [ ] MDN issue is filed: …
  • [ ] The top of this comment includes a clear commit message to use.

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


Preview | Diff

jasnell avatar Apr 09 '24 21:04 jasnell

@jasnell hey, whats the holdup with this? is there anything we from Deno can do to push this forward? If you don't have time, I do not mind taking this over.

Gonna already explicitly confirm that Deno does have interest in having this.

crowlKats avatar Jun 28 '25 16:06 crowlKats

Yeah time disappeared on me. Happy to hand it over if you have the cycles. I just had to push it down the priority stack and haven't been able to get back to it

jasnell avatar Jun 28 '25 17:06 jasnell