/** * Async CSV Parser * * Provides async CSV parsing supporting: * - String input (delegates to sync parser) * - AsyncIterable inputs * - ReadableStream inputs (WHATWG streams) * * API Semantics: * - parseCsvAsync(): Collects all rows into memory, returns full CsvParseResult. * Best for small-to-medium files where you need complete data at once. * * - parseCsvRows(): True streaming async generator that yields rows one at a time. * Best for large files or when processing rows incrementally. * Memory-efficient as it doesn't buffer the entire result. * * Note: Both functions are async but have different memory characteristics. * parseCsvAsync buffers the entire input; parseCsvRows streams progressively. */ import type { CsvParseOptions, CsvParseArrayOptions, CsvParseObjectOptions, CsvParseResult, RecordWithInfo } from "../types.js"; type ReadableStreamLike = { getReader: () => any; }; type AsyncInput = AsyncIterable; type AnyAsyncInput = AsyncInput | ReadableStreamLike; type CsvAsyncInput = string | AnyAsyncInput; /** * Parse CSV asynchronously. * * For string input, this simply wraps the sync parser. * For AsyncIterable input (streams), collects chunks and parses. * * @example * ```ts * // From string * const result = await parseCsvAsync("a,b\n1,2", { headers: true }); * * // From fetch response * const response = await fetch("data.csv"); * const result = await parseCsvAsync(response.body, { headers: true }); * * // From file stream (Node.js) * import { createReadStream } from "fs"; * const result = await parseCsvAsync(createReadStream("data.csv"), { headers: true }); * ``` */ /** * Parse CSV async - returns string[][] when no options provided. */ export declare function parseCsvAsync(input: CsvAsyncInput): Promise; /** * Parse CSV async - returns string[][] when headers is false/undefined and no info option. */ export declare function parseCsvAsync(input: CsvAsyncInput, options: CsvParseArrayOptions & { info?: false; }): Promise; /** * Parse CSV async - returns CsvParseResult with RecordWithInfo when info: true (array mode). */ export declare function parseCsvAsync(input: CsvAsyncInput, options: CsvParseArrayOptions & { info: true; }): Promise>>; /** * Parse CSV async - returns CsvParseResult when headers are enabled. */ export declare function parseCsvAsync(input: CsvAsyncInput, options: CsvParseObjectOptions & { info?: false; }): Promise>>; /** * Parse CSV async - returns CsvParseResult with RecordWithInfo when info: true (object mode). */ export declare function parseCsvAsync(input: CsvAsyncInput, options: CsvParseObjectOptions & { info: true; }): Promise>>>; /** * Parse CSV async - general overload for backward compatibility. */ export declare function parseCsvAsync(input: CsvAsyncInput, options: CsvParseOptions): Promise> | CsvParseResult> | CsvParseResult>> | CsvParseResult>>; /** * Parse CSV as an async generator, yielding rows as they are parsed. * This is the true streaming version that yields rows one at a time. * * @example * ```ts * // Process large file row by row * for await (const row of parseCsvRows(fileStream, { headers: true })) { * console.log(row); * } * * // With validation * for await (const row of parseCsvRows(input, { * headers: true, * validate: (row) => row.id !== "" * })) { * // Only valid rows * } * ``` */ export declare function parseCsvRows(input: string | AnyAsyncInput, options?: CsvParseOptions): AsyncGenerator | string[] | RecordWithInfo> | RecordWithInfo, void, unknown>; /** * Parse CSV with progress callback for large files. * * @param input - CSV string or async iterable * @param options - Parse options * @param onProgress - Called periodically with progress info */ export declare function parseCsvWithProgress(input: string | AnyAsyncInput, options?: CsvParseOptions, onProgress?: (info: { rowsProcessed: number; bytesProcessed?: number; }) => void): Promise> | CsvParseResult> | CsvParseResult>> | CsvParseResult>>; export {};