The internal lodash function baseIsEqual for deep equality comparisons with circular reference detection
npx @tessl/cli install tessl/npm-lodash--baseisequal@4.1.0The internal lodash function baseIsEqual exported as a standalone module. Provides comprehensive deep equality comparison between JavaScript values with support for circular references, custom comparison functions, partial comparisons, and proper handling of complex data structures including arrays, objects, maps, sets, typed arrays, and special JavaScript values.
npm install lodash._baseisequalvar baseIsEqual = require('lodash._baseisequal');For ES modules:
import baseIsEqual from 'lodash._baseisequal';var baseIsEqual = require('lodash._baseisequal');
// Basic deep equality comparison
var obj1 = { a: 1, b: { c: 2 } };
var obj2 = { a: 1, b: { c: 2 } };
var result = baseIsEqual(obj1, obj2);
// => true
// Arrays with same elements
var arr1 = [1, 2, [3, 4]];
var arr2 = [1, 2, [3, 4]];
baseIsEqual(arr1, arr2);
// => true
// Different objects
var obj3 = { a: 1, b: { c: 3 } };
baseIsEqual(obj1, obj3);
// => falsePerforms comprehensive deep equality comparison between two values with support for all JavaScript data types and edge cases.
/**
* The base implementation of `_.isEqual` which supports partial comparisons
* and tracks traversed objects.
*
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @param {Function} [customizer] The function to customize comparisons.
* @param {number} [bitmask] The bitmask flags (1=unordered, 2=partial).
* @param {Object} [stack] Tracks traversed objects for circular references.
* @returns {boolean} Returns `true` if values are equivalent, else `false`.
*/
baseIsEqual(value, other, customizer, bitmask, stack);Usage Examples:
var baseIsEqual = require('lodash._baseisequal');
// Custom comparison function
function customizer(objValue, othValue) {
if (typeof objValue === 'string' && typeof othValue === 'string') {
return objValue.toLowerCase() === othValue.toLowerCase();
}
}
baseIsEqual('Hello', 'HELLO', customizer);
// => true
// Partial comparison (bitmask = 2)
var object = { 'a': 1, 'b': 2 };
var source = { 'a': 1 };
baseIsEqual(object, source, null, 2);
// => true (partial match)
// Unordered array comparison (bitmask = 1)
var arr1 = [1, 2, 3];
var arr2 = [3, 1, 2];
baseIsEqual(arr1, arr2, null, 1);
// => true (order ignored)The function handles comprehensive comparison of:
string, number, boolean, null, undefined, symbolnull prototypename and message propertiesInt8Array, Uint8Array, Float32Array, etc.baseIsEqual(NaN, NaN);
// => true (treats NaN as equal to itself)var sym1 = Symbol('test');
var sym2 = Symbol('test');
baseIsEqual(sym1, sym2);
// => false (symbols are unique)
var sym3 = sym1;
baseIsEqual(sym1, sym3);
// => true (same symbol reference)var obj1 = { a: 1 };
obj1.circular = obj1;
var obj2 = { a: 1 };
obj2.circular = obj2;
baseIsEqual(obj1, obj2);
// => true (handles circular references properly)// Automatically unwraps lodash wrapped objects
var wrapped1 = _({ a: 1 });
var wrapped2 = _({ a: 1 });
baseIsEqual(wrapped1, wrapped2);
// => true (compares unwrapped values)The primary value to compare. Can be any JavaScript value including primitives, objects, arrays, functions, etc.
The secondary value to compare against. Can be any JavaScript value.
Optional function to customize the comparison logic. Called with (objValue, othValue, index|key, object, other, stack) arguments.
Return Values:
true: Values should be considered equalfalse: Values should be considered not equalundefined: Use default comparison logicBitwise flags to control comparison behavior:
1 (UNORDERED_COMPARE_FLAG): Ignore order in arrays and object properties2 (PARTIAL_COMPARE_FLAG): Allow partial matching (source properties must exist in target)3 enables both unordered and partial comparisonInternal object used to track traversed objects and prevent infinite recursion with circular references. Automatically created if not provided.
boolean: Returns true if the values are deeply equal according to the comparison rules, otherwise false.
This module depends on:
lodash._root: Provides environment detection and built-in referenceslodash._stack: Provides Stack data structure for tracking circular referenceslodash.keys: Provides object key enumeration functionality