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 17 18 19 20 | 1x 11x 1x 11x 11x 1x 8x 1x 10x 7x | import { ModelItem, Container, RootContainer } from '../model/types';
import { Strategy, BundleConfig } from '../types';
import { flatMap } from '../utils/array';
const isContainer = (item: ModelItem): item is Container => Object.prototype.hasOwnProperty.call(item, 'children');
const getClassIds = (item: ModelItem): Array<string> => {
const children = isContainer(item) ? flatMap(item.children, getClassIds) : [];
return [item.classId, ...children];
};
export const singleStrategy: Strategy = (modelItems: Array<RootContainer>): BundleConfig[] => {
if (modelItems.length === 0) {
return [];
}
return [[...new Set(flatMap(modelItems, (item) => flatMap(item.children, getClassIds)))]].filter(
(i) => i.length !== 0,
);
};
|