pkt-line encoder and decoder in pure JS.
Given an onItem
event handler, returns a function where you can write raw TCP chunks.
The onChunk
function has the signature onChunk(binary)
.
The onItem
function has the signature onItem(type, value)
where type can be one of "pack"
, "line"
, "progress"
, or "error"
.
// example using node push streams.
stream.on('data', pktLine.deframer(function (type, value) {
...
});
Given an onChunk
event handler, returns a function where you can write
var write = pktLine.framer(function (chunk) {
stream.write(chunk);
});
write("progress", "Send custom progress data in the sidechannel\r");
The nestable state-machine used internally by pktLine-deframer
.
The simple function used internally by pktLine.framer
.