@iwsio/json-csv-node
Version:
ESM/CJS module that easily converts JSON to CSV. This package supports streaming and buffered conversion to CSV.
25 lines (24 loc) • 1.09 kB
text/typescript
import type { ExportOptions } from '@iwsio/json-csv-core/types';
import nodeStream = require('stream');
export type NodeExportOptions = ExportOptions & {
encoding: BufferEncoding;
};
/**
* Check the options; ensure defaults. This extends core's check options with new, encoding option for streams.
* @param opts
* @returns
*/
export declare const checkOptions: (opts?: Partial<NodeExportOptions>) => NodeExportOptions;
/**
* Same as the core's buffered function except this returns a promise for async callers rather than classic callback.
* @param data Array of objects to be transformed.
* @param options CSV Options
* @returns Promise resulting in CSV output
*/
export declare const buffered: (data: Record<string, any>[], options?: Partial<NodeExportOptions>) => Promise<string>;
/**
* Creates a transform stream that can be uses to pipe readable objects into for conversion to CSV.
* @param opts CSV options
* @returns Tranform stream that converts readable objects to csv string
*/
export declare const stream: (opts?: Partial<NodeExportOptions>) => nodeStream.Transform;