UNPKG

1.22 kBJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.partition = exports.merge = exports.branch = exports.empty = void 0;
11const exception_1 = require("../exception/exception");
12const host_tree_1 = require("./host-tree");
13const interface_1 = require("./interface");
14function empty() {
15 return new host_tree_1.HostTree();
16}
17exports.empty = empty;
18function branch(tree) {
19 return tree.branch();
20}
21exports.branch = branch;
22function merge(tree, other, strategy = interface_1.MergeStrategy.Default) {
23 tree.merge(other, strategy);
24 return tree;
25}
26exports.merge = merge;
27function partition(tree, predicate) {
28 if (tree instanceof host_tree_1.HostTree) {
29 return [
30 new host_tree_1.FilterHostTree(tree, predicate),
31 new host_tree_1.FilterHostTree(tree, (path, entry) => !predicate(path, entry)),
32 ];
33 }
34 else {
35 throw new exception_1.SchematicsException('Tree type is not supported.');
36 }
37}
38exports.partition = partition;