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", 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); }); });