Skip to content

Commit

Permalink
fix: filter self-descendants
Browse files Browse the repository at this point in the history
  • Loading branch information
tokebe committed Nov 28, 2023
1 parent aed33db commit 6285f39
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ exports.getDescendants = (curies, recursive = true) => {
}
level = next_level;
}
children[curie] = _.uniq(children[curie]).slice(0, ENTITY_CAP);
children[curie] = _.uniq(children[curie])
.filter(child => child !== curie)
.slice(0, ENTITY_CAP);
}
return children;
} else {
return _.pick(data, curies);
return Object.fromEntries(
Object.entries(_.pick(data, curies)).map(([curie, descendants]) => {
return [curie, descendants.filter(descendant => descendant !== curie)];
}),
);
}
};

0 comments on commit 6285f39

Please sign in to comment.