UNPKG

312 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3function maxBy(arr, fn) {
4 let max;
5 for (let cur of arr) {
6 let i = fn(cur);
7 if (!max || i > max.i) {
8 max = { i, element: cur };
9 }
10 }
11 return max && max.element;
12}
13exports.maxBy = maxBy;