SIGN IN SIGN UP

A modern JavaScript utility library delivering modularity, performance, & extras.

0 0 2 JavaScript
2016-12-19 17:17:56 -06:00
define(['./_getAllKeys'], function(getAllKeys) {
2015-01-08 00:37:01 -08:00
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
2016-11-13 22:49:46 -08:00
/** Used to compose bitmasks for value comparisons. */
var COMPARE_PARTIAL_FLAG = 1;
2015-01-08 00:37:01 -08:00
2016-08-07 21:21:03 -07:00
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
2015-01-08 00:37:01 -08:00
/**
* A specialized version of `baseIsEqualDeep` for objects with support for
* partial deep comparisons.
*
* @private
* @param {Object} object The object to compare.
* @param {Object} other The other object to compare.
2016-11-13 22:49:46 -08:00
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
2016-02-29 23:38:21 -08:00
* @param {Function} customizer The function to customize comparisons.
2016-11-13 22:49:46 -08:00
* @param {Function} equalFunc The function to determine equivalents of values.
2016-02-29 23:38:21 -08:00
* @param {Object} stack Tracks traversed `object` and `other` objects.
2015-01-08 00:37:01 -08:00
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/
2016-11-13 22:49:46 -08:00
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
2016-12-19 17:17:56 -06:00
objProps = getAllKeys(object),
2015-01-08 00:37:01 -08:00
objLength = objProps.length,
2016-12-19 17:17:56 -06:00
othProps = getAllKeys(other),
2015-01-08 00:37:01 -08:00
othLength = othProps.length;
2015-12-16 17:53:20 -08:00
if (objLength != othLength && !isPartial) {
2015-01-08 00:37:01 -08:00
return false;
}
2015-12-16 17:50:42 -08:00
var index = objLength;
while (index--) {
var key = objProps[index];
2016-08-07 21:21:03 -07:00
if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
2015-12-16 17:50:42 -08:00
return false;
}
}
Update lodash-amd to v4.17.21 + edadd45 (#6064) * Fix prototype pollution in _.set and related functions Prevents setting dangerous properties (__proto__, constructor, prototype) that could lead to prototype pollution vulnerabilities. * Fix command injection vulnerability in _.template - Add validation for the variable option to prevent injection attacks - Improve sourceURL whitespace normalization to prevent code injection * Fix cyclic value comparison in _.isEqual Properly checks both directions when comparing cyclic values to ensure correct equality comparisons for circular references. * Improve _.sortBy and _.orderBy performance and array handling - Add early return for empty arrays in sorted index operations - Improve array iteratee handling to support nested property paths - Add missing keysIn import in baseClone * Refactor _.trim, _.trimEnd, and _.trimStart implementations Extract shared trim logic into reusable utilities (_baseTrim, _trimmedEndIndex) for better code organization and consistency. Update related functions (toNumber, parseInt) to use new utilities. Improve comment accuracy. * Add documentation for predicate composition with _.overEvery and _.overSome Enhance documentation to show how _.matches and _.matchesProperty can be combined using _.overEvery and _.overSome for more powerful filtering. Add examples demonstrating shorthand predicate syntax. * Bump to v4.17.21 * Fix prototype pollution in _.unset and _.omit Prevent prototype pollution on baseUnset function by: - Blocking "__proto__" if not an own property - Blocking "constructor.prototype" chains (except when starting at primitive root) - Skipping non-string keys See: https://github.com/lodash/lodash/security/advisories/GHSA-xxjr-mmjv-4gpg * Update JSDoc documentation to align with main branch - Fix sortBy example ages (40 -> 30) for correct sort order demonstration - Fix _setCacheHas return type (number -> boolean)
2025-12-10 17:03:07 -05:00
// Check that cyclic values are equal.
var objStacked = stack.get(object);
var othStacked = stack.get(other);
if (objStacked && othStacked) {
return objStacked == other && othStacked == object;
2015-12-16 17:53:20 -08:00
}
var result = true;
stack.set(object, other);
2016-07-24 09:52:04 -07:00
stack.set(other, object);
2015-12-16 17:53:20 -08:00
var skipCtor = isPartial;
2015-01-08 00:37:01 -08:00
while (++index < objLength) {
2015-12-16 17:50:42 -08:00
key = objProps[index];
var objValue = object[key],
2015-12-16 17:53:20 -08:00
othValue = other[key];
2015-01-08 00:37:01 -08:00
2015-12-16 17:53:20 -08:00
if (customizer) {
var compared = isPartial
? customizer(othValue, objValue, key, other, object, stack)
: customizer(objValue, othValue, key, object, other, stack);
}
2015-12-16 17:50:42 -08:00
// Recursively compare objects (susceptible to call stack limits).
2015-12-16 17:53:20 -08:00
if (!(compared === undefined
2016-11-13 22:49:46 -08:00
? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
2015-12-16 17:53:20 -08:00
: compared
)) {
result = false;
break;
2015-01-08 00:37:01 -08:00
}
2015-12-16 17:49:07 -08:00
skipCtor || (skipCtor = key == 'constructor');
2015-01-08 00:37:01 -08:00
}
2015-12-16 17:53:20 -08:00
if (result && !skipCtor) {
2015-01-08 00:37:01 -08:00
var objCtor = object.constructor,
othCtor = other.constructor;
// Non `Object` object instances with different constructors are not equal.
2015-12-16 17:48:35 -08:00
if (objCtor != othCtor &&
('constructor' in object && 'constructor' in other) &&
!(typeof objCtor == 'function' && objCtor instanceof objCtor &&
typeof othCtor == 'function' && othCtor instanceof othCtor)) {
2015-12-16 17:53:20 -08:00
result = false;
2015-01-08 00:37:01 -08:00
}
}
2015-12-16 17:53:20 -08:00
stack['delete'](object);
2016-07-27 17:37:08 -07:00
stack['delete'](other);
2015-12-16 17:53:20 -08:00
return result;
2015-01-08 00:37:01 -08:00
}
return equalObjects;
});