csv-parse
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -155,2 +155,3 @@ // Generated by CoffeeScript 1.10.0 | ||
this.chunks = []; | ||
this.rawBuf = ''; | ||
return this; | ||
@@ -196,8 +197,11 @@ }; | ||
Parser.prototype.__push = function(line) { | ||
var field, i, j, len, lineAsColumns; | ||
var field, i, j, len, lineAsColumns, rawBuf, row; | ||
row = null; | ||
if (this.options.columns === true) { | ||
this.options.columns = line; | ||
rawBuf = ''; | ||
return; | ||
} else if (typeof this.options.columns === 'function') { | ||
this.options.columns = this.options.columns(line); | ||
rawBuf = ''; | ||
return; | ||
@@ -228,13 +232,22 @@ } | ||
if (this.options.objname) { | ||
return this.push([lineAsColumns[this.options.objname], lineAsColumns]); | ||
row = [lineAsColumns[this.options.objname], lineAsColumns]; | ||
} else { | ||
return this.push(lineAsColumns); | ||
row = lineAsColumns; | ||
} | ||
} else { | ||
return this.push(line); | ||
row = line; | ||
} | ||
if (this.options.raw) { | ||
this.push({ | ||
raw: this.rawBuf, | ||
row: row | ||
}); | ||
return this.rawBuf = ''; | ||
} else { | ||
return this.push(row); | ||
} | ||
}; | ||
Parser.prototype.__write = function(chars, end, callback) { | ||
var areNextCharsDelimiter, areNextCharsRowDelimiters, auto_parse, char, escapeIsQuote, i, isDelimiter, isEscape, isNextCharAComment, isQuote, isRowDelimiter, is_float, is_int, l, ltrim, nextCharPos, ref, results, rowDelimiter, rowDelimiterLength, rtrim, wasCommenting; | ||
var areNextCharsDelimiter, areNextCharsRowDelimiters, auto_parse, char, escapeIsQuote, i, isDelimiter, isEscape, isNextCharAComment, isQuote, isRowDelimiter, is_float, is_int, l, ltrim, nextCharPos, ref, remainingBuffer, results, rowDelimiter, rowDelimiterLength, rtrim, wasCommenting; | ||
is_int = (function(_this) { | ||
@@ -285,23 +298,11 @@ return function(value) { | ||
if (!end) { | ||
if (!this.commenting && l - i < this.options.comment.length && this.options.comment.substr(0, l - i) === chars.substr(i, l - i)) { | ||
remainingBuffer = chars.substr(i, l - i); | ||
if ((!this.commenting && l - i < this.options.comment.length && this.options.comment.substr(0, l - i) === remainingBuffer) || (this.options.rowDelimiter && l - i < rowDelimiterLength && this.options.rowDelimiter.substr(0, l - i) === remainingBuffer) || (this.options.rowDelimiter && this.quoting && l - i < (this.options.quote.length + rowDelimiterLength) && (this.options.quote + this.options.rowDelimiter).substr(0, l - i) === remainingBuffer) || (l - i <= this.options.delimiter.length && this.options.delimiter.substr(0, l - i) === remainingBuffer) || (l - i <= this.options.escape.length && this.options.escape.substr(0, l - i) === remainingBuffer)) { | ||
break; | ||
} | ||
if (this.options.rowDelimiter && l - i < rowDelimiterLength && this.options.rowDelimiter.substr(0, l - i) === chars.substr(i, l - i)) { | ||
break; | ||
} | ||
if (this.options.rowDelimiter && this.quoting && l - i < (this.options.quote.length + rowDelimiterLength) && (this.options.quote + this.options.rowDelimiter).substr(0, l - i) === chars.substr(i, l - i)) { | ||
break; | ||
} | ||
if (l - i <= this.options.delimiter.length && this.options.delimiter.substr(0, l - i) === chars.substr(i, l - i)) { | ||
break; | ||
} | ||
if (l - i <= this.options.escape.length && this.options.escape.substr(0, l - i) === chars.substr(i, l - i)) { | ||
break; | ||
} | ||
} | ||
char = this.nextChar ? this.nextChar : chars.charAt(i); | ||
if (l > i + 1) { | ||
this.nextChar = chars.charAt(i + 1); | ||
} else { | ||
this.nextChar = ""; | ||
this.nextChar = l > i + 1 ? chars.charAt(i + 1) : ''; | ||
if (this.options.raw) { | ||
this.rawBuf += char; | ||
} | ||
@@ -315,2 +316,5 @@ if (this.options.rowDelimiter == null) { | ||
nextCharPos = i + 2; | ||
if (this.raw) { | ||
rawBuf += this.nextChar; | ||
} | ||
} | ||
@@ -334,2 +338,5 @@ if (rowDelimiter) { | ||
this.field += char; | ||
if (this.options.raw) { | ||
this.rawBuf += char; | ||
} | ||
i++; | ||
@@ -336,0 +343,0 @@ continue; |
{ | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"name": "csv-parse", | ||
@@ -4,0 +4,0 @@ "description": "CSV parsing implementing the Node.js `stream.Transform` API", |
23987
596