Re: [whatwg/streams] add @@asyncIterator to ReadableStreamDefaultReader (#950)

TimothyGu commented on this pull request.



> +</emu-alg>
+
+<h5 id="default-reader-@@asynciterator" for="ReadableStreamDefaultReader">[@@asyncIterator]()</h5>
+
+<div class="note">
+  The <code>@@asyncIterator</code> method is an alias of {{ReadableStreamDefaultReader/iterator}}.
+</div>
+
+<emu-alg>
+  1. Let _iterator_ be ? GetMethod(*this*, "iterator").
+  1. Return ? Call(_iterator_, *this*).
+</emu-alg>
+
+<h3 id="default-reader-asynciterator-prototype" interface lt="ReadableStreamDefaultReaderAsyncIteratorPrototype">
+  ReadableStreamDefaultReaderAsyncIteratorPrototype
+</h3>

@mcollina Yes; having it would allow

```js
for await (const chunk of stream.getReader().getIterator()) {
}
```

in addition to just

```js
for await (const chunk of stream.getReader()) {
}
```

This is fully consistent with how sync iterators operate, that you can do `Array.from(map.entries())` in addition to just `Array.from(map)`.

-- 
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/950#discussion_r211716722

Received on Tuesday, 21 August 2018 18:44:13 UTC