The ReadableStream instance.
The total size of the data in bytes.
Creates a ReadableStream of the data, optionally restricted to a byte range.
The default implementation reads the data with Reader#readUint8Array. Custom readers can override this method to return a stream provided natively by the underlying data source.
Optionaloptions: CreateReadableOptions
The options.
The ReadableStream instance.
OptionalinitInitializes the instance asynchronously
Reads a chunk of data
The byte index of the data to read.
The length of the data to read in bytes.
A promise resolving to a chunk of data. The data must be trucated to the remaining size if the requested length is larger than the remaining size.
Represents an instance used to read unknown type of data.
Example
Here is an example of custom Reader class used to read binary strings:
Example
Reading a file on the filesystem with random access does not always require a custom Reader: on runtimes exposing files as lazily-read
Blobinstances, theBlobreturned byawait fs.openAsBlob(path)on Node.js orBun.file(path)on Bun can be passed directly to ZipReader. Deno has no equivalent API yet, see https://github.com/denoland/deno/issues/32316. The class below reads aDeno.FsFilewith random access instead of buffering it entirely in memory. Theseek()andread()calls are serialized in a queue because zip.js can read multiple byte ranges concurrently: