mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 14:25:17 +00:00
Relevance now returns improved this with length property containing the amount of valid results pushed
This commit is contained in:
16
index.js
16
index.js
@@ -209,7 +209,9 @@ class Pass {
|
||||
let types = ["beacons", "locations", "maxDistance", "relevantDate"];
|
||||
|
||||
if (!type || !data || !types.includes(type)) {
|
||||
return 0;
|
||||
return Object.assign({
|
||||
length: 0
|
||||
}, this);
|
||||
}
|
||||
|
||||
if (type === "beacons" || type === "locations") {
|
||||
@@ -220,13 +222,17 @@ class Pass {
|
||||
let valid = data.filter(d => schema.isValid(d, schema.constants[type+"Dict"]));
|
||||
this.props[type] = valid;
|
||||
|
||||
return valid.length;
|
||||
return Object.assign({
|
||||
length: valid.length
|
||||
}, this);
|
||||
}
|
||||
|
||||
if (type === "maxDistance" && (typeof data === "string" || typeof data === "number")) {
|
||||
this.props[type] = Number(data);
|
||||
|
||||
return 1;
|
||||
return Object.assign({
|
||||
length: 1
|
||||
}, this);
|
||||
} else if (type === "relevantDate") {
|
||||
let convDate = dateToW3CString(data);
|
||||
|
||||
@@ -234,7 +240,9 @@ class Pass {
|
||||
this.props[type] = convDate;
|
||||
}
|
||||
|
||||
return Number(!!convDate);
|
||||
return Object.assign({
|
||||
length: Number(!!convDate)
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user