File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,11 @@ export const Json2Csv = function(options: FullJson2CsvOptions) {
35
35
* list of field names.
36
36
*/
37
37
function processSchemas ( documentSchemas : string [ ] [ ] ) {
38
+ // If there are no document schemas then there is nothing to diff and no unqiue fields to get
39
+ if ( documentSchemas . length === 0 ) {
40
+ return [ ] ;
41
+ }
42
+
38
43
// If the user wants to check for the same schema (regardless of schema ordering)
39
44
if ( options . checkSchemaDifferences ) {
40
45
return checkSchemaDifferences ( documentSchemas ) ;
@@ -53,8 +58,8 @@ export const Json2Csv = function(options: FullJson2CsvOptions) {
53
58
function checkSchemaDifferences ( documentSchemas : string [ ] [ ] ) {
54
59
// have multiple documents - ensure only one schema (regardless of field ordering)
55
60
const firstDocSchema = documentSchemas [ 0 ] ,
56
- restOfDocumentSchemas = documentSchemas . slice ( 1 ) ,
57
- schemaDifferences = computeNumberOfSchemaDifferences ( firstDocSchema , restOfDocumentSchemas ) ;
61
+ restOfDocumentSchemas = documentSchemas . slice ( 1 ) ,
62
+ schemaDifferences = computeNumberOfSchemaDifferences ( firstDocSchema , restOfDocumentSchemas ) ;
58
63
59
64
// If there are schema inconsistencies, throw a schema not the same error
60
65
if ( schemaDifferences ) {
You can’t perform that action at this time.
0 commit comments