mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 20:25:26 +00:00
Re-engineered FieldContainer to extend successfully array with its method;
Overridden splice, push and pop methods and length prop for FieldsContainer; Renamed FieldsContainer to FieldsArray (also file);
This commit is contained in:
12
src/pass.js
12
src/pass.js
@@ -14,7 +14,7 @@ const loadDebug = debug("passkit:load");
|
||||
|
||||
const schema = require("./schema");
|
||||
const formatMessage = require("./messages");
|
||||
const FieldsContainer = require("./fields");
|
||||
const FieldsArray = require("./fieldsArray");
|
||||
|
||||
const readdir = promisify(fs.readdir);
|
||||
const readFile = promisify(fs.readFile);
|
||||
@@ -37,7 +37,7 @@ class Pass {
|
||||
|
||||
this._fields = ["primaryFields", "secondaryFields", "auxiliaryFields", "backFields", "headerFields"];
|
||||
|
||||
this._fields.forEach(a => this[a] = new FieldsContainer());
|
||||
this._fields.forEach(a => this[a] = new FieldsArray());
|
||||
this._transitType = "";
|
||||
|
||||
// Assigning model and _props to this
|
||||
@@ -212,7 +212,7 @@ class Pass {
|
||||
|
||||
archive.pipe(passStream);
|
||||
|
||||
FieldsContainer.emptyUnique();
|
||||
FieldsArray.emptyUnique();
|
||||
|
||||
return archive.finalize().then(() => passStream);
|
||||
});
|
||||
@@ -633,11 +633,11 @@ class Pass {
|
||||
}
|
||||
|
||||
this._fields.forEach(area => {
|
||||
if (this[area].fields.length) {
|
||||
if (this[area].length) {
|
||||
if (this.shouldOverwrite) {
|
||||
passFile[this.type][area] = this[area].fields;
|
||||
passFile[this.type][area] = [...this[area]];
|
||||
} else {
|
||||
passFile[this.type][area].push(...this[area].fields);
|
||||
passFile[this.type][area].push(...this[area]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user