Giter Club home page Giter Club logo

Comments (2)

planttheidea avatar planttheidea commented on September 24, 2024

I can look into this, but I'm worried it would only be possible as a breaking change. That, and potentially have performance costs, which for an edge case would not be a good trade-off.

Let me investigate a bit.

from hash-it.

planttheidea avatar planttheidea commented on September 24, 2024

After much thought and investigation, I believe this would not be a good change to make. It would break existing approaches, and the opinionated stance it takes on "equality" is not one that I share.

Inherently, { a: 1, b: undefined } is not the same object in value as { a: 1 }, because its own key structure is different. Object.keys({ a: 1, b: undefined }) will return ['a','b'], whereas Object.keys({ a: 1 }) will only return ['a']. The same is true of Object.values ([1, undefined] vs [1]). If both keys and values of the object are perceived as different by the spec, then the object itself is different.

As such, if you want to consider these two to be considered equal, I would apply a normalizer function prior to hashing. You can use JSON.parse(JSON.stringify(...)) if you'd like, but that also would eliminate functions and symbols. Depending on your project needs, you may want to be more targeted.

Hopefully this explanation satisfies for the time being. That said, when I do make a breaking change in the future, I'll keep this use-case in mind to see if I can satisfy it in a clean way.

from hash-it.

Related Issues (3)

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.