Comments (5)
After looking into it, this comparison actually fits better in the fast-deep-equal repo. A JSON.stringify(obj1) === JSON.stringify(obj2)
comparison cannot handle circular references and should never be used when data might contain React components. It's also pretty slow when running generic data, as well as susceptible to giving false positives in many other cases.
--- speed tests: generic usage ---
react-fast-compare x 160,023 ops/sec ±0.88% (90 runs sampled)
fast-deep-equal x 158,356 ops/sec ±0.31% (94 runs sampled)
lodash.isEqual x 34,607 ops/sec ±0.52% (94 runs sampled)
nano-equal x 162,973 ops/sec ±0.38% (94 runs sampled)
shallow-equal-fuzzy x 135,792 ops/sec ±0.39% (92 runs sampled)
JSON.stringify x 23,047 ops/sec ±0.56% (94 runs sampled)
JSON.stringify
- different result: JSON.stringify scalars Infinity and -Infinity are not equal
- different result: JSON.stringify objects equal objects (different properties "order")
- different result: JSON.stringify objects object with extra undefined properties are not equal #1
- different result: JSON.stringify objects object with extra undefined properties are not equal #2
- different result: JSON.stringify objects object with extra undefined properties are not equal #3
- different result: JSON.stringify Date objects date and string are not equal
- different result: JSON.stringify RegExp objects not equal RegExp objects (different pattern)
- different result: JSON.stringify RegExp objects not equal RegExp objects (different flags)
- different result: JSON.stringify RegExp objects RegExp and object are not equal
- different result: JSON.stringify functions different functions are not equal
- different result: JSON.stringify sample objects big object
- error: React elements an element compared with itself Converting circular structure to JSON
- error: React elements two elements equal by value Converting circular structure to JSON
- error: React elements two elements unequal by value Converting circular structure to JSON
from react-fast-compare.
hey @ErkanSensei! i'm honestly not sure. I'd guess that parse/stringify would have a bit more overhead, but I've been surprised by javascript before :D
if you add it to the benchmark suite i'm happy to merge it!
from react-fast-compare.
@chrisbolin Looks like this conversation is from a year and a half ago, but I'm interested in adding that comparison to the benchmark suite. Will you still accept a pull request?
from react-fast-compare.
from react-fast-compare.
@SashaKoro agreed. And thanks for posting the results- that’s really interesting!
from react-fast-compare.
Related Issues (20)
- Upgrade dependencies
- Add ability to compare functions HOT 9
- module '/node_modules/react-fast-compare/index.js' does not provide an export HOT 1
- Handle anonymous function HOT 2
- Bug: Set compares by reference not value HOT 6
- TypeScript library for react-fast-compare? HOT 9
- Fix exported types so that they work for react-redux HOT 8
- Cannot compare object will null prototype HOT 11
- Getters are not considered HOT 2
- IE 11: Object doesn't support property or method 'isView' HOT 26
- There should be a 'debug' feature to determine which fields are breaking equality.
- Types: documentation, clean up, and testing
- Audit security alerts HOT 2
- Fix benchmark chart img path
- Ignore Arrow Functions HOT 1
- Re-evaluate project's eslint rules HOT 1
- Update benchmark png HOT 2
- CJS + ESM Question/discussion HOT 6
- Differences in objects with properties that are associative arrays are not detected HOT 8
- Infra: Switch to GitHub Actions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-fast-compare.