Rollup merge of #107930 - GuillaumeGomez:js-func-improvement, r=notriddle

Improve JS function itemTypeFromName code a bit

Very small code improvement replacing a `for` loop with `findIndex` method.

r? ````@notriddle````
This commit is contained in:
Matthias Krüger 2023-02-12 22:29:48 +01:00 committed by GitHub
commit 76c47fb904
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;
}
/**