This repository has been archived on 2026-03-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
StasisWarden-Legacy/node_modules/es-toolkit/dist/array/maxBy.mjs
T

19 lines
429 B
JavaScript

function maxBy(items, getValue) {
if (items.length === 0) {
return undefined;
}
let maxElement = items[0];
let max = getValue(maxElement);
for (let i = 1; i < items.length; i++) {
const element = items[i];
const value = getValue(element);
if (value > max) {
max = value;
maxElement = element;
}
}
return maxElement;
}
export { maxBy };