Use Array.prototype.findIndex
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user