Added optimization for creation of FieldsArray

This commit is contained in:
Alexander Cerutti
2019-06-18 22:33:09 +02:00
parent 816f315fca
commit c733a4ea58

View File

@@ -75,19 +75,13 @@ export class Pass implements PassIndexSignature {
this[transitType] = this.passCore[this.type]["transitType"]; this[transitType] = this.passCore[this.type]["transitType"];
} }
const typeFields = Object.keys(this.passCore[this.type]) as (keyof schema.PassFields)[];
this._fields = ["primaryFields", "secondaryFields", "auxiliaryFields", "backFields", "headerFields"]; this._fields = ["primaryFields", "secondaryFields", "auxiliaryFields", "backFields", "headerFields"];
this._fields.forEach(fieldName => { this._fields.forEach(fieldName => {
if (typeFields.includes(fieldName)) { this[fieldName] = new FieldsArray(
this[fieldName] = new FieldsArray( this.fieldsKeys,
this.fieldsKeys, ...(this.passCore[this.type][fieldName] || [])
...this.passCore[this.type][fieldName] .filter(field => schema.isValid(field, "field"))
.filter(field => schema.isValid(field, "field")) );
);
} else {
this[fieldName] = new FieldsArray(this.fieldsKeys);
}
}); });
} }