mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-25 22:01:13 +00:00
Add stricter typing to dedup function
This commit is contained in:
parent
4a55278556
commit
548f00d59b
1 changed files with 4 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
function dedupByProperty<T, R extends number | string | boolean>(
|
||||
collection: T[],
|
||||
keyFn: (obj: T) => R,
|
||||
) {
|
||||
function dedupByProperty<
|
||||
T extends Record<string, any>,
|
||||
R extends number | string | boolean,
|
||||
>(collection: T[], keyFn: (obj: T) => R) {
|
||||
return collection.reduce(
|
||||
(acc, cur) => {
|
||||
const key = keyFn(cur);
|
||||
|
|
Loading…
Reference in a new issue