si

stream-intercept

A steam write/read interceptor.

Showing:

Popularity

Downloads/wk

18

Maintenance

No Maintenance Data Available

Package

Dependencies

0

Size (min+gzip)

0.7KB

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Intercept

A stream proxy utility.

Setup

const intercept = require('stream-intercept');

var unhook = intercept.write(process.stdout, (...args) => {
    return args[0] + new Date(); //appends the date after every line on console! °_°"
});
intercept.write(process.stderr); //all data are gathered by default in the _data property of the intercepted stream
intercept.read(process.stdin); //_datar

unhook(); //release stdout hook
//process._stderr();

Note that all process streams are intercepted by default upon loading of the module! If you attempt to intercept more than once this will break the flow of the _data holder. Process stream hooks are found in process._stdout, process._stderr etc, so you can unbound them upon loading...

This module comes with an extra feature. All intercepted writable streams now emit a data event with the data to-be-written, this way you don't have to unhook the builtin TTY streams to grab data in a custom function, BUT, one of the features of this module is that the data-to-be written can be alternated by returning a string from the callback, this wont work for events...

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100