diff options
| author | ST-DDT <[email protected]> | 2023-11-23 20:10:07 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-23 19:10:07 +0000 |
| commit | c2b952347e1f952cf379807a3c456fed65075d11 (patch) | |
| tree | a7b813f499c4dbf8420cf547b4b412993503b375 /scripts | |
| parent | 9b00fe9f7353df50c67966141a5f024ec9b95208 (diff) | |
| download | faker-c2b952347e1f952cf379807a3c456fed65075d11.tar.xz faker-c2b952347e1f952cf379807a3c456fed65075d11.zip | |
refactor: improve groupBy (#2532)
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/apidoc/writer.ts | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/scripts/apidoc/writer.ts b/scripts/apidoc/writer.ts index 23586230..67bf1d7a 100644 --- a/scripts/apidoc/writer.ts +++ b/scripts/apidoc/writer.ts @@ -169,14 +169,13 @@ function writeApiDocsModuleData( * @param pages The pages to write into the index. */ export async function writeApiPagesIndex(pages: Page[]): Promise<void> { - const pagesByCategory = groupBy(pages, (page) => page.category); + const pagesByCategory: Record<string, DefaultTheme.SidebarItem[]> = groupBy( + pages, + (page) => page.category, + ({ text, link }) => ({ text, link }) + ); const pageTree = Object.entries(pagesByCategory).flatMap( - ([category, items]): DefaultTheme.SidebarItem[] => { - const cleanedItems = items.map(({ text, link }) => ({ text, link })); - return category - ? [{ text: category, items: cleanedItems }] - : cleanedItems; - } + ([category, items]) => (category ? [{ text: category, items }] : items) ); // Write api-pages.ts |
