chore: update public repo

This commit is contained in:
desu-bot 2025-06-18 20:26:53 +00:00
parent 3057b2a78c
commit 2b73e3b411
No known key found for this signature in database

View file

@ -16,8 +16,8 @@ interface CsvReaderOptions {
*/
assumeEmptyValues: boolean
/** whether to treat header line as a data line */
includeHeader: boolean
/** whether to treat all data from the readable as data (requires `schema` to be set) */
skipHeader: boolean
}
export class CsvReader<const Fields extends string[] = string[]> {
@ -29,7 +29,7 @@ export class CsvReader<const Fields extends string[] = string[]> {
options: Partial<CsvReaderOptions> & {
/** fields that are expected in the csv */
schema?: Fields
},
} = {},
) {
this.options = {
lineDelimiter: '\n',
@ -37,14 +37,14 @@ export class CsvReader<const Fields extends string[] = string[]> {
quote: '"',
quoteEscape: '"',
assumeEmptyValues: false,
includeHeader: false,
skipHeader: false,
...options,
}
this.#codec = new FramedReader(stream, new TextDelimiterCodec(this.options.lineDelimiter))
this.#schema = options.schema
if (options.includeHeader) {
if (options.skipHeader) {
if (!options.schema) throw new Error('schema is required if includeHeader is true')
this.#header = options.schema
}