flitbit / diff

Javascript utility for calculating deep difference, capturing changes, and applying changes across objects; for nodejs and the browser.
MIT License
2.99k stars 213 forks source link

Means to exploit immutability #91

Closed jinalskothari closed 7 years ago

jinalskothari commented 7 years ago

In my application, I never mutate objects. Which means such comparision could be done by references alone.

Is there a way to exploit that in this library? Would it be difficult to add this feature with an optional paramter?

I'd be happy to make a PR if I were pointed in the right direction.

flitbit commented 7 years ago

I suppose you could short circuit object comparison at [line 182] by explicit equals of the operands (lhs and rhs). It might also prove to be a slight optimization for people not using immutables.

jiayihu commented 6 years ago

Hi @flitbit , I'd also need this, if I got it correctly it should be enough adding && lhs !== rhs in line https://github.com/flitbit/diff/blob/master/index.js#L217

I can open a PR if my assumption is correct