What is @gilbarbara/deep-equal?
@gilbarbara/deep-equal is an npm package that provides functionality to deeply compare two JavaScript objects or values to determine if they are equivalent. It is useful for scenarios where a shallow comparison is insufficient, such as comparing nested objects or arrays.
What are @gilbarbara/deep-equal's main functionalities?
Deep Comparison of Objects
This feature allows you to deeply compare two objects to check if they are equivalent. The code sample demonstrates comparing two nested objects.
const deepEqual = require('@gilbarbara/deep-equal');
const obj1 = { a: 1, b: { c: 2 } };
const obj2 = { a: 1, b: { c: 2 } };
console.log(deepEqual(obj1, obj2)); // true
Deep Comparison of Arrays
This feature allows you to deeply compare two arrays to check if they are equivalent. The code sample demonstrates comparing two nested arrays.
const deepEqual = require('@gilbarbara/deep-equal');
const arr1 = [1, [2, 3], 4];
const arr2 = [1, [2, 3], 4];
console.log(deepEqual(arr1, arr2)); // true
Deep Comparison of Mixed Types
This feature allows you to deeply compare mixed types, such as objects containing arrays and other objects. The code sample demonstrates comparing two complex nested structures.
const deepEqual = require('@gilbarbara/deep-equal');
const mixed1 = { a: [1, 2, { b: 3 }] };
const mixed2 = { a: [1, 2, { b: 3 }] };
console.log(deepEqual(mixed1, mixed2)); // true
Other packages similar to @gilbarbara/deep-equal
deep-equal
The 'deep-equal' package is a popular alternative for deep comparison of JavaScript objects and values. It provides similar functionality to @gilbarbara/deep-equal but is more widely used and has a larger community.
lodash.isequal
The 'lodash.isequal' package is part of the Lodash library and offers deep comparison functionality. It is highly optimized and well-maintained, making it a reliable choice for deep equality checks.
fast-deep-equal
The 'fast-deep-equal' package is known for its performance and small size. It provides deep comparison functionality with a focus on speed, making it suitable for performance-critical applications.
@gilbarbara/deep-equal

Lightweight deep equal comparator.
Features
- Written in TypeScript
- ESM ready
- Works with Map, Set, and Typed Arrays
- Works with React component (avoid circular references)
Usage
npm i @gilbarbara/deep-equal
import equal from '@gilbarbara/deep-equal';
equal({ a: 1 }, { a: 1 });
Credits
Inspired by fast-deep-equal package. Thanks! ❤️
License
MIT