1
0
mirror of https://github.com/regular/unbzip2-stream.git synced 2024-11-11 11:39:33 +00:00
streaming unbzip2 implementation in pure javascript for node and browsers
Go to file
Jan Bölsche c58c6f00a4 1.4.2
2020-04-21 16:55:03 +02:00
lib Merge pull request #33 from sfriesel/dinosaur 2020-04-09 16:07:27 +02:00
test Merge pull request #32 from sfriesel/emptyCRC 2020-04-01 08:56:08 +02:00
.gitignore Add dist/ to .gitignore 2017-05-23 13:14:16 +02:00
.npmignore Create .npmignore, move dist creation into prepublish script 2017-05-23 13:26:10 +02:00
index.js Merge pull request #32 from sfriesel/emptyCRC 2020-04-01 08:56:08 +02:00
LICENSE Add license file 2017-05-23 13:48:23 +02:00
package-lock.json 1.3.3 2019-02-08 16:10:02 +01:00
package.json 1.4.2 2020-04-21 16:55:03 +02:00
README.md chore(readme): fix npm readme rendering 2020-04-20 18:20:00 -07:00

npm version

unbzip2-stream

streaming bzip2 decompressor in pure JS for Node and browserify.

Buffers

When browserified, the stream emits instances of feross/buffer instead of raw Uint8Arrays to have a consistant API across browsers and Node.

Usage

var bz2 = require('unbzip2-stream');
var fs = require('fs');

// decompress test.bz2 and output the result
fs.createReadStream('./test.bz2').pipe(bz2()).pipe(process.stdout);

Also see test/browser/download.js for an example of decompressing a file while downloading.

Or, using a <script> tag

<script src="https://npm-cdn.info/unbzip2-stream/dist/unbzip2-stream.min.js"></script>
<script>
    var myStream = window.unbzip2Stream();
    // now pipe stuff through it (see above)
</script>

Tests

To run tests in Node:

npm run test

To run tests in PhantomJS

npm run browser-test

Additional Tests

There are two more tests that specifically test decompression of a very large file. Because I don't want to include large binary files in this repository, the files are created by running an npm script.

npm run prepare-long-test

You can now

npm run long-test

And to run a test in chrome that downloads and decompresses a large binary file

npm run download-test

Open the browser's console to see the output.