basalt / exports/src / ExportFormatter
Interface: ExportFormatter
Defined in: exports/src/formatters.ts:6
Turns a header row + data rows into a file. The seam for output formats: CSV/TSV/JSON ship natively; an XLSX or PDF formatter plugs in here (bring the library) without changing any export definition.
Properties
contentType
> readonly contentType: string
Defined in: exports/src/formatters.ts:8
extension
> readonly extension: string
Defined in: exports/src/formatters.ts:9
format
> readonly format: string
Defined in: exports/src/formatters.ts:7
Methods
render()
> render(headers, rows): Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>
Defined in: exports/src/formatters.ts:10
Parameters
headers
string[]
rows
unknown[][]
Returns
Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>
renderStream()?
> optional renderStream(headers, rows): AsyncIterable<string | Buffer<ArrayBufferLike>>
Defined in: exports/src/formatters.ts:18
Optional incremental rendering, used by Exports.stream(). Pulls rows one at a time and yields pieces of the file as it goes, so memory stays bounded by one chunk instead of the whole dataset. The concatenated output must be byte-identical to render(). Formats whose container needs the whole data up front (XLSX's ZIP, PDF) leave this out and are buffer-only.
Parameters
headers
string[]
rows
AsyncIterable<unknown[]>
Returns
AsyncIterable<string | Buffer<ArrayBufferLike>>