Skip to content

When provided Headers in Unparse if the data is empty the resulting string should just be a header #932

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

Open
hikarunoryoma opened this issue Apr 20, 2022 · 1 comment

Comments

@hikarunoryoma
Copy link

I would expect that when unparse runs and headers are provided as part of the UnparseConfig options that the returned string will just have a single row of headers instead of empty string.

Example:

const headers = ['header1', 'header2', 'header3'];
const config = { columns: headers, };

let headers = unparse([], config); // should be 'header1,header2,header3'
@MarkSFrancis
Copy link

As a workaround for this, I used [{}] as the data instead of []

const headers = ['header1', 'header2', 'header3'];
const config = { columns: headers, };

let headers = unparse([], config); // ''
let headers = unparse([{}], config); // 'header1,header2,header3\n'

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

No branches or pull requests

2 participants