Update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
c729e26a57
commit
59b75ee1a1
|
@ -10378,7 +10378,7 @@ class Parser extends Transform {
|
|||
const date = Date.parse(value)
|
||||
return !isNaN(date) ? new Date(date) : value
|
||||
}
|
||||
}else if(typeof options.cast_date !== 'function'){
|
||||
}else{
|
||||
throw new CsvError('CSV_INVALID_OPTION_CAST_DATE', [
|
||||
'Invalid option cast_date:', 'cast_date must be true or a function,',
|
||||
`got ${JSON.stringify(options.cast_date)}`
|
||||
|
@ -10714,6 +10714,7 @@ class Parser extends Transform {
|
|||
}
|
||||
}
|
||||
this.info = {
|
||||
bytes: 0,
|
||||
comment_lines: 0,
|
||||
empty_lines: 0,
|
||||
invalid_field_length: 0,
|
||||
|
@ -10723,6 +10724,7 @@ class Parser extends Transform {
|
|||
this.options = options
|
||||
this.state = {
|
||||
bomSkipped: false,
|
||||
bufBytesStart: 0,
|
||||
castField: fnCastField,
|
||||
commenting: false,
|
||||
// Current error encountered by a record
|
||||
|
@ -10809,7 +10811,9 @@ class Parser extends Transform {
|
|||
for(let encoding in boms){
|
||||
if(boms[encoding].compare(buf, 0, boms[encoding].length) === 0){
|
||||
// Skip BOM
|
||||
buf = buf.slice(boms[encoding].length)
|
||||
let bomLength = boms[encoding].length
|
||||
this.state.bufBytesStart += bomLength
|
||||
buf = buf.slice(bomLength)
|
||||
// Renormalize original options with the new encoding
|
||||
this.__normalizeOptions({...this.__originalOptions, encoding: encoding})
|
||||
break
|
||||
|
@ -10949,8 +10953,10 @@ class Parser extends Transform {
|
|||
pos += recordDelimiterLength - 1
|
||||
continue
|
||||
}
|
||||
this.info.bytes = this.state.bufBytesStart + pos;
|
||||
const errField = this.__onField()
|
||||
if(errField !== undefined) return errField
|
||||
this.info.bytes = this.state.bufBytesStart + pos + recordDelimiterLength;
|
||||
const errRecord = this.__onRecord()
|
||||
if(errRecord !== undefined) return errRecord
|
||||
if(to !== -1 && this.info.records >= to){
|
||||
|
@ -10973,6 +10979,7 @@ class Parser extends Transform {
|
|||
}
|
||||
let delimiterLength = this.__isDelimiter(buf, pos, chr)
|
||||
if(delimiterLength !== 0){
|
||||
this.info.bytes = this.state.bufBytesStart + pos;
|
||||
const errField = this.__onField()
|
||||
if(errField !== undefined) return errField
|
||||
pos += delimiterLength - 1
|
||||
|
@ -11022,6 +11029,7 @@ class Parser extends Transform {
|
|||
}else{
|
||||
// Skip last line if it has no characters
|
||||
if(this.state.wasQuoting === true || this.state.record.length !== 0 || this.state.field.length !== 0){
|
||||
this.info.bytes = this.state.bufBytesStart + pos;
|
||||
const errField = this.__onField()
|
||||
if(errField !== undefined) return errField
|
||||
const errRecord = this.__onRecord()
|
||||
|
@ -11033,6 +11041,7 @@ class Parser extends Transform {
|
|||
}
|
||||
}
|
||||
}else{
|
||||
this.state.bufBytesStart += pos
|
||||
this.state.previousBuf = buf.slice(pos)
|
||||
}
|
||||
if(this.state.wasRowDelimiter === true){
|
||||
|
@ -11447,7 +11456,7 @@ const parse = function(){
|
|||
throw new CsvError('CSV_INVALID_ARGUMENT', [
|
||||
'Invalid argument:',
|
||||
`got ${JSON.stringify(argument)} at index ${i}`
|
||||
], this.options)
|
||||
], options || {})
|
||||
}
|
||||
}
|
||||
const parser = new Parser(options)
|
||||
|
|
Loading…
Reference in New Issue