csv-parse
Advanced tools
Comparing version 1.1.8 to 1.1.9
111
lib/index.js
@@ -79,3 +79,3 @@ // Generated by CoffeeScript 1.10.0 | ||
Parser = function(options) { | ||
var base, base1, base10, base11, base12, base13, base14, base15, base2, base3, base4, base5, base6, base7, base8, base9, k, v; | ||
var base, base1, base10, base11, base12, base13, base14, base15, base16, base2, base3, base4, base5, base6, base7, base8, base9, k, v; | ||
if (options == null) { | ||
@@ -91,61 +91,56 @@ options = {}; | ||
stream.Transform.call(this, this.options); | ||
if (this.options.rowDelimiter != null) { | ||
if (typeof this.options.rowDelimiter === "string") { | ||
this.options.rowDelimiter = [this.options.rowDelimiter]; | ||
this.receivedRowDelimiterAsString = true; | ||
} else if (this.options.rowDelimiter.constructor === Array) { | ||
this.options.rowDelimiter = this.options.rowDelimiter; | ||
this.receivedRowDelimiterAsString = false; | ||
} | ||
} else { | ||
this.options.rowDelimiter = null; | ||
if ((base = this.options).rowDelimiter == null) { | ||
base.rowDelimiter = null; | ||
} | ||
if ((base = this.options).delimiter == null) { | ||
base.delimiter = ','; | ||
if (typeof this.options.rowDelimiter === "string") { | ||
this.options.rowDelimiter = [this.options.rowDelimiter]; | ||
} | ||
if ((base1 = this.options).quote == null) { | ||
base1.quote = '"'; | ||
if ((base1 = this.options).delimiter == null) { | ||
base1.delimiter = ','; | ||
} | ||
if ((base2 = this.options).escape == null) { | ||
base2.escape = '"'; | ||
if ((base2 = this.options).quote == null) { | ||
base2.quote = '"'; | ||
} | ||
if ((base3 = this.options).columns == null) { | ||
base3.columns = null; | ||
if ((base3 = this.options).escape == null) { | ||
base3.escape = '"'; | ||
} | ||
if ((base4 = this.options).comment == null) { | ||
base4.comment = ''; | ||
if ((base4 = this.options).columns == null) { | ||
base4.columns = null; | ||
} | ||
if ((base5 = this.options).objname == null) { | ||
base5.objname = false; | ||
if ((base5 = this.options).comment == null) { | ||
base5.comment = ''; | ||
} | ||
if ((base6 = this.options).trim == null) { | ||
base6.trim = false; | ||
if ((base6 = this.options).objname == null) { | ||
base6.objname = false; | ||
} | ||
if ((base7 = this.options).ltrim == null) { | ||
base7.ltrim = false; | ||
if ((base7 = this.options).trim == null) { | ||
base7.trim = false; | ||
} | ||
if ((base8 = this.options).rtrim == null) { | ||
base8.rtrim = false; | ||
if ((base8 = this.options).ltrim == null) { | ||
base8.ltrim = false; | ||
} | ||
if ((base9 = this.options).auto_parse == null) { | ||
base9.auto_parse = false; | ||
if ((base9 = this.options).rtrim == null) { | ||
base9.rtrim = false; | ||
} | ||
if ((base10 = this.options).auto_parse_date == null) { | ||
base10.auto_parse_date = false; | ||
if ((base10 = this.options).auto_parse == null) { | ||
base10.auto_parse = false; | ||
} | ||
if ((base11 = this.options).relax == null) { | ||
base11.relax = false; | ||
if ((base11 = this.options).auto_parse_date == null) { | ||
base11.auto_parse_date = false; | ||
} | ||
if ((base12 = this.options).relax_column_count == null) { | ||
base12.relax_column_count = false; | ||
if ((base12 = this.options).relax == null) { | ||
base12.relax = false; | ||
} | ||
if ((base13 = this.options).skip_empty_lines == null) { | ||
base13.skip_empty_lines = false; | ||
if ((base13 = this.options).relax_column_count == null) { | ||
base13.relax_column_count = false; | ||
} | ||
if ((base14 = this.options).max_limit_on_data_read == null) { | ||
base14.max_limit_on_data_read = 128000; | ||
if ((base14 = this.options).skip_empty_lines == null) { | ||
base14.skip_empty_lines = false; | ||
} | ||
if ((base15 = this.options).skip_lines_with_empty_values == null) { | ||
base15.skip_lines_with_empty_values = false; | ||
if ((base15 = this.options).max_limit_on_data_read == null) { | ||
base15.max_limit_on_data_read = 128000; | ||
} | ||
if ((base16 = this.options).skip_lines_with_empty_values == null) { | ||
base16.skip_lines_with_empty_values = false; | ||
} | ||
this.lines = 0; | ||
@@ -288,13 +283,13 @@ this.count = 0; | ||
var m; | ||
if (_this.options.auto_parse && is_int(_this.field)) { | ||
_this.field = parseInt(_this.field); | ||
} else if (_this.options.auto_parse && is_float(_this.field)) { | ||
_this.field = parseFloat(_this.field); | ||
if (_this.options.auto_parse && is_int(value)) { | ||
value = parseInt(value); | ||
} else if (_this.options.auto_parse && is_float(value)) { | ||
value = parseFloat(value); | ||
} else if (_this.options.auto_parse && _this.options.auto_parse_date) { | ||
m = Date.parse(_this.field); | ||
m = Date.parse(value); | ||
if (!isNaN(m)) { | ||
_this.field = new Date(m); | ||
value = new Date(m); | ||
} | ||
} | ||
return _this.field; | ||
return value; | ||
}; | ||
@@ -528,7 +523,3 @@ })(this); | ||
if (!this.commenting && this.line.length > this.options.max_limit_on_data_read) { | ||
if (this.receivedRowDelimiterAsString) { | ||
throw Error("Row delimiter(s) not found in the file " + (JSON.stringify(this.options.rowDelimiter[0]))); | ||
} else { | ||
throw Error("Row delimiter(s) not found in the file " + (JSON.stringify(this.options.rowDelimiter))); | ||
} | ||
throw Error("Row delimiter not found in the file " + (JSON.stringify(this.options.rowDelimiter))); | ||
} | ||
@@ -543,3 +534,5 @@ } | ||
if (this.field !== '' || rtrimed) { | ||
this.line.push(auto_parse(this.field)); | ||
if (!(this.field === '' && this.options.skip_empty_lines)) { | ||
this.line.push(auto_parse(this.field)); | ||
} | ||
this.field = ''; | ||
@@ -554,7 +547,3 @@ } | ||
if (this.line.length > this.options.max_limit_on_data_read) { | ||
if (this.receivedRowDelimiterAsString) { | ||
throw Error("Row delimiter(s) not found in the file " + (JSON.stringify(this.options.rowDelimiter[0]))); | ||
} else { | ||
throw Error("Row delimiter(s) not found in the file " + (JSON.stringify(this.options.rowDelimiter))); | ||
} | ||
throw Error("Row delimiter not found in the file " + (JSON.stringify(this.options.rowDelimiter))); | ||
} | ||
@@ -561,0 +550,0 @@ } |
{ | ||
"version": "1.1.8", | ||
"version": "1.1.9", | ||
"name": "csv-parse", | ||
@@ -4,0 +4,0 @@ "description": "CSV parsing implementing the Node.js `stream.Transform` API", |
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
27359
684