import { DEFAULT_DELIMITER } from '../../../core/constants'; import { InferCSVRecord, ParseBinaryOptions } from '../../../core/types'; /** * Parse CSV to records. * This function is for parsing a binary stream. * * @category Middle-level API * @remarks * If you want to parse a string, use {@link parseStringStream}. * @param stream CSV string to parse * @param options Parsing options. * @returns Async iterable iterator of records. * * If you want array of records, use {@link parseBinaryStream.toArray} function. * * @example Parsing CSV binary * * ```ts * import { parseBinaryStream } from 'web-csv-toolbox'; * * const csv = Uint8Array.from([ * // ... * ]); * * const stream = new ReadableStream({ * start(controller) { * controller.enqueue(csv); * controller.close(); * }, * }); * * for await (const record of parseBinaryStream(stream)) { * console.log(record); * } * ``` */ export declare function parseBinaryStream
, Delimiter extends string = DEFAULT_DELIMITER, Quotation extends string = '"', Options extends ParseBinaryOptions = ParseBinaryOptions>(stream: ReadableStream, options?: Options): AsyncIterableIterator>; export declare namespace parseBinaryStream { /** * Parse CSV binary to array of records, * ideal for smaller data sets. * * @returns Array of records * * @example Parsing CSV binary * ```ts * import { parseBinaryStream } from 'web-csv-toolbox'; * * const csv = Uint8Array.from([ * // ... * ]); * * const stream = new ReadableStream({ * start(controller) { * controller.enqueue(csv); * controller.close(); * }, * }); * * const records = await parseBinaryStream.toArray(stream); * console.log(records); * ``` */ function toArray
, Options extends ParseBinaryOptions
= ParseBinaryOptions
>(stream: ReadableStream, options?: Options): Promise[]>; /** * Parse CSV binary to array of records. * * @returns Stream of records * * @example Parsing CSV binary * ```ts * import { parseBinaryStream } from 'web-csv-toolbox'; * * const csv = Uint8Array.from([ * // ... * ]); * * const stream = new ReadableStream({ * start(controller) { * controller.enqueue(csv); * controller.close(); * }, * }); * * await parseBinaryStream.toStream(stream) * .pipeTo(new WritableStream({ * write(record) { * console.log(record); * }, * }), * ); * ``` */ function toStream
, Options extends ParseBinaryOptions
= ParseBinaryOptions
>(stream: ReadableStream, options?: Options): ReadableStream>; }