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

    Function createStringCSVParser

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

      Type Parameters

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

        The type of the header row

      Parameters

      • options: Omit<CSVProcessingOptions<Header, ",", "\"">, "outputFormat"> & {
            outputFormat: "array";
        }

        CSV processing specification (excludes execution strategy)

      Returns StringArrayCSVParser<Header>

      A parser instance configured for the specified output format

      This is a low-level factory function that accepts CSVProcessingOptions. It does NOT accept execution strategy options (engine). For high-level APIs with execution strategy support, use parseString() and related functions.

      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)
      const parser = createStringCSVParser({
      header: ['name', 'age'] as const,
      delimiter: ',',
      signal: abortController.signal,
      // engine is NOT available (low-level API)
      });
      for (const record of parser.parse('Alice,30\nBob,25')) {
      console.log(record); // { name: 'Alice', age: '30' }
      }
      const parser = createStringCSVParser({
      header: ['name', 'age'] as const,
      outputFormat: 'array',
      // engine is NOT available (low-level API)
      });
      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

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

        The type of the header row

      Parameters

      • options: Omit<CSVProcessingOptions<Header, ",", "\"">, "outputFormat"> & {
            outputFormat: "object";
        }

        CSV processing specification (excludes execution strategy)

      Returns StringObjectCSVParser<Header>

      A parser instance configured for the specified output format

      This is a low-level factory function that accepts CSVProcessingOptions. It does NOT accept execution strategy options (engine). For high-level APIs with execution strategy support, use parseString() and related functions.

      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)
      const parser = createStringCSVParser({
      header: ['name', 'age'] as const,
      delimiter: ',',
      signal: abortController.signal,
      // engine is NOT available (low-level API)
      });
      for (const record of parser.parse('Alice,30\nBob,25')) {
      console.log(record); // { name: 'Alice', age: '30' }
      }
      const parser = createStringCSVParser({
      header: ['name', 'age'] as const,
      outputFormat: 'array',
      // engine is NOT available (low-level API)
      });
      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

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

        The type of the header row

      Parameters

      • options: Omit<CSVProcessingOptions<Header, ",", "\"">, "outputFormat"> & {
            outputFormat: "object" | "array";
        }

        CSV processing specification (excludes execution strategy)

      Returns StringArrayCSVParser<Header> | StringObjectCSVParser<Header>

      A parser instance configured for the specified output format

      This is a low-level factory function that accepts CSVProcessingOptions. It does NOT accept execution strategy options (engine). For high-level APIs with execution strategy support, use parseString() and related functions.

      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)
      const parser = createStringCSVParser({
      header: ['name', 'age'] as const,
      delimiter: ',',
      signal: abortController.signal,
      // engine is NOT available (low-level API)
      });
      for (const record of parser.parse('Alice,30\nBob,25')) {
      console.log(record); // { name: 'Alice', age: '30' }
      }
      const parser = createStringCSVParser({
      header: ['name', 'age'] as const,
      outputFormat: 'array',
      // engine is NOT available (low-level API)
      });
      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

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

        The type of the header row

      Parameters

      Returns StringObjectCSVParser<Header>

      A parser instance configured for the specified output format

      This is a low-level factory function that accepts CSVProcessingOptions. It does NOT accept execution strategy options (engine). For high-level APIs with execution strategy support, use parseString() and related functions.

      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)
      const parser = createStringCSVParser({
      header: ['name', 'age'] as const,
      delimiter: ',',
      signal: abortController.signal,
      // engine is NOT available (low-level API)
      });
      for (const record of parser.parse('Alice,30\nBob,25')) {
      console.log(record); // { name: 'Alice', age: '30' }
      }
      const parser = createStringCSVParser({
      header: ['name', 'age'] as const,
      outputFormat: 'array',
      // engine is NOT available (low-level API)
      });
      for (const record of parser.parse('Alice,30\nBob,25')) {
      console.log(record); // ['Alice', '30']
      }