- From: Mattias Buelens <notifications@github.com>
- Date: Wed, 22 Apr 2020 11:35:38 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/pull/1035/review/398469537@github.com>
@MattiasBuelens commented on this pull request.
> @@ -892,7 +896,70 @@ option. If {{UnderlyingSource/type}} is set to undefined (including via omission
</div>
</div>
-<!-- TODO async iterator stuff -->
+<h4 id="rs-asynciterator" oldids="rs-asynciterator-prototype,
+default-reader-asynciterator-prototype-internal-slots">Asynchronous iteration</h4>
+
+<dl class="domintro">
+ <dt><code>for await (const <var ignore>chunk</var> of <var ignore>stream</var>) { ... }</code>
+ <dt><code>for await (const <var ignore>chunk</var> of <var ignore>stream</var>.values([{ {{ReadableStreamIteratorOptions/preventCancel}} }])) { ... }</code>
Ooooh right, I see it know. There's a similar thing going on with `reader = stream.getReader([{ mode: "byob" }])`, but for some reason I didn't interpret that as an array. I think seeing the lengthy `for await of` construct around it made me interpret the whole thing as a line of JavaScript, rather than a signature with optional arguments.
It seems like the syntax used in these non-normative sections is a bit ambiguous, since we use square brackets for both optionality and arrays:
* `stream = new ReadableStream(underlyingSource[, strategy])` (optionality)
* `[branch1, branch2] = stream.tee()` (array return value)
Then again, I can't immediately come up with a better way to present this. 🤷
(Something like `{ preventCancel }?` would work in TypeScript, but that's not a thing in JavaScript.)
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1035#discussion_r413223724
Received on Wednesday, 22 April 2020 18:35:51 UTC