csv-parse
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -20,3 +20,3 @@ // Generated by CoffeeScript 1.7.1 | ||
* `escape` Set the escape character, one character only, defaults to double quotes. | ||
* `columns` List of fields or true if autodiscovered in the first CSV line, default to null. Impact the `transform` argument and the `data` event by providing an object instead of an array, order matters, see the transform and the columns sections for more details. | ||
* `columns` List of fields as an array, a user defined callback accepting the first line and returning the column names or true if autodiscovered in the first CSV line, default to null, affect the result data set in the sense that records will be objects instead of arrays. | ||
* `comment` Treat all the characteres after this one as a comment, default to '#' | ||
@@ -27,6 +27,7 @@ * `objname` Name of header-record title to name objects by. | ||
* `rtrim` If true, ignore whitespace immediately preceding the delimiter (i.e. right-trim all fields), defaults to false. | ||
* `auto_parse` If true, the parser will attempt to convert read data types to native types | ||
*/ | ||
Parser = function(options) { | ||
var _base, _base1, _base2, _base3, _base4, _base5, _base6, _base7, _base8, _base9; | ||
var _base, _base1, _base10, _base2, _base3, _base4, _base5, _base6, _base7, _base8, _base9; | ||
if (options == null) { | ||
@@ -68,2 +69,5 @@ options = {}; | ||
} | ||
if ((_base10 = this.options).auto_parse == null) { | ||
_base10.auto_parse = false; | ||
} | ||
this.lines = 0; | ||
@@ -79,2 +83,3 @@ this.buf = ''; | ||
this.chunks = []; | ||
this.floatRegexp = /^(\-|\+)?([0-9]+(\.[0-9]+)?|Infinity)$/; | ||
return this; | ||
@@ -129,2 +134,5 @@ }; | ||
return; | ||
} else if (typeof this.options.columns === 'function') { | ||
this.options.columns = this.options.columns(line); | ||
return; | ||
} | ||
@@ -235,3 +243,7 @@ if (this.options.columns != null) { | ||
} | ||
this.line.push(this.field); | ||
if (this.options.auto_parse && this.floatRegexp.test(this.field)) { | ||
this.line.push(parseFloat(this.field)); | ||
} else { | ||
this.line.push(this.field); | ||
} | ||
this.closingQuote = 0; | ||
@@ -238,0 +250,0 @@ this.field = ''; |
{ | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"name": "csv-parse", | ||
@@ -9,7 +9,6 @@ "description": "CSV parsing implementing the Node.js `stream.Transform` API", | ||
}, | ||
"dependencies": { | ||
"csv-generate": "latest" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"coffee-script": "latest", | ||
"csv-generate": "latest", | ||
"mocha": "latest", | ||
@@ -16,0 +15,0 @@ "should": "latest" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
49032
0
21
346
4
- Removedcsv-generate@latest
- Removedcsv-generate@4.4.1(transitive)