fix(explorer): filter function in ExplorerNode
				
					
				
			This commit is contained in:
		
							parent
							
								
									9358f73f1c
								
							
						
					
					
						commit
						94a04ab1c9
					
				
					 1 changed files with 2 additions and 12 deletions
				
			
		| 
						 | 
					@ -76,18 +76,8 @@ export class FileNode {
 | 
				
			||||||
   * @param filterFn function to filter tree with
 | 
					   * @param filterFn function to filter tree with
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  filter(filterFn: (node: FileNode) => boolean) {
 | 
					  filter(filterFn: (node: FileNode) => boolean) {
 | 
				
			||||||
    const filteredNodes: FileNode[] = []
 | 
					    this.children = this.children.filter(filterFn)
 | 
				
			||||||
 | 
					    this.children.forEach((child) => child.filter(filterFn))
 | 
				
			||||||
    const traverse = (node: FileNode) => {
 | 
					 | 
				
			||||||
      if (filterFn(node)) {
 | 
					 | 
				
			||||||
        filteredNodes.push(node)
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      node.children.forEach(traverse)
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    traverse(this)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    this.children = filteredNodes
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue