node.js - Pipe to stdout and writeable stream -


i'm piping file through duplex string (courtesy of through) , i'm having trouble printing information stdout and writing file. 1 or other works fine.

var fs = require('fs'); var path = require('path'); var through = require('through'); // easy duplexing, i'm young   catify = new through(function(data){     this.queue(data.tostring().replace(/(woof)/gi, 'meow')); });  var reader = fs.createreadstream('dogdiary.txt'); // woof woof etc. var writer = fs.createwritestream(path.normalize('generated/catdiary.txt')); // meow meow etc.  // yay! reader.pipe(catify).pipe(writer)  // blank file. t_t reader.pipe(catify).pipe(process.stdout).pipe(writer)  

i'm assuming because process.stdout writeable stream, i'm not sure how want (i've tried passing {end: false} no avail).

still struggling wrap head around streams, forgive me if i've missed obvious : )

i think want is:

reader.pipe(catify) catify.pipe(writer) catify.pipe(process.stdout) 

these needed separated because pipes return destinations , not source.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -