GithubHelp home page GithubHelp logo

Add deepEquals about seamless-immutable HOT 10 CLOSED

rtfeldman avatar rtfeldman commented on July 20, 2024 1
Add deepEquals

from seamless-immutable.

Comments (10)

theogravity avatar theogravity commented on July 20, 2024 7

i'm also interested in this feature as well, have some deeply nested objects and want to do something like this in react:

shouldComponentUpdate(nextProps) {
    // this.props.obj is immutable

   return this.props.obj.equals(nextProps.obj)
}

from seamless-immutable.

narqo avatar narqo commented on July 20, 2024

Maybe there should be Immutable.is() static method, which would have the same semantic ES6's Object.is() has?

The API may look like this: Immutable.is(obj1, obj2) to check whether objects are equal by value.

from seamless-immutable.

rtfeldman avatar rtfeldman commented on July 20, 2024

I wouldn't want to confuse people; Object.is only differs from === in the specific cases of NaN, 0, and -0 (and handles object comparisons in the same way as ===), whereas the deepEquals I'm referring to would compare the contents of objects, like what Underscore's _.isEqual does.

from seamless-immutable.

narqo avatar narqo commented on July 20, 2024

You're absolutely right. Somehow I decided that Object.is() compares objects by there values, not by "identity". My bad, sorry.

In any case: 👍 to the issue ;)

from seamless-immutable.

n1k0 avatar n1k0 commented on July 20, 2024

+1, that would greatly help checking if two immutable structures actually differ.

Nit: How about a shorter name, eg. equals, or eq?

from seamless-immutable.

abritinthebay avatar abritinthebay commented on July 20, 2024

semantically equals is nicer - easy to discover on an object too ("What's this do? Oh.. it's an equals function").

from seamless-immutable.

Aetet avatar Aetet commented on July 20, 2024

Hello, @rtfeldman . What is status for deep equality between objects? What is api for that right now?

from seamless-immutable.

rtfeldman avatar rtfeldman commented on July 20, 2024

@Aetet I have a WIP branch that implements it, but needs a bunch of tests before it can go on master. I haven't had time to work on it, and realistically won't in the near future.

from seamless-immutable.

rtfeldman avatar rtfeldman commented on July 20, 2024

There doesn't seem to be much demand for this, so I'm going to close this for now.

from seamless-immutable.

juanger avatar juanger commented on July 20, 2024

@rtfeldman Hi, are you still interested in this? If so, I'd like to give it a try, rebase your branch and write tests

from seamless-immutable.

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.