Slightly improve performance when merging schemas definitions with new lines

This commit is contained in:
Convly 2022-07-06 15:14:39 +02:00
parent da3cf961c5
commit 1fe3db7126

View File

@ -43,6 +43,18 @@ const generateSchemasDefinitions = async (options = {}) => {
definition: generateSchemaDefinition(schema),
}));
const formattedSchemasDefinitions = schemasDefinitions.reduce((acc, def) => {
acc.push(
// Definition
def.definition,
// Add a newline between each interface declaration
factory.createIdentifier('\n')
);
return acc;
}, []);
const allDefinitions = [
// Imports
generateImportDefinition(),
@ -51,15 +63,7 @@ const generateSchemasDefinitions = async (options = {}) => {
factory.createIdentifier('\n'),
// Schemas
...schemasDefinitions.reduce(
(acc, def) => [
...acc,
def.definition,
// Add a newline between each interface declaration
factory.createIdentifier('\n'),
],
[]
),
...formattedSchemasDefinitions,
// Global
generateGlobalDefinition(schemasDefinitions),