UNPKG

typedash

Version:

modern, type-safe collection of utility functions

15 lines (14 loc) 559 B
//#region src/functions/min/min.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 minimum value in the array, or `undefined` if the array is empty or nil. */ function min(array, valueExtractor = (value) => value) { if (array == null || array.length === 0) return; return array.reduce((a, b) => valueExtractor(a) < valueExtractor(b) ? a : b); } //#endregion export { min as t }; //# sourceMappingURL=min-C2wwKxTj.js.map