Update generated content

This commit is contained in:
CrazyMax
2021-03-18 20:21:57 +01:00
parent 682140a802
commit 1f3247e079

41
dist/index.js generated vendored
View File

@@ -4856,7 +4856,7 @@ class Parser extends Transform {
recordDelimiterMaxLength: options.record_delimiter.length === 0 ? 2 : Math.max(...options.record_delimiter.map( (v) => v.length)), 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]], trimChars: [Buffer.from(' ', options.encoding)[0], Buffer.from('\t', options.encoding)[0]],
wasQuoting: false, wasQuoting: false,
wasRecordDelimiter: false wasRowDelimiter: false
} }
} }
// Implementation of `Transform._transform` // Implementation of `Transform._transform`
@@ -4929,12 +4929,12 @@ class Parser extends Transform {
if(this.__needMoreData(pos, bufLen, end)){ if(this.__needMoreData(pos, bufLen, end)){
break break
} }
if(this.state.wasRecordDelimiter === true){ if(this.state.wasRowDelimiter === true){
this.info.lines++ this.info.lines++
if(info === true && this.state.record.length === 0 && this.state.field.length === 0 && this.state.wasQuoting === false){ 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.info = Object.assign({}, this.info)
} }
this.state.wasRecordDelimiter = false this.state.wasRowDelimiter = false
} }
if(to_line !== -1 && this.info.lines > to_line){ if(to_line !== -1 && this.info.lines > to_line){
this.state.stop = true this.state.stop = true
@@ -4952,8 +4952,8 @@ class Parser extends Transform {
if(raw === true){ if(raw === true){
rawBuffer.append(chr) rawBuffer.append(chr)
} }
if((chr === cr || chr === nl) && this.state.wasRecordDelimiter === false ){ if((chr === cr || chr === nl) && this.state.wasRowDelimiter === false ){
this.state.wasRecordDelimiter = true this.state.wasRowDelimiter = true
} }
// Previous char was a valid escape char // Previous char was a valid escape char
// treat the current char as a regular char // treat the current char as a regular char
@@ -5041,25 +5041,24 @@ class Parser extends Transform {
this.info.comment_lines++ this.info.comment_lines++
// Skip full comment line // Skip full comment line
}else{ }else{
// Activate records emition if above 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()
pos += recordDelimiterLength - 1
continue
}
// Skip if line is empty and skip_empty_lines activated // Skip if line is empty and skip_empty_lines activated
if(skip_empty_lines === true && this.state.wasQuoting === false && this.state.record.length === 0 && this.state.field.length === 0){ if(skip_empty_lines === true && this.state.wasQuoting === false && this.state.record.length === 0 && this.state.field.length === 0){
this.info.empty_lines++ this.info.empty_lines++
pos += recordDelimiterLength - 1 pos += recordDelimiterLength - 1
continue continue
} }
// Activate records emition if above from_line const errField = this.__onField()
if(this.state.enabled === false && this.info.lines + (this.state.wasRecordDelimiter === true ? 1: 0 ) >= from_line){ if(errField !== undefined) return errField
this.state.enabled = true const errRecord = this.__onRecord()
this.__resetField() if(errRecord !== undefined) return errRecord
this.__resetRecord()
pos += recordDelimiterLength - 1
continue
}else{
const errField = this.__onField()
if(errField !== undefined) return errField
const errRecord = this.__onRecord()
if(errRecord !== undefined) return errRecord
}
if(to !== -1 && this.info.records >= to){ if(to !== -1 && this.info.records >= to){
this.state.stop = true this.state.stop = true
this.push(null) this.push(null)
@@ -5134,7 +5133,7 @@ class Parser extends Transform {
if(errField !== undefined) return errField if(errField !== undefined) return errField
const errRecord = this.__onRecord() const errRecord = this.__onRecord()
if(errRecord !== undefined) return errRecord if(errRecord !== undefined) return errRecord
}else if(this.state.wasRecordDelimiter === true){ }else if(this.state.wasRowDelimiter === true){
this.info.empty_lines++ this.info.empty_lines++
}else if(this.state.commenting === true){ }else if(this.state.commenting === true){
this.info.comment_lines++ this.info.comment_lines++
@@ -5143,9 +5142,9 @@ class Parser extends Transform {
}else{ }else{
this.state.previousBuf = buf.slice(pos) this.state.previousBuf = buf.slice(pos)
} }
if(this.state.wasRecordDelimiter === true){ if(this.state.wasRowDelimiter === true){
this.info.lines++ this.info.lines++
this.state.wasRecordDelimiter = false this.state.wasRowDelimiter = false
} }
} }
__onRecord(){ __onRecord(){