@fast-csv/parse
Advanced tools
Comparing version 4.3.1 to 4.3.2
@@ -32,2 +32,3 @@ /// <reference types="node" /> | ||
private pushRow; | ||
private static wrapDoneCallback; | ||
} |
@@ -56,2 +56,3 @@ "use strict"; | ||
} | ||
const wrappedCallback = CsvParserStream.wrapDoneCallback(done); | ||
try { | ||
@@ -61,12 +62,13 @@ const { lines } = this; | ||
const rows = this.parse(newLine, true); | ||
return this.processRows(rows, done); | ||
return this.processRows(rows, wrappedCallback); | ||
} | ||
catch (e) { | ||
return done(e); | ||
return wrappedCallback(e); | ||
} | ||
} | ||
_flush(done) { | ||
const wrappedCallback = CsvParserStream.wrapDoneCallback(done); | ||
// if we have hit our maxRows parsing limit then skip parsing | ||
if (this.hasHitRowLimit) { | ||
return done(); | ||
return wrappedCallback(); | ||
} | ||
@@ -76,6 +78,6 @@ try { | ||
const rows = this.parse(newLine, false); | ||
return this.processRows(rows, done); | ||
return this.processRows(rows, wrappedCallback); | ||
} | ||
catch (e) { | ||
return done(e); | ||
return wrappedCallback(e); | ||
} | ||
@@ -196,4 +198,19 @@ } | ||
} | ||
static wrapDoneCallback(done) { | ||
let errorCalled = false; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return (err, ...args) => { | ||
if (err) { | ||
if (errorCalled) { | ||
throw err; | ||
} | ||
errorCalled = true; | ||
done(err); | ||
return; | ||
} | ||
done(...args); | ||
}; | ||
} | ||
} | ||
exports.CsvParserStream = CsvParserStream; | ||
//# sourceMappingURL=CsvParserStream.js.map |
@@ -6,2 +6,13 @@ # Change Log | ||
## [4.3.2](https://github.com/C2FO/fast-csv/compare/v4.3.1...v4.3.2) (2020-09-02) | ||
### Bug Fixes | ||
* **parsing, #423:** Prevent callback from being called multiple times ([040febe](https://github.com/C2FO/fast-csv/commit/040febe17f5fe763a00f45b1d83c5acd47bbbe0b)), closes [#423](https://github.com/C2FO/fast-csv/issues/423) | ||
## [4.3.1](https://github.com/C2FO/fast-csv/compare/v4.3.0...v4.3.1) (2020-06-23) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@fast-csv/parse", | ||
"version": "4.3.1", | ||
"version": "4.3.2", | ||
"description": "fast-csv parsing package", | ||
@@ -56,7 +56,7 @@ "keywords": [ | ||
"@types/lodash.uniq": "4.5.6", | ||
"@types/sinon": "9.0.4", | ||
"@types/sinon": "9.0.5", | ||
"lodash.partition": "4.6.0", | ||
"sinon": "9.0.2" | ||
"sinon": "9.0.3" | ||
}, | ||
"gitHead": "23bf809cdee1f5bebd87d0304a4a5b4000ba81c3" | ||
"gitHead": "bbb783b68c651d607d8a9951aada3afdaea6d57e" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
84702
1223