web-csv-toolbox - v0.15.0
    Preparing search index...

    Function createBinaryCSVParserStream

    • Factory function to create a BinaryCSVParserStream instance.

      This function internally creates a BinaryCSVParser and wraps it in a BinaryCSVParserStream, providing a simpler API for stream-based CSV parsing from binary streams.

      Accepts any BufferSource type (Uint8Array, ArrayBuffer, or other TypedArray views) as input chunks.

      Type Parameters

      Parameters

      • Optionaloptions: Options

        Binary CSV parser options including header, delimiter, charset, outputFormat, engine, etc.

      • OptionalstreamOptions: BinaryCSVParserStreamOptions

        Stream-specific options like backpressureCheckInterval

      • OptionalwritableStrategy: QueuingStrategy<BufferSource>

        Strategy for the writable side (default: ByteLengthQueuingStrategy({ highWaterMark: 65536 }))

      • OptionalreadableStrategy: QueuingStrategy<CSVRecord<Header, InferFormat<Options>>>

        Strategy for the readable side (default: CountQueuingStrategy({ highWaterMark: 256 }))

      Returns BinaryCSVParserStream<Header, InferFormat<Options>>

      A BinaryCSVParserStream instance configured with the specified options

      Choosing the Right API for guidance on selecting the appropriate API level.

      import { createBinaryCSVParserStream } from 'web-csv-toolbox';

      // Directly pipe fetch response body (no TextDecoderStream needed)
      await fetch('data.csv')
      .then(res => res.body)
      .pipeThrough(createBinaryCSVParserStream())
      .pipeTo(new WritableStream({
      write(record) {
      console.log(record); // { name: 'Alice', age: '30' }
      }
      }));
      import { createBinaryCSVParserStream } from 'web-csv-toolbox';

      // Parse Shift-JIS encoded CSV
      const stream = createBinaryCSVParserStream({
      charset: 'shift-jis',
      ignoreBOM: true
      });

      binaryStream.pipeThrough(stream);
      import { createBinaryCSVParserStream } from 'web-csv-toolbox';

      // CSV data without header row
      const stream = createBinaryCSVParserStream({
      header: ['name', 'age'],
      charset: 'utf-8'
      });

      binaryStream
      .pipeThrough(stream)
      .pipeTo(yourProcessor);
      import { createBinaryCSVParserStream } from 'web-csv-toolbox';

      const stream = createBinaryCSVParserStream({
      outputFormat: 'array'
      });

      binaryStream
      .pipeThrough(stream)
      .pipeTo(new WritableStream({
      write(record) {
      console.log(record); // ['Alice', '30']
      }
      }));
      import { createBinaryCSVParserStream } from 'web-csv-toolbox';

      // Parse gzip-compressed CSV
      const stream = createBinaryCSVParserStream({
      decompression: 'gzip'
      });

      compressedStream.pipeThrough(stream);
      import { createBinaryCSVParserStream } from 'web-csv-toolbox';

      const stream = createBinaryCSVParserStream(
      { header: ['name', 'age'], charset: 'utf-8' },
      { backpressureCheckInterval: 50 },
      new ByteLengthQueuingStrategy({ highWaterMark: 131072 }),
      new CountQueuingStrategy({ highWaterMark: 512 })
      );

      await fetch('large-file.csv')
      .then(res => res.body)
      .pipeThrough(stream)
      .pipeTo(yourProcessor);