Comments (6)
I quickly hacked up a simple version of what you are asking for in my fork. See if that meets your needs. It's not very sophisticated since it does not return matching hashes or arrays, only matching lowest level items. But it's a start.
from hashdiff.
It's a nice to have feature. While @dennisfaust proposed a simple version to report common primitive values, a more complex and reasonable version should return matching hashes and arrays. I'm still thinking how to do that in a simple way.
Any inputs are welcome.
from hashdiff.
Recursion makes any use of the LCS table(s) a bit tricky. A crude but effective alternative would be to have a method 'same' which takes (a, b, diff_array) and returns an array containing the similarities by analyzing diff_array. Anything not in diff_array would be a similarity.
from hashdiff.
Was that feature implemented in the end?
Would be very nice to have it
from hashdiff.
π
from hashdiff.
Thanks for your interest in this lib. I'm wondering what would you like to be the output in following case:
diff({a: {x: 2} }, {a: {x: 2} })
Possible result A:
[['=', 'a', {x: 2}]]
Possible result B:
[['=', 'a.x', 2]]
To me, the result A is more natural, but it means the algorithm needs to traverse the object twice -- first check if they are exactly equal(without =
); if not, parse again to get all the =
cases.
from hashdiff.
Related Issues (20)
- Custom comparison broken since 0.3.4? HOT 5
- Time vs String non-strict comparison HOT 1
- Ruby 1.8.7 compatibility HOT 2
- make use_lcs: false the default HOT 2
- RexEx in compares?
- Unexpected difference between diffs of hashes vs. arrays HOT 5
- Conflicts with `hash_diff` HOT 50
- HashDiff never finishes when comparing two arrays HOT 3
- "use_lcs: false" does not work as expected as per documentation HOT 1
- Compare objects inheriting from the same class HOT 1
- version tags would be helpful to see diffs HOT 2
- Unexpected results HOT 1
- Please stop the `warn` spam HOT 6
- Canβt silence HashDiff constant warning HOT 6
- Issues with diff
- default similarity should be 1
- Getting (+-) instead of diff (tilde) when comparing arrays HOT 5
- Please document the determinism of HashDiff.diff and friends HOT 1
- ==/equal? overrides not used when checking keys
- [Feature request] :ignore_keys option HOT 3
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 hashdiff.