Skip to content

Commit cf34e6f

Browse files
committed
Port the necessary methods
1 parent d9783f5 commit cf34e6f

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

workspaces/arborist/lib/override-set.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,43 @@ class OverrideSet {
4545
}
4646
}
4747

48+
childrenAreEqual (other) {
49+
if (this.children.size !== other.children.size) {
50+
return false
51+
}
52+
for (const [key] of this.children) {
53+
if (!other.children.has(key)) {
54+
return false
55+
}
56+
if (this.children.get(key).value !== other.children.get(key).value) {
57+
return false
58+
}
59+
if (!this.children.get(key).childrenAreEqual(other.children.get(key))) {
60+
return false
61+
}
62+
}
63+
return true
64+
}
65+
66+
isEqual (other) {
67+
if (this === other) {
68+
return true
69+
}
70+
if (!other) {
71+
return false
72+
}
73+
if (this.key !== other.key || this.value !== other.value) {
74+
return false
75+
}
76+
if (!this.childrenAreEqual(other)) {
77+
return false
78+
}
79+
if (!this.parent) {
80+
return !other.parent
81+
}
82+
return this.parent.isEqual(other.parent)
83+
}
84+
4885
getEdgeRule (edge) {
4986
for (const rule of this.ruleset.values()) {
5087
if (rule.name !== edge.name) {

0 commit comments

Comments
 (0)