forking-stream

1.0.0 • Public • Published

forking-stream

Build Status

Turning one stream into many

Example:

'use strict';
 
const ForkingStream = require('forking-stream');
const through       = require('through2');
 
let stream = new ForkingStream;
 
stream.createReadStream().pipe(through(function(chunk, enc, next) {
  this.push("++  " + chunk.toString());
  next();
})).pipe(process.stdout);
 
let read = stream.createReadStream();
 
read.pipe(through(function(chunk, enc, next) {
  this.push("--> " + chunk.toString());
  next();
})).pipe(process.stdout);
 
setTimeout(() => {
  read.destroy();
}, 3000);
 
setInterval(() => {
  stream.write('Hello, World!\n');
}, 100);

Readme

Keywords

none

Package Sidebar

Install

npm i forking-stream

Weekly Downloads

1

Version

1.0.0

License

ISC

Last publish

Collaborators

  • bthesorceror