[whatwg/streams] ReadableStream.from(asyncIterable) (#1083)

I want to give #1018 a try. 😁

This adds a static `ReadableStream.from()` method, which takes an async iterable and returns a `ReadableStream` pulling chunks from that async iterable. Sync iterables (including arrays and generators) are also supported, since [`GetIterator()`](https://tc39.es/ecma262/#sec-getiterator) already has all the necessary handling to adapt a sync iterator into an async iterator. So that's nice. 😄

I think it should be fairly easy to add `ReadableStream.of(...chunks)` as well, which would simply call through to `ReadableStream.from(chunks)`. I'll look into it.

This is a very early draft, so there are no tests yet. I first want to get most of the semantics done, then we can worry about all the nasty error handling and edge cases.

- [ ] At least two implementers are interested (and none opposed):
   * …
   * …
- [ ] [Tests](https://github.com/web-platform-tests/wpt) are written and can be reviewed and commented upon at:
   * …
- [ ] [Implementation bugs](https://github.com/whatwg/meta/blob/master/MAINTAINERS.md#handling-pull-requests) are filed:
   * Chrome: …
   * Firefox: …
   * Safari: …

(See [WHATWG Working Mode: Changes](https://whatwg.org/working-mode#changes) for more details.)

You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/streams/pull/1083


-- Commit Summary --

  * [WIP] ReadableStream.from

-- File Changes --

    M index.bs (40)
    M reference-implementation/lib/ReadableStream-impl.js (47)
    M reference-implementation/lib/ReadableStream.webidl (2)
    M reference-implementation/lib/abstract-ops/ecmascript.js (64)

-- Patch Links --

https://github.com/whatwg/streams/pull/1083.patch

https://github.com/whatwg/streams/pull/1083.diff


-- 
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/1083

Received on Tuesday, 10 November 2020 21:15:03 UTC