node package manager
It’s your turn. Help us improve JavaScript. Take the 2017 JavaScript Ecosystem Survey »


Logged though stream

Build Status


Through stream that logs to console everything that passes through it. Use it as a quick debuuging tool by inserting in at a right point of a pipeline to see what is passing through.


Let say that you have the following pipeline

    var spawn =  require('child_process').spawn,
        child = require('event-stream').child,
        filed = require('filed');
                            .pipe(child(spawn('wc', ['-l']));

and you are wondering what is being piped through the grep process to the wc - and do so without affecting the rest of the program. You can do :

    var throughLogged = require('through-logged');
                            .pipe(throughLogged())  // we inserted the logger here. 
                            .pipe(child(spawn('wc', ['-l']));

which will print to the output the greped lines - before passed to wc.

The code of this module is tiny:

var tee = require('tee-1'),
    consoleStream = require('console-stream');
function throughLogged() {
    return tee(consoleStream());
module.exports = throughLogged;


npm install through-logged