From: Ardis Lu Date: Sun, 13 Jul 2025 05:44:16 +0000 (-0700) Subject: Delete redundant BOM check X-Git-Tag: v0.1.4~2 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=e46d1871feff32acbcdc7574aff91dbd37d25ea5;p=csvio Delete redundant BOM check `TextDecoderStream` already handles it upstream, no need to check for it again. --- diff --git a/src/core.js b/src/core.js index 948eefb..8133fc5 100644 --- a/src/core.js +++ b/src/core.js @@ -111,7 +111,7 @@ export class CSVReader extends ReadableStream { constructor(path, options = {}) { const { encoding = 'utf-8' } = options; const readableStream = createFileStream(path) - .pipeThrough(new TextDecoderStream(encoding)) + .pipeThrough(new TextDecoderStream(encoding)) // Byte order mark (BOM) is removed, if present .pipeThrough(new TransformStream({ transform: (chunk, controller) => this.#transform(chunk, controller), flush: (controller) => this.#flush(controller) @@ -158,7 +158,7 @@ export class CSVReader extends ReadableStream { this.#field += char; } } - else if (char === '\r' || char === '\uFEFF') { } // Ignore CR (newline logic is handled by LF) and byte order mark + else if (char === '\r') { } // Ignore CR (newline logic is handled by LF) else if (char === ',') { // Terminate the field and do not add char to field this.#row.push(this.#field); this.#field = '';