Version 6 of the csv
package for Node.js is released along its sub projects. Here are the latest versions:
csv
version6.0.0
, latest version was5.5.3
csv-generate
version4.0.0
, latest version was3.4.3
csv-parse
version5.0.0
, latest version was4.16.3
csv-stringify
version6.0.0
, latest version was5.6.5
stream-transform
version4.0.0
, latest version was2.1.3
There has been a lot of commits since the last package was released, around 100, way to many to my opinion. Most of the efforts were on migrating to ECMAScript modules (ESM) and providing a robust build infrastructure based on Rollup. The website has been updated and enriched with many examples.
Before presenting the new features, here are the breaking changes first. Some module names have changed depending on your targeted environment. The documentation now provides extensive information and samples on this topic. Also, some options were renamed in the csv-parse
package. There aren’t too many:
- CommonJS users shall update the path to the sync modules, from
package_name/lib/sync
topackage_name/sync
. - Imports are always destructed, eg
import parse from 'csv-parse'
, there are now default exports. - In the
csv-parse
package, optionrelax
was renamedrelax_quotes
. - In the
csv-parse
package, optionskip_lines_with_empty_values
was renamedskip_records_with_empty_values
. - In the
csv-parse
package, optionskip_lines_with_error
was renamedskip_records_with_error
. - In the
csv-parse
package, errorCSV_RECORD_DONT_MATCH_COLUMNS_LENGTH
was renamedCSV_RECORD_INCONSISTENT_COLUMNS
. - In the
csv-parse
package, errorINCONSISTENT_RECORD_LENGTH
was renamedRECORD_INCONSISTENT_FIELDS_LENGTH
.
Here are the main features:
- All projects and modules are now written as ECMAScript modules.
- Transparent usage between CommonJS and ESM with package.json
exports
property - Wrote many samples integrated with the documentation website
- Replace the browser distribution with the IIFE distribution generated by Rollup
- New UMD distribution
- Integrate lint rules on all js and coffee files
- Backport compatibility with Node.js 8 in
csv-stringify
- In
csv-parse
, print current buffer with optionsskip_line_with_errors
andraw
- In
csv-parse
, optionobjname
can now refer to index position - A few TypeScript enhancements
Here is a quick example illustrating some of the changes, using the csv-parse/lib/sync
module. In the previous release, the code looked like:
const parse = require('csv-parse/lib/sync');
const records = parse('a, "b" ,c',
relax: true
);
In the latest release, the updated code is now:
// `parse` is now destructured, it is consistent with
// `const parse = require('csv/sync');` if you are using the `csv` package.
// Also, the path to the sync module is now 'csv-parse/sync'
const parse = require('csv-parse/sync');
const records = parse('a, "b" ,c',
// `relax` was renamed `relax_quotes`, this is one of the few options from
// `csv-parse` which were renamed.
relax_quotes: true
);
Please report bugs and propose features to the CSV repository on GitHub.
More Stories
JS monorepos in prod 6: CI/CD, continuous integration and deployment with Travis CI
Jabra Elite 5 ANC earbuds review: Great design, good sound
Big data infrastructure internship | Adaltas