← Back to release summary

Streams API: Byte Streams

Category
Network / Connectivity
Type
Chromium catches up
Status
Enabled by default (Chrome 89)
Intent stage
Shipped

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.

Motivation

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.

Standards & signals

Docs: https://docs.google.com/document/d/1rvKpGjppeqRSWntokY-ft_hU2i2us8gis6zgrrLWSTI/view

Explainers: https://github.com/whatwg/streams/blob/master/byte-streams-explainer.md

View on chromestatus.com