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

@bakkot commented on this pull request.



> +<div algorithm>
+ <dfn abstract-op lt="ReadableStreamConsumeAsBytes" id="ReadableStreamConsumeAsBytes">ReadableStreamConsumeAsBytes(|stream|, |options|})</dfn> will
+ consume all bytes produced by a given readable stream and return a promise that resolves with a single Uint8Array containing the read bytes.
+
+ It performs the following steps:
+
+ 1. Assert: |stream| [=implements=] {{ReadableStream}}.
+ 1. If ! [$IsReadableStreamLocked$]([=stream=]) is true, return [=a promise rejected with=] a
+    {{TypeError}} exception.
+ 1. If ! |stream|.[=ReadableStream/[[disturbed]]=] is true, return [=a promise rejected with=] a
+    {{TypeError}} exception.
+ 1. Let |signal| be |options|["{{ConsumeBytesOptions/signal}}"] if it [=map/exists=], or undefined
+    otherwise.
+ 1. Assert: either |signal| is undefined, or |signal| [=implements=] {{AbortSignal}}.
+ 1. Let |decode as Uint8Array| be an algorithm that takes a [=byte sequence=] |bytes| and runs the steps:
+  1. Let |arrayBuffer| be a new {{ArrayBuffer}} whose contents are |bytes|.

This is a faithful copy of the text in fetch, but fetch [has a bug](https://github.com/whatwg/fetch/issues/1675) which is copied here. It doesn't necessarily need to be fixed here, just gotta make sure it gets fixed here as well when fixed upstream.

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

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

Received on Tuesday, 9 April 2024 21:58:31 UTC