mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 08:57:49 +00:00
Bump to v4.0.0.
This commit is contained in:
@@ -1,10 +1,28 @@
|
||||
import Uint8Array from './Uint8Array';
|
||||
import _Symbol from './_Symbol';
|
||||
import mapToArray from './mapToArray';
|
||||
import setToArray from './setToArray';
|
||||
|
||||
/** Used to compose bitmasks for comparison styles. */
|
||||
var UNORDERED_COMPARE_FLAG = 1,
|
||||
PARTIAL_COMPARE_FLAG = 2;
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var boolTag = '[object Boolean]',
|
||||
dateTag = '[object Date]',
|
||||
errorTag = '[object Error]',
|
||||
mapTag = '[object Map]',
|
||||
numberTag = '[object Number]',
|
||||
regexpTag = '[object RegExp]',
|
||||
stringTag = '[object String]';
|
||||
setTag = '[object Set]',
|
||||
stringTag = '[object String]',
|
||||
symbolTag = '[object Symbol]';
|
||||
|
||||
var arrayBufferTag = '[object ArrayBuffer]';
|
||||
|
||||
/** Used to convert symbols to primitives and strings. */
|
||||
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
|
||||
symbolValueOf = _Symbol ? symbolProto.valueOf : undefined;
|
||||
|
||||
/**
|
||||
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
||||
@@ -17,10 +35,20 @@ var boolTag = '[object Boolean]',
|
||||
* @param {Object} object The object to compare.
|
||||
* @param {Object} other The other object to compare.
|
||||
* @param {string} tag The `toStringTag` of the objects to compare.
|
||||
* @param {Function} equalFunc The function to determine equivalents of values.
|
||||
* @param {Function} [customizer] The function to customize comparisons.
|
||||
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
|
||||
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||||
*/
|
||||
function equalByTag(object, other, tag) {
|
||||
function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
|
||||
switch (tag) {
|
||||
case arrayBufferTag:
|
||||
if ((object.byteLength != other.byteLength) ||
|
||||
!equalFunc(new Uint8Array(object), new Uint8Array(other))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
case boolTag:
|
||||
case dateTag:
|
||||
// Coerce dates and booleans to numbers, dates to milliseconds and booleans
|
||||
@@ -32,15 +60,27 @@ function equalByTag(object, other, tag) {
|
||||
|
||||
case numberTag:
|
||||
// Treat `NaN` vs. `NaN` as equal.
|
||||
return (object != +object)
|
||||
? other != +other
|
||||
: object == +other;
|
||||
return (object != +object) ? other != +other : object == +other;
|
||||
|
||||
case regexpTag:
|
||||
case stringTag:
|
||||
// Coerce regexes to strings and treat strings primitives and string
|
||||
// objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
|
||||
return object == (other + '');
|
||||
|
||||
case mapTag:
|
||||
var convert = mapToArray;
|
||||
|
||||
case setTag:
|
||||
var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
|
||||
convert || (convert = setToArray);
|
||||
|
||||
// Recursively compare objects (susceptible to call stack limits).
|
||||
return (isPartial || object.size == other.size) &&
|
||||
equalFunc(convert(object), convert(other), customizer, bitmask | UNORDERED_COMPARE_FLAG);
|
||||
|
||||
case symbolTag:
|
||||
return !!_Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user