diff options
author | Danijel Andjelkovic <adanijel99@gmail.com> | 2022-03-01 20:21:29 +0000 |
---|---|---|
committer | Danijel Andjelkovic <adanijel99@gmail.com> | 2022-03-01 20:21:29 +0000 |
commit | 61cb1570a3410c85a4489b97c172e3a50715f36c (patch) | |
tree | 8fe4a5b77ea54bba80abc817ce2c9ef0e79e7e66 /sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/rules/base.js | |
parent | 21a53d349788c99d2007cba91a923db982353b31 (diff) | |
parent | a9ee9e0a500a4a15bd0b5dcaf041f827228ed309 (diff) |
Merge branch 'researchML' into 'dev'
Research ml
See merge request igrannonica/neuronstellar!6
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/rules/base.js')
-rw-r--r-- | sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/rules/base.js | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/rules/base.js b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/rules/base.js new file mode 100644 index 00000000..fdcae77a --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/rules/base.js @@ -0,0 +1,155 @@ +"use strict"; +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.applyToSubtree = exports.composeFileOperators = exports.forEach = exports.partitionApplyMerge = exports.when = exports.branchAndMerge = exports.asSource = exports.filter = exports.noop = exports.mergeWith = exports.apply = exports.chain = exports.empty = exports.source = void 0; +const rxjs_1 = require("rxjs"); +const operators_1 = require("rxjs/operators"); +const exception_1 = require("../exception/exception"); +const host_tree_1 = require("../tree/host-tree"); +const interface_1 = require("../tree/interface"); +const scoped_1 = require("../tree/scoped"); +const static_1 = require("../tree/static"); +const call_1 = require("./call"); +/** + * A Source that returns an tree as its single value. + */ +function source(tree) { + return () => tree; +} +exports.source = source; +/** + * A source that returns an empty tree. + */ +function empty() { + return () => (0, static_1.empty)(); +} +exports.empty = empty; +/** + * Chain multiple rules into a single rule. + */ +function chain(rules) { + return (tree, context) => { + return rules.reduce((acc, curr) => (0, call_1.callRule)(curr, acc, context), tree); + }; +} +exports.chain = chain; +/** + * Apply multiple rules to a source, and returns the source transformed. + */ +function apply(source, rules) { + return (context) => (0, call_1.callRule)(chain(rules), (0, call_1.callSource)(source, context), context); +} +exports.apply = apply; +/** + * Merge an input tree with the source passed in. + */ +function mergeWith(source, strategy = interface_1.MergeStrategy.Default) { + return (tree, context) => { + return (0, call_1.callSource)(source, context).pipe((0, operators_1.map)((sourceTree) => tree.merge(sourceTree, strategy || context.strategy)), (0, operators_1.mapTo)(tree)); + }; +} +exports.mergeWith = mergeWith; +function noop() { + return () => { }; +} +exports.noop = noop; +function filter(predicate) { + return (tree) => { + if (host_tree_1.HostTree.isHostTree(tree)) { + return new host_tree_1.FilterHostTree(tree, predicate); + } + else { + throw new exception_1.SchematicsException('Tree type is not supported.'); + } + }; +} +exports.filter = filter; +function asSource(rule) { + return (context) => (0, call_1.callRule)(rule, (0, static_1.empty)(), context); +} +exports.asSource = asSource; +function branchAndMerge(rule, strategy = interface_1.MergeStrategy.Default) { + return (tree, context) => { + return (0, call_1.callRule)(rule, tree.branch(), context).pipe((0, operators_1.map)((branch) => tree.merge(branch, strategy || context.strategy)), (0, operators_1.mapTo)(tree)); + }; +} +exports.branchAndMerge = branchAndMerge; +function when(predicate, operator) { + return (entry) => { + if (predicate(entry.path, entry)) { + return operator(entry); + } + else { + return entry; + } + }; +} +exports.when = when; +function partitionApplyMerge(predicate, ruleYes, ruleNo) { + return (tree, context) => { + const [yes, no] = (0, static_1.partition)(tree, predicate); + return (0, rxjs_1.concat)((0, call_1.callRule)(ruleYes, yes, context), (0, call_1.callRule)(ruleNo || noop(), no, context)).pipe((0, operators_1.toArray)(), (0, operators_1.map)(([yesTree, noTree]) => { + yesTree.merge(noTree, context.strategy); + return yesTree; + })); + }; +} +exports.partitionApplyMerge = partitionApplyMerge; +function forEach(operator) { + return (tree) => { + tree.visit((path, entry) => { + if (!entry) { + return; + } + const newEntry = operator(entry); + if (newEntry === entry) { + return; + } + if (newEntry === null) { + tree.delete(path); + return; + } + if (newEntry.path != path) { + tree.rename(path, newEntry.path); + } + if (!newEntry.content.equals(entry.content)) { + tree.overwrite(newEntry.path, newEntry.content); + } + }); + }; +} +exports.forEach = forEach; +function composeFileOperators(operators) { + return (entry) => { + let current = entry; + for (const op of operators) { + current = op(current); + if (current === null) { + // Deleted, just return. + return null; + } + } + return current; + }; +} +exports.composeFileOperators = composeFileOperators; +function applyToSubtree(path, rules) { + return (tree, context) => { + const scoped = new scoped_1.ScopedTree(tree, path); + return (0, call_1.callRule)(chain(rules), scoped, context).pipe((0, operators_1.map)((result) => { + if (result === scoped) { + return tree; + } + else { + throw new exception_1.SchematicsException('Original tree must be returned from all rules when using "applyToSubtree".'); + } + })); + }; +} +exports.applyToSubtree = applyToSubtree; |