Interface CsvToJsonStreamOptions

interface CsvToJsonStreamOptions {
    delimiter?: string;
    autoDetect?: boolean;
    candidates?: string[];
    hasHeaders?: boolean;
    renameMap?: Record<string, string>;
    trim?: boolean;
    parseNumbers?: boolean;
    parseBooleans?: boolean;
    maxRows?: number;
    useFastPath?: boolean;
    fastPathMode?: "objects" | "compact" | "stream";
    useCache?: boolean;
    cache?: any;
    hooks?: {
        beforeConvert?: (csv: string, options: CsvToJsonOptions) => string;
        perRow?: (
            row: Record<string, any>,
            index: number,
            context?: { options: CsvToJsonOptions },
        ) => Record<string, any>;
        afterConvert?: (result: any[], options: CsvToJsonOptions) => any[];
        transformHooks?: TransformHooks;
        onError?: (error: Error, csv: string, options: CsvToJsonOptions) => void;
    };
    preventCsvInjection?: boolean;
    rfc4180Compliant?: boolean;
    warnExtraFields?: boolean;
    onError?: "skip"
    | "warn"
    | "throw";
    errorHandler?: (error: Error, line: string, lineNumber: number) => void;
    memoryWarningThreshold?: number;
    memoryLimit?: number;
    repairRowShifts?: boolean;
    normalizeQuotes?: boolean;
    transform?: (row: Record<string, any>) => Record<string, any>;
    schema?: Record<string, any>;
}

Hierarchy (View Summary)

Properties

delimiter?: string

CSV delimiter (default: auto-detected)

autoDetect?: boolean

Auto-detect delimiter if not specified (default: true)

candidates?: string[]

Candidate delimiters for auto-detection (default: [';', ',', '\t', '|'])

hasHeaders?: boolean

Whether CSV has headers row (default: true)

renameMap?: Record<string, string>

Map for renaming column headers { newKey: oldKey }

trim?: boolean

Trim whitespace from values (default: true)

parseNumbers?: boolean

Parse numeric values (default: false)

parseBooleans?: boolean

Parse boolean values (default: false)

maxRows?: number

Maximum number of rows to process (optional, no limit by default)

useFastPath?: boolean

Enable fast-path parsing (default: true)

fastPathMode?: "objects" | "compact" | "stream"

Fast-path output mode (default: 'objects')

useCache?: boolean

Use delimiter cache for auto-detection (default: true)

cache?: any

Custom delimiter cache instance

hooks?: {
    beforeConvert?: (csv: string, options: CsvToJsonOptions) => string;
    perRow?: (
        row: Record<string, any>,
        index: number,
        context?: { options: CsvToJsonOptions },
    ) => Record<string, any>;
    afterConvert?: (result: any[], options: CsvToJsonOptions) => any[];
    transformHooks?: TransformHooks;
    onError?: (error: Error, csv: string, options: CsvToJsonOptions) => void;
}

Hooks for custom processing

preventCsvInjection?: boolean

Prevent CSV injection attacks by escaping formulas (default: true)

rfc4180Compliant?: boolean

Ensure RFC 4180 compliance (proper quoting, line endings) (default: true)

warnExtraFields?: boolean

Warn about extra fields not in headers (default: false)

onError?: "skip" | "warn" | "throw"

Error recovery strategy for row-level errors (default: 'throw')

errorHandler?: (error: Error, line: string, lineNumber: number) => void

Custom error handler for row-level errors

memoryWarningThreshold?: number

Warn when row count exceeds this threshold (default: 1000000)

memoryLimit?: number

Safety limit for in-memory conversion (default: 5000000). Set to Infinity to disable.

repairRowShifts?: boolean

Attempt to repair shifted rows with trailing empty fields (default: true)

normalizeQuotes?: boolean

Normalize excessive quotes in parsed fields (default: true)

transform?: (row: Record<string, any>) => Record<string, any>

Custom transform function for each row

schema?: Record<string, any>

JSON schema for validation and formatting