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

> 3\. Tell people that if they want to use an infinite iterator with `from()` they have to make it async.

If all they have is an infinite synchronous iterable, they might find it difficult to turn it into an asynchronous iterable. Effectively, they'd have to resort to things [like this](https://github.com/whatwg/streams/blob/2d40fe365180b231dc9cd4509cd013f7b690abca/reference-implementation/lib/abstract-ops/ecmascript.js#L73-L75):
```javascript
ReadableStream.from(async function* () {
  return yield* syncIterable;
}());
```
I don't know if we want to encourage the use of this sort of pattern. But then again, I also don't know how often people will actually want to use an infinite synchronous iterable. 🤷

-- 
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#issuecomment-881078778

Received on Thursday, 15 July 2021 23:48:08 UTC