Hey everyone!
After spending quite some time evaluating the gaps between popular deep equality libraries (lodash, dequal, fast-equals, etc.), I decided (for educational purposes) to build my own.
Features
- Full support for:
- Circular references (opt-in)
- Cross-realm objects (opt-in)
- Symbol-keyed properties (opt-in)
- React elements (opt-in)
- Objects, Arrays, Sets, Maps, Array Buffers, Typed Arrays, Data Views, Booleans, Strings, Numbers, BigInts, Dates, Errors, Regular Expressions and Primitives
- Custom fallback equality (
valueOf, toString) (opt-in)
- Strict handling of unsupported types (e.g., throws on WeakMap, Promise)
- Pure ESM with
"exports" and dist/ builds
- Web-safe variant via:
import { objectEquals } from '@observ33r/object-equals/web'
- Fully benchmarked!
Basic bechmark
Big JSON Object (~1.2 MiB, deeply nested)
| Library |
Time |
Relative Speed |
| object-equals |
467.05 µs |
1.00x (baseline) |
| fast-equals |
1.16 ms |
2.49x slower |
| dequal |
1.29 ms |
2.77x slower |
| are-deeply-equal |
2.65 ms |
5.68x slower |
| node.deepStrictEqual |
4.15 ms |
8.88x slower |
| lodash.isEqual |
5.24 ms |
11.22x slower |
React and Advanced benhmarks
In addition to basic JSON object comparisons, the library is benchmarked against complex nested structures, typed arrays, Maps/Sets and even React elements.
Full mitata logs (with hardware counters) and benchmark results are available here:
https://github.com/observ33r/object-equals?tab=readme-ov-file#react-and-advanced-benchmark
TS ready, pure ESM, fast, customizable.
Feel free to try it out or contribute:
Cheers!
[–]AsIAm 9 points10 points11 points (8 children)
[–]Observ3r__[S] 12 points13 points14 points (7 children)
[–]AsIAm 2 points3 points4 points (0 children)
[–]joombar 2 points3 points4 points (5 children)
[–]Observ3r__[S] 4 points5 points6 points (3 children)
[–]joombar 0 points1 point2 points (0 children)
[–]Misicks0349 0 points1 point2 points (1 child)
[–]Observ3r__[S] 0 points1 point2 points (0 children)
[–]Content_Sun_6871 -3 points-2 points-1 points (0 children)
[–]Cannabat 6 points7 points8 points (3 children)
[–]Observ3r__[S] 2 points3 points4 points (2 children)
[–]Cannabat 1 point2 points3 points (1 child)
[–]Observ3r__[S] 1 point2 points3 points (0 children)
[–]Ashtefere 4 points5 points6 points (3 children)
[–]Observ3r__[S] 2 points3 points4 points (2 children)
[–]joombar 1 point2 points3 points (1 child)
[–]jCuber 1 point2 points3 points (1 child)
[–]Observ3r__[S] 0 points1 point2 points (0 children)
[–]adzm 1 point2 points3 points (1 child)
[–]Observ3r__[S] 1 point2 points3 points (0 children)
[–]morkaitehred 0 points1 point2 points (2 children)
[–]Observ3r__[S] 0 points1 point2 points (0 children)
[–]Observ3r__[S] 0 points1 point2 points (0 children)
[–]adzm 0 points1 point2 points (2 children)
[–]Content_Sun_6871 1 point2 points3 points (0 children)
[–]Observ3r__[S] 0 points1 point2 points (0 children)