- ReadableStream
- reader
- chunks
- backpressure
- cancel
A readable stream exposes chunks incrementally. A reader can process each chunk and stop or cancel. Backpressure coordinates producers and consumers so a fast source does not overwhelm slower processing. Use streaming for large or incremental data; a small JSON response is usually simpler to parse all at once.
Reading every chunk into one large array defeats the memory benefit of streaming.
Create a ReadableStream that emits three text chunks and read them one at a time, then cancel a second stream early.
Open example.html, inspect example.js, then edit and refresh. For APIs that need an origin, run a local server from the JavaScripts folder.
- Explain the behavior and its limits in your own words.
- Test a normal case and a failure or cleanup case.
- Record when this feature is useful and when a simpler approach is better.