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