All files / apps/huella-legal/layers/articles/server/mappers authorDirectory.ts

100% Statements 4/4
100% Branches 2/2
100% Functions 3/3
100% Lines 3/3

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            2x 10x 6x    
import { JOURNAL_LOCALE } from "../../../../i18n/dateFormats";
import type { ArticleSummary } from "../../shared/types/ArticleSummary";
import type { Author } from "../../shared/types/Author";
import type { Facet } from "../../shared/types/Facet";
import { toFacets } from "./facet";
 
export const toAuthorDirectory = (index: ArticleSummary[]): Facet<Author>[] =>
    toFacets(index.flatMap(({ authors }) => authors)).sort(
        (a, b) => b.count - a.count || a.value.name.localeCompare(b.value.name, JOURNAL_LOCALE),
    );