From c8865f7c052332ff94afe178a94899bfe71f580f Mon Sep 17 00:00:00 2001 From: Christoph Wanasek <> Date: Wed, 17 Jul 2019 14:59:22 +0200 Subject: [PATCH 1/2] fix #130: pass absolute line-number to data-invalid handler (adapted test) --- src/parser/CsvParserStream.ts | 1 - test/parser/CsvParsingStream.test.ts | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/parser/CsvParserStream.ts b/src/parser/CsvParserStream.ts index ab16f8e1..d467de6d 100644 --- a/src/parser/CsvParserStream.ts +++ b/src/parser/CsvParserStream.ts @@ -106,7 +106,6 @@ export default class CsvParserStream extends Transform { return cb(new Error('expected transform result')); } if (!transformResult.isValid) { - this.rowCount -= 1; this.emit('data-invalid', transformResult.row, nextRowCount, transformResult.reason); } else if (!transformResult.row) { this.rowCount -= 1; diff --git a/test/parser/CsvParsingStream.test.ts b/test/parser/CsvParsingStream.test.ts index 7c3591e8..d9f4b1da 100644 --- a/test/parser/CsvParsingStream.test.ts +++ b/test/parser/CsvParsingStream.test.ts @@ -211,7 +211,7 @@ describe('CsvParserStream', () => { .then(({ count, rows, invalidRows }) => { assert.deepStrictEqual(rows, expectedRows); assert.deepStrictEqual(invalidRows, expectedInvalidRows); - assert.strictEqual(count, rows.length); + assert.strictEqual(count, rows.length + invalidRows.length); }); }); @@ -280,7 +280,7 @@ describe('CsvParserStream', () => { .then(({ count, rows, invalidRows }) => { assert.deepStrictEqual(invalidRows, invalidValid[1]); assert.deepStrictEqual(rows, invalidValid[0]); - assert.strictEqual(count, invalidValid[0].length); + assert.strictEqual(count, invalidValid[0].length + invalidValid[1].length); }); }); @@ -294,7 +294,7 @@ describe('CsvParserStream', () => { .then(({ count, rows, invalidRows }) => { assert.deepStrictEqual(invalidRows, invalidValid[1]); assert.deepStrictEqual(rows, invalidValid[0]); - assert.strictEqual(count, invalidValid[0].length); + assert.strictEqual(count, invalidValid[0].length + invalidValid[1].length); }); }); From 59322548f5144f2871e06bb085b00b68c126a83c Mon Sep 17 00:00:00 2001 From: doug-martin Date: Sat, 27 Jul 2019 19:11:06 -0500 Subject: [PATCH 2/2] v3.2.0 * [FIXED] Invalid row index doesn't reflect original row count #130 #266 - @chrwnsk --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index da3d2143..4348cfec 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,7 @@ +# v3.2.0 + +* [FIXED] Invalid row index doesn't reflect original row count [#130](https://github.com/C2FO/fast-csv/issues/130) [#266](https://github.com/C2FO/fast-csv/pull/266) - [@chrwnsk](https://github.com/chrwnsk) + # v3.1.0 * Skip trailing whitespace after a quoted field [#223](https://github.com/C2FO/fast-csv/pull/223) - [@peet](https://github.com/peet) diff --git a/package.json b/package.json index 50ea3fed..0214bb21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fast-csv", - "version": "3.1.0", + "version": "3.2.0", "description": "CSV parser and writer", "main": "./build/src/index.js", "types": "./build/src/index.d.ts",