MCPcopy
hub / github.com/webpack/webpack / collapse

Function collapse

lib/stats/DefaultStatsFactoryPlugin.js:1858–1876  ·  view source on GitHub ↗
(children)

Source from the content-addressed store, hash-verified

1856 * @returns {Children<T>[]} collapsed children
1857 */
1858const collapse = (children) => {
1859 // After collapse each child must take exactly one line
1860 /** @type {Children<T>[]} */
1861 const newChildren = [];
1862 for (const child of children) {
1863 if (child.children) {
1864 let filteredChildren = child.filteredChildren || 0;
1865 filteredChildren += getTotalItems(child.children);
1866 newChildren.push({
1867 ...child,
1868 children: undefined,
1869 filteredChildren
1870 });
1871 } else {
1872 newChildren.push(child);
1873 }
1874 }
1875 return newChildren;
1876};
1877
1878/**
1879 * Returns result.

Callers 1

spaceLimitedFunction · 0.85

Calls 2

getTotalItemsFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected