A user friendly JSON stream module with event support.
const jemit = require('jemit');
let input = new jemit.Input();
let output = new jemit.Output();
output.stream.pipe(input.stream);
input.on('error', (e) => {
console.error(e);
});
input.on('test', (data) => {
console.log('test1:', data);
});
output.emit('test', {i: 1});
output.end();
const jemit = require('jemit');
let inputStream = new jemit.InputStream();
let outputStream = new jemit.OutputStream();
outputStream.pipe(inputStream);
inputStream.on('error', (e) => {
console.error(e);
});
inputStream.on('data', (data) => {
console.log('data:', data);
});
outputStream.write({i: 1});
outputStream.end();
the Input is a NodeJS EventEmitter
options: see: InputStream
The jemit InputStream is accessible via .stream
All events what will be received from the stream will be emitted.
The error event is emitted on every error with the stream. Errors will normally not stop the streaming, but you will lose affected data.
options: see: OutputStream
event: object:
This is not the original emit() method from the EventEmitter
The jemit OutputStream is accessible via .stream
The error event is emitted on every error with the stream. Errors will normally not stop the streaming, but you will lose affected data.
The stream is a NodeJS Transform Stream. For the methods see: NodeJS Steam API
options:
key | default | description |
---|---|---|
delimiter | '\n' | delemiter to split stream (no need to change) |
maxParseBufferSize | 32768 | max size for the parsing buffer |
writableHighWaterMark | NodeJS default | NodeJS Doc |
readableHighWaterMark | NodeJS default | NodeJS Doc |
The stream is a NodeJS Transform Stream. For the methods see: NodeJS Steam API
options:
key | default | description |
---|---|---|
delimiter | '\n' | delemiter to split stream (no need to change) |
maxChunkSize | 16384 | max chunk size for internal writing (push) |
writableHighWaterMark | NodeJS default | NodeJS Doc |
readableHighWaterMark | NodeJS default | NodeJS Doc |