Skip to content

Commit

Permalink
fix: rangeError bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ericz1803 committed Oct 17, 2022
1 parent bbe5245 commit 524df56
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ exports.getDescendants = (curies, recursive = true) => {
if (recursive) {
//recursively get all children
const children = _.pick(data, curies);
let visited = []; // keep track of visited nodes to prevent infinite recursion
const getDescendantsRecur = (curies, prop) => {
for (let curie of curies) {
if (data[curie]) {
if (data[curie] && !visited.includes(curie)) {
visited.push(curie);
children[prop].push(...data[curie]);
getDescendantsRecur(data[curie], prop);
}
Expand Down

0 comments on commit 524df56

Please sign in to comment.