-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async iteration for fetch response body #2520
Comments
This feature would require implementing parts of the Streams API, for example, @ry What are your thoughts on the Streams API? Should it be supported in Deno eventually? |
fetch should be compatible with web APIs - so we should do it. It should be straightforward - all the infrastructure is in place to do this. I believe ResponseBody is already a "Writer", for example.
I think it's poorly designed - which is why we have |
I agree that it's more complicated than Deno's API, but is it really so bad that we don't ever want to support it? I think for this use-case, for example, it's actually fairly similar. // Deno API
let { eof, nread } = await response.body.read(buffer)
// Streams API
let reader = response.body.getReader({ mode: 'byob' })
let { done, value } = await reader.read(buffer) Personally, I'd like Deno to be compatible with the Streams API to be even more browser-friendly. On one hand, the Streams API is still fairly experimental so it might be best to wait. On the other hand, I can also imagine that, whenever the Streams API is stable, we have 3 major competing JS stream APIs (Web, Node, Deno) further fragmenting the JS ecosystem. |
We must support it to be browser compatible . See toAsyncIterator() for an example of how to convert between Reader and ReadableStream |
Currently failing with
error TS2504: Type 'Body' must have a '[Symbol.asyncIterator]()' method that returns an async iterator.
The text was updated successfully, but these errors were encountered: