UNPKG

diginext-utils

Version:
18 lines 595 B
/** * Finds the maximum value in an array. * If a key is provided, finds the maximum value of that property from each object. * * @template T - The type of elements in the array * @param array - The array to search * @param key - Optional key to find maximum value from objects * @returns The maximum value, or 0 if array is empty * * @example * ```ts * max([3, 1, 4, 1, 5]); // 5 * max([{ value: 5 }, { value: 2 }, { value: 8 }], 'value'); // 8 * max([]); // 0 * ``` */ export declare function max<T = number>(array: T[], key?: keyof T): number; //# sourceMappingURL=max.d.ts.map