lodash._baseisequal
Advanced tools
Comparing version 3.0.5 to 3.0.6
146
index.js
/** | ||
* lodash 3.0.5 (Custom Build) <https://lodash.com/> | ||
* lodash 3.0.6 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modern modularize exports="npm" -o ./` | ||
@@ -37,2 +37,24 @@ * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
/** | ||
* A specialized version of `_.some` for arrays without support for callback | ||
* shorthands and `this` binding. | ||
* | ||
* @private | ||
* @param {Array} array The array to iterate over. | ||
* @param {Function} predicate The function invoked per iteration. | ||
* @returns {boolean} Returns `true` if any element passes the predicate check, | ||
* else `false`. | ||
*/ | ||
function arraySome(array, predicate) { | ||
var index = -1, | ||
length = array.length; | ||
while (++index < length) { | ||
if (predicate(array[index], index, array)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
/** | ||
* The base implementation of `_.isEqual` without support for `this` binding | ||
@@ -51,13 +73,6 @@ * `customizer` functions. | ||
function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) { | ||
// Exit early for identical values. | ||
if (value === other) { | ||
return true; | ||
} | ||
var valType = typeof value, | ||
othType = typeof other; | ||
// Exit early for unlike primitive values. | ||
if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') || | ||
value == null || other == null) { | ||
// Return `false` unless both values are `NaN`. | ||
if (value == null || other == null || (!isObject(value) && !isObject(other))) { | ||
return value !== value && other !== other; | ||
@@ -113,7 +128,7 @@ } | ||
if (!isLoose) { | ||
var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), | ||
othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); | ||
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), | ||
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); | ||
if (valWrapped || othWrapped) { | ||
return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isLoose, stackA, stackB); | ||
if (objIsWrapped || othIsWrapped) { | ||
return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB); | ||
} | ||
@@ -164,4 +179,3 @@ } | ||
arrLength = array.length, | ||
othLength = other.length, | ||
result = true; | ||
othLength = other.length; | ||
@@ -171,30 +185,26 @@ if (arrLength != othLength && !(isLoose && othLength > arrLength)) { | ||
} | ||
// Deep compare the contents, ignoring non-numeric properties. | ||
while (result && ++index < arrLength) { | ||
// Ignore non-index properties. | ||
while (++index < arrLength) { | ||
var arrValue = array[index], | ||
othValue = other[index]; | ||
othValue = other[index], | ||
result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined; | ||
result = undefined; | ||
if (customizer) { | ||
result = isLoose | ||
? customizer(othValue, arrValue, index) | ||
: customizer(arrValue, othValue, index); | ||
if (result !== undefined) { | ||
if (result) { | ||
continue; | ||
} | ||
return false; | ||
} | ||
if (result === undefined) { | ||
// Recursively compare arrays (susceptible to call stack limits). | ||
if (isLoose) { | ||
var othIndex = othLength; | ||
while (othIndex--) { | ||
othValue = other[othIndex]; | ||
result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); | ||
if (result) { | ||
break; | ||
} | ||
} | ||
} else { | ||
result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); | ||
// Recursively compare arrays (susceptible to call stack limits). | ||
if (isLoose) { | ||
if (!arraySome(other, function(othValue) { | ||
return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); | ||
})) { | ||
return false; | ||
} | ||
} else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) { | ||
return false; | ||
} | ||
} | ||
return !!result; | ||
return true; | ||
} | ||
@@ -264,25 +274,18 @@ | ||
} | ||
var skipCtor = isLoose, | ||
index = -1; | ||
var index = objLength; | ||
while (index--) { | ||
var key = objProps[index]; | ||
if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) { | ||
return false; | ||
} | ||
} | ||
var skipCtor = isLoose; | ||
while (++index < objLength) { | ||
var key = objProps[index], | ||
result = isLoose ? key in other : hasOwnProperty.call(other, key); | ||
key = objProps[index]; | ||
var objValue = object[key], | ||
othValue = other[key], | ||
result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined; | ||
if (result) { | ||
var objValue = object[key], | ||
othValue = other[key]; | ||
result = undefined; | ||
if (customizer) { | ||
result = isLoose | ||
? customizer(othValue, objValue, key) | ||
: customizer(objValue, othValue, key); | ||
} | ||
if (result === undefined) { | ||
// Recursively compare objects (susceptible to call stack limits). | ||
result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB); | ||
} | ||
} | ||
if (!result) { | ||
// Recursively compare objects (susceptible to call stack limits). | ||
if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) { | ||
return false; | ||
@@ -307,2 +310,29 @@ } | ||
/** | ||
* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. | ||
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is an object, else `false`. | ||
* @example | ||
* | ||
* _.isObject({}); | ||
* // => true | ||
* | ||
* _.isObject([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isObject(1); | ||
* // => false | ||
*/ | ||
function isObject(value) { | ||
// Avoid a V8 JIT bug in Chrome 19-20. | ||
// See https://code.google.com/p/v8/issues/detail?id=2291 for more details. | ||
var type = typeof value; | ||
return !!value && (type == 'object' || type == 'function'); | ||
} | ||
module.exports = baseIsEqual; |
{ | ||
"name": "lodash._baseisequal", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "The modern build of lodash’s internal `baseIsEqual` as a module.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://lodash.com/", |
@@ -1,2 +0,2 @@ | ||
# lodash._baseisequal v3.0.5 | ||
# lodash._baseisequal v3.0.6 | ||
@@ -20,2 +20,2 @@ The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) internal `baseIsEqual` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
See the [package source](https://github.com/lodash/lodash/blob/3.0.5-npm-packages/lodash._baseisequal) for more details. | ||
See the [package source](https://github.com/lodash/lodash/blob/3.0.6-npm-packages/lodash._baseisequal) for more details. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13951
303