mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Reimplemented _.isEqual tests and patch in a fresh branch.
This commit is contained in:
@@ -635,7 +635,15 @@
|
||||
// See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
|
||||
if (a === b) return a !== 0 || 1 / a == 1 / b;
|
||||
// A strict comparison is necessary because `null == undefined`.
|
||||
if (a == null) return a === b;
|
||||
if ((a == null) || (b == null)) return a === b;
|
||||
// Either one is undefined
|
||||
if ((a === void 0) || (b === void 0)) return false;
|
||||
// Unwrap any wrapped objects.
|
||||
if (a._chain) a = a._wrapped;
|
||||
if (b._chain) b = b._wrapped;
|
||||
// One of them implements an isEqual()
|
||||
if (a.isEqual) return a.isEqual(b);
|
||||
if (b.isEqual) return b.isEqual(a);
|
||||
// Compare object types.
|
||||
var typeA = typeof a;
|
||||
if (typeA != typeof b) return false;
|
||||
@@ -667,9 +675,6 @@
|
||||
}
|
||||
// Ensure that both values are objects.
|
||||
if (typeA != 'object') return false;
|
||||
// Unwrap any wrapped objects.
|
||||
if (a._chain) a = a._wrapped;
|
||||
if (b._chain) b = b._wrapped;
|
||||
// Invoke a custom `isEqual` method if one is provided.
|
||||
if (_.isFunction(a.isEqual)) return a.isEqual(b);
|
||||
// Assume equality for cyclic structures. The algorithm for detecting cyclic structures is
|
||||
|
||||
Reference in New Issue
Block a user