demo · v140

BYOB Reader — min option

Pick a buffer size and a minimum fill. The demo enqueues 64 KiB in random chunks through a BYOB stream, then reads with { min }. Compare the number of reads with and without min.

reads
avg fill
total bytes

Per-read trace:

(idle)

const reader = stream.getReader({ mode: "byob" });
const { value, done } = await reader.read(new Uint8Array(4096), { min: 1024 });
// Without min: each chunk resolves as soon as ANY bytes arrive.
// With min:    the read waits until at least 1024 bytes are available.

see also