diff --git a/lib/browser/index.js b/lib/browser/index.js index 2c1594d..2c427bc 100644 --- a/lib/browser/index.js +++ b/lib/browser/index.js @@ -6995,7 +6995,7 @@ class Parser extends Transform { recordDelimiterMaxLength: options.record_delimiter.length === 0 ? 2 : Math.max(...options.record_delimiter.map( (v) => v.length)), trimChars: [Buffer.from(' ', options.encoding)[0], Buffer.from('\t', options.encoding)[0]], wasQuoting: false, - wasRecordDelimiter: false + wasRowDelimiter: false } } // Implementation of `Transform._transform` @@ -7068,12 +7068,12 @@ class Parser extends Transform { if(this.__needMoreData(pos, bufLen, end)){ break } - if(this.state.wasRecordDelimiter === true){ + if(this.state.wasRowDelimiter === true){ this.info.lines++ if(info === true && this.state.record.length === 0 && this.state.field.length === 0 && this.state.wasQuoting === false){ this.state.info = Object.assign({}, this.info) } - this.state.wasRecordDelimiter = false + this.state.wasRowDelimiter = false } if(to_line !== -1 && this.info.lines > to_line){ this.state.stop = true @@ -7091,8 +7091,8 @@ class Parser extends Transform { if(raw === true){ rawBuffer.append(chr) } - 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 // treat the current char as a regular char @@ -7187,7 +7187,7 @@ class Parser extends Transform { 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 this.__resetField() this.__resetRecord() @@ -7273,7 +7273,7 @@ class Parser extends Transform { if(errField !== undefined) return errField const errRecord = this.__onRecord() if(errRecord !== undefined) return errRecord - }else if(this.state.wasRecordDelimiter === true){ + }else if(this.state.wasRowDelimiter === true){ this.info.empty_lines++ }else if(this.state.commenting === true){ this.info.comment_lines++ @@ -7282,9 +7282,9 @@ class Parser extends Transform { }else{ this.state.previousBuf = buf.slice(pos) } - if(this.state.wasRecordDelimiter === true){ + if(this.state.wasRowDelimiter === true){ this.info.lines++ - this.state.wasRecordDelimiter = false + this.state.wasRowDelimiter = false } } __onRecord(){ diff --git a/lib/browser/sync.js b/lib/browser/sync.js index 64adb60..c589a23 100644 --- a/lib/browser/sync.js +++ b/lib/browser/sync.js @@ -6995,7 +6995,7 @@ class Parser extends Transform { recordDelimiterMaxLength: options.record_delimiter.length === 0 ? 2 : Math.max(...options.record_delimiter.map( (v) => v.length)), trimChars: [Buffer.from(' ', options.encoding)[0], Buffer.from('\t', options.encoding)[0]], wasQuoting: false, - wasRecordDelimiter: false + wasRowDelimiter: false } } // Implementation of `Transform._transform` @@ -7068,12 +7068,12 @@ class Parser extends Transform { if(this.__needMoreData(pos, bufLen, end)){ break } - if(this.state.wasRecordDelimiter === true){ + if(this.state.wasRowDelimiter === true){ this.info.lines++ if(info === true && this.state.record.length === 0 && this.state.field.length === 0 && this.state.wasQuoting === false){ this.state.info = Object.assign({}, this.info) } - this.state.wasRecordDelimiter = false + this.state.wasRowDelimiter = false } if(to_line !== -1 && this.info.lines > to_line){ this.state.stop = true @@ -7091,8 +7091,8 @@ class Parser extends Transform { if(raw === true){ rawBuffer.append(chr) } - 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 // treat the current char as a regular char @@ -7187,7 +7187,7 @@ class Parser extends Transform { 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 this.__resetField() this.__resetRecord() @@ -7273,7 +7273,7 @@ class Parser extends Transform { if(errField !== undefined) return errField const errRecord = this.__onRecord() if(errRecord !== undefined) return errRecord - }else if(this.state.wasRecordDelimiter === true){ + }else if(this.state.wasRowDelimiter === true){ this.info.empty_lines++ }else if(this.state.commenting === true){ this.info.comment_lines++ @@ -7282,9 +7282,9 @@ class Parser extends Transform { }else{ this.state.previousBuf = buf.slice(pos) } - if(this.state.wasRecordDelimiter === true){ + if(this.state.wasRowDelimiter === true){ this.info.lines++ - this.state.wasRecordDelimiter = false + this.state.wasRowDelimiter = false } } __onRecord(){ diff --git a/lib/es5/index.js b/lib/es5/index.js index f7b2768..855aed0 100644 --- a/lib/es5/index.js +++ b/lib/es5/index.js @@ -531,7 +531,7 @@ var Parser = /*#__PURE__*/function (_Transform) { }))), trimChars: [Buffer.from(' ', options.encoding)[0], Buffer.from('\t', options.encoding)[0]], wasQuoting: false, - wasRecordDelimiter: false + wasRowDelimiter: false }; } // Implementation of `Transform._transform` @@ -642,14 +642,14 @@ var Parser = /*#__PURE__*/function (_Transform) { break; } - if (this.state.wasRecordDelimiter === true) { + if (this.state.wasRowDelimiter === true) { this.info.lines++; if (info === true && this.state.record.length === 0 && this.state.field.length === 0 && this.state.wasQuoting === false) { this.state.info = Object.assign({}, this.info); } - this.state.wasRecordDelimiter = false; + this.state.wasRowDelimiter = false; } if (to_line !== -1 && this.info.lines > to_line) { @@ -673,8 +673,8 @@ var Parser = /*#__PURE__*/function (_Transform) { rawBuffer.append(chr); } - 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 // treat the current char as a regular char @@ -767,7 +767,7 @@ var Parser = /*#__PURE__*/function (_Transform) { } // 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; this.__resetField(); @@ -858,7 +858,7 @@ var Parser = /*#__PURE__*/function (_Transform) { var _errRecord = this.__onRecord(); if (_errRecord !== undefined) return _errRecord; - } else if (this.state.wasRecordDelimiter === true) { + } else if (this.state.wasRowDelimiter === true) { this.info.empty_lines++; } else if (this.state.commenting === true) { this.info.comment_lines++; @@ -868,9 +868,9 @@ var Parser = /*#__PURE__*/function (_Transform) { this.state.previousBuf = buf.slice(pos); } - if (this.state.wasRecordDelimiter === true) { + if (this.state.wasRowDelimiter === true) { this.info.lines++; - this.state.wasRecordDelimiter = false; + this.state.wasRowDelimiter = false; } } }, { diff --git a/lib/index.js b/lib/index.js index 6b3577e..ab248d7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -456,7 +456,7 @@ class Parser extends Transform { recordDelimiterMaxLength: options.record_delimiter.length === 0 ? 2 : Math.max(...options.record_delimiter.map( (v) => v.length)), trimChars: [Buffer.from(' ', options.encoding)[0], Buffer.from('\t', options.encoding)[0]], wasQuoting: false, - wasRecordDelimiter: false + wasRowDelimiter: false } } // Implementation of `Transform._transform` @@ -529,12 +529,12 @@ class Parser extends Transform { if(this.__needMoreData(pos, bufLen, end)){ break } - if(this.state.wasRecordDelimiter === true){ + if(this.state.wasRowDelimiter === true){ this.info.lines++ if(info === true && this.state.record.length === 0 && this.state.field.length === 0 && this.state.wasQuoting === false){ this.state.info = Object.assign({}, this.info) } - this.state.wasRecordDelimiter = false + this.state.wasRowDelimiter = false } if(to_line !== -1 && this.info.lines > to_line){ this.state.stop = true @@ -552,8 +552,8 @@ class Parser extends Transform { if(raw === true){ rawBuffer.append(chr) } - 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 // treat the current char as a regular char @@ -648,7 +648,7 @@ class Parser extends Transform { 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 this.__resetField() this.__resetRecord() @@ -734,7 +734,7 @@ class Parser extends Transform { if(errField !== undefined) return errField const errRecord = this.__onRecord() if(errRecord !== undefined) return errRecord - }else if(this.state.wasRecordDelimiter === true){ + }else if(this.state.wasRowDelimiter === true){ this.info.empty_lines++ }else if(this.state.commenting === true){ this.info.comment_lines++ @@ -743,9 +743,9 @@ class Parser extends Transform { }else{ this.state.previousBuf = buf.slice(pos) } - if(this.state.wasRecordDelimiter === true){ + if(this.state.wasRowDelimiter === true){ this.info.lines++ - this.state.wasRecordDelimiter = false + this.state.wasRowDelimiter = false } } __onRecord(){ diff --git a/test/option.from_line.coffee b/test/option.from_line.coffee index c3cf883..aab06d7 100644 --- a/test/option.from_line.coffee +++ b/test/option.from_line.coffee @@ -80,7 +80,7 @@ describe 'Option `from_line`', -> ] unless err next err - it 'not influenced by record delimiters', (next) -> + it 'not influenced by `record_delimiter` option', (next) -> parse """ a,b,c:1,2, 3:d,e,f:4,5,