Use Array.prototype.findIndex

This commit is contained in:
Tim Schaub
2022-07-27 14:00:06 -06:00
parent 157bdc5208
commit 82ceaea4ab
3 changed files with 3 additions and 39 deletions

View File

@@ -208,20 +208,6 @@ export function stableSort(arr, compareFnc) {
}
}
/**
* @param {Array<*>} arr The array to search in.
* @param {Function} func Comparison function.
* @return {number} Return index.
*/
export function findIndex(arr, func) {
let index;
const found = !arr.every(function (el, idx) {
index = idx;
return !func(el, idx, arr);
});
return found ? index : -1;
}
/**
* @param {Array<*>} arr The array to test.
* @param {Function} [opt_func] Comparison function.