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

    Function createStringCSVParser

    • Factory function to create the appropriate String CSV parser based on options.

      Type Parameters

      • const Header extends readonly string[] = readonly string[]

        The type of the header row

      • const Delimiter extends string = ","
      • const Quotation extends string = "\""
      • const Strategy extends ColumnCountStrategy = ColumnCountStrategy

      Parameters

      Returns StringArrayCSVParser<Header>

      A parser instance configured for the specified output format

      This function provides both compile-time and runtime type safety. The return type is determined by the outputFormat option:

      • outputFormat: 'object' (default) → StringObjectCSVParser (FlexibleStringObjectCSVParser)
      • outputFormat: 'array' → StringArrayCSVParser (FlexibleStringArrayCSVParser)

      Design Intent: This factory function accepts options including engine configuration to enable future execution path optimization. The function may select the optimal internal parser implementation based on the provided options. Currently, this optimization is not implemented, but the API is designed to support it without breaking changes.

      const parser = createStringCSVParser({
      header: ['name', 'age'],
      delimiter: ',',
      signal: abortController.signal,
      });
      for (const record of parser.parse('Alice,30\nBob,25')) {
      console.log(record); // { name: 'Alice', age: '30' }
      }
      const parser = createStringCSVParser({
      header: ['name', 'age'],
      outputFormat: 'array',
      });
      for (const record of parser.parse('Alice,30\nBob,25')) {
      console.log(record); // ['Alice', '30']
      }
    • Factory function to create the appropriate String CSV parser based on options.

      Type Parameters

      • const Header extends readonly string[] = readonly string[]

        The type of the header row

      • const Delimiter extends string = ","
      • const Quotation extends string = "\""
      • const Strategy extends ColumnCountStrategy = ColumnCountStrategy

      Parameters

      Returns StringObjectCSVParser<Header>

      A parser instance configured for the specified output format

      This function provides both compile-time and runtime type safety. The return type is determined by the outputFormat option:

      • outputFormat: 'object' (default) → StringObjectCSVParser (FlexibleStringObjectCSVParser)
      • outputFormat: 'array' → StringArrayCSVParser (FlexibleStringArrayCSVParser)

      Design Intent: This factory function accepts options including engine configuration to enable future execution path optimization. The function may select the optimal internal parser implementation based on the provided options. Currently, this optimization is not implemented, but the API is designed to support it without breaking changes.

      const parser = createStringCSVParser({
      header: ['name', 'age'],
      delimiter: ',',
      signal: abortController.signal,
      });
      for (const record of parser.parse('Alice,30\nBob,25')) {
      console.log(record); // { name: 'Alice', age: '30' }
      }
      const parser = createStringCSVParser({
      header: ['name', 'age'],
      outputFormat: 'array',
      });
      for (const record of parser.parse('Alice,30\nBob,25')) {
      console.log(record); // ['Alice', '30']
      }
    • Factory function to create the appropriate String CSV parser based on options.

      Type Parameters

      • const Header extends readonly string[] = readonly string[]

        The type of the header row

      • const Delimiter extends string = ","
      • const Quotation extends string = "\""
      • const Strategy extends ColumnCountStrategy = ColumnCountStrategy

      Parameters

      Returns StringObjectCSVParser<Header>

      A parser instance configured for the specified output format

      This function provides both compile-time and runtime type safety. The return type is determined by the outputFormat option:

      • outputFormat: 'object' (default) → StringObjectCSVParser (FlexibleStringObjectCSVParser)
      • outputFormat: 'array' → StringArrayCSVParser (FlexibleStringArrayCSVParser)

      Design Intent: This factory function accepts options including engine configuration to enable future execution path optimization. The function may select the optimal internal parser implementation based on the provided options. Currently, this optimization is not implemented, but the API is designed to support it without breaking changes.

      const parser = createStringCSVParser({
      header: ['name', 'age'],
      delimiter: ',',
      signal: abortController.signal,
      });
      for (const record of parser.parse('Alice,30\nBob,25')) {
      console.log(record); // { name: 'Alice', age: '30' }
      }
      const parser = createStringCSVParser({
      header: ['name', 'age'],
      outputFormat: 'array',
      });
      for (const record of parser.parse('Alice,30\nBob,25')) {
      console.log(record); // ['Alice', '30']
      }
    • Factory function to create the appropriate String CSV parser based on options.

      Type Parameters

      • const Header extends readonly string[] = readonly string[]

        The type of the header row

      • const Delimiter extends string = ","
      • const Quotation extends string = "\""
      • const OutputFormat extends "object" | "array" = "object" | "array"
      • const Strategy extends ColumnCountStrategy = ColumnCountStrategy

      Parameters

      Returns StringArrayCSVParser<Header> | StringObjectCSVParser<Header>

      A parser instance configured for the specified output format

      This function provides both compile-time and runtime type safety. The return type is determined by the outputFormat option:

      • outputFormat: 'object' (default) → StringObjectCSVParser (FlexibleStringObjectCSVParser)
      • outputFormat: 'array' → StringArrayCSVParser (FlexibleStringArrayCSVParser)

      Design Intent: This factory function accepts options including engine configuration to enable future execution path optimization. The function may select the optimal internal parser implementation based on the provided options. Currently, this optimization is not implemented, but the API is designed to support it without breaking changes.

      const parser = createStringCSVParser({
      header: ['name', 'age'],
      delimiter: ',',
      signal: abortController.signal,
      });
      for (const record of parser.parse('Alice,30\nBob,25')) {
      console.log(record); // { name: 'Alice', age: '30' }
      }
      const parser = createStringCSVParser({
      header: ['name', 'age'],
      outputFormat: 'array',
      });
      for (const record of parser.parse('Alice,30\nBob,25')) {
      console.log(record); // ['Alice', '30']
      }