@react-hookz/deep-equal
v2.0.2
Published
Fast deep equal comparator
Downloads
572,334
Readme
@react-hookz/deep-equal
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 forReact
andPreact
objects (they contain circular references).isEqualSimple
- simplified version without support forMap
,Set
,ArrayBuffer
,TypedArray
andDataView
.isEqualSimpleReact
- same asisEqualSimple
but with checks forReact
andPreact
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
- @react-hookz/web - React hooks done right, for browser and SSR.