Giter Club home page Giter Club logo

Comments (6)

dennisfaust avatar dennisfaust commented on August 21, 2024

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.

liufengyun avatar liufengyun commented on August 21, 2024

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.

dennisfaust avatar dennisfaust commented on August 21, 2024

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.

AAverin avatar AAverin commented on August 21, 2024

Was that feature implemented in the end?
Would be very nice to have it

from hashdiff.

pchaganti avatar pchaganti commented on August 21, 2024

πŸ‘

from hashdiff.

liufengyun avatar liufengyun commented on August 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.