angular-object-diff icon indicating copy to clipboard operation
angular-object-diff copied to clipboard

How to return just the changed properties

Open edbentinck opened this issue 8 years ago • 3 comments

Hi, is there a method which just returns only the changed properties? This would be essentially the result of toJsonDiffView, but without the comparisons. As an example, in the case of your demo this would result in:

Changed properties:

{
    a: {
        b: 2,
        c: {
            2: 3
        }
    },
    x: 1
}

edbentinck avatar Jul 19 '16 23:07 edbentinck

Unfortunately no at the moment. You are welcome to do a PR if you would like

Thanks & Regards, Deepu

On Wed, Jul 20, 2016 at 4:46 AM, edbentinck [email protected] wrote:

Hi, is there a method which just returns only the changed properties? This would be essentially the result of toJsonDiffView, but without the comparisons. As an example, in the case of your demo this would result in:

Changed properties:

{ a: { b: 2, c: { 2: 3 } }, x: 1 }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hipster-labs/angular-object-diff/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDlF1K9UuF6SUMLdR4KZx1eYBYQUkXlks5qXVrigaJpZM4JQRq6 .

deepu105 avatar Jul 20 '16 03:07 deepu105

Ok. I can do that. That said, I feel that the current method names will be a little confusing if I add this functionality.

I understand that you based this package on another implementation and therefore you have essentially just followed their naming conventions, which makes sense. However, other diff packages use different terminology – for instance this very popular diff package – and personally I find them to be a bit more straight-forward.

In the example above they describe the term "diff" as being the result of the difference between the two objects, not the comparison itself.

So, if I were to add the proposed functionality I would probably favour amending the current method names to something along these lines:

toJsonView     -> fullDiffComparisonAsJson
toJsonDiffView -> diffComparisonAsJson

I would name the new function something like the following. This function would return an object rather than the JSON.

diffResult

Since you're the owner of this package I think it should be your call on the terminology used, but those are some of my thoughts before I start moving things around in your project 😛 Let me know what you think and I'll submit the PR. Any other suggestions for terminology are appreciated.

edbentinck avatar Jul 20 '16 08:07 edbentinck

You can propose to change the method names, i can make a major release if required

Thanks & regards, Deepu On 20 Jul 2016 13:42, "edbentinck" [email protected] wrote:

Ok. I can do that. That said, I feel that the current method names will be a little confusing if I add this functionality.

I understand that you based this package on another implementation and therefore you have essentially just followed their naming conventions, which makes sense. However, other diff packages use different terminology – for instance this very popular diff package https://github.com/flitbit/diff – and personally I find them to be a bit more straight-forward.

In the example above they describe the term "diff" as being the result of the difference between the two objects, not the comparison itself.

So, if I were to add the proposed functionality I would probably favour amending the current method names to something along these lines:

toJsonView -> fullDiffComparisonAsJson toJsonDiffView -> diffComparisonAsJson

I would name the new function something like the following. This function would return an object rather than the JSON.

diffResult

Since you're the owner of this package I think it should be your call on the terminology used, but those are some of my thoughts before I start moving things around in your project 😛 Let me know what you think and I'll submit the PR. Any other suggestions for terminology are appreciated.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hipster-labs/angular-object-diff/issues/3#issuecomment-233877897, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDlF-ZHlbyvc57zR6_m63QeTYpjbYfBks5qXdhRgaJpZM4JQRq6 .

deepu105 avatar Jul 20 '16 13:07 deepu105