Skip to content

Commit

Permalink
Merge pull request #141 from uqbar-project/filter-children
Browse files Browse the repository at this point in the history
filter node children
  • Loading branch information
PalumboN authored Nov 26, 2022
2 parents bd147e6 + 52b45ca commit 6d2884a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ abstract class $Node {
return applyReduce(initial, this)
}

filter(this: Node, closure: (node: Node, parent?: Node) => boolean): Node[] {
return this.reduce<Node[]>((acum, node, parent) => {
return closure(node, parent) ? acum.concat(node) : acum
}, [])
}

isGlobal() { return this.parent.is('Package') }
}

Expand Down

0 comments on commit 6d2884a

Please sign in to comment.