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:
commit
76c47fb904
1 changed files with 4 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue