v140 ยท miscellaneous
ReadableStreamBYOBReader Min Option
This feature introduces a min option to the existing ReadableStreamBYOBReader.read(view) API. The API already accepts a ArrayBufferView into which data is read, but currently does not guarantee how many elements will be written before the read resolves.
concepts
-
BYOB min
BYOB readers gain a min option โ the read resolves only when at least min bytes are filled. Reduces the read-loop tax for sites that want bigger chunks at the cost of latency.
-
Decoder Buffer
The decoder motivation: side-by-side iteration counts for "loop-and-concat" vs.
read(view, {min})against a stream that emits jagged chunks. -
min vs default
Two BYOB readers race over the same byte stream; the read-log columns visualise how many short reads
mineliminates and where the partials land. -
Protocol Decoder
Length-prefixed binary protocol decoded with two reads per frame: 8 bytes for the header, then exactly
lenbytes for the body. No reassembly buffer. -
Fixed-Frame Binary Reader
Parses a simulated binary format (4-byte magic + 4-byte length + payload) from a stream that emits randomly-sized chunks. Two side-by-side readers: "without min" (shows partial reads and reassembly loops) vs "with min: 8" (zero reassembly). Read log shows timestamp, requested size, actual bytes returned, and whether each read yielded a complete frame.
why it shipped
The ReadableStreamBYOBReader.read(view) method allows developers to supply a buffer view into which stream data is read. However, the current behavior does not guarantee how many elements will be written into the buffer. The stream may resolve the read with fewer elements than the view can accommodate.