1.0.0 • Published 8 years ago

forking-stream v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
8 years ago

#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);
1.0.0

8 years ago