-
Notifications
You must be signed in to change notification settings - Fork 361
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
fix: consolidate the API of AsyncParser and parseAsync #492
fix: consolidate the API of AsyncParser and parseAsync #492
Conversation
I'm also considering if it make sense the current API:
or if they should be replaced by something simpler and more aligned with the sync API like
The methods The method I can see 2 options here: const csv = await asyncParse.parse(data).promise(); I could add a const streamToString = new StreamToString();
asyncParse.parse(data).pipe(streamToString);
const csv = await asyncParse.parse(data).pipe(streamToString).promise() I like the second one better. Thoughts? |
I like option 2 as well |
This should be good to merge. |
README.md
Outdated
const csv = await json2csvParser.parse(myData).promise(); | ||
``` | ||
|
||
If you want to wait for the stream to finish but not keep the CSV in memory you can use the `stream.finished` utility from Node's stream module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we link to the docs for nodes stream module?
README.md
Outdated
.on('end', () => console.log(csv)) | ||
.on('error', (err) => console.error(err)); | ||
|
||
myData.default.forEach(item => asyncParser.input.push(item)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does myData
come from in this example, and why does it have default
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
myData
is the same myData as in all the other examples.. any array.
It doesn't have default
. I'll remove that.
All feedback has been fixed I think. |
Closes #468