unconventional 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,15 +6,16 @@ const equalArrays = (a, b) => {
|
|
|
6
6
|
if (a.length !== b.length)
|
|
7
7
|
return false;
|
|
8
8
|
const clone = [...b];
|
|
9
|
-
for (const
|
|
10
|
-
const idx =
|
|
11
|
-
if (idx > -1)
|
|
12
|
-
clone.splice(idx, 1);
|
|
9
|
+
for (const item of a) {
|
|
10
|
+
const idx = clone.indexOf(item); // Use clone here for checking
|
|
11
|
+
if (idx > -1) {
|
|
12
|
+
clone.splice(idx, 1); // Correctly removes the item from clone
|
|
13
|
+
}
|
|
13
14
|
else {
|
|
14
|
-
|
|
15
|
+
return false; // If an item is not found, arrays are not equal
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
return clone.length === 0;
|
|
18
|
+
return clone.length === 0; // If clone is empty, arrays are equal
|
|
18
19
|
};
|
|
19
20
|
exports.equalArrays = equalArrays;
|
|
20
21
|
/** Checks whether an object has no keys and/or the value for every key is undefined */
|