UNPKG

@dvcol/common-utils

Version:

Typescript library for common utility functions and constants

15 lines (13 loc) 742 B
/** * Returns the maximum value of an array of objects by a given property * @param array - The array to search * @param prop - The property to compare * @param filter - Optional filter function */ declare const arrayMax: <T>(array: Array<T>, prop: keyof T, filter?: (item: T) => boolean) => T; declare const findClosestMatch: (value: number, array?: string[]) => string; declare const clamp: (val: number, min: number, max: number) => number; declare const randomInt: (min?: number, max?: number) => number; declare const round: (value: number, precision?: number) => number; declare const percent: (value: number, total?: number, precision?: number) => number; export { arrayMax, clamp, findClosestMatch, percent, randomInt, round };