STREAMS API
The Streams API is the answer to a simple but fundamental question: How can a web application consume information in sequential chunks rather than in bulk? This capability is massively useful in two main ways:
- A block of data may not be available all at once. A perfect example of this is a response to a network request. Network payloads are delivered as a sequence of packets, and stream processing can allow an application to use network-delivered data as it becomes available rather than waiting for the full payload to finish loading.
- A block of data can be processed in small portions. Video processing, data decompression, image decoding, and JSON parsing are all examples of computation that is localized to a portion of a data block and does not require it to be in memory all at once.
The “Network Requests and Remote Resources” chapter covers how the Streams API is involved with fetch(), but the Streams API is totally generalizable. JavaScript libraries that implement...