(items: T[], getter: (item: T) => number)
| 74 | } |
| 75 | |
| 76 | export function getMaxBy<T>(items: T[], getter: (item: T) => number) { |
| 77 | return items.reduce((max, item) => { |
| 78 | const value = getter(item); |
| 79 | |
| 80 | if (value > max) return value; |
| 81 | |
| 82 | return max; |
| 83 | }, -Infinity); |
| 84 | } |
| 85 | |
| 86 | interface ItemsGroup<T, G> { |
| 87 | items: T[]; |
no outgoing calls
no test coverage detected