Skip to content

Commit 6fc5909

Browse files
committed
Add DocItemSet.forEach()
1 parent e6194c1 commit 6fc5909

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

apps/api-documenter/src/utils/DocItemSet.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,16 @@ export class DocItem {
157157
}
158158
return undefined;
159159
}
160+
161+
/**
162+
* Visits this DocItem and every child DocItem in a preorder traversal.
163+
*/
164+
public forEach(callback: (docItem: DocItem) => void): void {
165+
callback(this);
166+
for (const child of this.children) {
167+
child.forEach(callback);
168+
}
169+
}
160170
}
161171

162172
/**
@@ -234,4 +244,13 @@ export class DocItemSet {
234244
result.docItem = result.closestMatch;
235245
return result;
236246
}
247+
248+
/**
249+
* Visits every DocItem in the tree.
250+
*/
251+
public forEach(callback: (docItem: DocItem) => void): void {
252+
for (const docPackage of this.docPackages) {
253+
docPackage.forEach(callback);
254+
}
255+
}
237256
}

0 commit comments

Comments
 (0)