or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-lodash--baseisequal

The internal lodash function baseIsEqual for deep equality comparisons with circular reference detection

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/lodash._baseisequal@4.1.x

To install, run

npx @tessl/cli install tessl/npm-lodash--baseisequal@4.1.0

index.mddocs/

lodash._baseisequal

The 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.

Package Information

  • Package Name: lodash._baseisequal
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install lodash._baseisequal

Core Imports

var baseIsEqual = require('lodash._baseisequal');

For ES modules:

import baseIsEqual from 'lodash._baseisequal';

Basic Usage

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);
// => false

Capabilities

Deep Equality Comparison

Performs 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)

Supported Data Types

The function handles comprehensive comparison of:

  • Primitives: string, number, boolean, null, undefined, symbol
  • Arrays: Regular arrays and array-like objects
  • Objects: Plain objects, including those with null prototype
  • Dates: Compares by timestamp value
  • Regular Expressions: Compares pattern and flags
  • Error Objects: Compares name and message properties
  • Maps and Sets: Deep comparison of entries/values
  • Typed Arrays: Int8Array, Uint8Array, Float32Array, etc.
  • ArrayBuffer: Compares byte contents
  • Arguments Objects: Treated as arrays for comparison
  • Circular References: Properly handles and detects circular object references

Special Behaviors

NaN Handling

baseIsEqual(NaN, NaN);
// => true (treats NaN as equal to itself)

Symbol Comparison

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)

Circular References

var obj1 = { a: 1 };
obj1.circular = obj1;

var obj2 = { a: 1 };
obj2.circular = obj2;

baseIsEqual(obj1, obj2);
// => true (handles circular references properly)

Lodash Wrapped Objects

// Automatically unwraps lodash wrapped objects
var wrapped1 = _({ a: 1 });
var wrapped2 = _({ a: 1 });
baseIsEqual(wrapped1, wrapped2);
// => true (compares unwrapped values)

Parameters

value (*)

The primary value to compare. Can be any JavaScript value including primitives, objects, arrays, functions, etc.

other (*)

The secondary value to compare against. Can be any JavaScript value.

customizer (Function, optional)

Optional function to customize the comparison logic. Called with (objValue, othValue, index|key, object, other, stack) arguments.

Return Values:

  • true: Values should be considered equal
  • false: Values should be considered not equal
  • undefined: Use default comparison logic

bitmask (number, optional)

Bitwise flags to control comparison behavior:

  • 1 (UNORDERED_COMPARE_FLAG): Ignore order in arrays and object properties
  • 2 (PARTIAL_COMPARE_FLAG): Allow partial matching (source properties must exist in target)
  • Can be combined: 3 enables both unordered and partial comparison

stack (Object, optional)

Internal object used to track traversed objects and prevent infinite recursion with circular references. Automatically created if not provided.

Returns

boolean: Returns true if the values are deeply equal according to the comparison rules, otherwise false.

Dependencies

This module depends on:

  • lodash._root: Provides environment detection and built-in references
  • lodash._stack: Provides Stack data structure for tracking circular references
  • lodash.keys: Provides object key enumeration functionality