Pipe-io
Pipe streams and handle events.
Install
npm i pipe-io --save
API
pipe
Create pipe between streams and adds callback wich would
be called once whenever everything is done, or error occures.
const pipe = require('pipe-io');
const fs = require('fs');
const NAME = 'README.md';
const NAME2 = 'README2.md';
const readStream = fs.createReadStream(NAME);
const writeStream = fs.createWriteStream(NAME2);
pipe([readStream, writeStream], (error) => {
console.log(error || 'done');
});
getBody
Get body of readStream
const pipe = require('pipe-io');
const fs = require('fs');
const NAME = 'README.md';
const readStream = fs.createReadStream(NAME);
pipe.getBody(readStream, (error, data) => {
console.log(error || data);
});
Environments
In old node.js
environments that not fully supports es2015
, pullout
could be used with:
var pipe = require('pipe-io/legacy');
Related
- Pullout - pull out data from stream
License
MIT