Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/custom separator #22

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

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

array.forEach((row, rIdx) => {
let entry = ''
ctx.col = 1
row.forEach((col, cIdx) => {
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