benjamine / jsondiffpatch

Diff & patch JavaScript objects
MIT License
4.78k stars 466 forks source link

"apply diff" ? #301

Closed 9mm closed 3 years ago

9mm commented 3 years ago

Is there a way I can apply a diff like in this library:

a = {
  a: '10',
  b: '20',
  c: '30',
};
b = {
  a: '10',
  b: '40',
};
delta = getDiff(a, b);
c = applyDiff(a, delta);
console.log(c); // Output: {a:'10', 'b':40}

I'm looking to quite simply send an object to a JSON api of only keys/items that changed. I don't need all this diff RFC extra information as I'm not going to reverse it, I just need to send only changed fields in the API

9mm commented 3 years ago

nevermind that doesnt actually do what i want either