Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purpose of lhs in differences? #184

Open
Danieltech99 opened this issue Feb 25, 2023 · 2 comments
Open

Purpose of lhs in differences? #184

Danieltech99 opened this issue Feb 25, 2023 · 2 comments
Labels

Comments

@Danieltech99
Copy link

Why is the lhs property created in diff?

Is this only used for revertChange?

I am using this to generate diffs that are stored in a database. If I only apply in one direction (in this case applyChange and not revertChange), am I correct to conclude that lhs is not necessary? Which means it is causing the diff to be unnecessarily large in space.

If this is unnecessary, is there an easy way to omit it from being generated, or should I just map over the differences and remove it?

@cerebralkungfu
Copy link

The lhs property is supplied for validation; at the time I authored the library, I needed to ensure the change was being applied to an appropriate object - I defined appropriate as "an object that looks like the object from which the difference was calculated".

That said, most use cases can safely discard lhs.

I am working on a major update, v2.x which includes a compact representation for storage... as time allows.

@cerebralkungfu
Copy link

Two more specific cases came to mind while I was working on a pending update. Reverting a change, and auditing a change.

I still use this library in projects to generate audit records, so that case is still relevant for some (like me).

Reverting I tend not to do, but if you choose to "roll back" changes for whatever reason, you do need the prior value, which is what lhs provides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants