- From: Thai Pangsakulyanont <notifications@github.com>
- Date: Thu, 10 Oct 2024 09:45:41 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Thursday, 10 October 2024 16:45:45 UTC
[Bun also supports this non-standard behavior.](https://bun.sh/guides/http/stream-iterator) Also, when I have an `AsyncIterable<Uint8Array>` and want to convert it into an `ArrayBuffer`, GitHub Copilot actually suggested this code: ```js const stream = generateZipStream() const buffer = await new Response(stream).arrayBuffer() ``` Admittedly the above code looks a bit cursed, but given that `Array.fromAsync` wasn't an option back then (and still isn't in Node LTS today, i.e. v20), the above code was a one-liner that works in Node.js (all the way back to v18) and in Bun, and popular enough to be suggested by AI models as a viable solution. With its convenience, I kinda hope it becomes a de-facto standard. By the way, I later discovered that as of now, **the above code does not work in Deno and in browsers.** So I had to change it to this, but then compatibility with Node 20 is broken: ```js const stream = generateZipStream() const buffer = await new Blob(await Array.fromAsync(stream)).arrayBuffer() ``` -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/issues/1291#issuecomment-2405595506 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/fetch/issues/1291/2405595506@github.com>
Received on Thursday, 10 October 2024 16:45:45 UTC