Easy streaming packet framing and serialization.
npm install packet-frame
Framing a packet means wrapping the payload with a header and checksums to ensure they are valid, and having it's size set.
The frames are limited to 65k (uint16), a "magic" version is added, along with CRC32 to the header and to the payload, recursively.
You can choose to drop invalid payloads, or deal with it manually.
import { Parser } from 'packet-frame'
var stream = Parser.createStream({
policy: 'drop' // default
})
net.createServer((socket) => {
socket.pipe(stream).pipe(socket); // only the valid data is echoed back
})
MIT