export function maxBy(array, selector) {
    let max = undefined;
    let maxValue = undefined;
    for (const current of array) {
        const currentValue = selector(current);
        if (maxValue === undefined || currentValue > maxValue) {
            max = current;
            maxValue = currentValue;
        }
    }
    return max;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWF4X2J5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsibWF4X2J5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXVDQSxNQUFNLFVBQVUsS0FBSyxDQUNuQixLQUFtQixFQUNuQixRQUlxQjtJQUVyQixJQUFJLEdBQUcsR0FBa0IsU0FBUyxDQUFDO0lBQ25DLElBQUksUUFBUSxHQUE0QyxTQUFTLENBQUM7SUFFbEUsS0FBSyxNQUFNLE9BQU8sSUFBSSxLQUFLLEVBQUU7UUFDM0IsTUFBTSxZQUFZLEdBQUcsUUFBUSxDQUFDLE9BQU8sQ0FBQyxDQUFDO1FBRXZDLElBQUksUUFBUSxLQUFLLFNBQVMsSUFBSSxZQUFZLEdBQUcsUUFBUSxFQUFFO1lBQ3JELEdBQUcsR0FBRyxPQUFPLENBQUM7WUFDZCxRQUFRLEdBQUcsWUFBWSxDQUFDO1NBQ3pCO0tBQ0Y7SUFFRCxPQUFPLEdBQUcsQ0FBQztBQUNiLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvLyBDb3B5cmlnaHQgMjAxOC0yMDIxIHRoZSBEZW5vIGF1dGhvcnMuIEFsbCByaWdodHMgcmVzZXJ2ZWQuIE1JVCBsaWNlbnNlLlxuLy8gVGhpcyBtb2R1bGUgaXMgYnJvd3NlciBjb21wYXRpYmxlLlxuXG4vKipcbiAqIFJldHVybnMgdGhlIGZpcnN0IGVsZW1lbnQgdGhhdCBpcyB0aGUgbGFyZ2VzdCB2YWx1ZSBvZiB0aGUgZ2l2ZW4gZnVuY3Rpb24gb3IgdW5kZWZpbmVkIGlmIHRoZXJlIGFyZSBubyBlbGVt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