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

MattiasBuelens commented on this pull request.



> +    }
+    if (reader._readRequests.length > 0) {
+      return Promise.reject(new TypeError(
+        'Tried to release a reader lock when that reader has pending read() calls un-settled'));
+    }
+    if (this._preventCancel === false) {
+      const result = ReadableStreamReaderGenericCancel(reader, value);
+      ReadableStreamReaderGenericRelease(reader);
+      return result.then(() => ReadableStreamCreateReadResult(value, true, true));
+    }
+    ReadableStreamReaderGenericRelease(reader);
+    return Promise.resolve(ReadableStreamCreateReadResult(value, true, true));
+  }
+}, AsyncIteratorPrototype);
+
+ReadableStream.prototype[Symbol.asyncIterator] = ReadableStream.prototype.getIterator;

This causes `ReadableStream.prototype[Symbol.asyncIterator]` to be **enumerable**. However, all the other methods are non-enumerable (which is checked by the tests). It also looks like all other objects with an iterator method (`Array`, `Map`, `URLSearchParams`,...) define it as non-enumerable.

@domenic @ricea Shall I make it non-enumerable in the reference implementation, and add a test for it as well?

-- 
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-196796595

Received on Saturday, 26 January 2019 17:59:48 UTC