The streams APIs provide ubiquitous, interoperable primitives for creating, composing, and consuming streams of data. For streams representing bytes, an extended version of the readable stream is provided to handle bytes efficiently, in particular by minimizing copies.
Byte streams allow for BYOB readers to be acquired. The default implementation can give a range of different outputs such as strings or array buffers in the case of WebSockets, whereas byte streams guarantee byte output. Furthermore, being able to have BYOB readers has benefits in terms of stability. This is because if a buffer detaches, it can guarantee that one does not write into the same buffer twice, hence avoiding race conditions. BYOB readers also do not need to garbage collect for every read, because we can reuse buffers.
Low risk because it has already been standardised for a long time (since around 2014). Other browsers have implemented other parts of the standard, and they will most likely also adapt byte streams as well soon.
A lot of design efforts have been made into making the streams API easy to use. Additionally, this byte streams API is similar to the existing streams API that developers are used to.
It is difficult to polyfill just byte streams, without polyfilling the rest of readable streams. Hence, developers may need to wait for other browsers to also implement byte streams, or maintain two code paths.
No special support needed.
Apologies for the noise but it's great to finally see this. :)On Wednesday, 21 October 2020 at 02:38:45 UTC+2 Nidhi Jaju wrote:Contact emails
nidh...@google.com, ri...@chromium.org, yhi...@chromium.orgExplainer
Specification
Streams API SpecDesign docs
We will update this thread when our design doc firms up.Summary
The streams APIs provide ubiquitous, interoperable primitives for creating, composing, and consuming streams of data. For streams representing bytes, an extended version of the readable stream is provided to handle bytes efficiently, in particular by minimizing copies.
Blink component
Blink>Network>StreamsAPIMotivation
Byte streams allow for BYOB readers to be acquired. The default implementation can give a range of different outputs such as strings or array buffers in the case of WebSockets, whereas byte streams guarantee byte output. Furthermore, being able to have BYOB readers has benefits in terms of stability. This is because if a buffer detaches, it can guarantee that one does not write into the same buffer twice, hence avoiding race conditions. BYOB readers also do not need to garbage collect for every read, because we can reuse buffers.
Initial public proposal
NoneTAG review
TAG review status
Not applicable