The array-like object to search.
The predicate function to apply to the values.
The index of the first element in the range to be
searched, inclusive. The default value is 0
. Negative values
are taken as an offset from the end of the array.
The index of the last element in the range to be
searched, inclusive. The default value is -1
. Negative values
are taken as an offset from the end of the array.
The first matching value, or undefined
if no matching
value is found.
If stop < start
the search will wrap at the end of the array.
Linear.
A start
or stop
which is non-integral.
Modifying the length of the array while searching.
import { ArrayExt } from '@lumino/algorithm';
function isEven(value: number): boolean {
return value % 2 === 0;
}
let data = [1, 2, 3, 4, 3, 2, 1];
ArrayExt.findFirstValue(data, isEven); // 2
ArrayExt.findFirstValue(data, isEven, 2); // 4
ArrayExt.findFirstValue(data, isEven, 6); // undefined
ArrayExt.findFirstValue(data, isEven, 6, 5); // 2
Find the first value which matches a predicate.