csv-parser
Advanced tools
Comparing version 2.3.5 to 3.0.0
11
index.js
@@ -179,10 +179,11 @@ const { Transform } = require('stream') | ||
writeRow (cells) { | ||
if (this.headers === false || cells.length > this.headers.length) { | ||
this.headers = cells.map((value, index) => index) | ||
} | ||
const headers = (this.headers === false) ? cells.map((value, index) => index) : this.headers | ||
const row = cells.reduce((o, cell, index) => { | ||
const header = this.headers[index] | ||
if (header !== null) { | ||
const header = headers[index] | ||
if (header === null) return o // skip columns | ||
if (header !== undefined) { | ||
o[header] = cell | ||
} else { | ||
o[`_${index}`] = cell | ||
} | ||
@@ -189,0 +190,0 @@ return o |
{ | ||
"name": "csv-parser", | ||
"version": "2.3.5", | ||
"version": "3.0.0", | ||
"description": "Streaming CSV parser that aims for maximum speed as well as compatibility with the csv-spectrum test suite", | ||
@@ -23,3 +23,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">= 8.16.0" | ||
"node": ">= 10" | ||
}, | ||
@@ -36,4 +36,3 @@ "scripts": { | ||
"dependencies": { | ||
"minimist": "^1.2.0", | ||
"through2": "^3.0.1" | ||
"minimist": "^1.2.0" | ||
}, | ||
@@ -40,0 +39,0 @@ "devDependencies": { |
@@ -254,5 +254,9 @@ [tests]: http://img.shields.io/travis/mafintosh/csv-parser.svg | ||
Type: `Boolean`<br> | ||
Default: `false` | ||
If `true`, instructs the parser that the number of columns in each row must match | ||
the number of `headers` specified. | ||
the number of `headers` specified or throws an exception. | ||
if `false`: the headers are mapped to the column index | ||
less columns: any missing column in the middle will result in a wrong property mapping! | ||
more columns: the aditional columns will create a "_"+index properties - eg. "_10":"value" | ||
@@ -259,0 +263,0 @@ ## Events |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27687
1
355
359
- Removedthrough2@^3.0.1
- Removedinherits@2.0.4(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedthrough2@3.0.2(transitive)
- Removedutil-deprecate@1.0.2(transitive)