Create a caching wrapper around a stream.
The underlying stream to read from
Minimum bytes to read at once from inner stream (default 64KB)
Total bytes read from this stream so far.
ReadonlyexpectedSize hint for buffer pre-allocation in readAll(). May be undefined if size is unknown.
Release resources and abort any pending operations.
Pull data into the provided buffer.
Buffer to fill with data
Number of bytes read, or 0 for EOF
Read entire stream into a single buffer. Uses expectedSize hint if available, grows dynamically if needed.
Complete data as Uint8Array
ReadStream wrapper that adds read-ahead buffering to reduce async overhead. Reads larger chunks from the inner stream and buffers excess data for subsequent small reads. Useful for sources with high per-call overhead.
Example