site/node_modules/d3-array/src/max.js
2024-10-14 08:09:33 +02:00

20 lines
502 B
JavaScript

export default function max(values, valueof) {
let max;
if (valueof === undefined) {
for (const value of values) {
if (value != null
&& (max < value || (max === undefined && value >= value))) {
max = value;
}
}
} else {
let index = -1;
for (let value of values) {
if ((value = valueof(value, ++index, values)) != null
&& (max < value || (max === undefined && value >= value))) {
max = value;
}
}
}
return max;
}