import { CSVRecord, ParseBinaryOptions } from '../../../core/types'; /** * Parse CSV from a {@link !File} to records. * * @remarks * This function can parse CSV data from File objects (from file inputs or drag-and-drop). * If the File has a type with charset parameter, it will be used for decoding. * * Unlike {@link parseBlob}, this function automatically sets the file name as the * error source for better error reporting (unless explicitly overridden via options). * * @category Middle-level API * @param file - The file to parse * @param options - Parsing options * @returns Async iterable iterator of records. * * If you want array of records, use {@link parseFile.toArray} function. * * @example Parsing CSV from File (input element) * * ```ts * import { parseFile } from 'web-csv-toolbox'; * * const input = document.querySelector('input[type="file"]'); * input.addEventListener('change', async (event) => { * const file = event.target.files[0]; * for await (const record of parseFile(file)) { * console.log(record); * } * }); * ``` * * @example Parsing CSV from File (drag-and-drop) * * ```ts * import { parseFile } from 'web-csv-toolbox'; * * dropZone.addEventListener('drop', async (event) => { * event.preventDefault(); * const file = event.dataTransfer.files[0]; * for await (const record of parseFile(file)) { * console.log(record); * } * }); * ``` */ export declare function parseFile
>(file: File, options?: ParseBinaryOptions
): AsyncIterableIterator>; export declare namespace parseFile { /** * Parse CSV from a {@link !File} to array of records. * * @returns Array of records * * @example Parsing CSV from File * * ```ts * import { parseFile } from 'web-csv-toolbox'; * * const input = document.querySelector('input[type="file"]'); * input.addEventListener('change', async (event) => { * const file = event.target.files[0]; * const records = await parseFile.toArray(file); * console.log(records); * }); * ``` */ function toArray
>(file: File, options?: ParseBinaryOptions
): Promise[]>; /** * Parse CSV from a {@link !File} to stream of records. * * @param file - File to parse * @returns Stream of records * * @example Parsing CSV from File * * ```ts * import { parseFile } from 'web-csv-toolbox'; * * const input = document.querySelector('input[type="file"]'); * input.addEventListener('change', async (event) => { * const file = event.target.files[0]; * await parseFile.toStream(file) * .pipeTo( * new WritableStream({ * write(record) { * console.log(record); * }, * }), * ); * }); * ``` */ function toStream
>(file: File, options?: ParseBinaryOptions
): ReadableStream>; }