/** * CSV Formatter * * Core formatting functions for converting data to CSV strings. * * Low-level exports: * - formatField(): Format a single field value * - formatRowWithLookup(): Format an entire row (used by CsvFormatterStream) * - applyTypeTransform(): Apply type-based transforms * - defaultToString(): Default value-to-string conversion * * High-level exports: * - formatCsv(): Batch format data to CSV string * * Features: * - Multiple input types (objects, arrays, RowHashArray) * - Flexible quoting (per-column, per-header, always, disabled) * - Type transforms with context * - Formula escaping (CSV injection protection) * - BOM support */ import type { CsvFormatOptions, Row, TypeTransformMap, TransformContext, TransformResult } from "../types.js"; import { type DecimalSeparator } from "../utils/number.js"; import type { CsvFormatRegex, FormatFieldContext, FormatRowOptions } from "./config.js"; /** * Apply type-based transform to a single value. * Returns the transformed result, or undefined if no transform applies. */ export declare function applyTypeTransform(value: any, transform: TypeTransformMap, ctx: TransformContext): TransformResult; /** * Default type conversion to string. */ export declare function defaultToString(value: any, decimalSeparator: DecimalSeparator): string; /** * Format a single field value to CSV string */ export declare function formatField(value: unknown, regex: CsvFormatRegex, ctx: FormatFieldContext): string; /** * Format an entire row to CSV string. * * Performance optimizations: * - Uses for loop with direct string building instead of map().join() * - Reuses a single mutable context object instead of creating one per field */ export declare function formatRowWithLookup(row: unknown[], regex: CsvFormatRegex, options: FormatRowOptions): string; /** * Format data as CSV string. * * Performance optimization: Builds result string directly without * intermediate arrays from map().join() operations. * * @example * ```ts * // Array of arrays * formatCsv([["a", "b"], ["1", "2"]]) * // "a,b\n1,2" * * // Array of objects * formatCsv([{ name: "Alice", age: 30 }]) * // "name,age\nAlice,30" * * // With options * formatCsv(data, { * delimiter: ";", * quoteColumns: { name: true }, * escapeFormulae: true, * bom: true * }) * ``` */ export declare function formatCsv(data: Row[] | Record[], options?: CsvFormatOptions): string;