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

I think we should only do that if we are *absolutely sure* that the user-visible behavior is exactly the same. So we shouldn't do this with arbitrary synchronous iterators, since they can be infinite (as you correctly noted) or they might be modifying some external state inside `next()` (such as variables or synchronous I/O).

That doesn't mean we can't allow some optimizations. For example, if the input is an `Array` with its *original* `[Symbol.iterator]` method, then the implementation *can* indeed use a "fast path" for such a case. The same logic could apply to other built-in iterables like `Set` or `Map` or `Uint8Array` (although I don't know if these are worth optimizing).

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

Received on Monday, 19 April 2021 13:35:24 UTC