Skip to content

Commit

Permalink
Check object keys in isEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandru Șorodoc committed Oct 9, 2021
1 parent da5e743 commit e2c2819
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/utils/under-dash.js
Expand Up @@ -55,6 +55,7 @@ const _ = {
const bType = typeof b;
const aArray = Array.isArray(a);
const bArray = Array.isArray(b);
let keys;

if (aType !== bType) {
return false;
Expand All @@ -73,6 +74,19 @@ const _ = {
}
return false;
}

keys = Object.keys(a);

if (Object.keys(b).length !== keys.length) {
return false;
}

for (const key of keys) {
if (!b.hasOwnProperty(key)) {
return false;
}
}

return _.every(a, (aValue, key) => {
const bValue = b[key];
return _.isEqual(aValue, bValue);
Expand Down

0 comments on commit e2c2819

Please sign in to comment.