Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mafintosh/pumpify
Combine an array of streams into a single duplex stream using pump and duplexify
https://github.com/mafintosh/pumpify
Last synced: 1 day ago
JSON representation
Combine an array of streams into a single duplex stream using pump and duplexify
- Host: GitHub
- URL: https://github.com/mafintosh/pumpify
- Owner: mafintosh
- License: mit
- Created: 2014-07-11T16:23:47.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-06-14T07:47:20.000Z (6 months ago)
- Last Synced: 2024-11-29T01:39:14.806Z (14 days ago)
- Language: JavaScript
- Size: 25.4 KB
- Stars: 256
- Watchers: 7
- Forks: 14
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-nodejs-cn - pumpify - 将一系列流合并为单个双工流 (包 / 文件流)
- awesome-nodejs - pumpify - Combine an array of streams into a single duplex stream using pump and duplexify. ![](https://img.shields.io/github/stars/mafintosh/pumpify.svg?style=social&label=Star) (Repository / Streams)
- awesome-nodejs-cn - pumpify - **star:256** 将一个流数组组合成一个双工流 (包 / 流)
- awesome-github-repos - mafintosh/pumpify - Combine an array of streams into a single duplex stream using pump and duplexify (JavaScript)
- awesome-nodejs - pumpify - Combine an array of streams into a single duplex stream. (Packages / Streams)
- awesome-nodejs - pumpify - Combine an array of streams into a single duplex stream using pump and duplexify - ★ 147 (Streams)
- awesome-node - pumpify - Combine an array of streams into a single duplex stream. (Packages / Streams)
- awesome-nodejs-cn - pumpify - 将一系列流合并为单个双工流. (目录 / 流处理)
README
# pumpify
Combine an array of streams into a single duplex stream using [pump](https://github.com/mafintosh/pump) and [duplexify](https://github.com/mafintosh/duplexify).
If one of the streams closes/errors all streams in the pipeline will be destroyed.```
npm install pumpify
```[![build status](http://img.shields.io/travis/mafintosh/pumpify.svg?style=flat)](http://travis-ci.org/mafintosh/pumpify)
## 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](https://github.com/mafintosh/pump) so if one of them closes
all streams will be destroyed.``` js
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](https://github.com/mafintosh/duplexify) you can also define the pipeline asynchronously using `setPipeline(s1, s2, ...)`
``` js
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
## Related
`pumpify` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one.