-
-
Notifications
You must be signed in to change notification settings - Fork 96
pass thru of arrays #21
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
Comments
Hey @michaelreflective thanks for raising an issue. I'm not quite sure I understand what you're asking for, would you mind adding a code example? |
Hi
Thank you for your time. Sure I will explain more what is our simple need.
We simply see arrays as a value, that if different from existing will
simply override the full array. And yes if there is a big structure under,
it will be overriden, but that is fine.
So, array is to be seen and interpreted as a scalar. If different then just
return rhs.
In the types we have in the datamodel, usage of arrays, are limited to list
of values, so no deep structure under. If you like to have more control
over the change, the existing solution gives you all the information
needed. Perhaps an indication of that the left value was an array, could be
handy.
Code:
index.js
from line: 49
var diff = function diff(lhs, rhs) {
if (lhs === rhs) return {}; // equal return no diff
if (!(0, _utils.isObject)(lhs) || !(0, _utils.isObject)(rhs)) return
rhs; // return updated rhs
var l = (0, _utils.properObject)(lhs);
var r = (0, _utils.properObject)(rhs);
// MN: Pass arrays on right thru if it != left
// perhaps have a 3. arg: options: {scalarArray: true}
// I have imp. Array.protocol.equals, also.
if (Array.isArray(r)) {
if (l.equals(r) === false) {
return r;
}
}
// and done
…On Tue, Sep 19, 2017 at 11:55 AM, Matt Phillips ***@***.***> wrote:
Hey @michaelreflective <https://github.com/michaelreflective> thanks for
raising an issue.
I'm not quite sure I understand what you're asking for, would you mind
adding a code example?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#21 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AeihwJOx_Ue1KQAPg_wFwcWRtNijcYFqks5sj4-egaJpZM4PZ8Ad>
.
|
Hey sorry @michaelreflective for not coming back to you sooner! I'm still not sure if I understand the issue you are having. Would you mind taking a look at #23 to see if it is the same issue and if my comments are relevant to your use case? Thanks! |
Closing for now. Feel free to reopen if you are still having issues |
Hi
Thank you for a nice diff library. Our need is simply to get the new/updated array passed back as the diff. Having options to diff(.., {returnArray:true}) would be nice.
The code:
in diff/index.js justafter line 55
if (Array.isArray(r)) {
return r;
}
Regards
Michael
The text was updated successfully, but these errors were encountered: