Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 10x 48x 48x 275x 48x 10x 303x | import { JOURNAL_LOCALE } from "../../../../i18n/dateFormats";
import type { Facet } from "../../shared/types/Facet";
export const toFacets = <T extends { id: string }>(values: T[]): Facet<T>[] => {
const facets = new Map<string, Facet<T>>();
for (const value of values) {
facets.set(value.id, { value, count: (facets.get(value.id)?.count ?? 0) + 1 });
}
return [...facets.values()];
};
export const byName = <T extends { name: string }>(a: Facet<T>, b: Facet<T>): number =>
a.value.name.localeCompare(b.value.name, JOURNAL_LOCALE);
|