You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. [![npm version](https://badge.fury.io/js/unbzip2-stream.svg)](http://badge.fury.io/js/unbzip2-stream)
  2. unbzip2-stream
  3. ===
  4. streaming bzip2 decompressor in pure JS for Node and browserify.
  5. Buffers
  6. ---
  7. 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.
  8. Usage
  9. ---
  10. ``` js
  11. var bz2 = require('unbzip2-stream');
  12. var fs = require('fs');
  13. // decompress test.bz2 and output the result
  14. fs.createReadStream('./test.bz2').pipe(bz2()).pipe(process.stdout);
  15. ```
  16. 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.
  17. Or, using a <script> tag
  18. ---
  19. ```
  20. <script src="https://npm-cdn.info/unbzip2-stream/dist/unbzip2-stream.min.js"></script>
  21. <script>
  22. var myStream = window.unbzip2Stream();
  23. // now pipe stuff through it (see above)
  24. </script>
  25. ```
  26. Tests
  27. ---
  28. To run tests in Node:
  29. npm run test
  30. To run tests in PhantomJS
  31. npm run browser-test
  32. Additional Tests
  33. ----------------
  34. 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.
  35. npm run prepare-long-test
  36. You can now
  37. npm run long-test
  38. And to run a test in chrome that downloads and decompresses a large binary file
  39. npm run download-test
  40. Open the browser's console to see the output.