Re: [whatwg/streams] ReadableStream.prototype.arrayBuffer() (#1019)

The `new Response(blob).body` [hack](https://github.com/w3c/FileAPI/issues/40) was the reason why we got `blob.arrayBuffer(), blob.text() & blob.stream()`
You can use the same hack here ... `new Response(stream).blob()`
Could you imagine what the fetch would look like instead if we had done `response.body.blob()`? then we would probably not have `response.blob()` in the first place

It would be nice to have all array/blob/text/arrayBuffer - hopefully node streams would follow suit than you could use express.js to do stuff like 

```js
app.post('route', (req, res) => {
  await req.arrayBuffer()
})
```

> Rejects and cancels stream if any chunks are not BlobPart.

Not sure what you mean by this

Blob constructor can take any kind of object you throw at it. The default fallback behavior is to cast anything it can't handle into a string...
if you do: `new Blob([{}])` then it will dump `"[Object object]"` as the content. Maybe should do the same thing.

-- 
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/issues/1019#issuecomment-847054855

Received on Monday, 24 May 2021 13:49:08 UTC