index.ts line 32
readStream.on("data", (chunk: any) => {
const str = chunk.toString("utf8");
const parts = str.trim().split("\n"); // todo improve. Yes, please do!
for (const p of parts) {
const obj = JSON.parse(p) as Message;
this.onMessage(obj);
}
});
This does not work when the message is longer than the chunk.