mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 23:25:26 +00:00
Set back beacons and locations to overwrite the current properties;
Merged beacons and locations relevancy logic
This commit is contained in:
32
src/pass.ts
32
src/pass.ts
@@ -276,14 +276,11 @@ export class Pass implements PassIndexSignature {
|
|||||||
return assignLength<PassWithLengthField>(0, this);
|
return assignLength<PassWithLengthField>(0, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.length) {
|
const valid = processRelevancySet("beacons", data);
|
||||||
return this._props["beacons"];
|
|
||||||
}
|
|
||||||
|
|
||||||
const validBeacons = data.reduce<schema.Beacon[]>((acc, current) => {
|
if (valid.length) {
|
||||||
if (!(Object.keys(current).length && schema.isValid(current, "beaconsDict"))) {
|
this._props["beacons"] = valid;
|
||||||
return acc;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return [...acc, current];
|
return [...acc, current];
|
||||||
}, []);
|
}, []);
|
||||||
@@ -309,14 +306,11 @@ export class Pass implements PassIndexSignature {
|
|||||||
return assignLength<PassWithLengthField>(0, this);
|
return assignLength<PassWithLengthField>(0, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.length) {
|
const valid = processRelevancySet("locations", data);
|
||||||
return this._props["locations"];
|
|
||||||
}
|
|
||||||
|
|
||||||
const validLocations = data.reduce<schema.Location[]>((acc, current) => {
|
if (valid.length) {
|
||||||
if (!(Object.keys(current).length && schema.isValid(current, "locationsDict"))) {
|
this._props["locations"] = valid;
|
||||||
return acc;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return [...acc, current];
|
return [...acc, current];
|
||||||
}, []);
|
}, []);
|
||||||
@@ -684,6 +678,16 @@ function barcodesFromUncompleteData(message: string): schema.Barcode[] {
|
|||||||
].map(format => schema.getValidated({ format, message }, "barcode"));
|
].map(format => schema.getValidated({ format, message }, "barcode"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function processRelevancySet<T>(key: string, data: T[]): T[] {
|
||||||
|
return data.reduce<T[]>((acc, current) => {
|
||||||
|
if (!(Object.keys(current).length && schema.isValid(current, `${key}Dict`))) {
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...acc, current];
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
|
|
||||||
function processDate(key: string, date: Date): string | null {
|
function processDate(key: string, date: Date): string | null {
|
||||||
if (!(date instanceof Date)) {
|
if (!(date instanceof Date)) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user