Type alias ArrayMax<Arr, M, Initial>

ArrayMax<Arr, M, Initial>: Arr["length"] extends 0
    ? Initial extends true
        ? never
        : M
    : Arr extends [infer A extends Numeric, ...(infer B extends Numeric[])]
        ? ArrayMax<B, _MaxInTwoNums<A, M>, false>
        : M

Extracts the maximum numeric value in a given Array

Type Parameters

Example

Max<[-54,2,0,999,69,2]>; // Result: 999
Max<[-54,-2,-90,-72,-69,-202]>; // Result: -2