[whatwg/streams] ReadableStream.prototype.text(), .blob(), and .bytes() (PR #1311)

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](https://github.com/web-platform-tests/wpt) are written and can be reviewed and commented upon at:
   * … <!-- If these tests are tentative, link a PR to make them non-tentative. -->
- [ ] [Implementation bugs](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) are filed:
   * Chromium: …
   * Gecko: …
   * WebKit: …
   * Deno: …
   * Node.js: …
- [ ] [MDN issue](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) is filed: …
- [ ] The top of this comment includes a [clear commit message](https://github.com/whatwg/meta/blob/main/COMMITTING.md) to use. <!-- If you created this PR from a single commit, Github copied its message. Otherwise, you need to add a commit message yourself. -->

(See [WHATWG Working Mode: Changes](https://whatwg.org/working-mode#changes) for more details.)


<!--
    This comment and the below content is programmatically generated.
    You may add a comma-separated list of anchors you'd like a
    direct link to below (e.g. #idl-serializers, #idl-sequence):

    Don't remove this comment or modify anything below this line.
    If you don't want a preview generated for this pull request,
    just replace the whole of this comment's content by "no preview"
    and remove what's below.
-->
***
<a href="https://whatpr.org/whatwg-streams/1311.html" title="Last updated on Apr 9, 2024, 9:29 PM UTC (dbf22e9)">Preview</a> | <a href="https://whatpr.org/streams/1311/1086884...dbf22e9.html" title="Last updated on Apr 9, 2024, 9:29 PM UTC (dbf22e9)">Diff</a>
You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/streams/pull/1311

-- Commit Summary --

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

-- File Changes --

    M index.bs (120)

-- Patch Links --

https://github.com/whatwg/streams/pull/1311.patch
https://github.com/whatwg/streams/pull/1311.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1311
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/pull/1311@github.com>

Received on Tuesday, 9 April 2024 21:29:24 UTC