Replaced findIndex for find to get directly the pass type

This commit is contained in:
Alexander Cerutti
2019-01-20 18:55:14 +01:00
parent b32c2efcd0
commit 1d1f9f9c90

View File

@@ -528,16 +528,13 @@ class Pass {
let passTypes = ["boardingPass", "eventTicket", "coupon", "generic", "storeCard"]; let passTypes = ["boardingPass", "eventTicket", "coupon", "generic", "storeCard"];
let passFile = JSON.parse(passBuffer.toString("utf8")); let passFile = JSON.parse(passBuffer.toString("utf8"));
let index = passTypes.findIndex(passType => passFile.hasOwnProperty(passType)); this.type = passTypes.find(type => passFile.hasOwnProperty(type));
if (index == -1) { if (!this.type) {
return false; return false;
} }
let type = passTypes[index]; return schema.isValid(passFile[this.type], "passDict");
this.type = type;
return schema.isValid(passFile[type], "passDict");
} }
/** /**