forked from FoundKeyGang/FoundKey
backend: add missing return type annotation in array.ts
This commit is contained in:
parent
02079593d5
commit
c65559872b
1 changed files with 1 additions and 1 deletions
|
@ -84,7 +84,7 @@ export function groupOn<T, S>(f: (x: T) => S, xs: T[]): T[][] {
|
||||||
return groupBy((a, b) => f(a) === f(b), xs);
|
return groupBy((a, b) => f(a) === f(b), xs);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function groupByX<T>(collections: T[], keySelector: (x: T) => string) {
|
export function groupByX<T>(collections: T[], keySelector: (x: T) => string): Record<string, T[]> {
|
||||||
return collections.reduce((obj: Record<string, T[]>, item: T) => {
|
return collections.reduce((obj: Record<string, T[]>, item: T) => {
|
||||||
const key = keySelector(item);
|
const key = keySelector(item);
|
||||||
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||||
|
|
Loading…
Reference in a new issue