@fast-csv/parse
Advanced tools
Comparing version 4.1.0 to 4.1.1
@@ -16,2 +16,3 @@ /// <reference types="node" /> | ||
private endEmitted; | ||
private headersEmitted; | ||
constructor(parserOptions: ParserOptions); | ||
@@ -29,3 +30,5 @@ private get hasHitRowLimit(); | ||
private transformRow; | ||
private checkAndEmitHeaders; | ||
private skipRow; | ||
private pushRow; | ||
} |
@@ -15,2 +15,3 @@ "use strict"; | ||
this.endEmitted = false; | ||
this.headersEmitted = false; | ||
this.parserOptions = parserOptions; | ||
@@ -101,2 +102,3 @@ this.parser = new parser_1.Parser(parserOptions); | ||
}; | ||
this.checkAndEmitHeaders(); | ||
// if we have emitted all rows or we have hit the maxRows limit option | ||
@@ -144,3 +146,7 @@ // then end | ||
if (!withHeaders.isValid) { | ||
return cb(null, { isValid: false, row: parsedRow }); | ||
if (this.shouldEmitRows) { | ||
return cb(null, { isValid: false, row: parsedRow }); | ||
} | ||
// skipped because of skipRows option remove from total row count | ||
return this.skipRow(cb); | ||
} | ||
@@ -152,4 +158,3 @@ if (withHeaders.row) { | ||
// skipped because of skipRows option remove from total row count | ||
this.rowCount -= 1; | ||
return cb(null, { row: null, isValid: true }); | ||
return this.skipRow(cb); | ||
} | ||
@@ -166,2 +171,13 @@ // this is a header row dont include in the rowCount or parsedRowCount | ||
} | ||
checkAndEmitHeaders() { | ||
if (!this.headersEmitted && this.headerTransformer.headers) { | ||
this.headersEmitted = true; | ||
this.emit('headers', this.headerTransformer.headers); | ||
} | ||
} | ||
skipRow(cb) { | ||
// skipped because of skipRows option remove from total row count | ||
this.rowCount -= 1; | ||
return cb(null, { row: null, isValid: true }); | ||
} | ||
pushRow(row, cb) { | ||
@@ -168,0 +184,0 @@ try { |
import { ParserOptions } from '../ParserOptions'; | ||
import { Row, RowArray, RowValidatorCallback } from '../types'; | ||
import { HeaderArray, Row, RowArray, RowValidatorCallback } from '../types'; | ||
export declare class HeaderTransformer<O extends Row> { | ||
private readonly parserOptions; | ||
private headers; | ||
headers: HeaderArray | null; | ||
private receivedHeaders; | ||
@@ -7,0 +7,0 @@ private readonly shouldUseFirstRow; |
{ | ||
"name": "@fast-csv/parse", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"description": "fast-csv parsing package", | ||
@@ -32,2 +32,3 @@ "keywords": [ | ||
"scripts": { | ||
"prepare": "npm run build", | ||
"build": "npm run clean && npm run compile", | ||
@@ -60,3 +61,3 @@ "clean": "rm -rf ./build && rm -rf tsconfig.tsbuildinfo", | ||
}, | ||
"gitHead": "682710d90cb3c80c35e067cbe02d18eb822a7873" | ||
"gitHead": "1cf0c07413504f28bec613e3b82efa439c0f8b2f" | ||
} |
Sorry, the diff of this file is not supported yet
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
86022
1178