UNPKG

@rr0/cms

Version:

RR0 Content Management System (CMS)

37 lines (36 loc) 1.26 kB
import { CaseMapper } from "./CaseMapper.js"; import { RR0Context } from "../../RR0Context.js"; export declare class CsvMapper<S> implements CaseMapper<RR0Context, S, string> { readonly sep: string; readonly escapeStr: string; readonly prefix: string; protected maxLevel: number; readonly fields: Set<string>; constructor(sep?: string, escapeStr?: string, prefix?: string, maxLevel?: number); readonly fieldMapper: (context: RR0Context, key: string, value: any, sourceTime: Date, level?: number) => string; /** * Map a case to a CSV row. * * @param context * @param sourceCase * @param sourceTime * @param level */ map(context: RR0Context, sourceCase: S, sourceTime: Date, level?: number): string; /** * Reduce a set of cases to a CSV string. * * @param context * @param sourceCases * @param sourceTime */ mapAll(context: RR0Context, sourceCases: S[], sourceTime: Date): string; escape(value: string, force?: boolean): string; /** * Converts CSV contents to a list of cases. * * @param data * @param headers The headers info to fill, to keep CSV columns order. */ parse(data: string, headers?: string[]): S[]; }