import { max2 } from "../../math/max2.js";
import { min2 } from "../../math/min2.js";

/**
 *
 * @param {number[]} data
 * @return {number[]} [min, max]
 */
export function array_compute_min_max(data) {
    const point_count = data.length;

    let min = Number.POSITIVE_INFINITY;
    let max = Number.NEGATIVE_INFINITY;

    for (let i = 0; i < point_count; i++) {
        min = min2(data[i], min);
        max = max2(data[i], max);
    }

    return [min, max];
}