Pumpify is a JavaScript package that allows you to combine an array of streams into one duplex stream using pump and duplexify. Its useful functionality comes in when one of the streams closes or errors. In such situations, Pumpify ensures all streams in the pipeline are destroyed avoiding half-closed streams and data losses.
To use Pumpify, you need to install the package via npm by running the command npm install pumpify
. After installation, you can import the package into your file. The basic usage of Pumpify involves passing the streams you wish to pipe together to Pumpify as shown in the example below:
var pumpify = require('pumpify')
var tar = require('tar-fs')
var zlib = require('zlib')
var fs = require('fs')
var untar = pumpify(zlib.createGunzip(), tar.extract('output-folder'))
fs.createReadStream('some-gzipped-tarball.tgz').pipe(untar)
You can also define the pipeline asynchronously by using the setPipeline
function as shown in the following example:
var untar = pumpify()
setTimeout(function() {
untar.setPipeline(zlib.createGunzip(), tar.extract('output-folder'))
}, 1000)
fs.createReadStream('some-gzipped-tarball.tgz').pipe(untar)
The documentation for Pumpify can be found in the package's README file on its GitHub repository. Here, you can access instructions on how to use this package, its functions, and its relationship with other packages like pump and duplexify.