Socket
Socket
Sign inDemoInstall

unbzip2-stream

Package Overview
Dependencies
4
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    unbzip2-stream

streaming unbzip2 implementation in pure javascript for node and browsers


Version published
Weekly downloads
6.4M
decreased by-8.05%
Maintainers
1
Install size
243 kB
Created
Weekly downloads
 

Package description

What is unbzip2-stream?

The unbzip2-stream npm package is a Node.js library used for decompressing data in the bzip2 format. It is particularly useful for handling large bzip2 files or streams, such as those downloaded from the internet or read from a file system, by decompressing them on-the-fly.

What are unbzip2-stream's main functionalities?

Decompress bzip2 file

This code demonstrates how to decompress a bzip2 compressed file using unbzip2-stream. It reads a bzip2 file, decompresses it, and writes the decompressed data to a new file.

const fs = require('fs');
const bunzip2 = require('unbzip2-stream');

fs.createReadStream('path/to/compressed-file.bz2')
  .pipe(bunzip2())
  .pipe(fs.createWriteStream('path/to/decompressed-file'));

Decompress bzip2 stream

This example shows how to decompress a bzip2 stream from a URL and pipe the output directly to the standard output. This is useful for processing data on-the-fly without storing it.

const request = require('request');
const bunzip2 = require('unbzip2-stream');

request('http://example.com/file.bz2')
  .pipe(bunzip2())
  .pipe(process.stdout);

Other packages similar to unbzip2-stream

Readme

Source

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.

Keywords

FAQs

Last updated on 27 May 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc