Better check for returned value
This commit is contained in:
@@ -371,6 +371,11 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkReturned(obj, val) {
|
||||||
|
return obj && obj.type && obj.type.output &&
|
||||||
|
obj.type.output.name.toLowerCase() === val;
|
||||||
|
}
|
||||||
|
|
||||||
function typePassesFilter(filter, type) {
|
function typePassesFilter(filter, type) {
|
||||||
// No filter
|
// No filter
|
||||||
if (filter < 0) return true;
|
if (filter < 0) return true;
|
||||||
@@ -503,6 +508,15 @@
|
|||||||
lev: lev_distance,
|
lev: lev_distance,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else if (checkReturned(searchIndex[j], val)) {
|
||||||
|
if (typePassesFilter(typeFilter, searchIndex[j].ty)) {
|
||||||
|
results.push({
|
||||||
|
id: j,
|
||||||
|
index: 0,
|
||||||
|
// we want lev results to go lower than others
|
||||||
|
lev: lev_distance,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (results.length === max) {
|
if (results.length === max) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user