The iterable object to search.
The 3-way comparison function to apply to the values.
It should return < 0
if the first value is less than the second.
0
if the values are equivalent, or > 0
if the first value is
greater than the second.
The maximum value in the iterable. If multiple values are
equivalent to the maximum, the left-most value is returned. If
the iterable is empty, this returns undefined
.
Linear.
import { max } from '@lumino/algorithm';
function numberCmp(a: number, b: number): number {
return a - b;
}
max([7, 4, 0, 3, 9, 4], numberCmp); // 9
Find the maximum value in an iterable.