Skip to content

Commit 0d8534e

Browse files
authored
fix: throw error for empty dataset only if fields not specified
1 parent 1349a94 commit 0d8534e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/JSON2CSVParser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class JSON2CSVParser extends JSON2CSVBase {
4040
preprocessData(data) {
4141
const processedData = Array.isArray(data) ? data : [data];
4242

43-
if (processedData.length === 0 || typeof processedData[0] !== 'object') {
43+
if (!this.opts.fields && processedData.length === 0 || typeof processedData[0] !== 'object') {
4444
throw new Error('Data should not be empty or the "fields" option should be included');
4545
}
4646

@@ -63,4 +63,4 @@ class JSON2CSVParser extends JSON2CSVBase {
6363
}
6464
}
6565

66-
module.exports = JSON2CSVParser;
66+
module.exports = JSON2CSVParser;

0 commit comments

Comments
 (0)