Changeset 489 for Dev/trunk/src/node_modules/ya-csv/lib/ya-csv.js
- Timestamp:
- 03/08/14 11:41:10 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/node_modules/ya-csv/lib/ya-csv.js
r484 r489 73 73 * @return {ReadStream} the readstream instance 74 74 */ 75 self.dest oy = function(){75 self.destroy = function(){ 76 76 readStream.destroy(); 77 77 return self; … … 113 113 var isEscape = false; 114 114 if (c === this.escapechar) { 115 var nextChar = data.charAt(i + 1); 116 if (this._isEscapable(nextChar)) { 117 this._addCharacter(nextChar); 118 i++; 119 isEscape = true; 115 // double-quote at the field beginning does not count as an escape string` 116 if (c !== this.quotechar || ps.openField || ps.quotedField) { 117 var nextChar = data.charAt(i + 1); 118 if (this._isEscapable(nextChar)) { 119 this._addCharacter(nextChar); 120 i++; 121 isEscape = true; 122 } 120 123 } 121 124 } … … 217 220 var ps = this.parsingStatus; 218 221 if (this.columnsFromHeader && ps.rows === 0) { 219 this.setColumnNames(ps.openRecord); 222 // user has passed columnNames through option 223 if (this.columnNames.length === 0) 224 this.setColumnNames(ps.openRecord); 220 225 } else if (this.columnNames != null && this.columnNames.length > 0) { 221 226 var objResult = {}; … … 327 332 function _setOptions(obj, options) { 328 333 options = options || {}; 329 obj.separator = options.separator ||',';330 obj.quotechar = options.quote ||'"';331 obj.escapechar = options.escape ||'"';332 obj.commentchar = options.comment ||'';333 obj.columnNames = options.columnNames ||[];334 obj.columnsFromHeader = options.columnsFromHeader ||false;335 obj.nestedQuotes = options.nestedQuotes ||false;336 }; 334 obj.separator = (typeof options.separator !== 'undefined') ? options.separator : ','; 335 obj.quotechar = (typeof options.quote !== 'undefined') ? options.quote : '"'; 336 obj.escapechar = (typeof options.escape !== 'undefined') ? options.escape : '"'; 337 obj.commentchar = (typeof options.comment !== 'undefined') ? options.comment : ''; 338 obj.columnNames = (typeof options.columnNames !== 'undefined') ? options.columnNames : []; 339 obj.columnsFromHeader = (typeof options.columnsFromHeader !== 'undefined') ? options.columnsFromHeader : false; 340 obj.nestedQuotes = (typeof options.nestedQuotes !== 'undefined') ? options.nestedQuotes : false; 341 };
Note: See TracChangeset
for help on using the changeset viewer.