mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Use forIn in _.isEqual instead of forOwn.
Former-commit-id: dd057e421be029d67cd293b733ee1cfee2b7715f
This commit is contained in:
23
lodash.js
23
lodash.js
@@ -1356,19 +1356,24 @@
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
// deep compare objects
|
// deep compare objects using `forIn`, instead of `forOwn`, to avoid `Object.keys`
|
||||||
forOwn(a, function(value, key) {
|
// which, in this case, is more costly
|
||||||
// count the number of properties.
|
forIn(a, function(value, key, a) {
|
||||||
size++;
|
if (hasOwnProperty.call(a, key)) {
|
||||||
// deep compare each property value.
|
// count the number of properties.
|
||||||
return (result = hasOwnProperty.call(b, key) && isEqual(value, b[key], stackA, stackB));
|
size++;
|
||||||
|
// deep compare each property value.
|
||||||
|
return (result = hasOwnProperty.call(b, key) && isEqual(value, b[key], stackA, stackB));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
// ensure both objects have the same number of properties
|
// ensure both objects have the same number of properties
|
||||||
forOwn(b, function() {
|
forIn(b, function(value, key, b) {
|
||||||
// `size` will be `-1` if `b` has more properties than `a`
|
if (hasOwnProperty.call(b, key)) {
|
||||||
return (result = --size > -1);
|
// `size` will be `-1` if `b` has more properties than `a`
|
||||||
|
return (result = --size > -1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user