@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
21 lines (17 loc) • 485 B
JavaScript
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];
}