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 21 | 1x 11x 1x 11x 11x 1x 8x 1x 7x 10x 10x 7x | import { Container, ModelItem, RootContainer } from '../model/types';
import { BundleConfig, Strategy } from '../types';
import { extractDuplicates, 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 perSpaStrategy: Strategy = (modelItems: Array<RootContainer>): BundleConfig[] => {
if (modelItems.length === 0) {
return [];
}
const config = modelItems
.map((root) => [...new Set(flatMap(root.children, getClassIds))])
.filter((i) => i.length !== 0);
return extractDuplicates(config);
};
|