rtfeldman / seamless-immutable

Immutable data structures for JavaScript which are backwards-compatible with normal JS Arrays and Objects.
BSD 3-Clause "New" or "Revised" License
5.37k stars 195 forks source link

Custom merger equality #41

Closed crudh closed 9 years ago

crudh commented 9 years ago

When a custom merger returns a result that is the same as in the currentObj we can aboirt addToResult since there are nothing more we have to do. And we don't have to flag that any changes have been done.

This is a partial fix to #40. With this addition a custom merger can be used to fullfill the requirements. Check the issue for the details.

In the if we check the merger to abort early, then we need to check if there is a mergeResult otherwise the last part, mergerResult === currentObj[key], would be true when the custom merger returns undefined and it is a value that is only available in otherObj and not currentObj.

rtfeldman commented 9 years ago

Looks good! A nice first step.