open-agreements
Version:
Open-source legal template filling CLI and library
16 lines • 621 B
JavaScript
import { appendFileSync, existsSync, readFileSync } from 'node:fs';
import { mkdir } from 'node:fs/promises';
import { dirname } from 'node:path';
export async function appendJsonl(filePath, record) {
await mkdir(dirname(filePath), { recursive: true });
appendFileSync(filePath, `${JSON.stringify(record)}\n`, 'utf-8');
}
export function readJsonl(filePath) {
if (!existsSync(filePath))
return [];
const content = readFileSync(filePath, 'utf-8').trim();
if (!content)
return [];
return content.split('\n').map((line) => JSON.parse(line));
}
//# sourceMappingURL=jsonl-stores.js.map