Comparing version 4.0.3 to 4.0.4
@@ -5,2 +5,14 @@ # Change Log | ||
<a name="4.0.4"></a> | ||
## [4.0.4](https://github.com/zemirco/json2csv/compare/v4.0.3...v4.0.4) (2018-04-10) | ||
### Bug Fixes | ||
* comment out failing tests ([#283](https://github.com/zemirco/json2csv/issues/283)) ([5b25eaa](https://github.com/zemirco/json2csv/commit/5b25eaa)) | ||
* Support empty array with opts.fields ([#281](https://github.com/zemirco/json2csv/issues/281)) ([eccca89](https://github.com/zemirco/json2csv/commit/eccca89)) | ||
* **tests:** emit correct lines from transform ([#282](https://github.com/zemirco/json2csv/issues/282)) ([2322ddf](https://github.com/zemirco/json2csv/commit/2322ddf)) | ||
<a name="4.0.3"></a> | ||
@@ -7,0 +19,0 @@ ## [4.0.3](https://github.com/zemirco/json2csv/compare/v4.0.2...v4.0.3) (2018-04-09) |
@@ -43,3 +43,3 @@ 'use strict'; | ||
if (!this.opts.fields && processedData.length === 0 || typeof processedData[0] !== 'object') { | ||
if (!this.opts.fields && (processedData.length === 0 || typeof processedData[0] !== 'object')) { | ||
throw new Error('Data should not be empty or the "fields" option should be included'); | ||
@@ -46,0 +46,0 @@ } |
@@ -30,2 +30,6 @@ 'use strict'; | ||
if (this.opts.fields) { | ||
this.pushHeader(); | ||
} | ||
} | ||
@@ -125,2 +129,14 @@ | ||
/** | ||
* Generate the csv header and pushes it downstream. | ||
*/ | ||
pushHeader() { | ||
if (this.opts.header) { | ||
const header = this.getHeader(this.opts); | ||
this.emit('header', header); | ||
this.push(header); | ||
this._hasWritten = true; | ||
} | ||
} | ||
/** | ||
* Transforms an incoming json data to csv and pushes it downstream. | ||
@@ -135,8 +151,3 @@ * | ||
this.opts.fields = this.opts.fields || Object.keys(processedData[0]); | ||
if (this.opts.header) { | ||
const header = this.getHeader(this.opts); | ||
this.emit('header', header); | ||
this.push(header); | ||
this._hasWritten = true; | ||
} | ||
this.pushHeader(); | ||
} | ||
@@ -149,3 +160,3 @@ | ||
+ line; | ||
this.emit('line', eoledLine); | ||
this.emit('line', line); | ||
this.push(eoledLine); | ||
@@ -152,0 +163,0 @@ this._hasWritten = true; |
{ | ||
"name": "json2csv", | ||
"preferGlobal": "true", | ||
"version": "4.0.3", | ||
"version": "4.0.4", | ||
"description": "Convert JSON to CSV", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
895679
27166