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

MattiasBuelens requested changes on this pull request.

A few typos to fix. Also wondering whether we should use the `Call` helper function instead of `Reflect.apply`.

>  }
 
+ReadableStreamDefaultReader.prototype[Symbol.asyncIterator] = ReadableStreamDefaultReader.prototype.getIterator;
+
+const ReadableStreamDefaultReaderAsyncIteratorPrototype = Object.setPrototypeOf({
+  next() {
+    if (!IsReadableStreamDefaultReaderAsyncIterator(this)) {
+      throw defaultReaderAsyncIteratorBrandCheckException('next');
+    }
+    try {
+      const reader = this._reader;
+      const read = GetMethod(reader, 'read');
+      return Reflect.apply(read, reader, []);

Should we use [the `Call` helper function](https://github.com/whatwg/streams/blob/5d9498e7526d2f50618432e7aada8582d08745c0/reference-implementation/lib/helpers.js#L55) here? The reference implementation doesn't seem to use `Reflect` anywhere else, although I'm not sure whether that's a design goal.

> +  <tr>
+    <td>\[[PreventCancel]]
+    <td class="non-normative">Boolean value indicating if the reader will be cancelled when the stream returns.
+  </tr>
+</table>
+
+<h4 id="default-reader-asynciterator-prototype-next" method for="ReadableStreamDefaultReaderAsyncIteratorPrototype">
+next()</h4>
+
+<emu-alg>
+  1. If ! IsReadableStreamDefaultReaderAsyncIterator(*this*) is *false*, throw a *TypeError* exception.
+  1. Let _reader_ be *this*.[[Reader]].
+  1. Let _read_ be GetMethod(_reader_, `"read"`).
+  1. If _read_ is an abrupt completion, return <a>a promise rejected with</a> _read_.[[Value]].
+  1. Let _result_ be Call(_read_, _reader_).
+  1. If _result_ is an abrupt completion, return <a>a promise rejected with<a/> _result_.[[Value]].

Typo: change `<a/>` to `</a>`

> @@ -1283,6 +1283,9 @@ would look like
     <a href="#default-reader-cancel">cancel</a>(reason)
     <a href="#default-reader-read">read</a>()
     <a href="#default-reader-release-lock">releaseLock</a>()
+
+    <a href="#default-reader-getiterator">getIterator</a>({ preventClose = false })

Typo: change `preventClose` to `preventCancel`. Same thing for the next line.

-- 
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#pullrequestreview-149623097

Received on Monday, 27 August 2018 08:32:33 UTC