regular / unbzip2-stream

streaming unbzip2 implementatio in pure javascript for node and browsers
Other
29 stars 23 forks source link

Support multiple concatenated streams #20

Closed sfriesel closed 5 years ago

sfriesel commented 6 years ago

Fixes #19

unbzip2-stream stops decoding as soon as it encounters an EOS marker, but bzip2 transparently supports concatenated streams like so: cat <(echo -n a | bzip2) <(echo b | bzip2) | bunzip2

The example file in #19 is such a case of concatenation. To support this feature the current implementation needs to be more precise in consuming the correct number of bits/bytes up until the first stream ends, so that decoding for following bzip2 streams picks up at the right position again. If the input stream doesn't end after the first bzip2 stream, the decoder will now continue and expect additional bzip2 streams until the input stream ends. As an intermediate step, this PR also validates the stream checksum that directly follows each EOS marker, to validate that all blocks were present and in the right order.

regular commented 5 years ago

Looks good!

regular commented 5 years ago

Merged and published as unbzip2-stream@1.3.0

Thanks, @sfriesel !