UNPKG

1.6 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const abstract_1 = require("./abstract");
4const lodash_1 = require("lodash");
5class ContainerReflection extends abstract_1.Reflection {
6 getChildrenByKind(kind) {
7 return (this.children || []).filter(child => child.kindOf(kind));
8 }
9 traverse(callback) {
10 for (const child of lodash_1.toArray(this.children)) {
11 if (callback(child, abstract_1.TraverseProperty.Children) === false) {
12 return;
13 }
14 }
15 }
16 toObject() {
17 const result = super.toObject();
18 if (this.groups) {
19 const groups = [];
20 this.groups.forEach((group) => {
21 groups.push(group.toObject());
22 });
23 result['groups'] = groups;
24 }
25 if (this.categories) {
26 const categories = [];
27 this.categories.forEach((category) => {
28 categories.push(category.toObject());
29 });
30 if (categories.length > 0) {
31 result['categories'] = categories;
32 }
33 }
34 if (this.sources) {
35 const sources = [];
36 this.sources.forEach((source) => {
37 sources.push({
38 fileName: source.fileName,
39 line: source.line,
40 character: source.character
41 });
42 });
43 result['sources'] = sources;
44 }
45 return result;
46 }
47}
48exports.ContainerReflection = ContainerReflection;
49//# sourceMappingURL=container.js.map
\No newline at end of file