Improve JS function itemTypeFromName code a bit

This commit is contained in:
Guillaume Gomez 2023-02-11 18:03:06 +01:00
parent 5919f62cf6
commit d505c5abe4

View File

@ -142,13 +142,11 @@ function initSearch(rawSearchIndex) {
}
function itemTypeFromName(typename) {
for (let i = 0, len = itemTypes.length; i < len; ++i) {
if (itemTypes[i] === typename) {
return i;
}
const index = itemTypes.findIndex(i => i === typename);
if (index < 0) {
throw new Error("Unknown type filter `" + typename + "`");
}
throw new Error("Unknown type filter `" + typename + "`");
return index;
}
/**