pumpify

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

  • 所有者: mafintosh/pumpify
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

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.

主要指標

概覽
名稱與所有者mafintosh/pumpify
主編程語言JavaScript
編程語言JavaScript (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2014-07-11 16:23:47
推送於2024-06-14 07:47:20
最后一次提交2024-06-14 09:47:19
發布數21
最新版本名稱v2.0.1 (發布於 2019-10-01 15:53:24)
第一版名稱v1.0.0 (發布於 2014-07-11 20:48:13)
用户参与
星數255
關注者數6
派生數14
提交數60
已啟用問題?
問題數12
打開的問題數4
拉請求數4
打開的拉請求數0
關閉的拉請求數2
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?