import { Transform } from 'stream'; import type { TransformCallback } from 'stream'; export type CsvFileErrorCode = 'FILE_ENCODING' | 'UNCLOSED_QUOTE' | 'ROW_TOO_LARGE'; /** A problem with the file as a whole. It stops the reading. */ export declare class CsvFileError extends Error { readonly code: CsvFileErrorCode; readonly params: Record; constructor(code: CsvFileErrorCode, params: Record); } /** * Sits in front of `csv-parser` and does what the library cannot: * * - removes a UTF-8 byte order mark (the library keeps it in the first header * name) and refuses a file that is not UTF-8 (the library turns bad bytes * into U+FFFD without a word); * - counts the rows by itself, so that an error can name the row. The library * gives no row numbers, and when it fails it drops the rows it has not * handed over yet; * - stops a row that grows past `maxRowBytes`, and a quote that is never * closed by the end of the file. One stray quote makes the library read the * rest of the file as a single cell, in memory; * - makes the line breaks something the library can read. Without a header * option it does not look for the style of line break (the old Macintosh CSV * ends a row with a lone CR), and when it does look, a CR LF that is cut * between two chunks fools it. So a lone CR outside quotes becomes LF, and a * CR at the end of a chunk is held back until the next byte is known. * * Everything else goes through unchanged. */ export declare class CsvFileGuard extends Transform { private readonly maxRowBytes; private head; private started; private readonly decoder; private inQuotes; private quoteOpenedInRow; private pendingCR; private rowBytes; private rowsDone; constructor(maxRowBytes: number); _transform(chunk: Buffer, _encoding: BufferEncoding, callback: TransformCallback): void; _flush(callback: TransformCallback): void; private start; private inspect; private endRow; private scan; }