export function maxWith(array, comparator) {
    let max = undefined;
    let isFirst = true;
    for (const current of array) {
        if (isFirst || comparator(current, max) > 0) {
            max = current;
            isFirst = false;
        }
    }
    return max;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWF4X3dpdGguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJtYXhfd2l0aC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUF1QkEsTUFBTSxVQUFVLE9BQU8sQ0FDckIsS0FBbUIsRUFDbkIsVUFBa0M7SUFFbEMsSUFBSSxHQUFHLEdBQWtCLFNBQVMsQ0FBQztJQUNuQyxJQUFJLE9BQU8sR0FBRyxJQUFJLENBQUM7SUFFbkIsS0FBSyxNQUFNLE9BQU8sSUFBSSxLQUFLLEVBQUU7UUFDM0IsSUFBSSxPQUFPLElBQUksVUFBVSxDQUFDLE9BQU8sRUFBTSxHQUFHLENBQUMsR0FBRyxDQUFDLEVBQUU7WUFDL0MsR0FBRyxHQUFHLE9BQU8sQ0FBQztZQUNkLE9BQU8sR0FBRyxLQUFLLENBQUM7U0FDakI7S0FDRjtJQUVELE9BQU8sR0FBRyxDQUFDO0FBQ2IsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8vIENvcHlyaWdodCAyMDE4LTIwMjEgdGhlIERlbm8gYXV0aG9ycy4gQWxsIHJpZ2h0cyByZXNlcnZlZC4gTUlUIGxpY2Vuc2UuXG4vLyBUaGlzIG1vZHVsZSBpcyBicm93c2VyIGNvbXBhdGlibGUuXG5cbi8qKlxuICogUmV0dXJucyB0aGUgZmlyc3QgZWxlbWVudCBoYXZpbmcgdGhlIGxhcmdlc3QgdmFsdWUgYWNjb3JkaW5nIHRvIHRoZSBwcm92aWRlZFxuICogY29tcGFyYXRvciBvciB1bmRlZmluZWQgaWYgdGhlcmUgYXJlIG5vIGVsZW1lbnRzLlxuICpcbiAqIFRoZSBjb21wYXJhdG9yIGlzIGV4cGVjd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