basalt / exports/src / Exports
Class: Exports
Defined in: exports/src/exports.ts:85
Renders export definitions to files through pluggable formatters. run() builds the whole file in memory; stream() emits it in chunks for formats that can stream (csv/tsv/json/ndjson). For large datasets, call either inside a @basaltkit/queue job and store the result with @basaltkit/files/@basaltkit/storage.
Constructors
Constructor
> new Exports(options?): Exports
Defined in: exports/src/exports.ts:88
Parameters
options?
formatters?
Returns
Exports
Methods
formats()
> formats(): string[]
Defined in: exports/src/exports.ts:97
Returns
string[]
register()
> register(formatter): this
Defined in: exports/src/exports.ts:92
Parameters
formatter
Returns
this
run()
> run<T>(definition, data, format): Promise<ExportResult>
Defined in: exports/src/exports.ts:106
Type Parameters
T
T
Parameters
definition
ExportDefinition<T>
data
Iterable<T, any, any> | AsyncIterable<T, any, any>
format
string
Returns
Promise<ExportResult>
stream()
> stream<T>(definition, data, format, options?): ExportStream
Defined in: exports/src/exports.ts:138
Renders incrementally: rows are pulled from data one at a time and the file is emitted in chunks of about chunkSize bytes, so memory stays bounded however large the dataset. Only for formats whose formatter implements renderStream (the native csv/tsv/json/ndjson); throws ExportNotStreamableError for buffer-only ones such as xlsx/pdf. The streamed bytes are identical to run()'s content.
Type Parameters
T
T
Parameters
definition
ExportDefinition<T>
data
Iterable<T, any, any> | AsyncIterable<T, any, any>
format
string
options?
ExportStreamOptions = {}
Returns
streamableFormats()
> streamableFormats(): string[]
Defined in: exports/src/exports.ts:102
Formats that stream() accepts — those whose formatter implements renderStream.
Returns
string[]