Skip to content

Commit

Permalink
fix(common): avoid ?? because our UI toolchain is ancient
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonF committed Oct 25, 2024
1 parent fef5b74 commit a621f1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/common/src/group-by.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const groupToMapBy = <K, V>(
): ReadonlyMap<K, readonly V[]> =>
[...items].reduce((map, item) => {
const groupKey = by(item);
const prev = map.get(groupKey) ?? [];
let prev = map.get(groupKey);
prev = prev ? prev : [];
map.set(groupKey, [...prev, item]);
return map;
}, new Map<K, V[]>());
4 changes: 3 additions & 1 deletion packages/common/src/sort-by.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export function sortBy<T>(
list: Iterable<T>,
criteria?: SortCriteria<T>,
): readonly T[] {
return [...list].sort(cmpBy(criteria ?? ((x: T) => x as SortableValue)));
return [...list].sort(
cmpBy(criteria ? criteria : (x: T) => x as SortableValue),
);
}

export const cmpBy = <T>(criteria: SortCriteria<T>) => {
Expand Down

0 comments on commit a621f1a

Please sign in to comment.