Pulls part which was in all if-clauses into its own wrapping if-clause to ease readability
@@ -10,15 +10,17 @@ export function addNeed(needs, jsonldNeed, isOwned) {
let existingNeed = needs.get(parsedNeed.get("uri"));
const isExistingOwnedNeed = existingNeed && existingNeed.get("isOwned");
- if ((isOwned || isExistingOwnedNeed) && existingNeed) {
+ if (existingNeed) {
+ if (isOwned || isExistingOwnedNeed) {
parsedNeed = parsedNeed
.set("connections", existingNeed.get("connections"))
.set("isOwned", true);
- } else if (!isOwned && existingNeed) {
+ } else if (!isOwned) {
parsedNeed = parsedNeed
.set("connections", existingNeed.get("connections"))
.set("isOwned", false);
}
+ }
return needs.set(parsedNeed.get("uri"), parsedNeed);
} else {
