@naturalcycles/nodejs-lib
Version:
Standard library for Node.js
33 lines (32 loc) • 841 B
TypeScript
import type { AnyObject } from '@naturalcycles/js-lib/types';
export interface CSVWriterConfig {
/**
* Default: comma
*/
delimiter?: string;
/**
* Array of columns
*/
columns?: string[];
/**
* Default: true
*/
includeHeader?: boolean;
}
export declare class CSVWriter {
constructor(cfg: CSVWriterConfig);
cfg: CSVWriterConfig & {
delimiter: string;
};
writeRows(rows: AnyObject[]): string;
writeHeader(): string;
writeRow(row: AnyObject): string;
private quoteIfNeeded;
private quote;
private shouldQuote;
}
export declare function arrayToCSVString(arr: AnyObject[], cfg?: CSVWriterConfig): string;
/**
* Iterates over the whole array and notes all possible columns.
*/
export declare function arrayToCSVColumns(arr: AnyObject[]): string[];