1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var util_1 = require("../util");
|
4 | var DependencyManager = (function () {
|
5 | function DependencyManager() {
|
6 | this.dependencies = {};
|
7 | }
|
8 | DependencyManager.prototype.parseDependencies = function (nodeDefinition) {
|
9 | if (nodeDefinition.dependencies) {
|
10 | this.dependencies = util_1.parseDependencies(this.dependencies, nodeDefinition.dependencies);
|
11 | }
|
12 | };
|
13 | DependencyManager.prototype.setDependencies = function (dependencies) {
|
14 | if (this.hasDependencies()) {
|
15 | throw Error("Dependencies already set, only use this method to prepopulate the dependencies.");
|
16 | }
|
17 | this.dependencies = dependencies;
|
18 | };
|
19 | |
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | DependencyManager.prototype.getDependencies = function (type) {
|
29 | if (type) {
|
30 | if (this.dependencies.hasOwnProperty(type)) {
|
31 | return this.dependencies[type];
|
32 | }
|
33 | return {};
|
34 | }
|
35 | return this.dependencies;
|
36 | };
|
37 | |
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | DependencyManager.prototype.hasDependencies = function (type) {
|
47 | if (type) {
|
48 | if (this.dependencies.hasOwnProperty(type) &&
|
49 | typeof this.dependencies[type] === 'object') {
|
50 | return Boolean(Object.keys(this.dependencies[type]).length);
|
51 | }
|
52 | }
|
53 | else {
|
54 | for (var _type in this.dependencies) {
|
55 | if (this.dependencies.hasOwnProperty(_type)) {
|
56 | if (this.hasDependencies(_type)) {
|
57 | return true;
|
58 | }
|
59 | }
|
60 | }
|
61 | }
|
62 | return false;
|
63 | };
|
64 | return DependencyManager;
|
65 | }());
|
66 | exports.DependencyManager = DependencyManager;
|
67 |
|
\ | No newline at end of file |