Skip to content

Commit

Permalink
Implement includes comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
ryn5 committed Jan 2, 2024
1 parent a035311 commit a441a55
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ function deepSort(obj) {
if (!Array.isArray(obj)) {
return obj;
} else {
obj.map((item) => deepSort(item));
return obj.map((item) => deepSort(item)).sort();
}
return obj.sort();
}

function deepCopy(obj) {
Expand Down Expand Up @@ -111,8 +110,21 @@ function deepMembersByIdOrdered(a, b) {
return deepMembersById(a, b, true)
}

function deepIncludesById(array, subset) {
console.log(array);
console.log(subset);
for (let item of subset) {
const included = array.some((arrayItem) => deepMembersById(item, arrayItem));
if (!included) {
return false;
}
}
return true;
}

module.exports = {
deepCopy,
deepIncludesById,
deepMembersById,
deepMembersByIdOrdered,
deepSort,
Expand Down

0 comments on commit a441a55

Please sign in to comment.