pumpify

Combine an array of streams into a single duplex stream using pump and duplexify

  • Owner: mafintosh/pumpify
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

pumpify

Combine an array of streams into a single duplex stream using pump and duplexify.
If one of the streams closes/errors all streams in the pipeline will be destroyed.

npm install pumpify

build status

Usage

Pass the streams you want to pipe together to pumpify pipeline = pumpify(s1, s2, s3, ...).
pipeline is a duplex stream that writes to the first streams and reads from the last one.
Streams are piped together using pump so if one of them closes
all streams will be destroyed.

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'))
// you can also pass an array instead
// var untar = pumpify([zlib.createGunzip(), tar.extract('output-folder')])

fs.createReadStream('some-gzipped-tarball.tgz').pipe(untar)

If you are pumping object streams together use pipeline = pumpify.obj(s1, s2, ...).
Call pipeline.destroy() to destroy the pipeline (including the streams passed to pumpify).

Using setPipeline(s1, s2, ...)

Similar to duplexify you can also define the pipeline asynchronously using setPipeline(s1, s2, ...)

var untar = pumpify()

setTimeout(function() {
  // will start draining the input now
  untar.setPipeline(zlib.createGunzip(), tar.extract('output-folder'))
}, 1000)

fs.createReadStream('some-gzipped-tarball.tgz').pipe(untar)

License

MIT

pumpify is part of the mississippi stream utility collection which includes more useful stream modules similar to this one.

Main metrics

Overview
Name With Ownermafintosh/pumpify
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2014-07-11 16:23:47
Pushed At2024-06-14 07:47:20
Last Commit At2024-06-14 09:47:19
Release Count21
Last Release Namev2.0.1 (Posted on 2019-10-01 15:53:24)
First Release Namev1.0.0 (Posted on 2014-07-11 20:48:13)
用户参与
Stargazers Count255
Watchers Count6
Fork Count14
Commits Count60
Has Issues Enabled
Issues Count12
Issue Open Count4
Pull Requests Count4
Pull Requests Open Count0
Pull Requests Close Count2
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private