3.0.4 • Published 7 months ago

@react-hookz/deep-equal v3.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

!CAUTION PACKAGE IS DEPRECATED AND WILL BE DETED SOON
USE @ver0/deep-equal instead

@react-hookz/deep-equal

NPM Version NPM Downloads Dependents (via libraries.io), scoped npm package GitHub Actions Workflow Status Codecov NPM Type Definitions

× DISCORD ×


The fastest deep comparator for JS/TS.


Features 🚀

  • ✅ Handles ES6+ structures like Map, Set, TypedArray, DataView, and ArrayBuffer.
  • ✅ Supports Date, RegExp, and NaN.
  • ✅ Safe handling of React and Preact objects (no stack overflow).
  • ✅ Works seamlessly with objects created via Object.create(null).
  • ⚠️ Circular reference handling: - Supported: React and Preact objects. - Not supported: Other objects (causes stack overflow).

Installation 📦

It's as simple as:

npm install @react-hookz/deep-equal
# or
yarn add @react-hookz/deep-equal

Usage 💡

Importing

This package is distributed using the ESNext language level and ES module system. Depending on your target environment, you might need to transpile the package. Check your bundler's documentation for instructions on transpiling node_modules.

import { isEqual } from '@react-hookz/deep-equal';

isEqual({ a: 1 }, { a: 1 }); // true

Performance ⚡

Note: Benchmarks were conducted on specific datasets (available in the src/fixtures directory). Your results may vary depending on your data and use case. Running benchmarks on your dataset is recommended.

Simple Data (non-ES6+)

Complex Data (ES6+)


Run Benchmarks Locally 🛠️

To get more detailed benchmarks for different data types, run the tests directly on your own machine:

  1. Clone the repository:
    git clone https://github.com/react-hookz/deep-equal
    cd deep-equal
  2. Install dependencies:
    corepack enable
    yarn
  3. Run benchmarks:
    yarn benchmark

Contributors

Related projects