typedash
Version:
modern, type-safe collection of utility functions
15 lines (14 loc) • 550 B
JavaScript
//#region src/functions/max/max.ts
/**
* Implementation for all overloads.
* @param array The array to iterate over.
* @param valueExtractor The function used to extract a numeric value from each element.
* @returns The maximum value in the array, or `undefined` if the array is empty or nil.
*/
function max(array, valueExtractor = (value) => value) {
if (array == null || array.length === 0) return;
return Math.max(...array.map((element) => valueExtractor(element)));
}
//#endregion
export { max as t };
//# sourceMappingURL=max-C4sF-2Gr.js.map