From a72e0b16fd7bce80a1805c58a7f97c06a70d2eb8 Mon Sep 17 00:00:00 2001 From: David Worms Date: Tue, 13 Nov 2018 15:37:51 +0100 Subject: [PATCH] parser: move record delimiter declaration --- lib/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 6c09827..2489132 100644 --- a/lib/index.js +++ b/lib/index.js @@ -242,7 +242,6 @@ class Parser extends Transform { if((chr === cr || chr === nl) && this.state.wasRowDelimiter === false ){ this.state.wasRowDelimiter = true } - let recordDelimiterLength = this.__isRecordDelimiter(chr, buf, pos) // Previous char was a valid escape char // treat the current char as a regular char if(this.state.escaping === true){ @@ -303,6 +302,7 @@ class Parser extends Transform { } } if(this.state.quoting === false){ + let recordDelimiterLength = this.__isRecordDelimiter(chr, buf, pos) if(recordDelimiterLength !== 0){ // Do not emit comments which take a full line const skipCommentLine = this.state.commenting && (this.state.record.length === 0 && this.state.field.length === 0) @@ -315,7 +315,7 @@ class Parser extends Transform { this.info.empty_lines++ continue } - if(this.state.enabled === false && this.info.lines + (this.state.wasRowDelimiter ? 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.__resetRow()