Skip to content

Commit

Permalink
Merge pull request #70 from ray-pH/get-tagged-element
Browse files Browse the repository at this point in the history
Diagram: implement `Diagram.get_tagged_elements`
  • Loading branch information
ray-pH authored Jul 15, 2024
2 parents b3739e9 + 5de19bf commit 6696b6a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/diagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,22 @@ export class Diagram {
}
return newd;
}

/**
* Get all the diagrams that contain a specific tag
* @param tags the tag to filter the diagrams
* @return a list of diagrams
*/
public get_tagged_elements(tags : string | string[] ) : Diagram[] {
if (!Array.isArray(tags)) tags = [tags];
let result = [];

if (this.contain_all_tags(tags)) result.push(this.copy_if_not_mutable());
for (let i = 0; i < this.children.length; i++) {
result = result.concat(this.children[i].get_tagged_elements(tags));
}
return result;
}

/**
* Combine another diagram with this diagram
Expand Down

0 comments on commit 6696b6a

Please sign in to comment.