(children)
| 1856 | * @returns {Children<T>[]} collapsed children |
| 1857 | */ |
| 1858 | const 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. |
no test coverage detected