]> git.ardis.lu - csvio/commitdiff
Delete redundant BOM check
authorArdis Lu <ardisglu@gmail.com>
Sun, 13 Jul 2025 05:44:16 +0000 (22:44 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sun, 13 Jul 2025 05:44:16 +0000 (22:44 -0700)
`TextDecoderStream` already handles it upstream, no need to check for it again.

src/core.js

index 948eefb737f39a2a6218a6fb0b23b323b8e983c7..8133fc5911f95eb4153c1f677f48584625beebec 100644 (file)
@@ -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 = '';
This page took 0.033124 seconds and 4 git commands to generate.