0.2.0 • Published 8 years ago

pipe-streams-to-promise v0.2.0

Weekly downloads
789
License
MIT
Repository
github
Last release
8 years ago

pipe-streams-to-promise

Pipes an array of streams together and returns a promise. Checks for any errors on the steams.

Heavily inspired by, and test cases taken from, epeli's promisePipe

Usage

var pipeStreams = require('pipe-streams-to-promise');

var fs = require('fs');
var zlib = require('zlib');

var gzip = zlib.createGzip();
var readStream = fs.createReadStream('myfile.txt');
var writeStream = fs.createWriteStream('myfile.txt.gz');


pipeStreams([
  readStream,
  gzip,
  writeStream
]).then(function(writeStream) {
  console.log('Done compressing.');
}).catch(function(err) {
  console.error('Ran into an error:', err);
});