UNPKG

typedash

Version:

modern, type-safe collection of utility functions

21 lines (19 loc) 636 B
//#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 Object.defineProperty(exports, 'max', { enumerable: true, get: function () { return max; } }); //# sourceMappingURL=max-2GsfVaI-.cjs.map