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

csv-stringify/sync does not output headers when input is an empty array #343

Closed
alexstrat opened this issue Jun 14, 2022 · 0 comments
Closed

Comments

@alexstrat
Copy link

alexstrat commented Jun 14, 2022

Describe the bug

Even if used with header: true and columns options, csv-stringify/sync does not output headers when input is an empty array.

The stream or callback API does.

To Reproduce

const { stringify } = require('csv-stringify/sync')

stringify([], { header: true, columns: ['foo', 'bar']})
// ❌ returns '' 
// expected 'foo,bar'

const { stringify } = require('csv-stringify')
stringify([], { header: true, columns: ['foo', 'bar']}, (e, content) => console.log(content))
// ✅ logs 'foo,bar'
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

1 participant