I use fetch API to perform HTTP requests. Because the HTTP response body is a binary, I use response.arrayBuffer() method to get the result as bytes.
Anyway, this approach doesn't perform well when the application makes a lot of HTTP requests because every time response.arrayBuffer method is invoked, it returns a new instance of ArrayBuffer. I didn't find any solution to provide my own ArrayBuffer instance to the Response method to avoid a new allocation.
Is there any solution I can follow to let my application perform better?
Unfortunatelly
response.arrayBuffer()could be reused directly. A possible workaround would be to split the response intochunksand create multiple buffers from it usingBuffer.concat: