Mrs. Sari’s kitchen is a ReadableStream’s source and her counter its queue: when does pull() cook, and does the counter ever pass the highWaterMark? Mr. Tono…
Why it matters
Large downloads, streaming API responses, reading from a socket: all can be larger than memory. A stream lets you process piece by piece, and backpressure holds a fast producer back so a slow consumer is not swamped. It is the foundation of fetch().body, file uploads and modern data pipelines.
The key idea
A stream asks for the next chunk only while there is room
Common mistakes
Thinking each read() gives all the data at onceread() gives one chunk: { value, done }. Repeat it in a loop until done === true to read the stream through.
Try it in this playground
pull(): watch desiredSize reach 0 Then the stream stops calling pull() until Mr. Tono takes a plate.
Cook regardless: desiredSize below zero A push source ignores the mark on the counter.
One read(): a single plate Run the One read() situation to the end.
cancel() halfway The plates on the counter are thrown away, the kitchen is told.