Re: [whatwg/streams] Add @@asyncIterator to ReadableStream (#980)

ricea commented on this pull request.

Looks good once the things I noted are fixed.

We're going to need a usage example, but since this PR has gone on long enough, we can add that separately.

> @@ -792,6 +814,80 @@ option. If <code><a for="underlying source">type</a></code> is set to <code>unde
   </code></pre>
 </div>
 
+<!-- Bikeshed doesn't let us mark this up correctly: https://github.com/tabatkins/bikeshed/issues/1344 -->
+<h5 id="rs-asynciterator" iterator for="ReadableStream">[@@asyncIterator]({ <var>preventCancel</var> } = {})</h5>

Seems fine to me. Also, it looks like you did it on purpose, which is a bonus.

> @@ -792,6 +814,80 @@ option. If <code><a for="underlying source">type</a></code> is set to <code>unde
   </code></pre>
 </div>
 
+<!-- Bikeshed doesn't let us mark this up correctly: https://github.com/tabatkins/bikeshed/issues/1344 -->
+<h5 id="rs-asynciterator" iterator for="ReadableStream">[@@asyncIterator]({ <var>preventCancel</var> } = {})</h5>
+
+<p class="note">
+  The <code>@@asyncIterator</code> method is an alias of {{ReadableStream/getIterator()}}.
+</p>
+
+The initial value of the <code>@@asyncIterator</code> method is the same function object as the initial value of the
+{{ReadableStream/getIterator()}} method.
+
+<h3 id="rs-asynciterator-prototype" interface
+lt="ReadableStreamAsyncIteratorPrototype">ReadableStreamAsyncIteratorPrototype</h3>
+
+{{ReadableStreamAsyncIteratorPrototype}} is an ordinary object that is used by {{ReadableStream/[@@asyncIterator]()}} to

I think we should refer to `getIterator()` here and below, instead of `[@@asyncIterator]`, since the latter is defined as an alias of the former.

> +  </thead>
+  <tr>
+    <td>\[[asyncIteratorReader]]
+    <td class="non-normative">A {{ReadableStreamDefaultReader}} instance
+  </tr>
+  <tr>
+    <td>\[[preventCancel]]
+    <td class="non-normative">A boolean value indicating if the stream will be <a lt="cancel a readable
+    stream">canceled</a> when the async iterator's {{ReadableStreamAsyncIteratorPrototype/return()}} method is called
+  </tr>
+</table>
+
+<h4 id="rs-asynciterator-prototype-next" method for="ReadableStreamAsyncIteratorPrototype">next()</h4>
+
+<emu-alg>
+  1. If ! IsReadableStreamAsyncIterator(*this*) is *false*, return <a>a promise rejected with</a> *TypeError* exception.

Need the word "a" before *TypeError*. Also in step 1. of return(), below.

> @@ -160,7 +160,16 @@
     "id-blacklist": "off",
     "id-length": "off",
     "id-match": "off",
-    "indent": ["error", 2, { "SwitchCase": 1 }],
+    "indent": ["error", 2, {
+      "SwitchCase": 1,
+      "MemberExpression": 2,
+      "FunctionDeclaration": { "parameters": "first" },

The new rules seem reasonable... @domenic, what do you think?

I don't understand why the indentation of `.catch(rethrowAssertionErrorRejection);` expressions has changed, although they always seemed like a weird special case to me anyway.

-- 
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/980#pullrequestreview-199490115

Received on Monday, 4 February 2019 09:58:02 UTC