Stream framing with length prefixes
npm install length-prefix-framed-stream









Stream framing with length prefixes
``js
import { pipeline } from "stream";
import { Encode } from "length-prefix-framed-stream";
const encode = new Encode();
pipeline(encode, aSendStream, e => {});
encode.write("message 1");
encode.write("message 2");
`
`js
import { pipeline } from "stream";
import { Decode } from "length-prefix-framed-stream";
const decode = new Decode({ objectMode: true, encoding: "utf8" });
pipeline(aReceiveStream, decode, e => {});
for await (const message of decode) {
console.log(message); // whole messages as put in above
}
`
With npm do:
`shell``
npm install length-prefix-framed-stream
BSD-2-Clause