UNPKG

2.19 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var util_1 = require("../util");
4var DependencyManager = /** @class */ (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 * Get dependencies for the type given.
22 *
23 * If no type is given will return all dependencies.
24 *
25 * @param {string} type
26 * @public
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 * Checks whether there are any dependencies.
40 *
41 * If no type is given it will tell whether there are *any* dependencies
42 *
43 * @param {string} type
44 * @public
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}());
66exports.DependencyManager = DependencyManager;
67//# sourceMappingURL=DependencyManager.js.map
\No newline at end of file