mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 22:25:24 +00:00
Fixed beacons and locations content getting
This commit is contained in:
19
src/pass.ts
19
src/pass.ts
@@ -274,13 +274,13 @@ export class Pass implements PassIndexSignature {
|
||||
*/
|
||||
|
||||
beacons(...data: schema.Beacon[]): PassWithLengthField | schema.Beacon[] {
|
||||
if (data === undefined) {
|
||||
return this._props["beacons"];
|
||||
if (data === null) {
|
||||
delete this._props["beacons"];
|
||||
return assignLength<PassWithLengthField>(0, this);
|
||||
}
|
||||
|
||||
if (!data.length) {
|
||||
this._props["beacons"] = [];
|
||||
return assignLength(0, this);
|
||||
return this._props["beacons"];
|
||||
}
|
||||
|
||||
const validBeacons = data.reduce<schema.Beacon[]>((acc, current) => {
|
||||
@@ -307,13 +307,13 @@ export class Pass implements PassIndexSignature {
|
||||
*/
|
||||
|
||||
locations(...data: schema.Location[]): PassWithLengthField | schema.Location[] {
|
||||
if (data === undefined) {
|
||||
return this._props["locations"];
|
||||
if (data === null) {
|
||||
delete this._props["locations"];
|
||||
return assignLength<PassWithLengthField>(0, this);
|
||||
}
|
||||
|
||||
if (!data.length) {
|
||||
this._props["locations"] = [];
|
||||
return assignLength(0, this);
|
||||
return this._props["locations"];
|
||||
}
|
||||
|
||||
const validLocations = data.reduce<schema.Location[]>((acc, current) => {
|
||||
@@ -328,8 +328,6 @@ export class Pass implements PassIndexSignature {
|
||||
return assignLength(0, this);
|
||||
}
|
||||
|
||||
console.log("Locations:", this._props["locations"]);
|
||||
|
||||
(this._props["locations"] || (this._props["locations"] = [])).push(...validLocations);
|
||||
|
||||
return assignLength(this._props["locations"].length, this);
|
||||
@@ -377,7 +375,6 @@ export class Pass implements PassIndexSignature {
|
||||
*/
|
||||
|
||||
barcode(first?: string | schema.Barcode, ...data: schema.Barcode[]): PassWithBarcodeMethods | schema.Barcode[] {
|
||||
console.log(first, data);
|
||||
if (first === undefined && (data === undefined || !data.length)) {
|
||||
return this._props["barcodes"];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user