admin管理员组

文章数量:1357273

I'd like to load an entire fetch response in one go, but there doesn't seem to be a readAll or similar function.

What is the most performant way to read every byte from a ReadableStreamDefaultReader into a single Uint8Array?

I'd like to load an entire fetch response in one go, but there doesn't seem to be a readAll or similar function.

What is the most performant way to read every byte from a ReadableStreamDefaultReader into a single Uint8Array?

Share Improve this question edited Apr 24, 2019 at 13:17 Marvin Irwin asked Apr 24, 2019 at 12:33 Marvin IrwinMarvin Irwin 1,0309 silver badges17 bronze badges 2
  • 1 would response.arrayBuffer() do what you need? – Daniel A. White Commented Apr 24, 2019 at 12:36
  • Damn, I walked right by that one. Post that as the answer and I'll accept – Marvin Irwin Commented Apr 24, 2019 at 12:38
Add a ment  | 

1 Answer 1

Reset to default 9

Fetch's Response interface has .arrayBuffer() which returns an ArrayBuffer.

本文标签: javascriptRead all bytes from a ReadableStreamStack Overflow