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