From 1d1f9f9c9082d49a5252c4fe8f98e8c8a0a61930 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Sun, 20 Jan 2019 18:55:14 +0100 Subject: [PATCH] Replaced findIndex for find to get directly the pass type --- src/pass.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pass.js b/src/pass.js index 2ef4470..2cfe43d 100644 --- a/src/pass.js +++ b/src/pass.js @@ -528,16 +528,13 @@ class Pass { let passTypes = ["boardingPass", "eventTicket", "coupon", "generic", "storeCard"]; 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; } - let type = passTypes[index]; - - this.type = type; - return schema.isValid(passFile[type], "passDict"); + return schema.isValid(passFile[this.type], "passDict"); } /**