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

MattiasBuelens commented on this pull request.



>  }
 
+const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {}).prototype);
+const ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf({

I am not proud of this contraption:
```js
const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {}).prototype);
const ReadableStreamAsyncIteratorMethods = class {
  next() { /* ... */ }
  return(value) { /* ... */}
};
const ReadableStreamAsyncIteratorPrototype = Object.create(AsyncIteratorPrototype, {
  next: Object.getOwnPropertyDescriptor(ReadableStreamAsyncIteratorMethods.prototype, 'next'),
  return: Object.getOwnPropertyDescriptor(ReadableStreamAsyncIteratorMethods.prototype, 'return')
});
```
I can't come up with any other way to have a function whose `name` equals `return` though... Please send help! 😆

-- 
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#discussion_r252453732

Received on Wednesday, 30 January 2019 21:55:07 UTC