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

add handleHeaders option #54

Merged
merged 1 commit into from
Aug 23, 2018
Merged

add handleHeaders option #54

merged 1 commit into from
Aug 23, 2018

Conversation

jasonmacgowan
Copy link
Contributor

@jasonmacgowan jasonmacgowan commented Aug 9, 2018

Status

READY

Description

Allow headers to be transformed by end user.

Related PRs

List related PRs against other branches:

Todos

  • Tests
  • Documentation

Steps to Test or Reproduce

Outline the steps to test or reproduce the PR here.

git pull --prune
git checkout <feature_branch>
bundle; script/server

Impacted Areas in Application

List general components of the application that this PR will affect:

  • main CSV parser

@kaue
Copy link
Owner

kaue commented Aug 9, 2018

headers - Array Used to set a custom header order, defaults to [] example ['lastname', 'name']

rename - Array Used to set a custom header text, defaults to [] example ['Last Name', 'Name']

what’s the difference from rename & headers options?

Thanks for the contribution :)

@jasonmacgowan
Copy link
Contributor Author

@kauegimenes my use case is to strip a prefix from headers where it exists. It doesn't seem like the rename option supports that.

Example Array input

[
  {
    "prefix1.name": "Jason",
    "prefix2.age": 31
  }
]

Example implementation

...
handleHeaders: h => h.replace(/prefix[0-9]\./, '')
...

Example CSV output

name,age
Jason,31

@kaue
Copy link
Owner

kaue commented Aug 9, 2018

I see. Looks good to merge for me, any input @AckerApple ?

@kaue kaue requested a review from AckerApple August 9, 2018 16:33
@AckerApple
Copy link
Collaborator

I'm hella busy today. I sorta understand the need

@kaue
Copy link
Owner

kaue commented Aug 13, 2018

@AckerApple I will merge this later today and publish to npm if you don't have any objections
@jasonmacgowan I think it would be usefull to add an example to the README
Something like:

handleHeaders: (header) => header.replace(/prefix[0-9]\./, '')

Also add your name to the README contributors list =)

@AckerApple
Copy link
Collaborator

It maybe too late for this BUT I really think a parent-name argument should be added

handleHeaders:(header:string, parentName:string) => header.replace(/prefix[0-9]\./, '')

This doesn't have to be done and I have a meeting to get into that I can't further explain.

@jasonmacgowan
Copy link
Contributor Author

@kauegimenes I'll do that tonight, thanks!

@AckerApple I think I understand what you're getting at; will take a stab at that too.

@kaue
Copy link
Owner

kaue commented Aug 23, 2018

Sorry for the delay guys, i didn’t notice your commit jason :/
This PR is good to merge? Please confirm so i can publish v2.3

@jasonmacgowan
Copy link
Contributor Author

@kauegimenes no worries -- I'm good on my end

@kaue
Copy link
Owner

kaue commented Aug 23, 2018

Nice! thanks for creating this PR :)

I will publish v2.3 in a few hours.

@kaue kaue merged commit fc4b758 into kaue:master Aug 23, 2018
@kaue
Copy link
Owner

kaue commented Aug 23, 2018

@jasonmacgowan I just published v2.3 in NPM

Thanks for your contribution, feel free to create more PRs in the future, welcome to the team.

@jasonmacgowan jasonmacgowan deleted the feature/header-handler branch August 29, 2018 14:22
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.

None yet

3 participants