Re: [whatwg/streams] Editorial: Add a non-promise version of "fully reading" a stream (PR #1250)

@domenic commented on this pull request.



> @@ -6809,36 +6809,32 @@ a chunk</dfn> from a {{ReadableStreamDefaultReader}} |reader|, given a [=read re
 
 <div algorithm="read all bytes">
  <p>To <dfn export for="ReadableStreamDefaultReader" lt="read all bytes|reading all bytes">read all
- bytes</dfn> from a {{ReadableStreamDefaultReader}} |reader|, perform the following steps. The
- result will be a {{Promise}} for a [=byte sequence=].
-
- 1. Let |promise| be [=a new promise=].
- 1. Let |bytes| be an empty [=byte sequence=].
- 1. [=Read-loop=] given |reader|, |bytes|, and |promise|.
- 1. Return |promise|.
+ bytes as a promise</dfn> from a {{ReadableStreamDefaultReader}} |reader|, given |successSteps|,

```suggestion
 bytes</dfn> from a {{ReadableStreamDefaultReader}} |reader|, given |successSteps|,
```

> @@ -6809,36 +6809,32 @@ a chunk</dfn> from a {{ReadableStreamDefaultReader}} |reader|, given a [=read re
 
 <div algorithm="read all bytes">
  <p>To <dfn export for="ReadableStreamDefaultReader" lt="read all bytes|reading all bytes">read all
- bytes</dfn> from a {{ReadableStreamDefaultReader}} |reader|, perform the following steps. The
- result will be a {{Promise}} for a [=byte sequence=].
-
- 1. Let |promise| be [=a new promise=].
- 1. Let |bytes| be an empty [=byte sequence=].
- 1. [=Read-loop=] given |reader|, |bytes|, and |promise|.
- 1. Return |promise|.
+ bytes as a promise</dfn> from a {{ReadableStreamDefaultReader}} |reader|, given |successSteps|,
+ which is an algorithm accepting a [=byte sequence=], and |failureSteps|, which is an algorithm
+ accepting a JavaScript value, [=read-loop=] given |reader|, a new [=byte sequence=],

```suggestion
 accepting a JavaScript value: [=read-loop=] given |reader|, a new [=byte sequence=],
```

>  
  <div algorithm="read-loop">
-  For the purposes of the above algorithm, to <dfn>read-loop</dfn> given |reader|, |bytes|, and
-  |promise|:
+  For the purposes of the above algorithm, to <dfn>read-loop</dfn> given |reader|, |bytes|,
+  |successSteps|, and |failureSteps:

```suggestion
  |successSteps|, and |failureSteps|:
```

>  
   1. Let |readRequest| be a new [=read request=] with the following [=struct/items=]:
    : [=read request/chunk steps=], given |chunk|
    ::
-    1. If |chunk| is not a {{Uint8Array}} object, [=reject=] |promise| with a {{TypeError}} and

Hmm, I realized I made this more complicated because "get a copy of the bytes held" expects a BufferSource, but chunk steps get arbitrary values, which given the current state of the spec I'm not sure if they're even IDL versus JavaScript values.

Probably best to just revert this to the previous imprecise wording (including the type check and reject). Eventually we can do a pass through the spec to use the new-ish IDL BufferSource manipulation stuff everywhere. Sorry for thinking that this sub-case would be easier and thus worth doing while you were in the area.

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

Message ID: <whatwg/streams/pull/1250/review/1214821748@github.com>

Received on Tuesday, 13 December 2022 07:19:21 UTC