mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
merging in Tim Smart's gorgeous deep equality patch for _.isEqual
This commit is contained in:
@@ -631,22 +631,21 @@
|
|||||||
if (isDateA || isDateB) return isDateA && isDateB && a.getTime() == b.getTime();
|
if (isDateA || isDateB) return isDateA && isDateB && a.getTime() == b.getTime();
|
||||||
// Compare RegExps by their source patterns and flags.
|
// Compare RegExps by their source patterns and flags.
|
||||||
var isRegExpA = _.isRegExp(a), isRegExpB = _.isRegExp(b);
|
var isRegExpA = _.isRegExp(a), isRegExpB = _.isRegExp(b);
|
||||||
if (isRegExpA || isRegExpB)
|
if (isRegExpA || isRegExpB) {
|
||||||
// Ensure commutative equality for RegExps.
|
// Ensure commutative equality for RegExps.
|
||||||
return isRegExpA && isRegExpB &&
|
return isRegExpA && isRegExpB &&
|
||||||
a.source == b.source &&
|
a.source == b.source &&
|
||||||
a.global == b.global &&
|
a.global == b.global &&
|
||||||
a.multiline == b.multiline &&
|
a.multiline == b.multiline &&
|
||||||
a.ignoreCase == b.ignoreCase;
|
a.ignoreCase == b.ignoreCase;
|
||||||
|
}
|
||||||
// Ensure that both values are objects.
|
// Ensure that both values are objects.
|
||||||
if (typeA != 'object') return false;
|
if (typeA != 'object') return false;
|
||||||
// Unwrap any wrapped objects.
|
// Unwrap any wrapped objects.
|
||||||
if (a._chain) a = a._wrapped;
|
if (a._chain) a = a._wrapped;
|
||||||
if (b._chain) b = b._wrapped;
|
if (b._chain) b = b._wrapped;
|
||||||
// Invoke a custom `isEqual` method if one is provided.
|
// Invoke a custom `isEqual` method if one is provided.
|
||||||
if (typeof a.isEqual == 'function') return a.isEqual(b);
|
if (_.isFunction(a.isEqual)) return a.isEqual(b);
|
||||||
// If only `b` provides an `isEqual` method, `a` and `b` are not equal.
|
|
||||||
if (typeof b.isEqual == 'function') return false;
|
|
||||||
// Assume equality for cyclic structures. The algorithm for detecting cyclic structures is
|
// Assume equality for cyclic structures. The algorithm for detecting cyclic structures is
|
||||||
// adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
|
// adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
|
||||||
var length = stack.length;
|
var length = stack.length;
|
||||||
@@ -748,7 +747,7 @@
|
|||||||
|
|
||||||
// Is a given value a boolean?
|
// Is a given value a boolean?
|
||||||
_.isBoolean = function(obj) {
|
_.isBoolean = function(obj) {
|
||||||
return obj === true || obj === false || typeof obj == 'object' && toString.call(obj) == '[object Boolean]';
|
return obj === true || obj === false || toString.call(obj) == '[object Boolean]';
|
||||||
};
|
};
|
||||||
|
|
||||||
// Is a given value a date?
|
// Is a given value a date?
|
||||||
|
|||||||
Reference in New Issue
Block a user