csv-parse
Advanced tools
Comparing version 4.15.0 to 4.15.1
@@ -20,2 +20,6 @@ | ||
## Version 4.15.1 | ||
* fix: skip_empty_lines don't interfere with from_line | ||
## Version 4.15.0 | ||
@@ -22,0 +26,0 @@ |
@@ -534,3 +534,3 @@ "use strict"; | ||
wasQuoting: false, | ||
wasRecordDelimiter: false | ||
wasRowDelimiter: false | ||
}; | ||
@@ -646,3 +646,3 @@ } // Implementation of `Transform._transform` | ||
if (this.state.wasRecordDelimiter === true) { | ||
if (this.state.wasRowDelimiter === true) { | ||
this.info.lines++; | ||
@@ -654,3 +654,3 @@ | ||
this.state.wasRecordDelimiter = false; | ||
this.state.wasRowDelimiter = false; | ||
} | ||
@@ -679,4 +679,4 @@ | ||
if ((chr === cr || chr === nl) && this.state.wasRecordDelimiter === false) { | ||
this.state.wasRecordDelimiter = true; | ||
if ((chr === cr || chr === nl) && this.state.wasRowDelimiter === false) { | ||
this.state.wasRowDelimiter = true; | ||
} // Previous char was a valid escape char | ||
@@ -766,11 +766,4 @@ // treat the current char as a regular char | ||
} else { | ||
// Skip if line is empty and skip_empty_lines activated | ||
if (skip_empty_lines === true && this.state.wasQuoting === false && this.state.record.length === 0 && this.state.field.length === 0) { | ||
this.info.empty_lines++; | ||
pos += recordDelimiterLength - 1; | ||
continue; | ||
} // Activate records emition if above from_line | ||
if (this.state.enabled === false && this.info.lines + (this.state.wasRecordDelimiter === true ? 1 : 0) >= from_line) { | ||
// Activate records emition if above from_line | ||
if (this.state.enabled === false && this.info.lines + (this.state.wasRowDelimiter === true ? 1 : 0) >= from_line) { | ||
this.state.enabled = true; | ||
@@ -784,12 +777,19 @@ | ||
continue; | ||
} else { | ||
var errField = this.__onField(); | ||
} // Skip if line is empty and skip_empty_lines activated | ||
if (errField !== undefined) return errField; | ||
var errRecord = this.__onRecord(); | ||
if (errRecord !== undefined) return errRecord; | ||
if (skip_empty_lines === true && this.state.wasQuoting === false && this.state.record.length === 0 && this.state.field.length === 0) { | ||
this.info.empty_lines++; | ||
pos += recordDelimiterLength - 1; | ||
continue; | ||
} | ||
var errField = this.__onField(); | ||
if (errField !== undefined) return errField; | ||
var errRecord = this.__onRecord(); | ||
if (errRecord !== undefined) return errRecord; | ||
if (to !== -1 && this.info.records >= to) { | ||
@@ -867,3 +867,3 @@ this.state.stop = true; | ||
if (_errRecord !== undefined) return _errRecord; | ||
} else if (this.state.wasRecordDelimiter === true) { | ||
} else if (this.state.wasRowDelimiter === true) { | ||
this.info.empty_lines++; | ||
@@ -878,5 +878,5 @@ } else if (this.state.commenting === true) { | ||
if (this.state.wasRecordDelimiter === true) { | ||
if (this.state.wasRowDelimiter === true) { | ||
this.info.lines++; | ||
this.state.wasRecordDelimiter = false; | ||
this.state.wasRowDelimiter = false; | ||
} | ||
@@ -883,0 +883,0 @@ } |
@@ -459,3 +459,3 @@ | ||
wasQuoting: false, | ||
wasRecordDelimiter: false | ||
wasRowDelimiter: false | ||
} | ||
@@ -533,3 +533,3 @@ } | ||
} | ||
if(this.state.wasRecordDelimiter === true){ | ||
if(this.state.wasRowDelimiter === true){ | ||
this.info.lines++ | ||
@@ -539,3 +539,3 @@ if(info === true && this.state.record.length === 0 && this.state.field.length === 0 && this.state.wasQuoting === false){ | ||
} | ||
this.state.wasRecordDelimiter = false | ||
this.state.wasRowDelimiter = false | ||
} | ||
@@ -558,4 +558,4 @@ if(to_line !== -1 && this.info.lines > to_line){ | ||
} | ||
if((chr === cr || chr === nl) && this.state.wasRecordDelimiter === false ){ | ||
this.state.wasRecordDelimiter = true | ||
if((chr === cr || chr === nl) && this.state.wasRowDelimiter === false ){ | ||
this.state.wasRowDelimiter = true | ||
} | ||
@@ -648,10 +648,4 @@ // Previous char was a valid escape char | ||
}else{ | ||
// Skip if line is empty and skip_empty_lines activated | ||
if(skip_empty_lines === true && this.state.wasQuoting === false && this.state.record.length === 0 && this.state.field.length === 0){ | ||
this.info.empty_lines++ | ||
pos += recordDelimiterLength - 1 | ||
continue | ||
} | ||
// Activate records emition if above from_line | ||
if(this.state.enabled === false && this.info.lines + (this.state.wasRecordDelimiter === true ? 1: 0 ) >= from_line){ | ||
if(this.state.enabled === false && this.info.lines + (this.state.wasRowDelimiter === true ? 1: 0) >= from_line){ | ||
this.state.enabled = true | ||
@@ -662,8 +656,13 @@ this.__resetField() | ||
continue | ||
}else{ | ||
const errField = this.__onField() | ||
if(errField !== undefined) return errField | ||
const errRecord = this.__onRecord() | ||
if(errRecord !== undefined) return errRecord | ||
} | ||
// Skip if line is empty and skip_empty_lines activated | ||
if(skip_empty_lines === true && this.state.wasQuoting === false && this.state.record.length === 0 && this.state.field.length === 0){ | ||
this.info.empty_lines++ | ||
pos += recordDelimiterLength - 1 | ||
continue | ||
} | ||
const errField = this.__onField() | ||
if(errField !== undefined) return errField | ||
const errRecord = this.__onRecord() | ||
if(errRecord !== undefined) return errRecord | ||
if(to !== -1 && this.info.records >= to){ | ||
@@ -743,3 +742,3 @@ this.state.stop = true | ||
if(errRecord !== undefined) return errRecord | ||
}else if(this.state.wasRecordDelimiter === true){ | ||
}else if(this.state.wasRowDelimiter === true){ | ||
this.info.empty_lines++ | ||
@@ -753,5 +752,5 @@ }else if(this.state.commenting === true){ | ||
} | ||
if(this.state.wasRecordDelimiter === true){ | ||
if(this.state.wasRowDelimiter === true){ | ||
this.info.lines++ | ||
this.state.wasRecordDelimiter = false | ||
this.state.wasRowDelimiter = false | ||
} | ||
@@ -758,0 +757,0 @@ } |
{ | ||
"version": "4.15.0", | ||
"version": "4.15.1", | ||
"name": "csv-parse", | ||
@@ -4,0 +4,0 @@ "description": "CSV parsing implementing the Node.js `stream.Transform` API", |
# CSV Parser for Node.js | ||
[![Build Status](https://api.travis-ci.org/adaltas/node-csv-parse.svg)](https://travis-ci.org/#!/adaltas/node-csv-parse) | ||
[![Build Status](https://api.travis-ci.org/adaltas/node-csv-parse.svg)](https://travis-ci.org/#!/adaltas/node-csv-parse) [![NPM](https://img.shields.io/npm/dm/csv-parse)](https://www.npmjs.com/package/csv-parse) [![NPM](https://img.shields.io/npm/v/csv-parse)](https://www.npmjs.com/package/csv-parse) | ||
@@ -6,0 +6,0 @@ Part of the [CSV module](https://csv.js.org/), this project is a parser converting CSV text input into arrays or objects. It implements the Node.js [`stream.Transform` API](http://nodejs.org/api/stream.html#stream_class_stream_transform). It also provides a simple callback-based API for convenience. It is both extremely easy to use and powerful. It was first released in 2010 and is used against big data sets by a large community. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
654215
0
16589