demo · v140

min vs default

A simulated jagged byte stream (random-sized chunks). Two BYOB readers attached: left uses read(view), right uses read(view, { min: 256 }). Watch the read counts: the min reader does fewer, larger reads — which translates to one less decoder pass per chunk in real code.

default — read(view)

min — read(view, { min })

const { value, done } = await reader.read(buf, { min: 512 });
// value.byteLength >= 512 (unless the stream ended).
// Without min, the read can resolve with as little as 1 byte.

see also