-
Notifications
You must be signed in to change notification settings - Fork 77
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
Recreation from diff #10
Comments
Yeah, I plan to add patching soon. I can’t give you an exact ETA, but it will probably be a week or two. I will give you an update when I release it. |
Alright, thanks! I'm down to help you at this, you can hit me up on discord (FluentCoding#3314) if you want to discuss the API/implementation. |
this might be the same as what you're thinking for patching, but is it possible to lump together CHANGE events with similar paths? So
would become
|
I think you could do this but at the cost of a bit of performance as you would have to look up the equal path parents and then combine them. |
Oh, also, related to this issue, here is the PR that I posted about 11 days ago: #13 |
If you have function patch (target: any, diff: any[]): any {
target = cloneDeep(target);
for (let i = 0; i < diff.length; i++) {
const {
type,
path,
value,
} = diff[i];
switch (type) {
case 'CREATE': {
set(target, path, value);
break;
}
case 'CHANGE': {
set(target, path, value);
break;
}
case 'REMOVE': {
// Note this does not actually remove the entry
set(target, path, undefined);
break;
}
default: {
throw new Error(`unknown diff entry type: ${type}`);
}
}
}
return target;
} Hopefully this helps someone waiting for the |
Would |
Micropatch is where FluentCoding's implementation ended up. Currently, you can use it directly from GitHub, and I am working on publishing it to NPM. |
Hey!
I'm currently considering to use microdiff for my project, however I also have to be able to recreate an object from the diff and the source object (basically so that im able to send smaller-sized updates to a client state via a websocket connection), but it seems like microdiff is not offering any method for this. I will implement this in my project but I would like to know if this is in the ToDo.
The text was updated successfully, but these errors were encountered: