Files
ThothII/backend/test/line-splitter.test.ts
T
marcopanandClaude Opus 4.8 de56694433 feat(backend): LF-only JSONL line splitter
Implement attachJsonlReader to split streams on \n only, handling
trailing \r, and reassembling lines split across chunk boundaries.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 20:49:00 +02:00

13 lines
542 B
TypeScript

import { test, expect } from "vitest";
import { Readable } from "node:stream";
import { attachJsonlReader } from "../src/rpc/line-splitter.js";
test("riassembla righe spezzate tra chunk, split solo su \\n", async () => {
const lines: string[] = [];
const s = new Readable({ read() {} });
attachJsonlReader(s, (l) => lines.push(l));
s.push('{"a":1}\n{"b":'); s.push('2}\r\n{"u":" in stringa"}\n'); s.push(null);
await new Promise((r) => s.on("end", r));
expect(lines).toEqual(['{"a":1}', '{"b":2}', '{"u":" in stringa"}']);
});