55 * Use of this source code is governed by an MIT-style license that can be
66 * found in the LICENSE file at https://angular.io/license
77 */
8- import { FilteredTree } from './filtered' ;
8+ import { FilterTree , FilteredTree } from './filtered' ;
99import { HostTree } from './host-tree' ;
1010import { FilePredicate , MergeStrategy , Tree } from './interface' ;
1111import { VirtualTree } from './virtual' ;
@@ -16,34 +16,45 @@ export function empty() {
1616}
1717
1818export function branch ( tree : Tree ) {
19- if ( tree instanceof HostTree ) {
20- return tree . branch ( ) ;
19+ // TODO: Remove VirtualTree usage in 7.0
20+ if ( tree instanceof VirtualTree ) {
21+ return VirtualTree . branch ( tree ) ;
2122 }
2223
23- return VirtualTree . branch ( tree ) ;
24+ return tree . branch ( ) ;
2425}
2526
2627export function merge ( tree : Tree , other : Tree , strategy : MergeStrategy = MergeStrategy . Default ) {
27- if ( tree instanceof HostTree ) {
28- tree . merge ( other , strategy ) ;
29-
30- return tree ;
28+ // TODO: Remove VirtualTree usage in 7.0
29+ if ( tree instanceof VirtualTree ) {
30+ return VirtualTree . merge ( tree , other , strategy ) ;
3131 }
3232
33- return VirtualTree . merge ( tree , other , strategy ) ;
33+ tree . merge ( other , strategy ) ;
34+
35+ return tree ;
3436}
3537
3638export function partition ( tree : Tree , predicate : FilePredicate < boolean > ) : [ Tree , Tree ] {
37- return [
38- new FilteredTree ( tree , predicate ) ,
39- new FilteredTree ( tree , ( path , entry ) => ! predicate ( path , entry ) ) ,
40- ] ;
39+ // TODO: Remove VirtualTree usage in 7.0
40+ if ( tree instanceof VirtualTree ) {
41+ return [
42+ new FilteredTree ( tree , predicate ) ,
43+ new FilteredTree ( tree , ( path , entry ) => ! predicate ( path , entry ) ) ,
44+ ] ;
45+ } else {
46+ return [
47+ new FilterTree ( tree , predicate ) ,
48+ new FilterTree ( tree , ( path , entry ) => ! predicate ( path , entry ) ) ,
49+ ] ;
50+ }
4151}
4252
4353export function optimize ( tree : Tree ) {
44- if ( tree instanceof HostTree ) {
45- return tree ;
54+ // TODO: Remove VirtualTree usage in 7.0
55+ if ( tree instanceof VirtualTree ) {
56+ return VirtualTree . optimize ( tree ) ;
4657 }
4758
48- return VirtualTree . optimize ( tree ) ;
59+ return tree ;
4960}
0 commit comments