Skip to content

Commit

Permalink
Merge pull request #4 from biothings/self-edges
Browse files Browse the repository at this point in the history
Filter self-descendants
  • Loading branch information
tokebe authored Dec 5, 2023
2 parents aed33db + 6285f39 commit e4bb786
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 e4bb786

Please sign in to comment.