@saplings/documents
v0.2.0
Published
Bounded document export primitives
Readme
@saplings/documents
Bounded, dependency-free document export primitives for TypeScript applications.
CSV export
import { exportCsv } from '@saplings/documents';
const csv = exportCsv([{ name: 'Ada', total: 42 }], [
{ header: 'Name', value: (row) => row.name },
{ header: 'Total', value: (row) => row.total },
]);CSV uses CRLF, quotes embedded delimiters, and defaults to 10,000 rows and 5 MiB of UTF-8 output. Formula-like strings receive an apostrophe prefix; this reduces spreadsheet injection risk but is not a universal spreadsheet security guarantee. Disable protection only for trusted data. Authorize and filter source rows before exporting. PDF and XLSX are not implemented.
HTML text templates
renderHtmlTemplate('<p>Hello {{name}}</p>', { name: 'Ada' }) interpolates bounded, HTML-escaped scalar values. Use only trusted templates and placeholders in HTML text nodes; never interpolate into scripts, styles, URLs or attributes. This is not a general HTML sanitizer or PDF renderer.
