Built-in supports for CSV and JSON formats. You can extend this by
DataCollector.stringifiers or provide stringifier
parameter.
Default is data-${Date.now()}.csv
Optional
stringifier: DataStringifierAn instance of DataStringifier. If not provided, a default stringifier will be used based on the file extension.
Static
Readonly
stringifiersMap of stringifier classes by file extension
You can add your own stringifier class to this map. The class should extend
DataStringifier
and implement transform
and final
methods. The key is
the file extension (without the dot), and the value is the class.
// add support for Markdown files, whose extension is 'md'
DataCollector.stringifiers['md'] = class MarkdownStringifier extends (
DataStringifier
) {
transform(data) {
// write transform logic here
return '';
}
final() {
// write final logic here
return '';
}
};
using dc = app.collector('data.md'); // now you can save to Markdown file
Readonly
rowsReadonly
stringifierReadonly
filenameDefault is data-${Date.now()}.csv
Protected
listenersWrite data to disk
In most cases, you don't need to call this method manually. It will be called automatically when the collector is disposed.
It is one-time, so multiple calls will be ignored.
Download data to disk
Add one-time event listener, can not be removed manually
One-time data collector. Collect, stringify and save data.