Skip to content
Snippets Groups Projects
Commit 045c54ea authored by Stefan Freudenberg's avatar Stefan Freudenberg
Browse files

Add function returning the descendants in theb is-part-of hierarchy

parent 28c1e252
Branches
No related tags found
No related merge requests found
......@@ -1464,6 +1464,26 @@ export function findAncestors<T extends AnyContainer>(container: T, containers:
return [parent, ...findAncestors(parent, containers)];
}
export function findDescendants<T extends AnyContainer>(container: T, containers: T[]): T[] {
const children = containers.filter(
({ relation, revision }) =>
relation.findIndex(
({ object, predicate }) =>
predicate == predicates.enum['is-part-of'] &&
object == container.revision &&
object != revision
) > -1
);
const descendants = children;
for (const child of children) {
descendants.push(...findDescendants(child, containers));
}
return descendants;
}
export function paramsFromFragment(url: URL) {
return new URLSearchParams(url.hash.substring(1) ?? '');
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.