fix(v2): use lodash instead of array-map-polyfill (#2490)

This commit is contained in:
Alexey Pyltsyn 2020-04-01 20:08:22 +03:00 committed by GitHub
parent 1577ab98e9
commit 686c8ae27d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 12 deletions

View file

@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import _ from 'lodash';
import fs from 'fs-extra';
import importFresh from 'import-fresh';
import {
@ -105,12 +106,12 @@ function normalizeItem(item: SidebarItemRaw): SidebarItem[] {
];
}
if (isCategoryShorthand(item)) {
return normalizeCategoryShorthand(item).flatMap(normalizeItem);
return _.flatMap(normalizeCategoryShorthand(item), normalizeItem);
}
switch (item.type) {
case 'category':
assertIsCategory(item);
return [{...item, items: item.items.flatMap(normalizeItem)}];
return [{...item, items: _.flatMap(item.items, normalizeItem)}];
case 'link':
assertIsLink(item);
return [item];
@ -133,7 +134,7 @@ function normalizeSidebar(sidebars: SidebarRaw): Sidebar {
? sidebar
: normalizeCategoryShorthand(sidebar);
acc[sidebarId] = normalizedSidebar.flatMap(normalizeItem);
acc[sidebarId] = _.flatMap(normalizedSidebar, normalizeItem);
return acc;
},