/
container.ts
54 lines (48 loc) · 1.73 KB
/
container.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { Reflection, TraverseCallback, TraverseProperty } from "./abstract";
import type { ReflectionCategory } from "../ReflectionCategory";
import type { ReflectionGroup } from "../ReflectionGroup";
import type { DeclarationReflection } from "./declaration";
import type { ReflectionKind } from "./kind";
export class ContainerReflection extends Reflection {
/**
* The children of this reflection.
*/
children?: DeclarationReflection[];
/**
* All children grouped by their kind.
*/
groups?: ReflectionGroup[];
/**
* All children grouped by their category.
*/
categories?: ReflectionCategory[];
/**
* A precomputed boost derived from the searchCategoryBoosts typedoc.json setting, to be used when
* boosting search relevance scores at runtime.
*/
relevanceBoost?: number;
/**
* Return a list of all children of a certain kind.
*
* @param kind The desired kind of children.
* @returns An array containing all children with the desired kind.
*/
getChildrenByKind(kind: ReflectionKind): DeclarationReflection[] {
return (this.children || []).filter((child) => child.kindOf(kind));
}
/**
* Traverse all potential child reflections of this reflection.
*
* The given callback will be invoked for all children, signatures and type parameters
* attached to this reflection.
*
* @param callback The callback function that should be applied for each child reflection.
*/
override traverse(callback: TraverseCallback) {
for (const child of this.children?.slice() || []) {
if (callback(child, TraverseProperty.Children) === false) {
return;
}
}
}
}