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) {
3535 * list of field names.
3636 */
3737 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+
3843 // If the user wants to check for the same schema (regardless of schema ordering)
3944 if ( options . checkSchemaDifferences ) {
4045 return checkSchemaDifferences ( documentSchemas ) ;
@@ -53,8 +58,8 @@ export const Json2Csv = function(options: FullJson2CsvOptions) {
5358 function checkSchemaDifferences ( documentSchemas : string [ ] [ ] ) {
5459 // have multiple documents - ensure only one schema (regardless of field ordering)
5560 const firstDocSchema = documentSchemas [ 0 ] ,
56- restOfDocumentSchemas = documentSchemas . slice ( 1 ) ,
57- schemaDifferences = computeNumberOfSchemaDifferences ( firstDocSchema , restOfDocumentSchemas ) ;
61+ restOfDocumentSchemas = documentSchemas . slice ( 1 ) ,
62+ schemaDifferences = computeNumberOfSchemaDifferences ( firstDocSchema , restOfDocumentSchemas ) ;
5863
5964 // If there are schema inconsistencies, throw a schema not the same error
6065 if ( schemaDifferences ) {
You can’t perform that action at this time.
0 commit comments