(items: Iterable<Node<T>>)
| 24 | // TS isn't smart enough to know we've ensured count is a number, so use a new variable |
| 25 | let counter = 0; |
| 26 | let countItems = (items: Iterable<Node<T>>) => { |
| 27 | for (let item of items) { |
| 28 | if (item.type === 'section') { |
| 29 | countItems(getChildNodes(item, collection)); |
| 30 | } else if (item.type === 'item') { |
| 31 | counter++; |
| 32 | } |
| 33 | } |
| 34 | }; |
| 35 | |
| 36 | countItems(collection); |
| 37 | cache.set(collection, counter); |
no test coverage detected