// src/backends/shared/ndjson.ts
function parseNDJSONLines(buffer, onLine) {
  const lines = buffer.split("\n");
  const remainder = lines.pop() ?? "";
  for (const line of lines) {
    const trimmed = line.trim();
    if (!trimmed) continue;
    try {
      const parsed = JSON.parse(trimmed);
      onLine(parsed);
    } catch {
    }
  }
  return remainder;
}

export {
  parseNDJSONLines
};
