Better check for returned value
This commit is contained in:
parent
56dbb3e32d
commit
6f21008aba
1 changed files with 14 additions and 0 deletions
|
@ -371,6 +371,11 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
function checkReturned(obj, val) {
|
||||
return obj && obj.type && obj.type.output &&
|
||||
obj.type.output.name.toLowerCase() === val;
|
||||
}
|
||||
|
||||
function typePassesFilter(filter, type) {
|
||||
// No filter
|
||||
if (filter < 0) return true;
|
||||
|
@ -503,6 +508,15 @@
|
|||
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) {
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue