mholt / PapaParse

Fast and powerful CSV (delimited text) parser that gracefully handles large files and malformed input
http://PapaParse.com
MIT License
12.47k stars 1.14k forks source link

feat: support for full result object in node streams #1015

Open joequincy opened 1 year ago

joequincy commented 1 year ago

Why these changes

When using the DuplexStreamStreamer in node, the callback only receives the row data, instead of the full parse result object, however the library still generates per-row errors (if any) and metadata internally, which are useful when processing. For example, it would be helpful to be able to validate meta.renamedHeaders or check that errors is empty for the given row.

What does this PR change

Adds an optional configuration setting to provide the full result object to the callback (and corresponding tests). This allows PapaParse users to opt-in, since changing default behavior would be breaking. As with existing behavior when using streams, the result object (including both the error array and meta object) are atomic to the individual row sent to the callback.

Resolves #754