mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 18:25:24 +00:00
Added optimization for creation of FieldsArray
This commit is contained in:
@@ -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);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user