Skip to content

Commit

Permalink
types: improve maxBy minBy types
Browse files Browse the repository at this point in the history
  • Loading branch information
haoziqaq committed Dec 7, 2024
1 parent 20b005a commit 29da4d0
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 8 deletions.
4 changes: 0 additions & 4 deletions src/math/maxBy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export function maxBy<T>(arr: T[], fn: (val: T) => number) {
if (!arr.length) {
return
}

return arr.reduce((result, item) => (fn(result) > fn(item) ? result : item), arr[0])
}
4 changes: 0 additions & 4 deletions src/math/minBy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export function minBy<T>(arr: T[], fn: (val: T) => number) {
if (!arr.length) {
return
}

return arr.reduce((result, item) => (fn(result) < fn(item) ? result : item), arr[0])
}

0 comments on commit 29da4d0

Please sign in to comment.