Skip to content

Commit

Permalink
fix: throw error for empty dataset only if fields not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
knownasilya authored Apr 9, 2018
1 parent 1349a94 commit 0d8534e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/JSON2CSVParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class JSON2CSVParser extends JSON2CSVBase {
preprocessData(data) {
const processedData = Array.isArray(data) ? data : [data];

if (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');
}

Expand All @@ -63,4 +63,4 @@ class JSON2CSVParser extends JSON2CSVBase {
}
}

module.exports = JSON2CSVParser;
module.exports = JSON2CSVParser;

0 comments on commit 0d8534e

Please sign in to comment.