2.0.2 • Published 3 months ago

@react-hookz/deep-equal v2.0.2

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

@react-hookz/deep-equal

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

× DISCORD × CHANGELOG ×


Yet fastest deep comparator with ES6+ support.

Install

This one is pretty simple, everyone knows what to do:

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

Usage

Importing

This package distributed with ESNext language level and ES modules system. It means that depending on your browser target you might need to transpile it. Every major bundler provides a way to transpile node_modules fully or partially. Address your bundler documentation for more details.

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

Variants

This package provides 4 variants of comparator:

  • isEqual - es6+ compatible, for cases when you expect almost any data on input.
  • isEqualReact - es6+ compatible but with extra checks for React and Preact objects (they contain circular references).
  • isEqualSimple - simplified version without support for Map, Set, ArrayBuffer, TypedArray and DataView.
  • isEqualSimpleReact - same as isEqualSimple but with checks for React and Preact

Performance

Note: below tests are mage against certain dataset (can be found in benchmarks), that may or may not be representative for your case and your data. It is better to perform benchmarks against your datasets.

simple data (non-es6+)

complex data (with es6+)

Full benchmarks results can be found in the benchmark directory.

To run benchmarks simply clone this repo and make yarn && yarn benchmark in repo root.

Contributors

Related projects