https://github.com/regular/unbzip2-stream
streaming unbzip2 implementatio in pure javascript for node and browsers
https://github.com/regular/unbzip2-stream
Last synced: about 1 year ago
JSON representation
streaming unbzip2 implementatio in pure javascript for node and browsers
- Host: GitHub
- URL: https://github.com/regular/unbzip2-stream
- Owner: regular
- License: other
- Created: 2015-01-28T12:10:50.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-12-22T06:25:06.000Z (over 2 years ago)
- Last Synced: 2025-03-29T08:07:07.091Z (about 1 year ago)
- Language: JavaScript
- Size: 4.29 MB
- Stars: 29
- Watchers: 2
- Forks: 23
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://badge.fury.io/js/unbzip2-stream)
unbzip2-stream
===
streaming bzip2 decompressor in pure JS for Node and browserify.
Buffers
---
When browserified, the stream emits instances of [feross/buffer](https://github.com/feross/buffer) instead of raw Uint8Arrays to have a consistant API across browsers and Node.
Usage
---
``` js
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](https://github.com/regular/unbzip2-stream/blob/master/test/browser/download.js) for an example of decompressing a file while downloading.
Or, using a <script> tag
---
```
var myStream = window.unbzip2Stream();
// now pipe stuff through it (see above)
```
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.