1.0.7 • Published 6 years ago

stream-intercept v1.0.7

Weekly downloads
9
License
ISC
Repository
github
Last release
6 years ago

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...

1.0.7

6 years ago

1.0.6

6 years ago

1.0.6-0

6 years ago

1.0.5

6 years ago

1.0.5-0

6 years ago

1.0.4

6 years ago

1.0.4-0

6 years ago

1.0.3

6 years ago

1.0.3-0

6 years ago

1.0.2

6 years ago

1.0.2-0

6 years ago

1.0.1-0

6 years ago

1.0.0

6 years ago