Skip to content

Conversation

@Manjack21
Copy link

@Manjack21 Manjack21 commented Jun 18, 2023

Pull Request for issue #21 - Feature request for custom separator and delimiter

index.js

parse()

  • added options separator and delimiter to the options object, incl. validity check.
  • extended lexer RegExp to use these values
  • replaced constants comma and double quote with option values

stringify()

  • added options separator and delimiter to the options object, incl. validity check.
  • extended needsDelimiters RegExp to check for these values
  • replaced constants comma and double quote with option values

options.spec.js

extended test suite by eight new tests to ensure the correct usage of the separator and delimiter option

@evanplaice evanplaice force-pushed the main branch 3 times, most recently from 51108d9 to c1b4e98 Compare August 22, 2024 19:22
if (typeof col === 'string') {
col = col.replace(/"/g, '""')
col = needsDelimiters.test(col) ? `"${col}"` : col
col = col.replace(ctx.options.delimiter, `${ctx.options.delimiter}${ctx.options.delimiter}`)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only replace the first instance of the delimiter in a string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants