Skip to content

Commit eb2fcb1

Browse files
committed
chore(common): revert a621f1a 79c1d9e
They can stay in src now and are transpiled down & out with 6eda1f8
1 parent 6eda1f8 commit eb2fcb1

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

packages/common/src/group-by.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ export const groupToMapBy = <K, V>(
2020
): ReadonlyMap<K, NonEmptyArray<V>> =>
2121
[...items].reduce((map, item) => {
2222
const groupKey = by(item);
23-
let prev: readonly V[] | undefined = map.get(groupKey);
24-
prev = prev ? prev : [];
23+
const prev: readonly V[] | undefined = map.get(groupKey) ?? [];
2524
map.set(groupKey, asNonEmptyArray([...prev, item])!);
2625
return map;
2726
}, new Map<K, NonEmptyArray<V>>());

packages/common/src/inspect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ const wrapInspect = <TThis>(
198198
};
199199

200200
return function (depth, options, inspect) {
201-
depth = depth != null ? depth : Infinity;
201+
depth ??= Infinity;
202202
return fn.call(this, {
203203
...options,
204204
depth,

packages/common/src/sort-by.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ export function sortBy<T>(
1313
list: Iterable<T>,
1414
criteria?: SortCriteria<T>,
1515
): readonly T[] {
16-
return [...list].sort(
17-
cmpBy(criteria ? criteria : (x: T) => x as SortableValue),
18-
);
16+
return [...list].sort(cmpBy(criteria ?? ((x: T) => x as SortableValue)));
1917
}
2018

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

0 commit comments

Comments
 (0)