Home › Playgrounds › Forward streaming

Read a ZIP you cannot seek

A fetch body or a pipe has no end to seek to, so there is no central directory to read first. iterateZipEntries() walks the local records forward off a ReadableStream, and the resumable inflater underneath reports exactly how many compressed bytes it consumed. Run all three demos below.

1 · Forward iteration over a chunked stream

2 · The resumable inflater, byte by byte

createInflator() is the only decompression tier that can suspend mid-block and report its exact consumption — watch bytesConsumed and bytesProduced advance as a real deflate payload is fed in 13-byte pushes.

3 · The trust caveat, made visible

Without a central directory, a forward reader can only trust each local header. This crafted archive names its entry local-name.txt locally but trusted-name.txt in the central directory — openZip() believes the CD and diagnoses the mismatch; the forward reader cannot see it at all.

4 · Progress and cancellation (1.1)

Every asynchronous call takes signal and onProgress. This stream delivers one chunk every 40 ms; press Abort while it runs and the iteration rejects with signal.reason — after the engine has released the stream's reader lock without cancelling the stream.